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

int main() {
	string s;
	cin>>s;
	int count=0;
	int count_max=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R')
		  count++;
		else{
			count_max=max(count_max,count);
			count=0;
		}
	}
	count_max=max(count,count_max);
	cout<<count_max<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3624
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 

ll f(ll x) {
    ll res = 0;
    
    FOR(i, 1, 41) {
        const ll P = 1LL << i;
        ll cnt = ((x+1) / P)*(P / 2) + max(0LL, ((x+1)%P) - (P/2));
        
        if (cnt%2 == 1) {
            res += 1LL << (i - 1);
        }
    }

    return res;
}

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

    ll A, B; cin >> A >> B;

    ll ans = f(B) ^ f(A - 1);
    cout << ans << endl;

    return 0;
}

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

public class Main{
  public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     String s = scanner.nextLine();
     String p = scanner.nextLine();
     String sss = s + s + s;
     if(sss.contains(p)){
       System.out.println("Yes");
     }else{
       System.out.println("No");
     }

  }
}



Measured memory_bytes: 26304
N, M = list(map(int, input().split()))  # N頂点, M個のクエリ

counter = {}
for i in range(1, N+1):
    counter.setdefault(i, 0)

for i in range(M):
    a, b = map(int, input().split())
    counter[a] += 1
    counter[b] += 1

for num in counter.values():
    if num % 2 == 1:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 15084
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
    string a;
    cin>>a;
    int n = a.size();
    n -= 2;
    cout << a[0] << n <<a[n+1];
    return 0;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

vector<ll> vv;

int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		ll a, b;
		cin >> a >> b;
		sum -= b;
		vv.push_back(a + b);
	}
	sort(ALL(vv));
	reverse(ALL(vv));
	for (int i = 0; i < vv.size(); i += 2)
		sum += vv[i];
	cout << sum << "\n";
	return 0;
}




Measured memory_bytes: 1400
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    ll n;
    cin>>n;
    int a,c=0,c1=0,flag=0;
    while(n!=0)
    {
        a=n%10;
        if(a==7)
        {
            flag=1;
            break;
        }
        n=n/10;
        c++;
    }
    if(flag==1)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n,x;
	cin >> n;
	x=n%1000;
	if(x==0){
		cout << 0 << endl;
	}
	else{
		cout << 1000-x << endl;
	}
}


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

int main(){
  int n, ai, i, k=0, ans=-1;
  cin >> n;
  vector<int> a(n,0);
  
  for (i=0; i<n; i++) {
    cin >> ai;
    a[i] = ai -1;
  }
  
  for (i=0; i<n; i++) {
    k = a[k];
    if (k==1) {
      ans = i+1;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;  
}

Measured memory_bytes: 640
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

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

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

int depth(int i, vector<int>& depths, vector<bool>& visit, const umap<int, uset<int>>& E) {
  if(visit[i]) return -1;
  if(depths[i] > 0) return depths[i];
  int ans = 0;
  auto js = E.find(i);
  if(js != E.end()) {
    visit[i] = true;
    for(auto j: (*js).second) {
      int d = depth(j, depths, visit, E);
      if(d == -1) {
        visit[i] = false;
        return -1;
      }
      ans = max(ans, d);
    }
    visit[i] = false;
  }
  depths[i] = 1 + ans;
  return depths[i];
}
void solve() {
  int N;
  cin >> N;
  int A[N][N];
  rep(i, N) {
    rep(j, N - 1) {
      cin >> A[i][j];
    }
  }

  unordered_map<int, unordered_set<int>> E;

  auto node_for = [N](int i, int j) {
    if(i < j) return i * N + j;
    else return j * N + i;
  };

  rep(i, N) {
    rep2(j, 1, N - 1) {
      E[node_for(i, A[i][j - 1] - 1)].insert(node_for(i, A[i][j] - 1));
    }
  }
  vector<int> depths(N * N);
  vector<bool> visit(N * N);
  int ans = -1;
  rep(i, N * (N - 1)) {
    int d = depth(i, depths, visit, E);
    if(d == -1) { ans = -1; break; }
    ans = max(ans, d);
  }

  cout << ans << endl;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int res = (a + b) % 24;
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,j,tmp;
  int mount[10];
 
  for(i=0;i<10;i++){
    scanf("%d ",&mount[i]);
  }
 
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(mount[i]<mount[j]){
    tmp = mount[i];
    mount[i] = mount[j];
    mount[j] = tmp;
      }
    }
  }
 
  printf("%d\n%d\n%d\n",mount[0],mount[1],mount[2]);
 
  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}


