akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  int N;cin >> N;
  vint a(N);
  repeat(i,N){
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  repeat(i,N){
    ans += a[a[i]]==i && i < a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll sum=0;
    ll x=stoll(s);
    rep(i,len(s)){
      sum+=ll(s[i]-'0');
    }
    if(x%sum==0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}

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

int main(void){
    int A, P;
    cin >> A >> P;
    int sum = 0;
    sum = A*3 + P;
    int ans = sum / 2;

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

Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    S = set()
    E = set()
    for m in range(M):
        a, b = il()
        if a == 1:
            S.add(b)
        if b == N:
            E.add(a)

    print('POSSIBLE' if len(S & E) == 1 else 'IMPOSSIBLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 18972
#include<iostream>

using namespace std;

#define rep(i,n) for(i=0;i<(n);i++)
#define For(i,a,b) for(i=(a);i<(b);i++)

int main(){
  int i,j,k;
  int a,b;

  cin >> a >> b;
  cout << a*b << " " << 2*(a+b) << endl;
  
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    rep(i, a){
        cin >> p[i];
    }
    sort(all(p), greater<ll>());

    vector<ll> q(b);
    rep(i, b){
        cin >> q[i];
    }
    sort(all(q), greater<ll>());

    priority_queue<ll> r;
    rep(i, c){
        ll d;
        cin >> d;
        r.push(d);
    }
    rep(i, x){
        r.push(p[i]);
    }
    rep(i, y){
        r.push(q[i]);
    }

    ll ans = 0;
    rep(i, x+y){
        ans += r.top();
        r.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8048
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let 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,
    ]
    .to_vec();
    println!("{}", a[k - 1]);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string.h>
#include<set>
#include<vector>
using namespace std;

int main(){
    int N;
    int A;
    int ans=0;
    vector<int> a;
    vector<int> b;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A;
        a.push_back(A);
        b.push_back(A);
    }
    sort(b.begin(),b.end());
    for(int i=0;i<a.size();i+=2){
        for(int j=1;j<b.size();j+=2){
            if(a[i]==b[j])ans++;
        }
    }
    cout<<ans<<endl;

}

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

int main(){
  int s=0;
  vector<int> vec(5);
  for(int i=0;i<5;i++){
    cin>>vec[i];
  }
  for(int i=0;i<5;i++){
    if(vec[i]==0){
      s=i+1;
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3592
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	#a = int(input())
	al = list(IN())
	#s = input()
	al.sort()
	return 'YES' if al == [5,5,7] else 'NO'
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	vector<ll> v;
	ll ans = 0;
	for(int i = 0; i<T;i++)
	{
		ll temp;
		cin >>temp;
		v.push_back(temp);
	}
	sort(v.rbegin(),v.rend());
	T--;
	T--;
	ans += v[0];
	for(int i = 1; i<v.size();i++)
	{
		if(T>0)
		{
			T--;
			ans += v[i];
		}
		if(T>0)
		{
			T--;
			ans += v[i];
		}
	}
	cout <<ans<<endl;
}


Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  int n, m, ans=0;
  cin >> n >> m;
  vector<set<int>> s(n);
  vector<int> p(m);
  rep (i, m) {
    int x=0;
    cin >> x;
    rep (j, x) {
      int y;
      cin >> y;
      s[y-1].insert(i);
    }
  }
  rep (i, m) cin >> p[i];
  

  int len=n;
  for (int tmp=0; tmp<(1 << len); ++tmp) {
   vector<int> denon(m, 0);
    rep(tmp2, len) {
      if (tmp & (1<<tmp2)) {
        rep (i, m) if (s[tmp2].count(i)) ++denon[i];
      }
    }
    int flag=1;
    rep(i, m) {
      if (denon[i]%2 != p[i]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) ++ans;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e6 + 1;
string s;
char ss[maxN];

int main()
{
  while (scanf(" %s", ss) != EOF)
  {
    s = string(ss);
    string ans = "";
    for (int i = 0; i < s.size(); i ++)
      ans += 'x';
    printf("%s\n", ans.c_str());
  }
  return 0;
}

Measured memory_bytes: 384
/*
Author : N_o_o_B
Created : May 02 2020 17:41:01 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int k,a,b;
    cin >> k >> a >> b;
    int n = b/k - (a-1)/k;
    cout << (n ? "OK":"NG") << endl;



    time_taken();
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, m; std::cin >> n >> m;
    vi k(m);
    vvi s(m);
    rep(i, m) {
        std::cin >> k[i];
        vi vec(k[i]);
        rep(j, k[i]) {
            std::cin >> vec[j];
        }
        s[i] = vec;
    }
    vi p(m);
    rep(i, m) std::cin >> p[i];

    auto calc = [&](int x) {
        int ret = 0;
        rep(i, m) {
            int c = 0;
            for (auto &v : s[i]) {
                c += (x >> (v-1)) & 1;
            }
            if (c % 2 == p[i]) ret++;
        }
        return ret;
    };
    int ans = 0;
    rep(i, 1 << n) {
        ans += calc(i) == m;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 101;
int n, m, i, s, x, y, a[maxn];
int main()
{
	scanf("%d", &n);
	s = 0;
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		s += a[i];
	}
	scanf("%d", &m);
	for (i = 1; i <= m; i++)
	{
		scanf("%d%d", &x, &y);
		printf("%d\n", s - (a[x] - y));
	}
	return 0;
}

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

using namespace std;

int main()
{
  
  int n; cin >> n;
  std::vector<long long> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  std::sort(l.begin(), l.end()); 
  
  long long ans = 0;
  for(int i = 0; i < n; i++)
  {
    for(int j = i+1; j < n; j++)
    {
      int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));
      
      ans += std::max(k-(j+1),0);
    }
  }
  std::cout << ans << std::endl;
  
  // long long ans = 0;
    
  // for (int i = 0; i < n; i++) {
  //     for (int j = i+1; j < n; j++) {
  //         int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));

  //         ans += std::max(k - (j+1), 0);
  //     }
  // }
  // cout << ans << endl;
}




Measured memory_bytes: 256
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
B=[]
C=[]
ans=[]
for i in range(H):
  if '#' in A[i]:
    B.append(A[i])
C=list(zip(*B))
for i in range(W):
  if '#' in C[i]:
    ans.append(C[i])
ans=list(zip(*ans))
for k in range(len(ans)):
  print(*ans[k],sep='')

Measured memory_bytes: 4724
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, A ...int) int {
  S := SumInt(A...)
  C := (*F)[S]
  for _, a := range A {
    C *= (*Finv)[a]
    C %= p
  }
  return C
}

const p = 1000000007

func SC(F, Finv *[]int, X, Y int) int {
  S := 0
  for y := 0; y <= Y; y++ {
    S += Comb(F, Finv, X, y + 1)
    S %= p
  }
  return S
}

func Solve() {
  var r1, c1, r2, c2 int
  NextInt(&r1, &c1, &r2, &c2)
  F, Finv, _ := Factorial(r2 + c2 + 1)
  ans := (SC(&F, &Finv, r2, c2) - SC(&F, &Finv, r2, c1 - 1) - SC(&F, &Finv, r1 - 1, c2) + SC(&F, &Finv, r1 - 1, c1 - 1) + 2 * p) % p
  Write(ans)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 49024
n = gets.to_s.to_i

a = Array.new(n+1,0)
1.upto(n) do |i|
  1.upto(n) do |j|
    a[i.gcd(j)] += 1
  end
end

ans = n * a[1]
2.upto(n) do |t|
  1.upto(n) do |k|
    ans += t.gcd(k) * a[t]
  end
end

puts ans

Measured memory_bytes: 14236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,cnt=0;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    	cin>>a[i];
  for(ll i=0;i<n;i++)
    	a[i] = (i+1)-a[i];
  
  for(ll i=0;i<n;i++)
    if(a[i]!=0)
      cnt++;
  if(cnt>2)
    	cout<<"NO\n";
  else
    	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 256
//ProblemD

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <memory>
#include <cstdio>
#include <cstring>

using namespace std;

//ProblemD

#define MAXN 100000
#define MAXM 200000
#define MAXD 1000000000

#define NOTSET 0x7FFFFFFF

class Solve {
private:
	int n, m;
	struct Edge {
		int to;
		int va;
	};
	vector<Edge> edges[MAXN];
	int dist[MAXN]{};

	bool dfs(int i, int d) {
		dist[i] = d;

		for (auto &e : edges[i]) {
			if (dist[e.to] == NOTSET) {
				if (dfs(e.to, d + e.va)) {
					return true;
				}
			}
			else {
				if (d + e.va != dist[e.to]) {
					return true;
				}
			}
		}
		return false;
	}

	void solve() {
		cin >> n >> m;

		for (int i = 0; i < n; i++) dist[i] = NOTSET;

		for (int i = 0; i < m; i++) {
			int l, r, d;
			cin >> l >> r >> d;
			l--; r--;
			edges[l].push_back({ r, d });
			edges[r].push_back({ l, -d });
		}

		for (int i = 0; i < n; i++) {
			if (dist[i] == NOTSET) {
				if (dfs(i, 0)) {
					cout << "No" << endl;
					return;
				}
			}
		}
		cout << "Yes" << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
long gcd(long a, long b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}
long lcm(long a, long b){
  return a*b/gcd(a,b);
}
int main(){
  long x,y; cin >> x >> y;
  cout << lcm(x,y) << endl;
}

Measured memory_bytes: 256
# encoding: utf-8
S = input()
K = int(input())

# confirm that 2 ** (5000 tri.) = (1024) ** (15 * 10 ** 14) >> 10 ** 18 >= K
tmp = 1
for i in range(5000 * (10 ** 12)):
    tmp = tmp << 1
    if tmp > K:
        for idx, si in enumerate(S):
            if si != "1": break
        # take care of 1
        if K <= idx: print(1)
        else: print(si)
        # end
        break
else:
    # not implemented
    print("WA")




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

int main() {
  vector<int> a={1,3,5,7,8,10,12};
  vector<int> b={4,6,9,11};
  
  bool xbool=false;
  bool ybool=false;
  
  int x,y;
  cin>>x>>y;
  for(int i:a){
    if(i==x) xbool=true;
    if(i==y) ybool=true;
  }
  if(xbool&&ybool){
    cout<<"Yes"<<endl;
    return 0;
  }
  xbool=ybool=false;
  
  for(int i:b){
    if(i==x) xbool=true;
    if(i==y) ybool=true;
  }
  if(xbool&&ybool){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,x,y,z,ans=0,ans2=0,count;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> n>>a>>b;
for(int i = 1 ; i <= n ; i++)
{
  c=0;
int t = i ; 
for (int j = 0 ; j < 5 ; j++)c += t % 10 , t /= 10;
if( a <= c&&c <= b ) ans += i ;
}
  cout << ans;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

/*  嘘解法
bool squareNumber(int n){
  for (int i = 1; i <= sqrt(n); i++){
    if (i * i == n) return true;
  }
  return false;
}
int main(void){
  int N;
  cin >> N;

  for (int i = N; i >= 1; i--){
    if (squareNumber(i)){
      cout << i << endl;
      return 0;
    }
  }
*/

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

  for (int i = 1; ; i++){
    if (i * i > N){
      cout << (i - 1) * (i - 1) << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		//
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		int[] inputInt = null;
		try {
			String[] inputStr = (input.readLine()).split(" ");
			inputInt = new int[inputStr.length];
			for (int i = 0; i < inputStr.length; i++) {
				inputInt[i] = Integer.parseInt(inputStr[i]);
			}
			int d = inputInt[0] / inputInt[1];
			int r = inputInt[0] % inputInt[1];
			double f = (double)(inputInt[0]) / inputInt[1];
			System.out.printf("%d %d %.5f",d,r,f);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 24684
#include <cstdio>

using namespace std;

int main()
{
	char s[11] = {};

	scanf("%s", &s[0]);

	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  ll N, W;
  cin >> N >> W;
  vector<ll> l1, l2, l3, l4;
  ll w1 = 0;
  for (int i = 0; i < N; i++) {
    ll wi, vi;
    cin >> wi >> vi;
    if (i == 0) {
      w1 = wi;
    }
    if (wi == w1 + 0) {
      l1.push_back(vi);
    }
    if (wi == w1 + 1) {
      l2.push_back(vi);
    }
    if (wi == w1 + 2) {
      l3.push_back(vi);
    }
    if (wi == w1 + 3) {
      l4.push_back(vi);
    }
  }
  sort(l1.begin(), l1.end(), greater<ll>());
  sort(l2.begin(), l2.end(), greater<ll>());
  sort(l3.begin(), l3.end(), greater<ll>());
  sort(l4.begin(), l4.end(), greater<ll>());

  vector<ll> l1s(l1.size() + 1, 0);
  vector<ll> l2s(l2.size() + 1, 0);
  vector<ll> l3s(l3.size() + 1, 0);
  vector<ll> l4s(l4.size() + 1, 0);

  for (int i = 0; i < l1.size(); i++) {
    l1s[i + 1] = l1s[i] + l1[i];
  }
  for (int i = 0; i < l2.size(); i++) {
    l2s[i + 1] = l2s[i] + l2[i];
  }
  for (int i = 0; i < l3.size(); i++) {
    l3s[i + 1] = l3s[i] + l3[i];
  }
  for (int i = 0; i < l4.size(); i++) {
    l4s[i + 1] = l4s[i] + l4[i];
  }

 ll ans = 0;
  for (int i = 0; i < l1s.size(); i++) {
    for (int j = 0; j < l2s.size(); j++) {
      for (int k = 0; k < l3s.size(); k++) {
        for (int l = 0; l < l4s.size(); l++) {
          if (w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l <= W) {
            ans = max(ans, l1s[i] + l2s[j] + l3s[k] + l4s[l]);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {


    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[] hs = new int[h];
        int[] ws = new int[w];
        int m = sc.nextInt();
        int[] xa = new int[m];
        int[] ya = new int[m];

        for(int i=0; i<m; i++) {
            xa[i] = sc.nextInt()-1;
            ya[i] = sc.nextInt()-1;
            hs[xa[i]]++;
            ws[ya[i]]++;
        }

        int hmax = 0;
        boolean[] hb = new boolean[h];
        for(int i=0; i<h; i++) {
            hmax = Math.max(hmax, hs[i]);
        }
        ArrayList<Integer> xi = new ArrayList<>();
        for(int i=0; i<h; i++) {
            if(hs[i] == hmax) {
                xi.add(i);
                hb[i] = true;
            }
        }
        int wmax = 0;
        boolean[] wb = new boolean[w];
        for(int i=0; i<w; i++) {
            wmax = Math.max(wmax, ws[i]);
        }
        ArrayList<Integer> yi = new ArrayList<>();
        for(int i=0; i<w; i++) {
            if(ws[i] == wmax) {
                yi.add(i);
                wb[i] = true;
            }
        }
        long count = 0;
        for(int i=0; i<m; i++) {
            if(hb[xa[i]] && wb[ya[i]]) {
                count++;
            }
        }
        if(count == (long)yi.size() * xi.size()) {
            System.out.println(hmax + wmax - 1);
        } else {
            System.out.println(hmax + wmax);

        }

    }
}

Measured memory_bytes: 74716
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> p(n);
	REP(i,n) cin >> p[i];
	int cnt = 0;
	int pmin = p[0];
	REP(i,n){
		if(pmin>=p[i]){
			cnt++;
			pmin = p[i];
		}
	}

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



Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
long int n,i,k;
scanf("%ld",&n);
k=1;
for(i=n*k;;i=n*k)
{
    if(i%2==0 && i%n==0)
    {
        break;
    }
    k++;
}
printf("%ld",i);
    return 0;
}


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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    vector<LL> a(n), p(n), q(n);
    for(LL i = 1; i <= n; ++i){
        a[i-1] = i;
    }
    for(LL i = 0; i < n; ++i){
        cin >> p[i];
    }
    for(LL i = 0; i < n; ++i){
        cin >> q[i];
    }
    LL pv = 0;
    LL qv = 0;
    LL cur = 0;
    while(next_permutation(a.begin(), a.end())){
        cur += 1;
        if(p == a) pv = cur;
        if(q == a) qv = cur;
    }
    cout << abs(pv-qv) << endl;
    return 0;
}




Measured memory_bytes: 3588
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    x=int(readline())
    to=1001
    memo=[0]*to
    #memo={}
    for i in range(to):
        memo[i]=i**5

    a=0
    b=0
    if x==0:
        print(a,b)
        return

    for i in range(to):
        z1=x-memo[i]
        z2=memo[i]-x
        if z1 in memo:
            a=i
            for j in range(to):
                if memo[j]==z1:
                    b=j*-1
            break
        if z2 in memo:
            a=i
            for j in range(to):
                if memo[j]==z2:
                    b=j
            break
    #if a!=0 or b!=0:
    #    print(a,b)
    #    return
    print(a,b)
    return
    
    b=1000**5
    for i in range(1001,100000000):
        a=b
        b=i**5
        if (b-a)==x:
            print(i,(i-1))
            return

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 75344
op = "G"
while op != "?" :
    a,op,b = map(str,input().split())
    if op == "+":
        print(int(a)+int(b))
    elif op == "-":
        print(int(a)-int(b))
    elif op == "*":
        print(int(a)*int(b))
    elif op == "/":
        print(int(int(a)/int(b)))
    else: pass


Measured memory_bytes: 5600
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef unsigned long long Hash;
int to[128] ={};
int info[1000][1000] = {};
int info2[1000][1000];
Hash hashing[1000][1000];

#define ONE 109
#define TWO 107
int pt[100][100] = {};


int vis(int a[100][100],int W,int H){
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++)cout << a[i][j]-1;
		cout << endl;
	}
	cout << endl;
}
int vis(int a[1000][1000],int W,int H){
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++)cout << a[i][j]-1;
		cout << endl;
	}
	cout << endl;
}
int main(){
	for(int i = 0 ; i < 26 ; i++) to['A'+i] = i;
	for(int i = 0 ; i < 26 ; i++) to['a'+i] = i+26;
	for(int i = 0 ; i < 10 ; i++) to['0'+i] = i+52;
	to['+'] = 62 , to['/'] = 63;

	int W,H,P;
	while(cin >> W >> H >> P && W){
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < (W+5) / 6 ; j++){
				char c;cin >> c;
				c = to[c];
				for(int k = 5 ; k >= 0 ; k--) info[i][j*6+(5-k)] = (c >> k & 1)+1;
			}
		}
		for(int i = 0 ; i < P ; i++){
			for(int j = 0 ; j < (P+5)/6 ; j++){
				char c;cin >> c;
				c = to[c];
				for(int k = 5 ; k >= 0 ; k--) pt[i][j*6+(5-k)] = (c >> k & 1)+1;
			}
		}
		set<Hash> use;
		for(int __ = 0 ; __ < 2 ; __++){
			for(int _ = 0 ; _ < 4 ; _++){
				//vis(pt,P,P);
				Hash h = 0;
				for(int i = 0 ; i < P ; i++){
					Hash ln = 0;
					//cout << pt[i][0] << " " << pt[i][1] << " " << pt[i][2] << " " << h << endl;
					for(int j = 0 ; j < P ; j++) ln = ONE * ln + pt[i][j];
					h = h * TWO + ln;
				}
				//cout << h << endl;
				use.insert(h);
				for(int i = 0 ; i < P ; i++)
					for(int j = 0 ; j < i ; j++)
						swap(pt[i][j],pt[j][i]);
				for(int i = 0 ; i < P ; i++)
					for(int j = 0 ; j < P / 2 ; j++)
						swap(pt[i][j],pt[i][P-j-1]);	
			}
			for(int i = 0 ; i < P ; i++)
				for(int j = 0 ; j < P / 2 ; j++)
					swap(pt[i][j],pt[i][P-j-1]);	
		}
		Hash B1 = 1 , B2 = 1;
		for(int j = 0 ; j < P ; j++) B1 *= ONE , B2 *= TWO;
	
		
		for(int i = 0 ; i < H ; i++){
			Hash h = 0;
			for(int j = 0 ; j < P ; j++) h = ONE * h + info[i][j];
			hashing[i][0] = h;
			for(int j = 0 ; j < W-P ; j++){
				h  = h * ONE + info[i][j+P];
				h -= B1 * info[i][j];
				hashing[i][j+1] = h;
			}
		}
		int ans = 0;
		for(int i = 0 ; i <= W-P ; i++){
			Hash h = 0;
			for(int j = 0 ; j < P ; j++) h = TWO * h + hashing[j][i];
			if(use.count(h))++ans;
			for(int j = 0 ; j < H-P ; j++){
				h  = h * TWO + hashing[j+P][i];
				h -= B2 * hashing[j][i];
				if(use.count(h))++ans;
			}
		}
		//vis(info,W,H);
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main () {
  string s;
  cin >> s;
  int nwin = 0;
  int k = s.size();
  for (int i = 0; i < k; i++) {
    if(s[i]=='o') {
      nwin++;
    }
  }

  if (nwin+(15-k) >= 8) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    a = LI()
    ans = 1000
    have = 0
    state = 0
    for i in range(n - 1):
        if state == 0:
            if a[i] < a[i + 1]:
                have += ans // a[i]
                ans %= a[i]
                state = 1
        else:
            if a[i] > a[i + 1]:
                ans += a[i] * have
                have = 0
                state = 0
    ans += a[-1] * have
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 67252
m=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l=factorization(m)
ans=0
for i in range(len(l)):
    a=1
    while(l[i][1]>=a):
        ans+=1
        l[i][1]-=a
        a+=1
if m==1:
    print("0")
else:
    print(ans)

Measured memory_bytes: 9500
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 998244353
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
double x[3], y[3], d[3];
signed main() {
	rep(i, 3)cin >> x[i] >> y[i];
	d[0] = hypot(x[0] - x[1], y[0] - y[1]);
	d[1] = hypot(x[1] - x[2], y[1] - y[2]);
	d[2] = hypot(x[2] - x[0], y[2] - y[0]);
	double s = (d[0] + d[1] + d[2]) / 2;
	double S = sqrt(s * (s - d[0]) * (s - d[1]) * (s - d[2]));
	double r = S / s;
	double mi = 0, ma = 1000;
	rep(i, 100000) {
		double md = (mi + ma) / 2;
		if (r < md)ma = md;
		else if (max({ d[0],d[1],d[2] }) / r * (r - md) >= 2 * md)mi = md;
		else ma = md;
	}
	printf("%.12Lf\n", mi);
	return 0;
}

Measured memory_bytes: 256
// compile & run:     g++ main.cpp -o main && ./main < input.txt > out.txt
// Problem Url:
//
// © Jose Garfias Lopez
//

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int North = 0;
    int South = 0;
    int West = 0;
    int East = 0;
    string path;
    cin>>path;
    for(int i=0;i<path.length(); i++) {
        if (path[i] == 'N') {
            North++;
        } else if (path[i] == 'S') {
            South++;
        } else if (path[i] == 'E') {
            East++;
        } else if (path[i] == 'W') {
            West++;
        }
    }
    if ((North > 0 && South > 0) && (West == 0 && East == 0)) {
        printf("Yes\n");
    } else {
        if ((West > 0 && East > 0) && (North == 0 && South == 0)) {
            printf("Yes\n");
        } else {
            if ((West > 0 && East > 0) && (North > 0 && South > 0)) {
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        }
    }
    return (0);
}


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

typedef long long ll;

int main() {
    int n,k;cin>>n>>k;
    ll r,s,p;cin>>r>>s>>p;
    string t;cin>>t;
    ll b[n];
    
    ll ans=0;
    rep(i,n){
        if(t[i]=='p'){
            b[i]=s;
        }
        else if(t[i]=='r'){
            b[i]=p;
        }
        else if(t[i]=='s'){
            b[i]=r;
        }
        
        if(i>=k && b[i] == b[i-k] && t[i]==t[i-k]){
            b[i]=0;
        }
    }
    rep(i,n)ans+=b[i];
    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1280
#[allow(dead_code)]
fn main() {
    let (n, a, b) = (i::u(), i::u(), i::u());
    let x = i::uv(n);
    let mut ans = (n - 1) * b;
    for i in 1..n {
        if (x[i] - x[i - 1]) * a < b {
            ans = ans + (x[i] - x[i - 1]) * a - b;
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		sc.close();
		if(op.equals("+")) {
			System.out.println(a + b);
		}else {
			System.out.println(a - b);
		}
	}
}

Measured memory_bytes: 21716
n, c, *t = map(int, open(0).read().split())
right = [0]
left = [0]
sushi = tuple([(0, 0)]) + tuple(zip(t[::2], t[1::2])) + tuple([(c, 0)])
for i in range(1, n + 1):
    x, v = sushi[i]
    y = sushi[i - 1][0]
    cost = right[-1] + v - (x - y)
    right.append(cost)
    x, v = sushi[n + 1 - i]
    y = sushi[n + 2 - i][0]
    cost = left[-1] + v - (y - x)
    left.append(cost)
ans = max(right + left)
right_max = right[:]
left_max = left[:]
for i in range(1, n + 1):
    right_max[i] = max(right_max[i], right_max[i - 1])
    left_max[i] = max(left_max[i], left_max[i - 1])
for i in range(1, n + 1):
    ans = max(ans, \
            right[i] - sushi[i][0] + left_max[n - i], \
            left[i] - c + sushi[n + 1 - i][0] + right_max[n - i])
print(ans)

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    set<string> st;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}

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

main(){
    int N;
    cin >> N;
    int a[N];
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
    int counter=0;
    int counter_min;
    for (int i=0; i<N; i++){
        counter = 0;
        int b=a[i];
        while(b%2==0){
            b = b/2;
            ++counter;
        }
        if(counter<counter_min || i==0){
            counter_min = counter;
        }
    }
    cout << counter_min << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map{ it.toLong() }.toList()

  val tb = mutableMapOf<Long, Long>()
  var sum = 0L
  var ans = 0L
  tb[0] = 1L
  for(x in A) {
    sum += x
    ans += tb.getOrElse(sum) { 0L }
    tb[sum] = tb.getOrElse(sum) { 0L } + 1
  }

  println(ans)
}

Measured memory_bytes: 105392
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int> m;
    int n,ans=0; cin>>n; 
    while (n--){
        int a; cin>>a;
        m[a] = m[a]^1;
    }
    for (auto it: m) if (it.ss>0) ans++;
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 9604
// B - ATCoder

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

string acgt = "ACGT";

// 文字列内に検索対象の文字があればtrue, なければfalseを返す
bool is_in(char needle, string& haystack) {
	return (haystack.find(needle) != string::npos);
}

// 文字列Sの[start, end]が a, c, g, t だけで構成されているかどうかを判定
int is_acgt(string& S, int start, int end) {
	for (int i=start; i<=end; i++) {
		if (!is_in(S[i], acgt)) {
			return false;
		}
	}

	return true;
}

int main() {
	string S;
	cin >> S;

	int ans = 0;

	for (int i=0; i<S.size(); i++) {
		for (int j=i; j<S.size(); j++) {
			if (is_acgt(S, i, j)) ans = max(ans, j - i + 1);
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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


ll factnum(ll a, ll b, ll c) {
    return b/c - (a-1)/c;
}

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll num = b - a + 1;
    ll ans = num - factnum(a,b,c) - factnum(a,b,d) + factnum(a,b,lcm(c,d));
    cout << ans << endl;
    return 0;
}


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

typedef pair<int, int> Job;

struct {
  bool operator()(Job a, Job b) const
  {
    return a.second < b.second;
  }
} custom;


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

  vector<Job> jobs;

  for(int i=0;i<N;i++) {
    int a, b;
    cin >> a >> b;
    jobs.push_back({a, b});
  }

  sort(jobs.begin(), jobs.end(), custom);

  long long required = 0;
  bool ans = true;
  for(int i=0;i<N;i++) {
    // cout << jobs[i].first << " " << jobs[i].second << endl;
    required += jobs[i].first;
    if(required > jobs[i].second) {
      ans = false;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;

}


Measured memory_bytes: 2420
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
    
		// 出力
		System.out.println((int)Math.ceil(((double)a + b) / 2));
	}
}


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

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

int N;
char c[4010];
int a[4010];
int cumW[4010][2010];
int cumB[4010][2010];
int posW[2010];
int posB[2010];
int dp[2010][2010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < 2*N; i++) {
    cin >> c[i] >> a[i];
    if (c[i] == 'W') {
      cumW[i+1][a[i]-1]++;
      posW[a[i]] = i+1;
    } else {
      cumB[i+1][a[i]-1]++;
      posB[a[i]] = i+1;
    }
  }  
  for (int j = 0; j <= N; j++) {
    for (int i = 1; i <= 2*N; i++) {
      if (cumW[i][j]) cumW[i][j] = cumW[i-1][j] + 1;
      else cumW[i][j] = cumW[i-1][j];
      if (cumB[i][j]) cumB[i][j] = cumB[i-1][j] + 1;
      else cumB[i][j] = cumB[i-1][j];
    }
  }
  for (int i = 0; i <= 2*N; i++) {
    for (int j = N; j > 0; j--) {
      cumW[i][j-1] += cumW[i][j];
      cumB[i][j-1] += cumB[i][j];
    }
  }

  fill_n((int*)dp, 2010*2010, 1 << 30);
  dp[0][0] = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      if (i+1 <= N) chmin(dp[i+1][j], dp[i][j] + cumW[posW[i+1]][i+1] + cumB[posW[i+1]][j]);
      if (j+1 <= N) chmin(dp[i][j+1], dp[i][j] + cumW[posB[j+1]][i] + cumB[posB[j+1]][j+1]);
    }
  }
  cout << dp[N][N] << endl;

  return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  vector<int> p(n);
  for (auto& e : p)
    cin >> e;

  int c1 = 0, c2 = 0, c3 = 0;

  for (auto e : p) {
    if (e <= a)
      ++c1;
    else if (e <= b)
      ++c2;
    else
      ++c3;
  }

  int ans = min({c1, c2, c3});
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	if((b-a)==(c-b))cout<<"YES";
    else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//AtCoder Beginner Contest 120
//B	K-th Common Divisor
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	}
}


Measured memory_bytes: 22868
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>'10000000'},'ruby',$0)
n, m = gets.chomp.split(" ").map(&:to_i)
node = Struct.new("Node", :to)
@g = Array.new(n+1){node.new([])}
@color = Array.new(n+1, 0)
m.times do
  a, b = gets.chomp.split(" ").map(&:to_i)
  @g[a].to << b
  @g[b].to << a
end
# 二部グラフ判定
def dfs(v, c)
  @color[v] = c
  @g[v].to.size.times do |i|
    if @color[@g[v].to[i]] == c
      return false
    end
    if @color[@g[v].to[i]] == 0 && !dfs(@g[v].to[i], -c)
      return false
    end
  end
  return true
end
 
1.upto(n) do |i|
  if @color[i] == 0
    if !dfs(i, 1)
      puts n * (n-1) / 2 - m
      exit
    end
  end
end
b = @color.count(1)
w = n - b
puts b * w - m

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int index = 0;
  int flag = 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a.at(j) > a.at(index)) {
        index = j;
      }
    } 
    ans += a.at(index) * flag;
    a.at(index) = 0;
    index = 0;
    flag *= -1;
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256