akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(){
  
  char N[200001];
  scanf("%s",N);
  
  int S=0;
  
  int k=0;
  
  int L=strlen(N);
  
  while(k<L){
    S=S+N[k]-'0';
    k++;
  }
  
  if(S%9==0)printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

i64 rec(i64 h)
{
    if (h == 1)
        return 1LL;
    return (rec(h >> 1) << 1) + 1LL;
}

int main()
{
    i64 H;
    cin >> H;

    cout << rec(H) << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{m:u32};
    println!("{}", 24-m+24);

}

Measured memory_bytes: 4352
#reversi
n=int(input())
lists=[]
for i in range(n):
    a=int(input())
    lists.append(a)
dp=[0 for i in range(n+1)]
dp[0]=1
mod=10**9+7
before=[0 for i in range(2*10**5+1)]

for i in range(n):
    a=lists[i]
    if before[a]==0:
        dp[i+1]=dp[i]
        before[a]=i+1
        continue
        
    elif before[a]!=0:
        if before[a]==i:
            before[a]=i+1
            dp[i+1]=dp[i]
        else:
            dp[i+1]=(dp[i]+dp[before[a]])%mod

            before[a]=i+1
print(dp[n]%mod)  


Measured memory_bytes: 20532
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int,input().split()))

def solve(A):
    n = sum(A) // (N*(N+1)//2)
    if sum(A) % (N*(N+1)//2) != 0:
        return 'NO'

    count = 0

    for i in range(N):
        diff = A[i] - A[i-1] 

        if diff == n:
            continue

        if -1 * (diff - n) % N != 0:
            return 'NO'
        c = -(diff-n)//N
        if c < 0:
            return 'NO'

        count += c

    if count == n:
        return 'YES'
    return 'NO'

print(solve(A))
        


Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << endl;
}

Measured memory_bytes: 3652
import java.util.*;
import java.math.*;
public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

	    List<Double> n1 = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            double d = (double)sc.nextInt();
			n1.add(d);
		}
		
		double ans = 0;
		
		Collections.sort(n1,Collections.reverseOrder());
		
		for (int i = 0; i < N-1; i++) {
            double d = n1.get(i);
			
			for ( int j = 0 ; j < i + 1 ; j++)
			{
			d = d / 2;
			}
			ans +=d ;
          
		}
		
		double d2 = n1.get(N-1);
		
		for ( int j = 0 ; j < N-1 ; j++)
			{
			d2 = d2 / 2;
			}
			ans += d2;
			
			System.out.println(ans);
	}
}
		
		

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int l,r,d,dem=0;

int main()
{
    cin>>l>>r>>d;
    for (int i=l;i<=r;++i)
        dem+=(i%d==0);
    cout<<dem;
    return 0;
}


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

#define int long long




signed main()
{
    int a, b;
    cin >> a >> b;
    if(a+b == 15) {
        cout << "+" << endl;
    } else if(a*b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
def divisor(n):
    ans = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            ans.append(i)
            if n//i != i:
                ans.append(n//i)
    return len(ans)
ans = 0
for i in range(1,N+1,2):
    if divisor(i) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int A,B,M;
  cin >> A >> B >> M;
  int a[A],b[B];
  int a_min = INF;
  int b_min = INF;
  REP(i,A) {
    cin >> a[i];
    a_min = min(a_min,a[i]);
  }
  REP(i,B) {
    cin >> b[i];
    b_min = min(b_min,b[i]);
  }
  int temp;
  int ans = INF;

  int x,y,c;
  REP(i,M) {
    cin >> x >> y >> c;
    x--;
    y--;
    temp = a[x] + b[y] - c;
    ans = min(ans,temp);
  }
  ans = min(ans,a_min+b_min);

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


Measured memory_bytes: 1024
tmp = input().split()
map_tmp = map(int, tmp)
values = list(map_tmp)
moves = int(input())

while(moves):
  if (values[1] <= values[0]):
  	values[1] *= 2
  	moves -=1
  elif(values[2] <= values[1]):
    values[2] *=2
    moves -=1
  else:
    break
    
if (values[1] > values[0]) and (values[2] > values[1]):
  print('Yes')
else:
  print('No')


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int d[n];
    for (auto &di:d) cin >> di;
    sort(d, d+n);
    int best = d[0];
    if (n > 1)
        best = min(best, 24 - d[n-2]-d[n-1]);
    if (n > 2)
        for (int i=0; i<n-2; i++)
            best = min(best, d[i+2] - d[i]);
    cout << best << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector< vector<int> > C(9,vector<int>(9,0));
  for(int i=1;i<=N;i++){
    if(i%10==0){
      continue;
    }
    int b=i%10;
    int t;
    int m=i;
    while(m>0){
      t=m;
      m/=10;
    }
    C[t-1][b-1]++;
  }
  ll ans=0;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      ans+=C[i-1][j-1]*C[j-1][i-1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3540
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

int main(void) {
    stack<int> st;
    string s;
    int a,b;
    while (cin >> s){
        if (s=="+"){
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a+b);
        }
        else if (s=="-"){
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b-a);
        }
        else if (s=="*"){
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a*b);
        }
        else{
            st.push((int)stoi(s));
        }
    }

    cout << st.top() << endl;

    return 0;
}

Measured memory_bytes: 3152
from itertools import permutations
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]
r = []
for pp in permutations(P):
    t = 0
    for i in range(1, N):
        t += ((pp[i][0]-pp[i-1][0])**2 + (pp[i][1]-pp[i-1][1])**2)**(0.5)
    r.append(t)
