akhauriyash/Code-Regression huggingface dataset:
import Data.Char

main = interact $ unlines . map code . lines

groupAt n xs
 | null xs = []
 | otherwise = take n xs : groupAt n (drop n xs)

code = map cipher . groupAt 5 . concatMap encode

cipher x = case x of
 "00000" -> 'A'
 "00001" -> 'B'
 "00010" -> 'C'
 "00011" -> 'D'
 "00100" -> 'E'
 "00101" -> 'F'
 "00110" -> 'G'
 "00111" -> 'H'
 "01000" -> 'I'
 "01001" -> 'J'
 "01010" -> 'K'
 "01011" -> 'L'
 "01100" -> 'M'
 "01101" -> 'N'
 "01110" -> 'O'
 "01111" -> 'P'
 "10000" -> 'Q'
 "10001" -> 'R'
 "10010" -> 'S'
 "10011" -> 'T'
 "10100" -> 'U'
 "10101" -> 'V'
 "10110" -> 'W'
 "10111" -> 'X'
 "11000" -> 'Y'
 "11001" -> 'Z'
 "11010" -> ' '
 "11011" -> '.'
 "11100" -> ','
 "11101" -> '-'
 "11110" -> '\''
 "11111" -> '?'
 _ -> cipher (x ++ (replicate (5 - length x) '0'))

encode c = case c of
 ' ' -> "101"
 '\'' -> "000000"
 ',' -> "000011"
 '-' -> "10010001"
 '.' -> "010001"
 '?' -> "000001"
 'A' -> "100101"
 'B' -> "10011010"
 'C' -> "0101"
 'D' -> "0001"
 'E' -> "110"
 'F' -> "01001"
 'G' -> "10011011"
 'H' -> "010000"
 'I' -> "0111"
 'J' -> "10011000"
 'K' -> "0110"
 'L' -> "00100"
 'M' -> "10011001"
 'N' -> "10011110"
 'O' -> "00101"
 'P' -> "111"
 'Q' -> "10011111"
 'R' -> "1000"
 'S' -> "00110"
 'T' -> "00111"
 'U' -> "10011100"
 'V' -> "10011101"
 'W' -> "000010"
 'X' -> "10010010"
 'Y' -> "10010011"
 'Z' -> "10010000"

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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define pii pair<int,int>
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;
void solve()    {
        ll n,k;         cin>>n>>k;
        ll temp=n%k;
        cout<<min(temp,k-temp);
}
/*  Integer Overflow  */
int main()  {
    fast;
    //test()
        solve();
}

