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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, c = 0, mi = 10000000000;
	cin >> n;
	vector<ll> v(n);
	for (ll i = 0; i < n; i++) {
		cin >> v.at(i);
	}
	for (ll i = -100; i < 101; i++) {
		for (ll j = 0; j < n; j++) {
			c += pow( i -v.at(j), 2);
		}
		mi = min(mi, c);
		c = 0;
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:36777216")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <sstream>
#include <vector>
#include <complex>
#include <ctime>
#include <stack>

//#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector< VI > VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define FOR(i, x, y) for(int i = (x); i <= (y); ++i)
#define RFOR(i, y, x) for(int i = (x); i >= (y); --i)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a)) 
#define CLEAR(x) memset(x, 0, sizeof x);
#define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);
#define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
#define pb push_back
#define mk make_pair
#define sqr(x) ((x)*(x))
#define X first
#define Y second
//typedef tree<int, null_type, less<int>, 
//  rb_tree_tag, tree_order_statistics_node_update> order_set;

const long double PI = acos(-1.0);
const double EPS = 1E-6;
const int INF = 2 * (1e+9) + 1;
const int MAXN = 3 * 100000001;
const int MOD = (1e+9) + 7;


ll n, m, k;
string s;
int main() {
    m = 0;
    //freopen("a.txt", "r", stdin);
    cin >> n;
    cout << PI * 2 * n;
    return 0;
}

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

# C - XYZ Triplets
def calc(x, y, z):
	return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


N = int(input())
ans = [0] * (N + 1)

for x in range(1, 100):
	for y in range(1, 100):
		for z in range(1, 100):
			i = calc(x, y, z)
			
			if i > N:
				break
			else:
				ans[i] += 1

for i in range(1, N + 1):
	print(ans[i])
			
 			   


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

					#define mp make_pair
					#define pb push_back
					#define sqr(x) (x) * (x)
					#define sors(s) sort(s.begin(), s.end())
					#define F first
					#define S second

					using namespace std;
					typedef long long ll;
					string s;
					int main()
					{
						cin >> s;
						for(int i = 0; i < s.size(); i++)
							if(!(i & 1) && s[i] == 'L')
								return cout << "No", 0;
							else if((i & 1) && s[i] == 'R')
								return cout << "No", 0;
						cout << "Yes"; 	
					}

Measured memory_bytes: 256
class Queue():
  def __init__(self, max=100):
    self.head = self.tail = 0
    self.max = max
    self.arr = [None for _ in range(max)]
  
  def is_empty(self):
    return self.head == self.tail

  def is_full(self):
    return self.head == (self.tail + 1) % self.max

  def enqueue(self, x):
    if self.is_full():
      raise IndexError()
    self.arr[self.tail] = x
    if self.tail + 1 == self.max:
      self.tail = 0
    else:
      self.tail += 1
  
  def dequeue(self):
    if self.is_empty():
      raise IndexError()
    x = self.arr[self.head]
    if self.head + 1 == self.max:
      self.head = 0
    else:
      self.head += 1
    return x

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

ps = Queue(100000)
for _ in range(n):
  name, time = input().split()
  ps.enqueue([name, int(time)])

elasp = 0
while not ps.is_empty():
  p = ps.dequeue()
  c = min(q, p[1])
  p[1] -= c
  elasp += c
  if p[1] > 0:
    ps.enqueue(p)
  else:
    print(p[0], elasp)



Measured memory_bytes: 13428
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		sugo();
	}

	public static void sugo() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int count = 0;
		;
		int keep = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for (int num : A) {
			if (num == 1) {
				keep++;
				if (count < keep) {
					count = keep;
				}
			} else {
				keep = 0;
			}
		}
		System.out.println(count + 1);
	}
}



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