void oneCase () {
    string s;
    cin >> s;
    for (auto& l : s) {
        if (l == ',') {
            l = ' ';
        }
    }
    cout << s;
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int n, m;
int a[51], b[51];
vector<pair<int, int>> g[51];
int u[21], v[21];
int eid[51][51];

void dfs(int *eid, int u, int p = -1) {
  for (pair<int, int> c : g[u]) {
    int t, id; tie(t, id) = c;
    if (t != p) {
      eid[t] = id;
      dfs(eid, t, u);
    }
  }
}

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

  read(n);
  rep(i, 1, n) {
    read(a[i], b[i]);
    g[a[i]].push_back({ b[i], i });
    g[b[i]].push_back({ a[i], i });
  }
  read(m);
  rep(i, 0, m) read(u[i], v[i]);

  rep(i, 1, n + 1)
    dfs(eid[i], i);

  ll sum = 0;
  rep(i, 1, 1 << m) {
    ll sgn = __builtin_popcountll(i) % 2 ? 1 : -1;
    ll ban[51]; fill(ban, ban + 51, 0);
    int cnt = n - 1;
    rep(j, 0, m) if (i & (1 << j)) {
      int *eid = ::eid[u[j]];
      int t = v[j];
      while (eid[t]) {
        ban[eid[t]] = 1;
        t = a[eid[t]] != t ? a[eid[t]] : b[eid[t]];
      }
    }
    rep(j, 1, n) if (ban[j]) cnt--;
    sum += sgn * (1ll << cnt);
  }

  ll ans = (1ll << (n - 1)) - sum;
  write(ans);
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  ll k;

  FOR(i, 1, 3501){
    FOR(j, 1, 3501){
      if(4 * i * j - n * (i + j) != 0){
        if((n * i * j) % (4 * i * j - n * (i + j)) == 0){
          k = (n * i * j) / (4 * i * j - n * (i + j));
          if(k >= 1 && k <= 3500){
            cout << i << " " << j << " " << k << endl;
            return 0;
          }
        }
      }
    }
  }
  return 0;
}


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