print(sum(r)/len(r))


Measured memory_bytes: 10712
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n,w;
    cin>>n>>w;
    vector<vector<ll>> dp(n+1,vector<ll>(100001,MOD));
    dp[0][0]=0;
    vector<pair<ll,ll>> v(n);
    rep(i,n){
        cin>>v[i].first>>v[i].second;
    }

    for(int i=0;i<n;i++){
        ll wi=v[i].first;
        ll vi=v[i].second;
        for(int j=0;j<100001;j++){
            dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
         if(j+vi<=100000&&dp[i][j]!=MOD) {
             dp[i + 1][j+vi] = min({dp[i + 1][j+vi], dp[i][j] + wi,dp[i][j+vi]});
         }else if(dp[i][j]!=MOD){
             dp[i + 1][100001] = min({dp[i + 1][100001], dp[i][j] + wi,dp[i][100001]});
         }

        }
    }


    for(int i=100000;i>=0;i--){
        if(dp[n][i]<=w){
            cout<<i<<endl;
            return 0;
        }
    }


return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a,b,c; cin >> a >> b >> c;
  for(int i = a; i <= a*b; i+=a){
    if(i % b == c){
      cout << "YES" << endl;
      system("pause");
      return 0;
    }
  }
  cout << "NO" << endl;
  system("pause");
}

Measured memory_bytes: 504
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

ll f[2000010];