void call(int n){
  int i = 1;

  for(int i=1; i<=n; i++){
    if(i%3==0 || i%10==3){
      cout << " " << i;
    }
    else{
      int x=i;
      while(x>10){
        x /= 10;
        if(x%10==3){
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;
}

int main(){
  int n;

  cin >> n;
  call(n);

  return(0);
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, q; cin >> n >> q;
    if(n == 0 && q == 0) break;

    map<string, P> m;
    REP(i, n) {
      string en; cin >> en;
      int ey, wy; cin >> ey >> wy;
      m[en] = make_pair(wy - ey + 1, wy);
    }

    REP(i, q) {
      int t; cin >> t;
      string name = "Unknown";
      int year = 0;
      MFOR(j, m) {
        if(j->second.first <= t && t <= j->second.second) {
          name = j->first;
          year = t - j->second.first + 1;
          break;
        }
      }
      if(name == "Unknown") cout << name << endl;
      else cout << name << " " << year << endl;
    }
  }
}



Measured memory_bytes: 3300
import collections


def split_even_odd_by_index(target_list):
    odd = []
    even = []
    for i in range(len(target_list)):
        if i % 2 == 0:
            even.append(target_list[i])
        else:
            odd.append(target_list[i])

    return [even, odd]


if __name__ == '__main__':
    n = int(input())
    number_list = list(map(int, input().split()))
    split_list = split_even_odd_by_index(number_list)
    even_list = split_list[0]
    odd_list = split_list[1]

    even_dic = collections.Counter(even_list).most_common()
    odd_dic = collections.Counter(odd_list).most_common()

    even_first = even_dic[0]
    if len(even_dic) != 1:
        even_second = even_dic[1]
    else:
        even_second = (0, 0)

    odd_first = odd_dic[0]
    if len(odd_dic) != 1:
        odd_second = odd_dic[1]
    else:
        odd_second = (0, 0)

    if even_first[0] != odd_first[0]:
        print(len(even_list) - even_first[1] + len(odd_list) - odd_first[1])
    else:
        print(min(len(even_list) - even_first[1] + len(odd_list) - odd_second[1], len(even_list) - even_second[1] + len(odd_list) - odd_first[1]))

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

ll INF = 1e18;
ll MOD = 1e9+7;

int main() {
    ll N,  SUM = 0;
    cin >> N;
    for(int i = 1; i <= N; i++){
        if(i % 5 != 0 && i % 3 != 0){
            SUM += i;
        }
    }
    cout << SUM << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s, a;
  cin >> s;
  fi(0, s.size()) {
    char c = s[i];
    if(c == 'B') {
      if(a != "")
        a.pop_back();
    }
    else{
      a.push_back(c);
    }
  }
  cout << a << endl;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int X, N;
	vector<int> p;
	cin >> X >> N;
	REP(i, N){
		int a;
		cin >> a;
		p.PB(a);
	}
	int ans=0;
	for(int i=0; i<=101; i++){
		if(count(ALL(p), i) != 0){
			continue;
		}
		if(abs(ans-X) > abs(i-X)){
			ans = i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
def slove():
    import sys
    input = sys.stdin.readline
    ls = [0] * 9
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    for v in a:
        if 1 <= v <= 399:
            ls[0] = 1
        elif 400 <= v <= 799:
            ls[1] = 1
        elif 800 <= v <= 1199:
            ls[2] = 1
        elif 1200 <= v <= 1599:
            ls[3] = 1
        elif 1600 <= v <= 1999:
            ls[4] = 1
        elif 2000 <= v <= 2399:
            ls[5] = 1
        elif 2400 <= v <= 2799:
            ls[6] = 1
        elif 2800 <= v <= 3199:
            ls[7] = 1
        else:
            ls[8] += 1
    print(max(sum(ls[:8]), 1), sum(ls[:8]) + ls[8])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int n,AC1=0,WA1=0,TLE1=0,RE1=0;
string a[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]=="AC")
		{
			AC1++;
		}
		if(a[i]=="WA")
		{
			WA1++;
		}
		if(a[i]=="TLE")
		{
			TLE1++;
		}
		if(a[i]=="RE")
		{
			RE1++;
		}
		}
	cout<<"AC"<<" x "<<AC1<<endl;
	cout<<"WA"<<" x "<<WA1<<endl;
	cout<<"TLE"<<" x "<<TLE1<<endl;
	cout<<"RE"<<" x "<<RE1<<endl;
}

Measured memory_bytes: 6748
#include<iostream>
#include<math.h>
using namespace std;

//exchange x for y
void swap(int& x, int& y){
    int t = x;
    x = y;
    y = t;
}

//judge if this data set is right triangle
bool judgeRightTriangle(int& a, int& b, int& c){
    //arrange in ascending order
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    //judge
    if(pow(c, 2) == pow(a, 2) + pow(b, 2)){
        return true;
    } else{
        return false;
    }
}

int main(){
    //入力
    int num = 0;
    cin >> num;

    //判定
    int a, b, c;
    bool check[num];
    for(int i = 0;i < num;i++){
        cin >> a >> b >> c;
        check[i] = judgeRightTriangle(a, b, c);
    }
    //出力
    for(int i = 0;i < num;i++){
        if(check[i] == true){
            cout << "YES\n";
        } else{
            cout << "NO\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3056
unittest
{
	assert( [ "4", "1", "3", "2", "4" ].parse.expand.solve == 2 );
	assert( [ "6", "3", "2", "5", "1", "4", "6" ].parse.expand.solve == 4 );
	assert( [ "8", "6", "3", "1", "2", "7", "4", "8", "5" ].parse.expand.solve == 5 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ps = new long[ n ];
	foreach( ref p; ps )
	{
		input.popFront;
		p = input.front.to!( long );
	}
	return tuple( ps );
}

auto solve( long[] ps )
{
	long[ long ] as;
	foreach( p; ps )
	{
		if( p - 1 in as )
		{
			as[ p ] = as[ p - 1 ] + 1;
			as.remove( p - 1 );
		}
		else
		{
			as[ p ] = 1;
		}
	}
	return ps.length - as.values.reduce!max;
}


Measured memory_bytes: 24060
// abc123_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    ull N;
    cin >> N;
    ull A[5];
    REP(i, 5) { cin >> A[i];}

    ull mn = *min_element(A, A+5);

    ull ans = N % mn == 0 ? N / mn + 4 : N / mn + 5;
    print(ans);

    return 0;
}


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

namespace ABC162A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for (int i = n; i > 0; i /= 10)
            {
                if(i%10 == 7)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string a, b;
    cin >> a >> b;
    string aa, bb;
    rep(i, 0, stoi(b)){
        aa += a;
    }
    rep(i, 0, stoi(a)){
        bb += b;
    }
    if(aa > bb){
        cout << bb << endl;
    }else{
        cout << aa << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

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

  vector<int> x(n);
  rep(i, 0, n) cin >> x[i];

  long long Min = (int)1e9+7;
  rep(i, 0, 101)
  {
    long long Sum = 0;
    rep(j, 0, n)
    {
      Sum += pow(abs(x[j] - i), 2);
    }
    if (Min > Sum)
    {
      Min = Sum;
    }
  }
  cout << Min << endl;
}

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

using namespace std;

constexpr static int MAXN = 1e6;

int n;
int a[MAXN];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int cnt = 0;
    for (int i = 0; i < n;) {
        int dir = 0;
        int j = i + 1;
        while (j < n && 1LL * (a[j] - a[j - 1]) * dir >= 0) {
            if (dir == 0) {
                if (a[j] - a[j - 1] > 0)
                    dir = 1;
                if (a[j] - a[j - 1] < 0)
                    dir = -1;
            }
            j++;
        }
        i = j;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
N = int(input())
def mojiOut(s, mx):
    if len(s) == N:
        print(s)
        return

    for i in range(ord("a"), ord(mx) + 2):
        strS = s
        strS += chr(i)
        mojiOut(strS, max(mx, chr(i)))

mojiOut("a",  "a")

Measured memory_bytes: 4404
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N;
ll C[510];
ll S[510];
ll F[510];

int main() {
    cin >> N;
    rep(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i,N-1){
        ll active = S[i];
        ll cur = i;
        while(cur < N-1){
            ll temp = active-S[cur];
            if (temp <= 0){
                active = S[cur]+C[cur];
                cur++;
            }
            else{
                ll t;
                if (temp%F[cur] != 0){
                    t = temp/F[cur]+1;
                }
                else t = temp/F[cur];
                
                active = S[cur]+ t*F[cur] +C[cur];
                cur ++;
            }
        }
        cout << active << endl;
    }
    cout << 0 << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  // find x s.t. a^x = b
  static T log(T a,T b){
    const T sq=40000;
    unordered_map<T, T> dp;
    dp.reserve(sq);
    Mint res(1);
    for(Int r=0;r<sq;r++){
      if(!dp.count(res.v)) dp[res.v]=r;
      res*=a;
    }
    Mint p=Mint(a).inv().pow(sq);
    res=b;
    for(Int q=0;q<=MOD/sq+1;q++){
      if(dp.count(res.v)){
        T idx=q*sq+dp[res.v];
        if(idx>0) return idx;
      }
      res*=p;
    }
    assert(0);
    return T(-1);
  }

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s;
  cin>>s;
  Int m=n*3;
  using M = Mint<Int, 998244353>;
  M ans{1};

  auto calc=
    [&](char c)->Int{
      if(c=='R') return 1;
      if(c=='G') return 2;
      if(c=='B') return 4;
      assert(0);
    };
  vector<Int> vs(8,0);
  vs[0]=1;
  for(Int i=0;i<m;i++){
    Int len=0,idx=0;
    for(Int j=1;j<8;j++){
      if(vs[j]==0) continue;
      if(j&calc(s[i])) continue;
      Int tmp=__builtin_popcount(j);
      if(tmp>len) len=tmp,idx=j;
    }
    //cout<<i<<":"<<idx<<endl;
    ans*=M(vs[idx]);
    if(idx) vs[idx]--;
    vs[idx|calc(s[i])]++;
  }
  //assert(vs[7]==n);
  for(Int i=1;i<=n;i++) ans*=M(i);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 900
def dec_to_base(num,base):  #Maximum base - 36
    base_num = ""
    while num>0:
        dig = int(num%base)
        if dig<10:
            base_num += str(dig)
        else:
            base_num += chr(ord('A')+dig-10)  #Using uppercase letters
        num //= base

    base_num = base_num[::-1]  #To reverse the string
    return base_num

N, K = map(int, input().split())
print(len(dec_to_base(N,K)))

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <queue>
#define N 100010
int n,d[N];char inq[N];
inline int spfa(int s,int t) {
	std::queue<int> q;int u,v;
	memset(d,33,sizeof(d));
	q.push(s);d[s]=0;inq[s]=1;
	while(!q.empty()) {
		u=q.front();q.pop();inq[u]=0;
		v=u*10%n;
		if(d[u]<d[v]) {
			d[v]=d[u];
			if(!inq[v]) q.push(v),inq[v]=1;
		}
		v=u+1;if(v==n) v=0;
		if(d[u]+1<d[v]) {
			d[v]=d[u]+1;
			if(!inq[v]) q.push(v),inq[v]=1;
		}
	}
	return d[t];
}
int main() {
	scanf("%d",&n);
	printf("%d\n",1+spfa(1,0));
	return 0;
}

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int m=in(),d=in(),ans=0;
    for (int i=4;i<=m;i++){
        for (int i2=22;i2<=d;i2++){
            if (i2%10<2) continue;
            if (i==(i2%10)*(i2/10)) ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){

  int n, A[100005];
  int i,j,k,cmp,tmp;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  cmp = A[n-1];

  i=0;
  
  for(j=0;j<n-1;j++){
    if(A[j] <= cmp){
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
      i++;
    }

  for(k=0;k<n;k++){
    // printf("%-5d",A[k]);
  }
  //printf("\n");
    
  }
  tmp = A[i];
  // printf("値tmp:%d",A[i]);
  A[i] = cmp;
  A[n-1] = tmp;
 
  
  for(k=0;k<n;k++){
    if(k==i) printf("[%d]",A[k]);
    else printf("%d",A[k]);
    if(k!=n-1)printf(" ");
  }
 

  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2104
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize, w:usize,
        s: [chars; h]
    }
    let mut white = 0;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '.' {
                white += 1;
            }
        }
    }
    let mut done = vec![vec![false; w]; h];
    let mut ans = -1;
    let mut count = 0;

    use std::collections::VecDeque;
    let mut queue = VecDeque::new();
    queue.push_back((0,0,0));
    while let Some((i, j, ct)) = queue.pop_front() {
        if done[i][j] {
            continue;
        }
        done[i][j] = true;
        if i == h-1 && j == w-1 {
            count = ct;
            break;
        }
        if i+1 < h && s[i+1][j] == '.' {
            queue.push_back((i+1, j, ct+1));
        }
        if j+1 < w && s[i][j+1] == '.' {
            queue.push_back((i, j+1, ct+1));
        }
        if i > 0 && s[i-1][j] == '.' {
            queue.push_back((i-1, j, ct+1));
        }
        if j > 0 && s[i][j-1] == '.' {
            queue.push_back((i, j-1, ct+1));
        }
    }
    if count > 0 {
        ans = (white -2) - (count - 1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

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



int main() {
    int a,b; cin >> a >> b;
    cout << (a*3+b)/2 << endl;
    return 0;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  // cout<<fixed<<setprecision(10);

  ll h,w; cin>>h>>w;
  vstring s(h); rep(i,h) cin>>s[i];

  vvint dist(h, vint(w, LLONG_MAX));
  if(s[0][0]=='#') dist[0][0] = 1;
  else dist[0][0] = 0;

  rep(i,h){
    rep(j,w){
      if(j < w-1){
        if(s[i][j] == '.' && s[i][j+1] == '#') chmin(dist[i][j+1], dist[i][j]+1);
        else chmin(dist[i][j+1], dist[i][j]);
      }
      if(i < h-1){
        if(s[i][j] == '.' && s[i+1][j] == '#') chmin(dist[i+1][j], dist[i][j]+1);
        else chmin(dist[i+1][j], dist[i][j]);
      }
    }
  }

  cout<<dist[h-1][w-1]<<endl;

}






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

int main(){
	int n;
	int a[220];
	cin >> n;
	rep(i,n) cin >> a[i];
	int ans = 0;
	while(true){
		bool odd = false;
		rep(i,n){
			if(a[i]%2!=0) odd = true;
		}
		if(odd) break;
		rep(i,n) a[i] /= 2;
		++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
ns = int(input())
s = list(map(int, input().split()))
nt = int(input())
t = list(map(int, input().split()))

count = 0

for i in t:
    left = 0
    right = ns
    while left < right:
        mid = int((left + right) / 2)
        if s[mid] == i:
            count += 1
            break
        elif i < s[mid]:
            right = mid
        else:
            left = mid + 1

print(count)



Measured memory_bytes: 16708
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int a_sum = 0;
    for (int i = 0; i < n; i++) {
        a_sum += a[i];
    }

    vector<int> div(0);
    for (int i = 1; 1LL * i * i <= a_sum; i++) {
        if (a_sum % i == 0) {
            div.push_back(i);
            div.push_back(a_sum / i);
        }
    }

    sort(div.begin(), div.end());

    int res = 0;
    for (int i = 0; i < static_cast<int>(div.size()); i++) {
        vector<int> a_mod(n);
        for (int j = 0; j < n; j++) {
            a_mod[j] = a[j] % div[i];
        }

        sort(a_mod.begin(), a_mod.end());

        vector<int> a_mod_sum_fwd(n), a_mod_sum_rev(n);
        for (int j = 0; j < n; j++) {
            a_mod_sum_fwd[j] = a_mod[j];
            a_mod_sum_rev[j] = div[i] - a_mod[j];
        }

        for (int j = 1; j < n; j++) {
            a_mod_sum_fwd[j] += a_mod_sum_fwd[j - 1];
        }

        for (int j = n - 2; j >= 0; j--) {
            a_mod_sum_rev[j] += a_mod_sum_rev[j + 1];
        }

        for (int j = 0; j < n - 1; j++) {
            if (a_mod_sum_fwd[j] % div[i] == a_mod_sum_rev[j + 1] % div[i]
                    && max(a_mod_sum_fwd[j], a_mod_sum_rev[j + 1]) <= k) {
                res = div[i];
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

# x = n // (a + b)
# pr/int(x)
x = 0
x = (n // (a + b)) * a
y = 0
if a != 0:
    y = n % (a+b)
    if not 0 <= y <= a:
        y = a

print(x + y)

        


Measured memory_bytes: 5192
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  double d, t, s;
  cin >> d >> t >> s;
  cout << (t >= d / s ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1e9+7;
const int N=1e6+3;
const int S=25000;

int n,k,sum;
int a[N];
bool vis[S];
int prime[S],pcnt;
int cnt[S];
vector<int>vec;

void Init() {
	for(int i=2;i<S;i++) {
		if(!vis[i]) prime[++pcnt]=i;
		for(int j=1;j<=pcnt&&i*prime[j]<S;j++) {
			vis[i*prime[j]]=true;
			if(i%prime[j]==0)
				break;
		}
	}
}
int ans;
int b[N];
void Check(int num) {
	for(int i=1;i<=n;i++)
		b[i]=a[i]%num;
	sort(b+1,b+n+1);
	int tot=0,l=1,r=n;
	while(l<r) {
		int dir=min(b[l],num-b[r]);
		tot+=dir;
		b[l]-=dir;
		b[r]+=dir;
		if(b[l]==0) l++;
		if(b[r]==num) r--;
	}
	if(tot<=k)
		ans=max(ans,num);
}
void Dfs(int pos,int num) {
	if(pos==vec.size()) {
		if(num>ans)
			Check(num);
		return ;
	}
	int id=vec[pos];
	Dfs(pos+1,num);
	for(int i=1;i<=cnt[id];i++)
		num*=prime[id],Dfs(pos+1,num);
}
int main() {
	Init();
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),sum+=a[i];
	for(int i=1;i<=pcnt;i++) {
		if(sum%prime[i]==0) {
			vec.push_back(i);
			while(sum%prime[i]==0)
				sum/=prime[i],cnt[i]++;
		}
	}
	if(sum!=1) {
		prime[++pcnt]=sum,cnt[pcnt]=1;
		vec.push_back(pcnt);
	}
	Dfs(0,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]=1/a[i];
    // cout<<fixed<<setprecision(10)<<a[i]<<endl;
    if(i>0)a[i]+=a[i-1];
  }
  double ans=1/a[n-1];
  cout<<fixed<<setprecision(7)<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
using namespace std;
ll n,k,a[N],ans,sum;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n-k;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>


using namespace std;
#define MAX 100000

int main(){
    int A;
    int B;

    scanf("%d%d", &A, &B);

    if ((8 >= A) && (8 >= B)){
        printf("Yay!");
    }
    else{
        printf(":(");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from functools import reduce
from operator import xor


def read():
    M, K = map(int, input().strip().split())
    return M, K


def solve(M, K):
    seq = [str(0) for i in range(2**(M+1))]
    if K == 0:
        for i in range(2**M):
            seq[2*i] = str(i)
            seq[2*i+1] = str(i)
    else:
        if K >= 2**M:
            return -1
        # (A) K ... 0 K 0 rev(...), xor(...) == K の形を作れればOK
        S = [a for a in range(2**M) if a not in (0, K)]
        if len(S) == 0 or reduce(xor, S) != K:
            return -1
            
        j = 0
        for i in range(2**M-2):
            j += 1
            if j == K:
                j += 1
            seq[i+1] = str(j)
            seq[2**(M+1) - i - 1] = str(j)
        seq[0] = str(K)
        seq[2**M] = str(K)
        
    return " ".join(seq)


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 34920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n,c,k;cin>>n>>c>>k;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    int before = v[0];
    int ans = 1;
    int cnt = 0;
    rep(i,n){
        cnt++;
        if(v[i] > before+k){
            before = v[i];
            ans++;
            cnt=1;
        }
        if(cnt==c){
            if(i+1 < n){
                before = v[i+1];
                cnt = 0;
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <stdio.h>

int main()
{
 int m, f, r;
 
 while(1)
 {
     scanf("%d %d %d\n", &m, &f, &r);

     if(m == -1 && f == -1 && r == -1)
     {
         break;
     }
     else if(m == -1 || f == -1)
     {
         printf("F\n");
     }
     else if(m + f >= 80)
     {
         printf("A\n");
     }
     else if(80 > m + f && m + f >= 65)
     {
         printf("B\n");
     }
     else if(65 > m + f && m + f >= 50)
     {
         printf("C\n");
     }
     else if(50 > m + f && m + f >= 30 && r >= 50)
     {
         printf("C\n");
     }
     else if(50 > m + f && m + f >= 30)
     {
         printf("D\n");
     }
     else if(m + f < 30)
     {
         printf("F\n");
     }
 }

 return 0;
}

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

int main(void){
    int a,b,c;string s;
    cin >> a >> b;
    if(a <= 0 && b >= 0)s = "Zero";
    else if(a > 0 && b > 0)s = "Positive";
    else if(a < 0 && b < 0){
        c = b-a+1;
        if(c % 2 == 1)s = "Negative";
        else s = "Positive";
    } else {
        c = -a;
        if(c % 2 == 1)s = "Negative";
        else s = "Positive";
    }
    cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i, 0, N) {
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, 0, k) {
            int v; cin >> v;
            v--;
            G[u].push_back(v);
        }
    }
    vector<int> d(N), f(N), visited(N);
    int cnt = 0;
    function<void(int)> dfs = [&](int cur) {
        if(visited[cur]) return;
        d[cur] = ++cnt;
        visited[cur] = 1;
        for(auto &to : G[cur]) {
            if(visited[to]) continue;
            dfs(to);
        }
        f[cur] = ++cnt;
    };
    rep(i, 0, N) dfs(i);
    rep(i, 0, N) cout << i + 1 << " " << d[i] << " " << f[i] << '\n';
    return 0;
}



Measured memory_bytes: 3140
s = [*input()]
for _ in range(int(input())):
	l = input().split()
	a = int(l[1])
	b = int(l[2]) + 1
	if l[0] == 'print':
		print(*s[a:b], sep='')
	elif l[0] == 'reverse':
		s[a:b] = reversed(s[a:b])
	elif l[0] == 'replace':
		s[a:b] = l[3]



Measured memory_bytes: 5740
a,b,c,d,e=map(int,input().split())
#b,w=map(int,input().split())
#t=int(input())
if a==0:
    print("1")
elif b==0:
    print("2")
elif c==0:
    print("3")
elif d==0:
    print("4")
elif e==0:
    print("5")



Measured memory_bytes: 9164
#include <stdio.h>

int main(void)

{
  int x, y;
  int i;
  int z = 0;

  int a, b;

 scanf("%d", &x);
 scanf("%d", &y);

  if(x < y)
{
    a = y;
    y = x;
    x = a;
}

  if(x != y)
{
   b = x % y;
  }else
{
   b = x;
}

 for(i = 1; i <= b; i++)
{
  if(b % i == 0 && y % i == 0 && i > z)
   z = i;
}

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

return 0;

}



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


int dp[1005][1005];


string generate(string arr,int n,string brr,int m)
{
	string str="";
	int i=n,j=m;
	while(i>0&&j>0)
	{
		if(arr[i-1]==brr[j-1])
		{
			str=arr[i-1]+str;
			i--;j--;
		}
		else if(dp[i-1][j]==dp[i][j])
		i--;
		else if(dp[i][j-1]==dp[i][j])
		j--;
	}
	return str;
}


int func(string arr,int n,string brr,int m)
{
	int i,j;
	for(i=0;i<=n;i++)
	dp[i][0]=0;
	for(j=0;j<=m;j++)
	dp[0][j]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(arr[i-1]==brr[j-1])
			dp[i][j]=dp[i-1][j-1]+1;
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	return dp[n][m];	
}
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
    int n;cin>>n;
    int arr[n],i;
    for(i=0;i<n;i++)
    cin>>arr[i];
    if(n==1){cout<<0;return 0;}
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    
    cout<<dp[n-1];
    return 0;
    
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct BIT{
  ll M=1;
  vector<ll> dat;
  BIT(ll N){
    while(N>M) M*=2;
    dat.resize(M*2-1, 0);
  }
  void update(ll x, ll k){
    for(int i=k+1;i<=M;i+=(i&(-i))){
      dat[i] += x;
    }
  }
  ll sum(ll r){
    ll ret = 0;
    for(int k=r;k>0;k-=(k&(-k))) ret += dat[k];
    return ret;
  }

  ll query(ll l, ll r){
    return sum(r) - sum(l);
  }
};

int main(int argc, char const *argv[]) {
  ll n, q;std::cin >> n >> q;
  vll c(n);
  vvl x = VV(n, 0, 0, ll);
  re(i, n) {
    std::cin >> c[i];
    c[i]--;
    x[c[i]].push_back(i);
  }
  BIT seg(n+1);
  vll ans(q, 0);
  vector<vector<pair<ll, ll>>> d(n);
  for(int i=0;i<q;i++){
    ll l, r;std::cin >> l >> r;
    l--, r--;
    d[r].push_back(pair<ll, ll>(l, i));
  }
  for(int i=0;i<n;i++){
    ll now = c[i];
    auto itr = lower_bound(all(x[now]), i);
    ll pre = 0;
    if(itr!=x[now].begin()){
      itr--;
      pre = (*itr) + 1;
    }
    seg.update(1, i);
    if(pre!=0) seg.update(-1, pre-1);
    for(auto v:d[i]){
      ll l = v.first;
      ll idx = v.second;
      ans[idx] = seg.query(l, i+1);
    }
  }
  re(i, q) std::cout << ans[i] << endl;
  return 0;
}


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

int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(auto& i : A) cin >> i;
  
  int ans = X;
  for(int i = 0; i < N; ++i)
  {
    if(D % A[i] == 0) ans += D / A[i];
    else ans += (D / A[i]) + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
 
public class Main implements Runnable {

  public void run() {
    Scanner scanner = new Scanner(System.in);

    long n = scanner.nextLong();
    long x = scanner.nextLong();
    long res = x + calc(n - x, x);

    System.out.println(res);
  }

  public long calc(long a, long b) {
    if (b == 0) {
      return 0;
    }
    if (a >= b) {
      return calc(b, a - b) + a + b;
    } else {
      long q = b / a;
      long r = b % a;
      return calc(a, r) + 2 * a * q;
    }
  }

  public static void main(String[] args) {
    Main main = new Main();
    main.run();
  }
 
  public static class BetterScanner {
 
    private InputStream stream;
    private byte[] buffer = new byte[1024];
    private int pointer = 0;
    private int bufferLength = 0;
 
    public BetterScanner(InputStream stream) {
      this.stream = stream;
    }
 
    private boolean updateBuffer() {
      if (pointer >= bufferLength) {
        pointer = 0;
        try {
          bufferLength = stream.read(buffer);
        } catch (IOException exception) {
          exception.printStackTrace();
        }
        return bufferLength > 0;
      } else {
        return true;
      }
    }
 
    private int read() {
      if (updateBuffer()) {
        return buffer[pointer ++];
      } else {
        return -1;
      }
    }
 
    public boolean hasNext() {
      skipUnprintable();
      return updateBuffer();
    }
 
    private void skipUnprintable() { 
      while (updateBuffer() && !isPrintableChar(buffer[pointer])) {
        pointer ++;
      }
    }
 
    public String next() {
      if (hasNext()) {
        StringBuilder builder = new StringBuilder();
        int codePoint = read();
        while (isPrintableChar(codePoint)) {
          builder.appendCodePoint(codePoint);
          codePoint = read();
        }
        return builder.toString();
      } else {
        throw new NoSuchElementException();
      }
    }
 
    public long nextLong() {
      if (hasNext()) {
        long number = 0;
        boolean minus = false;
        int codePoint = read();
        if (codePoint == '-') {
          minus = true;
          codePoint = read();
        }
        if (codePoint >= '0' && codePoint <= '9') {
          while (true) {
            if (codePoint >= '0' && codePoint <= '9') {
              number *= 10;
              number += codePoint - '0';
            } else if (codePoint < 0 || !isPrintableChar(codePoint)) {
              return (minus) ? -number : number;
            } else {
              throw new NumberFormatException();
            }
            codePoint = read();
          }
        } else {
          throw new NumberFormatException();
        }
      } else {
        throw new NoSuchElementException();
      }
    }
 
    public int nextInt() {
      long number = nextLong();
      if (number >= Integer.MIN_VALUE && number <= Integer.MAX_VALUE) {
        return (int)number;
      } else {
        throw new NumberFormatException();
      }
    }
 
    private boolean isPrintableChar(int codePoint) {
      return codePoint >= 33 && codePoint <= 126;
    }
 
  }
 
}


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

int main(){
  
  int a, b, c;
  
  cin >> a >> b >> c;
    
  if (a - b == b - c){
    
    cout << "YES";
    
  }else{
    cout << "NO";
    
  }
  
  cout << endl;
  
}

Measured memory_bytes: 3484
//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	//入力
	long a[100000], b[100000],x[100000];
	long N, M=0, ans=0,T,X;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		M = max(M, a[i]);
		ans += a[i];
	}
	//処理
	//出力
	cout << ans - (M/2) << endl;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    string ans = "Yes";
    for(int i=0; i<s.length();i++){
        if(s.at(i)!=t.at(i)) ans ="No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600