Measured memory_bytes: 256
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N=I()
    A=[0]*N
    B=[0]*N
    for i in range(N):
        A[i],B[i]=MI()
        
    ans=0
    for i in range(N-1,-1,-1):
        A[i]+=ans
        target=(((A[i]+B[i]-1)//B[i]))*B[i]
        ans+=target-A[i]
        
    print(ans)
            
    


main()

Measured memory_bytes: 48632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

class RollingHash{
private:
    int M = 1e9+7;
    int base = 1213;
    string str;
    int n;
    vector<int> pow,sum;

    void build(){
        n = str.size();
        sum = pow = vector<int> (n+1);
        sum[0] = 0;
        pow[0] = 1;
        for(int i = 0; i < n; i++){
            sum[i+1] = (str[i] + sum[i] * base) % M;
            pow[i+1] = pow[i] * base % M;
        }
    }


public:
    RollingHash(){}
    RollingHash(string in){
        str = in;
        build();
    }
    RollingHash(string in, int p, int mod){
        M = mod;
        base = p;
        str = in;
        build();
    }

    int calc(int l, int r){//[l,r)のハッシュ値を計算
        int len = r - l;
        int ret = sum[r] + M;
        ret -= sum[l] * pow[len] % M;
        return ret % M;
    }

};

signed main(void) {
    string s,t;
    while(cin >> s){
        cin >> t;
        RollingHash rs(s);
        RollingHash rt(t);
        int n = s.size();
        int m = t.size();
        int ok = 0, ng = min(n,m)+1;
        while(ng - ok > 1){
            int mid = (ok + ng)/2;
            set<int> st;
            rep(i,n-mid+1){
                st.insert(rs.calc(i,i+mid));
            }
            bool c = false;
            rep(i,m-mid+1){
                if(st.count(rt.calc(i,i+mid)))c = true;
            }
            if(c)ok = mid;
            else ng = mid;
        }
        cout << ok << endl;
    }

}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
typedef long long ll; 
typedef long double ld ; 
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

 
int main() {
  	
  	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
 	
 	ll a , b , c , d ; 
 	cin >> a >> b >> c >> d ; 
 	ll ans = -2e18 ; 
 	ans = max(ans , a*c) ; 
 	ans = max(ans , b*d)  ;
 	ans = max(ans, a*d) ; 
 	ans = max(ans , b*c) ;  
 	cout << ans ;
	
 	return 0 ; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N;cin>>N;
  vector<int> data(10e5+1,0);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    data[A]++;
  }
  int ANS = 0;
  for (int i = 0; i < 10e5-1; i++)
  {
    chmax(ANS,data[i] + data[i+1] + data[i+2]);
  }
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

int main()
{
    MOAE;
    string s;
    cin >> s;
    bool f = false;
    for (auto it : s)
        if (it == '7')
            f = true;
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
 
  int main(){
      lint n;
      cin>>n;
      string s;
      lint a=0,b=0,c=0,d=0;
      rep(i,n){
          cin>>s;
          if(s=="AC")a++;
          if(s=="WA")b++;
          if(s=="TLE")c++;
          if(s=="RE")d++;
      }
      cout<<"AC x "<<a<<endl;
       cout<<"WA x "<<b<<endl;
       cout<<"TLE x "<<c<<endl;
       cout<<"RE x "<<d<<endl;
      
     }
     
 

Measured memory_bytes: 3616
// * template

#include <bits/stdc++.h>
#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

template<class T, class U> inline void fill_array(T &e, const U &v) { e = v; }
template<class T, class U, size_t s> inline void fill_array(T (&a)[s], const U &v) {for(auto&e:a)fill_array(e,v);}
template<class T, class U, size_t s> inline void fill_array(array<T, s> &a, const U &v) {for(auto&e:a)fill_array(e,v);}
template<class T, class U> inline void fill_array(vector<T> &a, const U &v) {for(auto&e:a)fill_array(e,v);}

// * solve

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

	using Graph = vector<vector<int>>;

	int n, q;
	cin >> n >> q;

	set<int> circle, hexagon;
	array<Graph, 2> rG;
	rG.fill(Graph(n));

	for(int v = 0; v < n; ++v) {
		int kind, zero, one;
		cin >> kind >> zero >> one;

		rG[0][zero].emplace_back(v);
		rG[1][one].emplace_back(v);

		if(kind == 0) {
			circle.emplace(v);
		}
		else {
			hexagon.emplace(v);
		}
	}

	vector<int> idx(n);
	vector<set<int>> S;
	queue<int> que;

	const auto update = [&idx, &S, &que](const set<int> &V) {
		for(const auto &v : V) {
			idx[v] = S.size();
		}
		que.emplace(S.size());
		S.emplace_back(V);
	};

	update(circle);
	update(hexagon);

	while(!que.empty()) {
		const set<int> V = S[que.front()];
		que.pop();

		for(const auto &G : rG) {
			map<int, set<int>> M;

			for(const auto &v : V) {
				for(const auto &u : G[v]) {
					M[idx[u]].emplace(u);
				}
			}

			for(const auto &e : M) {
				const int i = e.first;
				set<int> U = e.second;

				assert(0 <= i && i < S.size());
				if(S[i].size() == U.size()) continue;

				set<int> W;
				for(const auto &v : S[i]) {
					if(!U.count(v)) W.emplace(v);
				}
				update(U);
				update(W);
			}
		}
	}

	while(q--) {
		int v;
		cin >> v;
		cout << S[idx[v]].size() << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 214752
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        long N = sc.nextLong();
                        int ans = 100000;
                        for (long i = 1; i <= Math.sqrt(N) + 1; i++) {
                                if (N % i == 0) {
                                        long M = N / i;
                                        int count = 0;
                                        while (M != 0) {
                                                M /= 10;
                                                count++;
                                        }
                                        ans = Math.min(count, ans);
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 21332
#include<iostream>

using namespace std;

int n;
int main () {
    cin >> n;
    int total = 0;
    int max = 0;
    for(int i=0; i<n; i++) {
        int p;
        cin >> p;
        total += p;
        if( p > max ) max = p;
    }
    cout << total - max / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
def d_even_relation_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(input())
    Edges = [[int(i) for i in input().split()] for j in range(N - 1)]

    graph = [[] for _ in range(N)]
    for u, v, w in Edges:  # 頂点は 0-indexed とする
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))

    def distance_from_root(parent, current, distance, ret=None):
        """根 (頂点 0) から各頂点への距離"""
        if ret is None:
            ret = [0] * N

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
    ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0))  # 根の親は -1 番
    return ' '.join(map(str, ans))

print(d_even_relation_dfs())

Measured memory_bytes: 110476
#include<iostream>
using namespace std;
#define MAX 100000

int binarySearch(int S[], int n, int v){
    int left = 0, right = n, mid;

    while ( left < right){
        mid = (left + right) / 2;
        if ( v == S[mid] ) return 1;
        else if ( v < S[mid] ) right = mid;
        else if ( v > S[mid] ) left = mid + 1;
    }
   return 0;
}

int main(){
    int n, S[MAX], q, v, c = 0;
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> S[i];
    cin >> q;
    for ( int i = 0; i < q; i++ ) {
        cin >> v;
        c += binarySearch(S, n, v);
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3436
# -*- coding:utf-8 -*-
n,a,b = map(int,input().split())
member_list = list(input())

thr_dom = a+b
thr_nat = b
pass_num = 0
pass_nat = 0

for member in member_list:
    if member == 'a':
        if pass_num < thr_dom:
            print("Yes")
            pass_num += 1
        else:
            print("No")
    elif member == "b":
        if pass_num < thr_dom and pass_nat < thr_nat:
            print("Yes")
            pass_num += 1
            pass_nat += 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 9916
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	long long n,x;
	cin >> n >> x;
	vector<long long> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];

	vector<long long> mini(n);
	for(int i=0;i<n;i++)
		mini[i]=a[i];

	long long ans=1000000000000000;

	for(int i=0;i<n;i++)
	{
		long long tmp=x*i;
		for(int j=0;j<n;j++)
		{
			if(a[(j-i+n)%n]<mini[j])mini[j]=a[(j-i+n)%n];
			tmp+=mini[j];
		}
		if(tmp<ans)ans=tmp;
	}


	cout << ans << endl;


}

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

using namespace std;

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<pair<int, pair<int, int>>> event;
    while (n--)
    {
        int s, t, x;
        cin >> s >> t >> x;
        event.push_back(make_pair(max(0, s - x), make_pair(0, x)));
        event.push_back(make_pair(max(0, t - x), make_pair(1, x)));
    }
    vector<int> ans(q);
    for (int i = 0; i < q; i++)
    {
        int d;
        cin >> d;
        event.push_back(make_pair(d, make_pair(2, i)));
    }
    sort(event.begin(), event.end());
    multiset<int> stopper;
    for (auto &e : event)
    {
        int query = e.second.first;
        if (query == 0)
        {
            stopper.insert(e.second.second);
        }
        else if (query == 1)
        {
            stopper.erase(stopper.find(e.second.second));
        }
        else
        {
            ans[e.second.second] = (stopper.empty() ? -1 : *stopper.begin());
        }
    }
    for (int a : ans)
    {
        cout << a << '\n';
    }
}

int main()
{
    solve();
    cerr << "\"努力不足ですね！\"" << endl;
    return 0;
}

Measured memory_bytes: 18408
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
const int maxn = 200009;
const double pi = acos(-1.0);
int n,m,a[10009];
int main(){
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= m; i++) scanf("%d",&a[i]),n -= a[i];
    if(n < 0) printf("-1");
    else printf("%d",n);
    return 0;
}

Measured memory_bytes: 3796
N=int(input())
if N%10 == 3:# N%10 == 2 or N%10 == 4 or N%10 == 5 or N%10 == 7 or N%10 == 9:
    print("bon")
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9164
use std::collections::BTreeSet;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut a: Vec<u64> = sc.vec(n);
    a.sort();
    a.dedup();
    if a.len() == n {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_090b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int begin = int.Parse(input[0]);
            int end =  int.Parse(input[1]);
            int count = 0;
            for(int i = begin; i <= end; i++)
            {
                int A = i / 10000;
                int B = (i - A*10000) / 1000;
                int C = (i - A * 10000 - B * 1000) / 100;
                int D = (i - A * 10000 - B * 1000 - C * 100) / 10;
                int E = i % 10;
                if (A == E && B == D)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
    typedef long long ll;
    using namespace std;
    inline ll read(){
    	ll f=1,x=0;char ch;
    	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
    	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    	return f*x;
    }
    const int N=2010;
    const int yql=1e9+7;
    int s[N][N],f[N][N],c[N][N];
    inline void pre(){
    	for(int i=0;i<N;i++){
    		f[i][0]=1;s[i][0]=1;c[i][0]=1;
    		for(int j=1;j<i+1;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%yql;
    		for(int j=1;j<N;j++)s[i][j]=(s[i][j-1]+c[i][j])%yql;
    		for(int j=1;j<N;j++)f[i][j]=(f[i][j-1]+s[i][j])%yql;
    	}
    }
    inline int solve(int t,int b){
    	int ans=1;
    	for(int i=1;i<=min(t-1,b);i++)ans=(ans+(1LL*f[i-1][t-i-1]*c[b][i])%yql)%yql;
    	return ans;
    }
    int main(){
    	//freopen("dick.in","r",stdin);
    	//freopen("dick.out","w",stdout);
    	int a=read(),b=read();
    	int ans=0;pre();
    	for(int i=1;i<=a+1;i++)ans=(ans+solve(i,b-1))%yql;
    	printf("%d\n",ans);
    	return 0;
    }

Measured memory_bytes: 46720
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VLL l(n);
  INPUT(l);
  SORT(l);
  LL ans = 0;
  REP(i, n-2) REP2(j, i+1, n-1) ans += bisect_left(l, l[i]+l[j]) - j - 1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if (A >= K) {
        cout << K << endl;
    } else if (A + B >= K) {
        cout << A << endl;
    } else {
        cout << A - (K - (A + B)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
ans = 0

def yakusuu(num):
  yakusuu_array = []
  for j in range(1,num):
    if num % j == 0:
          yakusuu_array.append(j)
  return len(yakusuu_array)


for i in range(N):
  if (i+1) % 2 == 1 and yakusuu(i+1) == 7:
    ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    ll sum = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0) sum += i;
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int INF=(int)1e9;
int H,W,K;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int main(){
  int x1,y1,x2,y2;
  cin>>H>>W>>K;
  cin>>x1>>y1>>x2>>y2;
  x1--,y1--,x2--,y2--;
  vector<string>S(H);
  for(int i=0;i<H;i++)cin>>S[i];
  vector<vector<int>> D(H,vector<int>(W,INF));
  queue<pair<int,int>> P;
  D[x1][y1]=0;
  P.push({x1,y1});
  while(!P.empty()){
    int x=P.front().first,y=P.front().second;
    P.pop();
    int nd=D[x][y]+1;
    for(int r=0;r<4;r++){
      int tx=x,ty=y;
      for(int i=0;i<K;i++){
        tx+=dx[r],ty+=dy[r];
        if(tx<0||ty<0||tx>=H||ty>=W||S[tx][ty]=='@'||D[tx][ty]<nd)break;
        if(D[tx][ty]>nd){
          D[tx][ty]=nd;
          P.push(make_pair(tx,ty));
        }
      }
    }
  }
  int ans=D[x2][y2];
  cout<<(ans<INF?ans:-1)<<endl;
}


Measured memory_bytes: 12080
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#endif
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> nums;
  for (int t, i = 0; i < n; ++i) {
    cin >> t;
    nums.push_back(t);
  }

  int count = 0;
  for (auto it = nums.begin(); it != nums.end(); ++it) {
    auto it2 = min_element(it, nums.end());
    iter_swap(it, it2);
    if (it != it2) {
      ++count;
    }
  }
  for (auto&& num : nums) {
    cout << num;
    if (&num != &nums.back()) {
      cout << " ";
    }
  }
  cout << endl << count << endl;
}

Measured memory_bytes: 3140
#include<stdio.h>
int main(){
int N,Y,a,b,c;
scanf("%d %d",&N,&Y);
for(a=0;a<=N;a++){
for(b=0;b<=(N-a);b++){
c=N-(a+b);
if(a*10000+b*5000+c*1000==Y){
printf("%d %d %d",a,b,c);
return 0;
}
}}
printf("%d %d %d",-1,-1,-1);
return 0;

}

Measured memory_bytes: 128
#include <stdio.h>


int ope[101];
char com[100];
int top = 0;

void push(int x) {
	top++;
	ope[top] = x;   
}

int pop() {
	top--;
	return ope[top+1];
}
  
int main() {
	int num1,num2;
	while( scanf("%s",com) != EOF) {
		if( com[0] == '+') push( pop() + pop());
		else if( com[0] == '-'){
			num1 = pop();
			num2 = pop();
			push(num2 - num1);
		}else if( com[0] == '*') push( pop() * pop());
		else push(atoi(com));
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2112
d  = {}
l = []
while True:
  try:
    s,n = input().split()
    if s in d:
      d[s].append(int(n))
    else:
      d[s] = [int(n)]
      l.append(s)
  except:
    break
l.sort()
for s in l:
  print(s)
  d[s].sort()
  d[s] = [str(s) for s in d[s]]
  print(' '.join(d[s]))

Measured memory_bytes: 7620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using std::vector;
using std::find;
using std::distance;
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);

    for(int i = 0; i < M; i++) {
        int  x, y, z;
        cin >> x >> y >> z;
        tree.unite(x-1, y-1); // xの木とyの木を併合する
    }

    int cnt=1;
    for(int i=0;i<N;i++){
        if(!tree.same(0,i)){
            tree.unite(0, i);
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;
ll MOD=1000000007;
ll f(int a){
	ll t=1;
	loop(i,1,a+1)(t*=i)%=MOD;
	return t;
}
int main(){
	int n,b;
	cin>>n>>b;
	vvi dp(n+1,vi(300));
	dp[0][0]=1;
	rep(i,n){
		int a;cin>>a;
		for(int j=n-1;j>=0;j--)rep(k,300)if((k^a)<300)(dp[j+1][k^a]+=dp[j][k])%=MOD;
	}
	ll out=0;
	rep(i,n+1)if(dp[i][b]){
		(out+=f(i)*dp[i][b]%MOD)%=MOD;
	}
	cout<<out<<endl;
}









Measured memory_bytes: 384
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back 
#define MP make_pair
typedef long long ll;
const ll INF=1<<28;
const ll LINF=1ll<<61;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n,a[100111];
map<int,int> mp,cnt;
set<int> st;
ll ans[100111];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)
	{
		geti(a[i]);
		if(mp.find(a[i])==mp.end())
		{
			mp[a[i]]=i;
		}
		cnt[a[i]]++;
		st.insert(-a[i]);
	}
	st.insert(0);mp[0]=0;
	int pre=-1,c=0,pos=n;
	for(auto xx:st)
	{
		int x=-xx;
//		cout<<"x="<<x<<" c="<<c<<endl;
		if(pre!=-1)
		{
			pos=min(pos,mp[pre]);
			ans[pos]+=1ll*(pre-x)*c;
		}
		c+=cnt[x];
		pre=x;
	}
	for(int i=1;i<=n;i++)putsi(ans[i]);
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N = 5;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  int ret = INF;
  REP(i, N) {
    int tmp = 0;
    REP(j, N) {
      if(j != i) {
        tmp += ((A[j] + 9) / 10) * 10;
      }else{
        tmp += A[j];
      }
    }
    ret = min(ret, tmp);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A[3][3],N,b[10],ans;
bool zahyou[3][3];
int main(void){
    for(int i=0;i<3;i++){
        for (int k=0;k<3;k++){
            cin>>A[i][k];
            
        }
        
    }
    cin>>N;
    for(int j=0;j<N;j++){
        cin>>b[j];
    }
    for (int i=0;i<3;i++){
        for(int k=0;k<3;k++){
            zahyou[i][k]=false;
            for (int j=0;j<N;j++){
                if(b[j]==A[i][k]) zahyou[i][k]=true;
            }
        }
    }
    ans=0;
    for(int i=0;i<3;i++){
        if (zahyou[i][0]==true&&zahyou[i][1]==true&&zahyou[i][2]==true) ans=1;
    }
    for(int k=0;k<3;k++){
        if(zahyou[0][k]==true&&zahyou[1][k]==true&&zahyou[2][k]==true)ans=1;
    }
    if(zahyou[0][0]==true&&zahyou[1][1]==true&&zahyou[2][2]==true)ans=1;
    if(zahyou[2][0]==true&&zahyou[1][1]==true&&zahyou[0][2]==true)ans=1;
    if(ans==1)cout<<"Yes"<<endl;
    else if(ans==0) cout <<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
csf = [list(map(int, input().split())) for i in range(n - 1)]
for i in range(n):
    ans = 0
    for j in range(i, n - 1):
        c, s, f = csf[j][0], csf[j][1], csf[j][2]
        if ans < s:
            ans = s
        elif ans % f != 0:
            ans += f - ans % f
        ans += c
    print(ans)

Measured memory_bytes: 9232
n=int(input())
l1=[input() for i in range(n)]
m=int(input())
l2=[input() for i in range(m)]
d={}
for w in l1:
    if w in list(d.keys()):
        d[w]+=1
    else:
        d[w]=1
for w in l2:
    if w in list(d.keys()):
        d[w]-=1
print(max(0,max(list(d.values()))))


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, h[111];


int dfs(int l, int r, int x)
{
  int xm = *std::min_element(h + l, h + r), c = xm - x, ll = l;

  assert(l < r);
  
  for (int i = l; i < r; i ++)
    if (h[i] == xm) {
      if (ll < i)
        c += dfs(ll, i, xm);

      ll = i + 1;
    }

  if (ll < r)
    c += dfs(ll, r, xm);

  return c;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> h[i];

  std::cout << dfs(0, N, 0) << std::endl;

  return 0;
}


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

int main (){
  int x,y,z;
  cin >> x >> y;
  if ( ( x + y ) > 0){ z = 1;
  }else if ( ( x + y )==0){ z = 0;
  }else { z = -1;
	      }
  cout<< z << endl;
  return 0;
}



Measured memory_bytes: 3100
char s[4005];u[4005],m,j,c,d;main(n){for(;d=~scanf("%s ",s);m=!printf("%d\n",m))for(n=strlen(s);d-10;d=getchar())for(j=n;j--;m<c?m=c:0)u[j+1]=c=s[j]-d?0:u[j]+1;}

Measured memory_bytes: 428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if(i % 2 == 0 && a % 2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int a[5] ;
int main()
{
    int n , m ;
    cin >> n >> m ;
    for(int i = 1 ;i <= n ;i ++) a[i] = -1 ;
    for(int i = 1; i <= m ; i ++)
     {
       int x , y ;
       cin >> x >> y ;
       if(a[x] == -1 || a[x] == y) a[x] = y ;
       else return 0 * puts("-1") ;
     }
     if(n == 1)
      {
        if(a[1] >= 0) cout << a[1] << endl ;
        else cout << 0 << endl ;
      }
      else
       {
         if(a[1] == 0)
          return 0 * puts("-1") ;
         if(a[1] == -1) a[1] = 1 ;
         for(int i = 1; i <= n ;i ++)
           {
             if(a[i] == -1) a[i] = 0 ;
             cout << a[i] ;
           }
          puts("") ; 
       }
    return 0 ;
}


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

int main(void)
{
	int N, T;
	cin >> N >> T;
	
	vector<long long> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

	long long y = A[0];
	vector<long long> b(N);
	for(int i=0; i<N; i++)
	{
		y = min(y, A[i]);
		b[i] = A[i] - y;
	}
	
	long long maxb = *max_element(b.begin(), b.end());
	int ret = count(b.begin(), b.end(), maxb);

	cout << ret << endl;

	return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a;
  b=a/100;
  c=a/10-b*10;
  d=a-b*100-c*10;
  if(b==d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

	for (int i = 0; i < n; i++) {
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		ll sum = x * b + y * p;
		ll count = (x*0.2)*b + (y*0.2)*p;
		if (b >= 5 && p >= 2) {
			sum -= count;
		}
		else {
			ll add = 0,add_b = 0,add_p = 0;
			if (b < 5) {
				add += x * (5 - b);
				add_b = 5 - b;
			}
			if (p < 2) {
				add += y * (2 - p);
				add_p = 2 - p;
			}
			count = (x*0.2) * (b+add_b) + (y*0.2) * (p+add_p);
			sum = min(sum,sum+add-count);
		}
		cout<< sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> s(n);
    ll sum = 0, mini = INF;
    rep(i, n) {
        cin >> s[i];
        sum += s[i];
    }

    sort(s.begin(), s.end());
    rep(i, n) {
        if (s[i] % 10 != 0) {
            mini = s[i];
            break;
        }
    }

    if (sum % 10 == 0 && mini != INF) {
        cout << sum - mini << "\n";
    } else if (mini != INF) {
        cout << sum << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] p = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            for (int k= 0; k < N; k++)
            {
                if (p[k] != k + 1)
                {
                    cnt++;
                    if (2 < cnt)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
            }
            Console.WriteLine("YES");
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13268
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

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

    if (S.size() < 15)
        S += string(15 - S.size(), 'o');

    int cnt = count(S.begin(), S.end(), 'o');
    if (cnt >= 8)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int check(string s){
    if(s.find("7")!=string::npos
    && s.find("5")!=string::npos
    && s.find("3")!=string::npos
    ) return 1;
    return 0;
}

int search(string s, ll N){
    ll cnt = 0;
    if(!s.empty() && stol(s)>N) return 0;  
    
    if(check(s)) cnt++;

    cnt += search(s+"7", N);
    cnt += search(s+"5", N);
    cnt += search(s+"3", N);

    return cnt;
}

int main(){
    ll N;
    cin >> N;
    cout << search("", N) << endl;
    return 0;
}


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

using namespace std;

int dp[200][5][(1<<15)+1];

int main(){
    int n;
    vector<int> sq;
    
    for(int i=1;i*i<=(1 << 15);++i){
        sq.push_back(i*i);
    }
    int sqn = sq.size();



    dp[0][0][0] = 1;

    for(int i=1;i<=sqn;++i){
        for(int j=0;j<=(1 << 15);++j){
            for(int k=0;k<=4;++k){
                for(int l=0;l<=4;++l){
                    if(k+l <= 4 && j+sq[i-1]*l <= (1 << 15)){
                        dp[i][k+l][j+sq[i-1]*l] += dp[i-1][k][j];
                    }
                }
            }
        }
    }
    
    while(cin >> n && n){
        int ret = 0;

        for(int i=0;i<=4;++i){
            ret += dp[sqn][i][n];
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
# rとcを受け取る
r, c = map(int, input().split())

# 表を受け取る
rc = [list(map(int, input().split())) for i in range(r)]

# 処理実行
for j in rc:
    sumr = sum(j)
    j.append(sumr)
    print(" ".join(map(str, j)))

last = []
for k in range(c + 1):
    sumc = 0
    for l in range(r):
        sumc += rc[l][k]
    last.append(sumc)
print(" ".join(map(str, last)))



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

int main() {
  int N;
  cin >> N;
  vector<long long>A(N);
  for(int i=0; i<N; i++)cin >> A.at(i);
  long long zenbu=0;
  for(int i=0; i<N; i++){
    zenbu ^= A.at(i);
  }

  for(int i= 0; i<N-1; i++){
    cout << (zenbu ^A.at(i)) << " ";
  }
  cout << (zenbu ^ A.at(N-1)) << endl;
}

Measured memory_bytes: 4764
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
          long long int a,b,c;
          cin>>a>>b>>c;
          if((a+b+c)>=22)
          {
                    cout<<"bust\n";
          }
          else
                    cout<<"win\n";
return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

int main()
{
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  vector<ll> Ps, Qs, Rs;
  REP(i, A)
  {
    ll p;
    cin >> p;
    Ps.push_back(p);
  }
  REP(i, B)
  {
    ll q;
    cin >> q;
    Qs.push_back(q);
  }
  REP(i, C)
  {
    ll r;
    cin >> r;
    Rs.push_back(r);
  }
  sort(ALL(Ps), greater<ll>());
  sort(ALL(Qs), greater<ll>());
  sort(ALL(Rs), greater<ll>());
  Ps.erase(Ps.begin() + X, Ps.end());
  Qs.erase(Qs.begin() + Y, Qs.end());

  vector<ll> As;
  As.insert(As.end(), ALL(Ps));
  As.insert(As.end(), ALL(Qs));
  As.insert(As.end(), ALL(Rs));
  sort(ALL(As), greater<ll>());

  ll ans = 0;
  ll cnt = X + Y;
  for (auto a : As)
  {
    if (cnt == 0) break;

    ans += a;
    cnt--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N  = 500010;
int n,a,b,c,d;
int main(){
	bool flag =false;
	cin>>n>>a>>b>>c>>d;
	for(int i = 0;i<n;i++){
		//ll tmp = 1ll*c*(2*i-n+1)+1ll*(d-c)*i;
		ll tmp2 = 1ll*c*(2*i-n+1);
		if(tmp2<=abs(b-a)) {
			//flag =true;
			ll tmp = 1ll*c*(2*i-n+1)+1ll*(d-c)*i;
			if(tmp>=abs(b-a)) flag= true;
			//printf("%d\n",i);
		} else{
			ll tmp = 1ll*c*(2*i-n+1)-1ll*(d-c)*(n-1-i);
			if(tmp<=abs(b-a)) flag =true;
		}
	}
	if(flag) puts("YES");else puts("NO");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define nmax
#define pii pair<int,int>
#define inf
using namespace std;

int main() {
    int a, b;
    cin>>a>>b;
    if (a > b) swap(a,b);
    if (a == 1 && b == 2){
        cout<<"3\n";
    } else if (a == 1 && b == 3){
        cout<<"2\n";
    } else{
        cout<<"1\n";
    }
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int main()
{
	int i,j,k,n,m;
	int *p,*q;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<k;i++)
	{
		if(i%2==0)
		{
			p=&n;
			q=&m;
		}
		else
		{
			p=&m;
			q=&n;
		}
		*p=*p>>1;
		*q+=*p;
	}
	printf("%d %d",n,m);
}


Measured memory_bytes: 256