ll lcm(ll a,ll b)
{
  return (a*b)/__gcd(a,b);
}
ll binpow(ll a, ll b) {
     ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
 
ll find_ncr(ll n, ll r)
{
    ll m1=max(r,n-r);
    ll i,j,s,d=1,k;
    s=1;
 
    for(i=m1+1;i<=n;i++)
    {
        s=((s%m)*(i%m))%m;
    }
 
    m1=min(r,n-r);
 
    for(i=1;i<=m1;i++)
    {
        k=binpow(i,m-2);
        d=((d%m)*(k%m))%m;
    }
 
    k=(s%m*(d%m))%m;
 
    return k;
}

int main()
{
  // int x = -1, y = 10000;
  // double z = 0.2;
  // string s2 = "beginner1010";
  // long long b = 1LL << 60;
    
  // // debug(x, y, z, s, b);
    
  // double aux = 1010.0;
  // string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll n,a,b;
  cin >> n >> a >> b;
  ll s = a+b;
  ll ans = n%s;
  if (ans > a)
  {
    cout << (n/s)*a +a;
  }
  else
    cout << (n/s)*a+ans;
  return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
score = [0 for _ in range(n)]
loopn = [0 for _ in range(n)]
done = {i: True for i in range(n)}
cycles = []
nux = -1000000000000000
cycles_score = []
for start in range(n):
    if done[start]:
        done[start] = False
        cycle = [start]
        score = C[start]
        nex = P[start]-1
        while nex != start:
            done[nex] = False
            cycle.append(nex)
            score += C[nex]
            nex = P[nex]-1
        cycles.append(cycle)
        cycles_score.append(score)

for score, cycle in zip(cycles_score, cycles):
    l = len(cycle)
    acum = [0 for _ in range(2*l+1)]
    for i in range(2*l):
        acum[i+1] = acum[i]+C[cycle[i % l]]
    if score < 0:
        for r in range(l+1):
            for i in range(l):
                if r == 0:
                    continue
                if r <= k:
                    nux = max(nux, acum[i+r]-acum[i])
    else:
        for r in range(l+1):
            q = (k-r)//l
            for i in range(l):
                if r == 0 and q == 0:
                    continue
                if q <= 0 and r > k:
                    continue
                nux = max(nux, score*q+acum[i+r]-acum[i])


print(nux)

"""n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

score = [0 for _ in range(n)]
loopn = [0 for _ in range(n)]
done = {i: True for i in range(n)}
for start in range(n):
    if done[start]:
        nex = -1
        j = 0
        tuuka = []
        nax = -float("inf")
        while nex != start:
            if nex == -1:
                nex = P[start]-1
            else:
                nex = P[nex]-1
            tuuka.append(nex)
            score[start] += C[nex]
            nax = max(nax, score[start])
            j += 1
        loopn[start] = j
        for i in tuuka:
            done[i] = False
            loopn[i] = j
            score[i] = score[start]
            nokori = k-(k//loopn[start])*loopn[start]

    if score[start] < 0:
        score[start] = 0
    else:
        score[start] = (k//loopn[start])*score[start]
        nokori = k-(k//loopn[start])*loopn[start]
        i = 0
        nnnnn = (k//loopn[start])
        nscore = 0
        nax = 0
        while i < nokori:
            nex = P[nex]-1
            nscore += C[nex]
            if nscore < 0:
                break
            nax = max(nax, nscore)
            i += 1
        if nax > 0:
            score[start] += nax


ans = max(score)
if ans <= 0:
    ans = max(C)
print(ans)
"""


Measured memory_bytes: 75228
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

string to_s(int i) {
    ostringstream os;
    os << i;
    return os.str();
}

void operate(string& s) {
    string t;
    int len = s.length();
    char prev = s[0];
    int count = 1;
    for (int i = 1; i < len; i++) {
        if (prev == s[i]) {
            count++;
        } else {
            t.append(to_s(count));
            t.push_back(prev);
            prev = s[i];
            count = 1;
        }
    }
    t.append(to_s(count));
    t.push_back(prev);
    s = t;
}

int main() {
    int n;
    string s;
    while (cin >> n, n != 0) {
        cin >> s;
        for (int i = 0; i < n; i++) {
            operate(s);
        }
        cout << s << endl;
    }
    return 0;
}

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


#define ll long long
using box = vector<ll>;


ll check(ll v1, box& q, box& x, box& s, box& t)
{
    int Q = q.size();
    ll v = v1;
    rep(i, Q)
    {
        if(q[i] == 1)
        {
            if(v >= x[i])
            {
                v = t[i] * (v + s[i]);
            }
        }
        else
        {
            if(v <= x[i])
            {
                v = (v - s[i]) / t[i]; 
            }
        }
        //cout << v << endl;
    }
    return v;
}
void solve()
{
    ll N, Q, L, R;
    cin >> N >> Q >> L >> R;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    vector<ll> q(Q);
    vector<ll> x(Q);
    vector<ll> s(Q);
    vector<ll> t(Q);
    rep(i, Q)
    {
        cin >> q[i] >> x[i] >> s[i] >> t[i];
    }
    //L以上となる最初の頂点
    int ok = N;
    int ng = -1;
    while(abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if(check(A[mid], q, x, s, t) >= L)
        {
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    //cout << ok << " " << ng << endl;

    //R以下となる最大の頂点
    int rok = -1;
    int rng = N;
    while(abs(rok - rng) > 1)
    {
        int mid = (rok + rng) / 2;
        if(check(A[mid], q, x, s, t) <= R)
        {
            rok = mid;
        }
        else{
            rng = mid;
        }
    }
    //cout << rok << " " << rng << endl;

    cout << (max(rok - ok + 1, 0)) << endl;

    // rep(i, N){
    //     cout << A[i] << " " << (check(A[i], q, x, s, t)) << endl;
    // }

}

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



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x, n;
	cin >> x >> n;

	set<ll> a;
	while (n--) {
		ll y; cin >> y;
		a.insert(y);
	}

	FOR(d,0,oo) FOR(s,-1,2) if (s) {
		ll y = x + s*d;
		if (!a.count(y)) {
			cout << y << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3648
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

fun query(a: Long, b: Long): Long {
    val ab = a * b
    val f = (a - 1) * 2
    return f + if ((a + 1) * (a + 1) < ab) {
        val m = Math.ceil(Math.sqrt(ab.toDouble()) - 1).toLong()
        val alpha = m - a
        if (m * (m + 1) < ab) {
            2 * alpha + (if (a + alpha * 2 + 1 < b) 1 else 0)
        } else {
            (alpha - 1) * 2 + 1 + + (if (a + alpha * 2 < b) 1 else 0)
        }
    } else {
        if (a + 1 < b) 1L else 0L
    }
}

fun main(args: Array<String>) {
    val Q = readInts()[0]
    (0 until Q).forEach {
        val (a, b) = readInts().sorted()
        println(query(a.toLong(), b.toLong()))
    }
}

Measured memory_bytes: 36080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s; cin>>s;
    int ans=700;
    rep(i,3){
        if(s[i]=='o'){
            ans+=100;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

void print_result(int* A, int n) {
  for (size_t k = 0; k < n; ++k) {
    if (k < n-1) {
      cout << A[k] << " ";
    } else {
      cout << A[k];
    }
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  int A[n-1];
  for (size_t i = 0; i < n; ++i) {
    cin >> A[i];
  }
  print_result(A, n);
  for (size_t i = 1; i < n; ++i) {
    int v = A[i];
    int j = i-1;
    while (j >=0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    print_result(A, n);
  }
  return 0;
}



Measured memory_bytes: 3088
/*
时间:2020-7-27
书籍：算法和数据结构
内容：希尔排序
页数：P52
*/
#include<iostream>
#include<vector>
using namespace std;
long long int count = 0;
vector<int> G;
void insertionSort(int a[],int length, int g)               //间隔为g的插入排序
{
	for (int i = g; i <= length - 1; ++i)
	{
		int temp = a[i];
		int j;
		for (j = i-g; j >= 0&& a[j] > temp; j -= g)
		{
			a[j + g] = a[j];
			++::count;
		}
		a[j + g] = temp;
	}
}
void shellSort(int a[], int length)
{
	for(int h=1;h<=length;)               //生成间隔数列G，即gn+1=3gn+1,使算法复杂度维持在N的1.25次方
	{
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; --i)
	{
		insertionSort(a, length, G[i]);
	}
}
int main()
{
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	shellSort(a, n);
	cout << G.size()<<endl;
	for (int i = G.size() - 1; i > 0; --i)
	{
		cout << G[i] << " ";
	}
	cout << G[0] << endl;
	cout << ::count << endl;
	for (int i = 0; i < n; ++i)
		cout << a[i] << endl;
	delete[]a;
	return 0;
}


Measured memory_bytes: 6764
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;*/ //int order_of_key, it find_by_order

typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> pii;

#define pb push_back
#define ft first
#define sd second
#define mpr make_pair
#define max3(a, b, c) max((a), max((b), (c)))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define all(x) begin((x)), end((x))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define isz(x) (int)(x).size()

/* <----------------------------------------------------------> */

void solve()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    forn (i, n + 1) forn (j, m + 1)
        if (i * (m - j) + j * (n - i) == k)
        {
            puts("Yes");
            return;
        }
    puts("No");
}

/* <----------------------------------------------------------> */

// #define LOCAL
// #define FILE_NAME ""

int main()
{
    #if defined LOCAL
        freopen("input.txt", "r", stdin);
    #elif defined FILE_NAME
        freopen(FILE_NAME".in", "r", stdin);
        freopen(FILE_NAME".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    REP(i, N) REP(j, N) cin >> a[i][j];

    // dp[i][j]: 男性は 1-index, 女性は 0 index で状態
    //           i 番目の男性までマッチングしたとき、 女性 j もマッチングが終わっている場合の数
    vector<vector<long long>> dp(N+1, vector<long long>(1<<N));
    dp[0][0] = 1;
    REP(i, N){
        REP(j, (1<<N)){  // 立っている bit はマッチが終わっている
            if(i != __builtin_popcount(j)) continue;
            REP(k, N){
                if(!(j & (1<<k)) and a[i][k] == 1){
                    dp[i+1][j+(1<<k)] += dp[i][j];
                    dp[i+1][j+(1<<k)] %= MOD;
                }
            }
        }
    }
    cout << dp[N][(1<<N)-1] << endl;

    return 0;
}

Measured memory_bytes: 377216
#include <stdio.h>
#include <string.h>

char S[11];
int cou, length;
long long int res, ans;

int main(void)
{
	scanf("%s", &S);

	length = strlen(S);
	for (int i = 0; i < 1 << length - 1; ++i)
	{
		cou = i;
		res = S[0] - '0';
		for (int j = 0; j < length - 1; ++j)
		{
			if (cou % 2 == 0)
			{
				ans += res;
				res = S[j + 1] - '0';
			}
			else
			{
				res *= 10, res += S[j + 1] - '0';
			}
			cou /= 2;
		}
		ans += res;
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

void Rect(int h, int w){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << '#';
			if (j==w-1) cout << endl;
		}
	}
}

int main(){
	int H,W;
	
	while(true){
		
		cin >> H >> W;
		if(H==0&&W==0) break;
		Rect(H,W);
		cout << endl;
	}
}

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


using namespace std;

int main(void){
    int N, M, A, tot;
    double R;
    cin >> N >> M;
    tot = 0;
    for (int i = 0; i < M; i++)
    {
        cin >> A;
        tot += A;
    }

    if(tot>N) cout << -1 << endl;
    else cout << N-tot << endl;
    
    return 0;
}

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

int main(){
    long N;
    cin >> N;
    long i;
    long j;
    long k;
    long a;
    long b;
    long c;
    long r;
    long sum=0;
    long tmp;
    for(i=1;i<N+1;i++){
        for(j=1;j<N+1;j++){
            
            for(k=1;k<N+1;k++){
                a = i;
                b = j;
                if(a<b){
                    tmp = a;
                    a = b;
                    b = tmp;
                }
                r = a % b;
                while(r!=0){
                    a = b;
                    b = r;
                    r = a % b;
                }
                //cout << "b:" << b << endl;
                c = k;
                if(b<c){
                    tmp = b;
                    b = c;
                    c = tmp;
                }
                r = b % c;
                while(r!=0){
                    b = c;
                    c = r;
                    r = b % c;
                }
                //cout << "c:" << c << endl;
                sum = sum + c;
                //cout << "i:" << i << " j" << j << " k:" << k << " c:" << c << endl;
                //cout << "i:" << i << " j" << j << " k:" << k << " sum:" << sum << endl;
            }
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

vector<int> DivAll(int n) {
	vector<int> ret;
	int i = 1;
	for (; i*i < n; i++)
		if (n%i == 0)ret.push_back(i);
	bool flag = i * i == n;
	if (flag)ret.push_back(i);
	for (i = ret.size() - 1 - flag; i >= 0; --i)
		ret.push_back(n / ret[i]);
	return ret;
}

int main() {
	int h, a, b; cin >> h >> a >> b;
	VI div = DivAll(h);
	int ans = 0;
	for (auto n : div) {
		if (a <= n && n <= b)ans++;
	}
	Cout(ans);
}


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

int main(){
  int N;
  cin >> N;
  vector<vector<pair<int,int>>> V(N);
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    for(int j = 0; j < a; ++j){
      int x, y;
      cin >> x >> y;
      --x;
      V[i].emplace_back(x,y);
    }
  }
  int ans = 0;
  for(int i = 0; i < (1<<N); ++i){
    bool f = true;
    for(int j = 0; j < N; ++j){
      if((i>>j)&1){
        for(auto e : V[j]){
          if(((i>>e.first)&1) != e.second){
            f = false;
            break;
          }
        }
      }
    }
    if(f){
      ans = max(ans,__builtin_popcount(i));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	vector<string> s(n);
	Foz(i, n) cin >> s[i];
	auto sorted = [&] (const string& t) {
		string r = t;
		sort(all(r));
		return r;
	};

	map<string, ll> freq;
	Foz(i, n) freq[sorted(s[i])]++;

	ll ans = 0;
	Trav(p, freq) {
		ll k = p.second;
		ans += k * (k - 1) / 2;
	}
	cout << ans << '\n';
}



Measured memory_bytes: 16640
using System;

namespace abc158_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NAB = Console.ReadLine().Split(" ");
            long N = long.Parse(NAB[0]);
            long A = long.Parse(NAB[1]);
            long B = long.Parse(NAB[2]);

            long ans = N / (A + B);
            long rem = N % (A + B);
            ans = ans * A + Math.Min(rem,A);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27552
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   string s, t; cin>>s>>t;

   if(t.substr(0, t.size() -1) == s){
       cout<<"Yes";
   }else cout<<"No\n";
}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}




Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#define rnt register int
using namespace std;
int n,m,x,cnt;
int main()
{
	scanf("%d %d",&n,&m);
	for(;n;--n)
	{
		scanf("%d",&x);
		if(x>=m) cnt=-~cnt;
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int[][] ab=new int[a+1][b+1];
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++)
				ab[i][j]=sc.nextInt();
		}
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				ab[i][b]=ab[i][b]+ab[i][j];
				ab[a][j]=ab[a][j]+ab[i][j];
			}
			ab[a][b]=ab[a][b]+ab[i][b];
		}
		for(int i=0;i<=a;i++){
			for(int j=0;j<=b;j++){
				if(j==b){
					System.out.print(ab[i][j]);
					System.out.print("\n");
				}else
					System.out.print(ab[i][j]+" ");
			}
		}
	}
}



Measured memory_bytes: 42064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] visited = new boolean[n+1];
		int[] res = {0, 0};
		
		Map<Integer, List<Integer>> g = new HashMap<>();
		
		for (int i = 0; i < m; i++) {
			int v = sc.nextInt();
			int w = sc.nextInt();
			
			if (!g.containsKey(v)) {
				g.put(v, new ArrayList<Integer>());
			}
			g.get(v).add(w);
			
			if (!g.containsKey(w)) {
				g.put(w, new ArrayList<Integer>());
			}
			g.get(w).add(v);
		}
		visited[1] = true;
		dfs(n, 1, g, visited, res);
		System.out.println(res[0]);
	}
	
	private static void dfs(int n, int v, Map<Integer, List<Integer>> g, boolean[] visited, int[] res) {
		if (complete(n, visited)) {
			res[0]++;
		} else {
			
			for (int i = 0; i < g.get(v).size(); i++) {
				int next = g.get(v).get(i);
				if (!visited[next]) {
					visited[next] = true;
					dfs(n, next, g, visited, res);
					visited[next] = false;
				}
			}
			
		}
	}
	
	private static boolean complete(int n, boolean[] visited) {
		boolean res = true;
		
		for (int i = 1; i < visited.length; i++) {
			res = res & visited[i];
		}
		return res;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22184
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int A, B, C; cin >> A >> B >> C;
  
  int sum = 0;
  for (int i = 1; sum < 2000; i++) {
    if (sum % B == C) {
      cout << "YES" << endl;
      return 0;
    }
    sum += A;
  }
  
  cout << "NO" << endl;
}

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

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

int d[101];

int main(){
    string s;
    cin>>s;
    if(s[1]=='B'){
        cout<<"ARC";
    }else{
        cout<<"ABC";
    }

    return 0;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	a, b, m := scanInt(sc), scanInt(sc), scanInt(sc)
	as := nextIntSlice(sc, a)
	bs := nextIntSlice(sc, b)
	r := math.MaxInt64
	for i := 0; i < m; i++ {
		v := as[scanInt(sc)-1] + bs[scanInt(sc)-1] - scanInt(sc)
		if v < r {
			r = v
		}
	}
	sort.Sort(sort.IntSlice(as))
	sort.Sort(sort.IntSlice(bs))
	v := as[0] + bs[0]
	if v < r {
		r = v
	}
	return r
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}
func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

Measured memory_bytes: 5928
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    map<int,vector<int>> v[n];
    int p, q, c;
    while(m-- > 0){
        scanf("%d %d %d", &p, &q, &c);
        p--, q--;
        v[p][c].push_back(q);
        v[q][c].push_back(p);
    }
    
    // pos, kind
    map<int,int> dp[n];
    
    // cost, pos, kind
    priority_queue<pair<int,pair<int,int>>> pq;
    pq.push({-1, {0, 0}});
    while(!pq.empty()){
        auto p = pq.top();  pq.pop();
        int cost = -p.first, pos = p.second.first, kind = p.second.second;
        if(kind == 0){
            for(auto q : v[pos]){
                int kind = q.first;
                for(int next : q.second){
                    if(dp[next].count(kind) == 0){
                        dp[next][kind] = cost;
                        pq.push({-cost, {next,kind}});
                    }
                }
            }
        }else{
            if(dp[pos].count(0) == 0){
                dp[pos][0] = cost+1;
                pq.push({-(cost+1), {pos, 0}});
            }
            for(int next : v[pos][kind]){
                if(dp[next].count(kind) == 0){
                    dp[next][kind] = cost;
                    pq.push({-cost, {next,kind}});
                }
            }
        }
    }

    int ans = 1<<30;
    for(auto p : dp[n-1]){
        ans = min(ans, p.second);
    }

    cout << (ans == 1<<30 ? -1 : ans) << endl;

    return 0;
}

Measured memory_bytes: 77368
#include <cstdio>
#include<bits/stdc++.h> 
#include <algorithm>
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<pair<int,int>,int> iii;



int main(){
    ofstream out("output.txt");
    

    int a,p;
    cin>>a>>p;

    cout<<(a*3 + p)/2;    

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    StringTokenizer st = new StringTokenizer(in.readLine());
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());
    String u = in.readLine();
    System.out.println(u.equals(str[0])?(a-1) + " " + b:a + " " + (b-1));
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//約数の個数
int f(int n) {
    int cnt = 0;
    rep1(i,n+1) if(n % i == 0) cnt++;
    return cnt;
}

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

    int N; cin >> N;
    int cnt = 0;
    rep1(i,N+1) {
        if(i % 2 == 1 and f(i) == 8) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var L = int.Parse(s.Substring(0, 2));
            var R = int.Parse(s.Substring(2, 2));

            Func<int, bool> isMonth = x => (1 <= x && x <= 12);
            
            if(isMonth(L) && isMonth(R))
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if(isMonth(L) && !isMonth(R))
            {
                Console.WriteLine("MMYY");
            }
            else if(!isMonth(L) && isMonth(R))
            {
                Console.WriteLine("YYMM");
            }
            else
            {
                Console.WriteLine("NA");
            }

        }
    }
}


Measured memory_bytes: 13140
n = int(input())
a = list(map(int,input().split()))
res = [0 for i in range(n)]
for i in range(n,n//2,-1):
    res[i-1] = a[i-1]

for i in range(n//2,0,-1):
    l = []
    flag = 0
    t = i*2
    while t <= n:
        flag = flag ^ res[t-1]
        t = t+i
    if a[i-1] != flag:
        res[i-1] = 1

if res == [0 for i in range(n)]:
    print(0)
else:
    lres = []
    for i in range(n):
        if res[i] == 1:
            lres.append(str(i+1))
    print(len(lres))
    print(" ".join(lres))
 

Measured memory_bytes: 17204
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[][][] rooms = new int[5][4][11];
        
        int n = sc.nextInt();
        sc.nextLine();
        
        for(int i=0;i<n;i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            sc.nextLine();
            
            rooms[b][f][r] += v;
        }
        
        for(int i=1;i<=4;i++){
            for(int j=1;j<=3;j++){
                for(int k=1;k<=10;k++){
                   System.out.print(" "+rooms[i][j][k]); 
                }
                System.out.println();
            }
            if(i!=4)System.out.println("####################");
        }
    }
}


Measured memory_bytes: 30720
use std::io::*;
use std::str::*;

fn main() {
    let a: u32 = read_one();
    let b: u32 = read_one();
    println!("{}", a * b - a - b + 1);
}

fn read_one<T: std::str::FromStr>() -> T {
    let mut s = stdin().bytes().map(|c| c.unwrap() as char)
                       .skip_while(|c| c.is_whitespace())
                       .take_while(|c| !c.is_whitespace())
                       .collect::<String>();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352