using namespace std;
using ll = long long;
int n,x[16],y[16],d[16],D[16],p[16];
ll ans[16];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    memset(ans , 0x3f , sizeof(ans));
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>p[i];
    }

    for(int i=0;i<n;i++){
        D[i] = min(abs(x[i]) , abs(y[i]));
    }
    ans[0] = 0;
    for(int i=0;i<n;i++){
        ans[0] += (ll)D[i]*p[i];
    }
    for(int i=1;i<(1<<n);i++){
        int j = i;
        do{
            memcpy(d,D,sizeof(D));
            for(int k=0;k<n;k++){
                if(i>>k&1){
                    if(j>>k&1){
                        for(int q=0;q<n;q++){
                            d[q] = min(d[q] , abs(x[q] - x[k]));
                        }
                    }
                    else{
                        for(int q=0;q<n;q++){
                            d[q] = min(d[q] , abs(y[q] - y[k]));
                        }
                    }
                }
            }
            ll tmp = 0;
            for(int i=0;i<n;i++) tmp += (ll)d[i] * p[i];
            ans[__builtin_popcount(i)] = min(ans[__builtin_popcount(i)] , tmp);
            j = (j-1) & i;
        }while(j != i);
    }
    for(int i=0;i<=n;i++) cout<<ans[i]<<endl;
    return 0;
}









Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define setp(n) fixed<<setprecision(n)
int main(){
    int n, a, b=0, c=0;
    cin>>n;
    vector<int> h;
    rep(i, n){
        cin>>a;
        h.push_back(a);
        b+=abs(a-c);
        c=a;
    }
    b+=a;
    cout<<b/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = 10**9+7

n = int(input())
S = [s=="W" for s in input().rstrip()]
B = []
l, r = 0, 0
ans = 1
for i in range(n):
  ans *= i+1
  ans %= mod
for s in S:
  if (l+r+s)%2:
    if l == r or r == n:
      print(0)
      exit()
    ans *= (l-r)
    ans %= mod
    r += 1
  else:
    if l == n:
      print(0)
      exit()
    l += 1
print(ans)

Measured memory_bytes: 10968
package main

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

const WIDTH = 502
const HEIGHT = 502

/*
var nrs = bufio.NewReaderSize(os.Stdin, 1000000)

func readLineToInt() []int {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := nrs.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    line := strings.Split(string(buf), " ")
    var intLine []int
    for _, str := range line {
        n, _ := strconv.Atoi(str)
        intLine = append(intLine, n)
    }
    return intLine
}
*/
var sc = bufio.NewScanner(os.Stdin)

func readLineToInt() []int {
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    var intLine []int
    for _, str := range line {
        n, _ := strconv.Atoi(str)
        intLine = append(intLine, n)
    }
    return intLine
}

func main() {
    var m, q int
    var l, r int
    var a, b int
    var mp [HEIGHT][WIDTH]int
    nmq := readLineToInt()
    _, m, q = nmq[0], nmq[1], nmq[2]
    //sc.Scan()
    //fmt.Sscanf(sc.Text(), "%d %d %d", &n, &m, &q)

    for i := 0; i < m; i++ {
        lr := readLineToInt()
        l, r = lr[0], lr[1]
        //sc.Scan()
        //fmt.Sscanf(sc.Text(), "%d %d", &l, &r)
        mp[l][r] += 1
    }

    for x := 0; x < WIDTH - 1; x++ {
        mp[0][x] += mp[0][x + 1]
    }

    for y := 1; y < HEIGHT; y++ {
        for x := 0; x < WIDTH - 1; x++ {
            mp[y][x + 1] += mp[y][x]
            mp[y][x] += mp[y - 1][x]
        }
    }

    for i := 0; i < q; i++ {
        ab := readLineToInt()
        a, b = ab[0], ab[1]
        //sc.Scan()
        //fmt.Sscanf(sc.Text(), "%d %d", &a, &b)
        fmt.Println(mp[b][b] - mp[b][a - 1] - mp[a - 1][b] + mp[a - 1][a - 1])
    }
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
//#define int long long
using namespace std;

signed main() {
	vector<int> a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>meels(n);
    vector<int>man(n);
    vector<int>tuiman(n);
    for(int i=0;i<n;i++){
        cin>>meels.at(i);
    }
    long int manzoku=0;
    for(int i=0;i<n;i++){
        cin>>man.at(i);
        manzoku+=man.at(i);
    }
    for(int i=0;i<n-1;i++){
        cin>>tuiman.at(i);
    }
    for(int i=1;i<n;i++){
        if(meels.at(i)==meels.at(i-1)+1){
            manzoku+=tuiman.at(meels.at(i-1)-1);
        }
        else{
            int unko=0;
        }

    }
    cout<<manzoku<<endl;
    
    
}

Measured memory_bytes: 256
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {


        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            Set<String> str = new HashSet<>();
            int prev = -1;
            for (int i = 0; i < n; i++) {
                String s =sc.next();
                if (prev != -1 && s.charAt(0) != prev) {
                    pw.println("No");
                    return;
                }
                prev = s.charAt(s.length() - 1);
                if (str.contains(s)) {
                    pw.println("No");
                    return;
                } else {
                    str.add(s);
                }
            }
            pw.println("Yes");
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll lcm(int a, int b){
    return (ll)a * b / __gcd(a, b);
}

int main() {
    for(;;) {
        ll n, x, ans = 0;
        cin >> n >> x;
        if(n==0)break;
        for (ll i = 1; i <= n; i++) {
            for (ll j = i + 1; j <= n; j++) {
                for (ll k = j + 1; k <= n; k++) {
                    if (i + j + k == x)ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3072
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int N, M; readf("%d %d\n", &N, &M);
    int[] A = new int[N];
    int[] c = new int[N];
    foreach (i; 0 .. N) {
        readf("%d\n", &A[i]);
    }
    foreach (i; 0 .. M) {
        int b; readf("%d\n", &b);
        foreach (j; 0 .. N) {
            if (A[j] <= b) {
                c[j]++;
                break;
            }
        }
    }
    int a = c.reduce!max;
    foreach (i; 0 .. N) {
        if (c[i] == a) {
            writeln(i + 1);
            break;
        }
    }
}

Measured memory_bytes: 1060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  double ans = 0;
  double halfbeki[100001];
  halfbeki[0] = 1;
  long long twohat[19];
  twohat[0] = 1;
  int times[100001];
  double tmp = 1;
  long long tmpp  = 1;
  for(int i=1; i <= 100000; i++){
    halfbeki[i] = (tmp /= 2);
    if(i < 19) twohat[i] = (tmpp *= 2);
  }

  for(int i=1; i <= N; i++){
    for(int j = 0; j < 19; j++){
      if(i * twohat[j] >= K){
        times[i] = j;
        break;
      }
    }
  }

  for(int i=1; i <= N; i++){
    //cout << halfbeki[times[i]] << endl;
    ans += halfbeki[times[i]];
  }
  //cout << ans << endl;
  ans /= N;
  cout << setprecision(20) << ans << endl;


  return 0;
}


Measured memory_bytes: 1536
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    a = li()
    bunshi = 1
    bunbo = 0
    for i in a:
        bunshi *= i
    for i in a:
        bunbo += bunshi / i
    
    print(bunshi/bunbo)


main()


Measured memory_bytes: 3060
from collections import deque
d = deque()
n,k = map(int,input().split())
l = [0]*n
for i in range(n):
  l[i] = int(input())
l.sort()
for i in range(k-1):
  d.append(l[i])
mini = 10**9
for i in range(k-1,n):
  x = d.popleft()
  y = l[i]
  mini = min(mini,y-x)
  d.append(y)
print(mini)

Measured memory_bytes: 47320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
typedef long long ll;
typedef vector<long long> vl;
const ll mod = 1000000007;

int main(){
	ll a[10][10];
	rep(i,3){
		rep(j,3)cin >> a[i][j];
	}
	ll n; cin >> n;
	vl b(n); rep(i,n)cin >> b[i];
	bool r[10][10];
	rep(i,3){
		rep(j,3){
			r[i][j] = false;
		}
	}
	rep(i,3){
		rep(j,3){
			rep(k,n){
				if(a[i][j] == b[k]){
					r[i][j] = true;
				}
			}
		}
	}
	bool s = false;
	rep(i,3){
			if(r[i][0] == r[i][1] && r[i][1] == r[i][2] && r[i][0] == true)s = true;
		
	}
	rep(i,3){
		if(r[0][i] == r[1][i] && r[1][i] == r[2][i] && r[0][i] == true)s = true;

	}
	if(r[0][0] == r[1][1] && r[1][1] == r[2][2] && r[0][0] == true)s = true;
	else if(r[0][2] == r[1][1] && r[1][1] == r[2][0] && r[0][2] == true)s = true;
	if(s) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n;
long long a[111111];
int main(void){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  long long ans = 0;
  for(int i = 0; i < n; i++){
    if(i && a[i] && a[i-1]%2){
      ans++;
      a[i]--;
    }
    ans += a[i]/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,H[(int)2e5],K;
  cin>>N>>K;
  for (int i(0);i<N;i++) cin>>H[i];
  sort(H,H+N,greater<int>());
  ll ans(0);
  if (K >= N){
    cout << 0 << endl;
    return 0;
  }
  for (int i(K);i<N;i++){
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define db(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x) double(x * acos(-1) / 180.0)
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int v[3][3];
int vis[3][3];
int main(){
    //FL;
    fin;
    cls(vis, 0);
    fore(i, 0, 3)
        fore(j, 0, 3)
            cin >> v[i][j];
    int n;
    cin >> n;
    w(n){
        int x;
        cin >> x;
        fore(i, 0, 3)
            fore(j, 0, 3)
                if(v[i][j] == x)
                    vis[i][j] = 1;
    }
    bool flag = ((vis[0][0] > 0) && (vis[1][1] > 0) && (vis[2][2] > 0));
    flag |= (vis[0][2] > 0 && vis[1][1] > 0 && vis[2][0] > 0);
    fore(i, 0, 3){
        int cur = 0;
        int tmp = 0;
        fore(j, 0, 3){
            if(vis[i][j] > 0)
                cur++;
            if(vis[j][i] > 0)
                tmp++;
        }
        if(cur == 3 or tmp == 3)
            flag = 1;
    }
    cout << (flag ? "Yes" : "No") << '\n';
    time;
    return 0;
}       


Measured memory_bytes: 384
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    print(a/b)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    cnt=Dict{Char,Int}('a'=>0,'b'=>0,'c'=>0)
    for i in s
        cnt[i]+=1
    end
    ans="YES"
    for i in 'a':'c',j in 'a':'c'
        if abs(cnt[i]-cnt[j])>1
            ans="NO"
        end
    end
    println(ans)
end
main()

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

#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) for(int i = 1; i < n; ++i)
#define repm(i, n, m)  for(int i = n; i <= m; i++)

int main(){
    int m, d; cin >> m >> d;
    int ans = 0;
    repm(i, 1, m){
        repm(j, 10, d){
            if(j%10 >= 2&& j/10 >= 2 && (j%10)*(j/10) == i){
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	var s, w int
	fmt.Scan(&s, &w)
	if s <= w {
		fmt.Println("unsafe")
		return
	}
	fmt.Println("safe")
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)


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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// =================================

Measured memory_bytes: 1820
#include <stdio.h>

int main(void){
 int N;
 scanf("%d",&N);
 int A[N];
 int i=0;
 for(i=0;i<N;i++){
   scanf("%d",&A[i]);
 }
 int max=0;
 for(i=0;i<N;i++){
 if(A[i]>max){
  max = A[i];

   }
 }
 int sum=0;
 i=0;
 for(i=0;i<N;i++){
   sum=sum+A[i];
 }
 if(sum-max>max){
  printf("Yes\n");
  }else if(sum-max<=max){
  printf("No\n");
  }

 return 0;

}



Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
const int Maxn=400000;
int n;
int left[Maxn+5],right[Maxn+5];
int a[Maxn+5],b[Maxn+5];
struct Segment{
	int left,right;
	friend bool operator <(Segment a,Segment b){
		return a.left<b.left;
	}
}seg[Maxn+5];
int len;
int f[Maxn+5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(left[a[i]]==0){
			left[a[i]]=i;
		}
		right[a[i]]=i;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		b[i+n]=b[i];
	}
	for(int i=1;i<=(n<<1);i++){
		if(left[b[i]]==0){
			continue;
		}
		seg[++len].left=i-right[b[i]]+1;
		seg[len].right=i-left[b[i]]+1;
	}
	for(int i=1;i<=len;i++){
		if(seg[i].left<1){
			f[1]++;
		}
		else{
			f[seg[i].left]++;
		}
		if(seg[i].right<0){
			f[1]--;
		}
		else{
			f[seg[i].right+1]--;
		}
	}
	for(int i=1;i<=n;i++){
		f[i]+=f[i-1];
	}
	int pos=-1;
	for(int i=1;i<=n;i++){
		if(f[i]==0){
			pos=i;
			break;
		}
	}
	if(pos==-1){
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=pos;i<pos+n;i++){
		printf("%d ",b[i]);
	}
	puts("");
	return 0;
}


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

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;
set <ll> s;
int main()
{_
    ll a , b , k; cin >> a >> b >> k;
    for(ll i = a ; i < a + k and i < b ; i++)
        s.insert(i);
    for(ll i = b - k + 1 ; i <= b; i++)
        if(i >= a)s.insert(i);
    set <ll> ::iterator it = s.begin();
    while(it != s.end())
    {
        cout << *it << endl;
        it++;
    }
    return 0;
}
///SAliB


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a;
    cin >> a;
    if (isupper(a)){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

from queue import Queue,PriorityQueue

from string import ascii_lowercase


sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")
    
def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)


def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)

                


def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
            
    
def solve():
    n=inp()
    l=li()
    s=sum(l)
    d={i+1:l[i] for i in range(n)}
    m=inp()
    for i in range(m):
        x=s
        a,b=mp()
        x-=d[a]
        x+=b
        pr(x)


for _ in range(1):
    solve()
    


Measured memory_bytes: 10256
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
a.unshift nil
b=[]
i=1
list = []
loop do
  break if b[i]
  b[i]=true
  list << a[i]
  i=a[i]
end
c = 0
list_dup=list.dup
loop do
  break if list[0]==a[i]
  list.shift
  c+=1
end
if k > c
  k-=c
  p list[k%list.size-1]
else
  p list_dup[k-1]
end


Measured memory_bytes: 32024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

ll f(int a){
    return (ll)a*a*a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    ll ans = 0;
    if(k%2==0){
        // n以下で、kの倍数および、kで割ってk/2余る個数
        ans = f(n/k);
        int cnt=0;
        while(cnt*k+k/2 <= n) cnt++;
        ans += f(cnt);
        // ans += f((n-k/2)/k+1);
        // cerr<<cnt<<endl;
        cerr<<(n-k/2)/k+1<<endl;
    } else {
        // n以下でkの倍数の個数
        ans = f(n/k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N,C = map(int, input().split())
s =[0]*N
t =[0]*N
c =[0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int, input().split())

imos = [[0]*int(1e5+20) for _ in range(31)]
for i in range(N):
    imos[c[i]][s[i]]+=1
    imos[c[i]][t[i]+1]-=1

ans = 0
for i in range(1,int(1e5+10)):
    sm = 0
    for j in range(C+1):
        imos[j][i]=imos[j][i-1]+ imos[j][i]
        if imos[j][i] >= 1:
            sm+=1
    ans = max(ans,sm)
print(ans)

Measured memory_bytes: 38040
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 998244353;
#define int ll
int n, m, ans, cnt[100010];

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>m;
	cout<<n*m/__gcd(n, m);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int k;
    cin >> k;
    ll ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                int t = __gcd(a, b);
                ans += __gcd(t, c);
            }
        }
    }
    cout << ans << endl;
}

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

// defines
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define casti static_cast<int>
#define cast static_cast
#define ll long long int
#define vi vector<int>
#define vpi vector<pair<int,int >>
#define v vector
#define forl(n) for(int i=0;i<n;i++)
#define fora(a,b,c) for(int i=a;i<b;i+=c)

using namespace std;

ll modF=998244353;

// topcoder



//codechef and codeforces and atcoder

void solve(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
}


int main(){
    boost_io;
    solve();
} 


Measured memory_bytes: 3580
mycode = '''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL

cdef extern int __builtin_popcount(unsigned int) nogil

import numpy as np

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち


cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


cdef read_matrix(LL H,LL W):
    #return np.ndarray shape=(H,W) matrix
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)

# この問題をあえてグラフの構造を持つことで解く
from libcpp.vector cimport vector as vec

cdef LL N,M
N,M=ints()
AB=read_matrix(M,2)-1
cdef LL a,b

ctypedef vec[vec[LL]] Graph
cdef Graph graph=Graph(N)

for a,b in AB:
    graph[a].push_back(b)
    graph[b].push_back(a)

cdef vec[int] ans
for i in range(N):
    ans.push_back(graph[i].size())
print(*ans, sep='\\n')
'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 28312
import sys

p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def pbit(aa,L):
    for a in aa:print(format(a,"b").zfill(L))
    print()

def main():
    n=II()
    aa=[[int(c) for c in SI()] for _ in range(n-1)]
    #p2D(aa)
    
    # 人iが勝てる相手をbitで管理する
    win=[0]*n
    for i,row in enumerate(aa,1):
        for j,a in enumerate(row):
            if a:win[i]|=1<<j
            else:win[j]|=1<<i
    #pbit(win,n)

    # dpl[i]...[j,i]の範囲で優勝できるjをbitで
    # dpr[i]...[i,j]の範囲で優勝できるjをbitで
    dpl=[1<<i for i in range(n)]
    dpr=[1<<i for i in range(n)]
    for d in range(1,n):
        for i in range(n):
            j=i+d
            if j<n and dpl[j] & dpr[i+1] & win[i]:dpl[j]|=1<<i
            j=i-d
            if j>=0 and dpl[i-1] & dpr[j] & win[i]:dpr[j]|=1<<i
    #pbit(dpl,n)
    #pbit(dpr,n)
    #print(format(dpl[n-1]&dpr[0],"b").zfill(n))
    print(bin(dpl[n-1]&dpr[0]).count("1"))

main()

Measured memory_bytes: 130184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define LL long long
using namespace std;

int main(void){
    int n;
    int max = 0;
    int result = 1;
    vector<int> h;

    cin >> n;
    for (int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    max = h[0];
    for (int i = 1; i < n; i++){
        if(max <= h[i]){
            max = h[i];
            result++;
        }
    }
    cout << result << endl;
}

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

signed main()
{
  int t,n;
  cin>>t>>n;
  n=n*n;
  int count=0;
  for(int i=0;i<t;i++)
  {
    int first,second;
    cin>>first>>second;
    if(first*first+second*second<=n)
      count++;
  }
  
  cout<<count<<endl;
 
  return 0;
}
      


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
ll ans;
int main(){
	ll n, x;
	cin >> n >> x;
	vector<ll>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	if (v[0] >=x) {
		ans += v[0]-x;
		v[0] = x;
	}
	for (int i = 0; i < n - 1; i++) {
		if (v[i] + v[i + 1] >= x) {
			ll t = (v[i] + v[i + 1] - x);
			v[i + 1] = v[i + 1] -t ;
			ans +=t;
		}
	}
	cout << ans << endl;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N + 1; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    vector<int> B;
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        B.push_back(b);
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int a = A[i];
        int b = B[i];
        if (a >= b) {
            ans += b;
        } else {
            ans += a;
            b -= a;
            int next_a = A[i+1];
            if (next_a >= b) {
                ans += b;
                A[i+1] = next_a - b;
            } else {
                ans += next_a;
                A[i+1] = 0;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1400
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        if a[i]+a[i+1]-x<=a[i+1]:
            a[i+1]-=a[i]+a[i+1]-x
        else:
            a[i]=x
            a[i+1]=0
print(ans)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    

    pair<int,int> arr[3][3];
    for (int i=0;i<=2;i++)
    {
    	for (int j=0;j<=2;j++)
    	{
    		cin >> arr[i][j].first;
    		arr[i][j].second=0;
    	}
    }

    int n;
    cin >> n;
    for (int alpha=0;alpha<=n-1;alpha++)
    {
    	int a;
    	cin >> a;
    	for (int i=0;i<=2;i++)
    	{
    		for (int j=0;j<=2;j++)
    		{
    			if (arr[i][j].first==a)
    			{
    				arr[i][j].second=1;
    			}
    		}
    	}
    }

    int flag=0;
    for (int i=0;i<=2;i++)
    {
    	int count=0;
    	for (int j=0;j<=2;j++)
    	{
    		if (arr[i][j].second==1)
    		{
    			count++;
    		}
    	}
    	if (count==3)
    	{
    		flag=1;
    		break;
    	}
    }

    for (int j=0;j<=2;j++)
    {
    	int count=0;
    	for (int i=0;i<=2;i++)
    	{
    		if (arr[i][j].second==1)
    		{
    			count++;
    		}
    	}
    	if (count==3)
    	{
    		flag=1;
    		break;
    	}
    }

    int count=0;
    for (int i=0;i<=2;i++)
    {
    	if (arr[i][i].second==1)
    	{
    		count++;
    	}
    }
    if (count==3)
    {
    	flag=1;
    }

    count=0;
    for (int i=0;i<=2;i++)
    {
    	if (arr[i][2-i].second==1)
    	{
    		count++;
    	}
    }
    if (count==3)
    {
    	flag=1;
    }

    if (flag==1)
    {
    	cout << "Yes" << endl;
    }
    else
    {
    	cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
for i in range(1,N+1):
    count = 0
    for x in range(1,int(math.sqrt(i/6))+2):
        for y in range(x,int(math.sqrt(i/3))+2):
            for z in range(y,int(math.sqrt(i))+1):
                if x**2+y**2+z**2+x*y+y*z+z*x != i:
                    continue
                if x == y and x == z:
                    count += 1
                elif x == y or x == z or y == z:
                    count += 3
                else:
                    count += 6
    print(count) 

Measured memory_bytes: 69996
N=int(input())
x,y,z=0,0,0
ans=True
for i in range(N):
    a,b,c=map(int,input().split())
    n=(a-x)-abs(b-y)-abs(c-z)
    x,y,z=a,b,c
    if n<0 or n%2==1:
        ans=False
if ans==True:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 3064