akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll h, w, k; cin >> h >> w >> k;
    vector<vector<ll>> field(h,vector<ll>(w,-1));
    REP(i,h){
        string s; cin >> s;
        REP(j,w){
            if(s[j]=='.') field[i][j]=0;
            else field[i][j]=1;
        }
    }
    ll ans = 0;
    REP(i,(1<<(h+w))){
        ll cnter=0;
        vector<vector<ll>> jud(h,vector<ll>(w,0));
        REP(i,h)REP(j,w)if(field[i][j]==1) jud[i][j]=1;
        FOR(j,0,h-1){
            if ((i>>j)%2) REP(k,w) jud[j][k]=0;
        }
        FOR(j,h,h+w-1){
            if ((i>>j)%2) REP(k,h) jud[k][j-h]=0;
        }
        REP(i,h)REP(j,w)if(jud[i][j]==1) cnter++;
        if (cnter==k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	long long int a, b;
	cin >> a >> b;
	long long int t = 2019;
	for (long long int i = b; i > a; i--) {
		for (long long int j = a; j < b; j++) {
			//cout << t << endl;
			t = min(t, (i*j) % 2019);
			if (t == 0) {
				cout << t << endl;;
				return 0;
			}
		}
	}
	cout << t << endl;
	return 0;



}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

class vertex {
public:
    int color;
    vector<pair<int,int>> neighbors;

    vertex() {
        this->color = -1;
        this->neighbors = vector<pair<int,int>>();
    }
};

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


    vector<vertex> vtx(N);

    for(int i=0; i<N-1; i++) {
        ull u, v, w;
        cin >> u >> v >> w;
        vtx[u-1].neighbors.push_back(pair<int,int>(v-1, w%2+2));
        vtx[v-1].neighbors.push_back(pair<int,int>(u-1, w%2+2));
    }

    auto que = queue<pair<int,int>>({pair<int,int>(0, 0)});

    while(!que.empty()) {
        auto& idx_c = que.front();
        auto idx = idx_c.first;
        auto c = idx_c.second;
        que.pop();

        vtx[idx].color = c;
        for(auto next : vtx[idx].neighbors) {
            if(vtx[next.first].color==-1) {
                auto next_idx = next.first;
                auto next_color = (next.second%2==0) ? c : 1-c;
                que.push(pair<int,int>(next_idx, next_color));
            }
        }
    }
    
    for(auto& v : vtx)
        cout << v.color << endl;

    return 0;
}

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


int main(){
        int A;
        int B;
        int C;
        
        cin>>A>>B>>C;
        
        std::set<int> st;
        
        st.insert(A);
        st.insert(B);
        st.insert(C);
        
        if(st.size()==2){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
}


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

int main() {
	long long N, ANS = 1000000000000;
	cin >> N;
	for (long long i = 1; i * i <= N; i++) {
		if (N % i == 0) ANS = min(ANS, N / i + i);
	}
	cout << ANS - 2 << endl;
}

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

long long dfs(long long a){
  if(a==1) return 2;
  return (dfs(a/2)+1)*2;
}

int main(){
  long long h;cin>>h;
  if(h==1) cout<<1;
  else cout<<dfs(h/2)+1;
}

Measured memory_bytes: 256
n, x, m = map(int, input().split())

tmp = [x]
while x**2%m not in tmp:
    x = x**2%m
    tmp.append(x)

cnt = len(tmp)
x = x**2%m

if n <= cnt:
    print(sum(tmp[:n]))
    exit()

for i in range(len(tmp)):
    if tmp[i] == x:
        st = sum(tmp[:i])
        rp = tmp[i:]
        div, mod = divmod(n-i, len(rp))
        en = sum(rp[:mod])
        print(st+sum(rp)*div+en)
        exit()

Measured memory_bytes: 68044
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
#include <string>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<ll,ll>;
 
int main() {
    string S,T;
    cin>>S>>T;
    int answer=T.size();
    for(int start=0;start<=S.size()-T.size();start++)
    {
      int diff =0;
      for(int i=0;i<T.size();i++)
      {
        if(T[i]!=S[start+i]){
          diff++;
        }
      }
      answer=min(answer,diff);
    }
    
    //if(D/S>T)cout<<"No"<<endl;
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 3600
from sys import stdin
from collections import defaultdict

N = int(input())
lines = stdin.readlines()

dic = defaultdict(dict)

for i, line in enumerate(lines):
    line = line.strip().split()
    if i==0:
        tuple1 = ([i+1, line[0], int(line[1])],)
    else:
        tuple1 = tuple1 + ([i+1, line[0], int(line[1])],)


#print(tuple1)

tuple1 = sorted(tuple1, key = lambda x:x[2], reverse=True)
result = sorted(tuple1, key = lambda x:x[1])
for i in range(0,N):
    print(result[i][0])

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

int cnt[30];
string s;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		cnt[s[i]-'a']++;
	}

	for (int i = 0; i < 26; i++) {
		if (cnt[i]&1) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	int k;
	cin>>k;
	sort(a,a+3);
	for(int i=0;i<k;i++){
		a[2]*=2;
	}
	cout<<a[0]+a[1]+a[2]<<endl;
    return 0;
}


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

using ll=long long;
const ll MOD=1e9+7;

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll r=b/x;
  ll l=(a-1)/x;
  if (a==0)
    l=-1;
  cout << r-l << endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	string S;
	cin >> S;
	
	int n = S.size();
	
	for_(x,1,3) for_(i,0,n-x) {
		if (S[i] == S[i + x]) {
			cout << i+1 << " " << i+x+1 << endl;
			exit(0);
		}
	}
	
	puts("-1 -1");
}

Measured memory_bytes: 512
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    long long a, b, n;
    cin >> a >> b >> n;
    long long x = min(b - 1, n);
    cout << ((a * x) / b) - a * (x / b) << endl;
    return 0;
}

Measured memory_bytes: 3608
n,c,k=map(int,input().split())

t=[]
for i in range(n):
 start_t=int(input())
 t.append([start_t,start_t+k])
t=sorted(t,key=lambda x:x[1])

ans=0
inx=0
while inx<n:
 ans+=1
 time=t[inx][1]

 for i in range(c):
  if inx==n:
   break
  if time>=t[inx][0]:
   inx+=1
  else:
   break

print(ans)

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

int main(){
  string s;
  cin >> s;
  if(s.back() == 's') s += 'e';
  s += 's';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3632
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    int N,K;cin >> N >> K;
    cout << N-K+1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
     long n=sc.nextLong();
      ArrayList<Long> a1=new ArrayList<Long>();
      HashMap<Long,Long>  map=new HashMap<Long,Long>();
	long a[]=new long[(int)n];
	long s=0;
       for(int i=0;i<n;i++)
      {
	    a[i]=sc.nextLong();
	    s=s+a[i];
               if(map.containsKey(a[i]))
	                 map.put(a[i],map.get(a[i])+1);
              else
  	                map.put(a[i],1l);
      }
       int q=sc.nextInt();
    Long sum=s;
      for(int i=0;i<q;i++)
      {
	long x1=sc.nextLong();
	long x2=sc.nextLong();
                 if(map.containsKey(x1))
                {
	                  sum=sum+((x2-x1)*map.get(x1));
	                  if(map.containsKey(x2))
	                         map.put(x2,map.get(x2)+map.get(x1));
                          else
	                  {
		                  map.put(x2,map.get(x1));
	                  }
                          map.remove(x1);
	           }
                   a1.add(sum);
    }     
   for(int t=0;t<a1.size();t++)
	     System.out.println(a1.get(t));
  }
}

Measured memory_bytes: 76200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextInt();
			sum += input[i];
		}
		double average = sum / (double) N;
		int pos = (int) Math.round(average);
		long res = 0;
		for (int i : input) {
			res += Math.pow(pos - i, 2);
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
const int Maxn = 410;
#define For( i, j, k ) for( int i = j; i <= k; ++i )
using std::cin;
using std::cout;
struct Node
{
	int col[ 4 ];
	friend bool operator < ( const Node &a, const Node &b )
	{
		For( i, 0, 3 )
			if( a.col[ i ] != b.col[ i ] )
				return a.col[ i ] < b.col[ i ];
		return 0;
 }
}elvahs[ 410 ];
Node nxt( Node x )
{
	return ( Node ) { x.col[ 1 ], x.col[ 2 ], x.col[ 3 ], x.col[ 0 ] }; 
}
std::map < Node, int > mp;
inline void insert( Node a, int x )
{
	for( int i = 0; i < 4; ++i, a = nxt( a ) )
		mp[ a ] += x;
}
int main( )
{
	std::ios::sync_with_stdio( false );
	int n;
	long long ans = 0;
	cin >> n;
	For( i, 1, n )
		cin >> elvahs[ i ].col[ 0 ] >> elvahs[ i ].col[ 1 ] >> elvahs[ i ].col[ 2 ] >> elvahs[ i ].col[ 3 ],
		insert( elvahs[ i ], 1 );
	For( i, 1, n )
	{
		insert( elvahs[ i ], -1 );
		For( j, i + 1, n )
		{
			insert( elvahs[ j ], -1 );
			For( t, 0, 3 )
			{
				Node a1 = Node{ elvahs[ j ].col[ 3 ], elvahs[ i ].col[ 0 ], elvahs[ i ].col[ 3 ], elvahs[ j ].col[ 0 ] },
				a2 = Node{ elvahs[ j ].col[ 0 ], elvahs[ i ].col[ 3 ], elvahs[ i ].col[ 2 ], elvahs[ j ].col[ 1 ] },
			 a3 = Node{ elvahs[ j ].col[ 1 ], elvahs[ i ].col[ 2 ], elvahs[ i ].col[ 1 ], elvahs[ j ].col[ 2 ] },
				a4 = Node{ elvahs[ j ].col[ 2 ], elvahs[ i ].col[ 1 ], elvahs[ i ].col[ 0 ], elvahs[ j ].col[ 3 ] };
				elvahs[ j ] = nxt( elvahs[ j ] );
				if( !mp[ a1 ] || !mp[ a2 ] || !mp[ a3 ] || !mp[ a4 ] )
					continue;
    long long res = 1;
				res *= mp[ a1 ];insert( a1, -1 );
				res *= mp[ a2 ];insert( a2, -1 );
				res *= mp[ a3 ];insert( a3, -1 );
				res *= mp[ a4 ];
				insert( a1, 1 ); insert( a2, 1 ); insert( a3, 1 );
				ans += res;
			}
			insert( elvahs[ j ], 1 );
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 23668
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn main(){
    let n = read::<i32>();
    let mut s = HashMap::new();
    for _ in 0..n{
        let r = read::<String>();
        let v = s.entry(r).or_insert(0);
        *v += 1;
    }
    let m = read::<i32>();
    for _ in 0..m{
        let r  = read::<String>();
        let v = s.entry(r).or_insert(0);
        *v -= 1;
    }
    let mut maxvalue = 0; //最悪で0が可
    for (_, v) in &s{
        if *v > maxvalue{
            maxvalue = *v;
        }
    }
    println!("{}", maxvalue)
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
	int n; cin >> n;
  double *arr = new double[n];
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  double s = 0;
  for(int i = 0; i < n; i++){
  	s += 1/arr[i];
  }
  cout << 1/s << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  double ans = 0;
  rep(i,n){
    double x; string s;
    cin >> x >> s;
    if(s == "JPY") ans += x;
    else ans += 380000.0 * x;
  }
  printf("%.10f\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s;cin >> s;
	int n = s.size();
	reverse(s.begin(),s.end());
	int i = 0;
	while(i < n){
		if(s.substr(i,5) == "maerd")i += 5;
		else if(s.substr(i,7) == "remaerd")i += 7;
		else if(s.substr(i,5) == "esare")i += 5;
		else if(s.substr(i,6) == "resare")i += 6;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n;
	cin >> n;
	
	vcL num(n);
	lli max1 = 0, max2 = 0;
	for (auto &x : num) {
		cin >> x;
		if (x > max1) {
			max2 = max1;
			max1 = x;
		}
		else if (x > max2) {
			max2 = x;
		}
	}
	
	for (auto x : num) {
		if (x == max1) cout << max2 << '\n';
		else cout << max1 << '\n';
	}
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 6272
#関数リスト
import sys
import itertools
input = sys.stdin.readline
mylist = ["+", "-"]

num = input().rstrip()
num = [int(num[i]) for i in range(len(num))]
first = num[0]
num = num[1:]

for i in itertools.product(mylist, repeat = len(num)):
    temp = first
    for j, k in zip(i, num):
        if j == "+":
            temp += k
        else:
            temp -= k
    if temp == 7:
        print(first, end = '')
        for j, k in zip(i, num):
            print(j+str(k), end = '')
        print("=7")
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    int ans = 1;
    while(ans <= N){
        ans <<= 1;
    }
    ans >>= 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=97
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):b(p:=j+t-1);a(q:=p+1,n,q);[*map(b,r(q,j+29))];a(j+29,x,i+t,1);b(p);a(q,i+t,q)
p(3933)
a(0,1,n)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):a(2,2,2);[(a(5+t-s,36+s,98),a(n,98,99,1),a(2,99,2))for s in r(t+1)if t-30<s<30]

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

int main(void){
   int A,B;
   cin>>A>>B;
   if(A==1) A=A+13;
   if(B==1) B=B+13;
   if(A>B) cout<<"Alice"<<endl;
   else if(A<B) cout<<"Bob"<<endl;
   else cout<<"Draw"<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main(void)
{
	using namespace std;
	
	int n;
	cin >> n;

	int num_tenant[4][3][10];
	for(int i = 0; i<4; i++){
		for(int j = 0; j<3; j++){
			for(int k = 0; k<10; k++){
				num_tenant[i][j][k] = 0; 
			}
		}
	}

	for(int i=0; i<n; i++){
		int building,floor,room, v;
		cin >> building;
		cin >> floor;
		cin >> room;
		cin >> v;

		num_tenant[building-1][floor-1][room-1] += v;
	}


	for(int i = 0; i<4; i++){
		for(int j = 0; j<3; j++){
			for(int k = 0; k<10; k++){
				if(num_tenant[i][j][k] <= 0)	cout << " 0";
				else													cout << " " << num_tenant[i][j][k];
			}
			cout << endl;
		}
		if(i <= 2)	cout << "####################" << endl;
	}

	return 0;

}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    int a[n];
    ffor(i,0,n) cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1];
    return 0;
}


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

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

  int ans = 0;
  for ( int i = 1; i <= n; i++ ) {
    int a;
    cin >> a;
    if ( i%2 == 1 && a%2 == 1 ) { ans++; }
  }

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


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
void out(vector<ll> v,ll n){
  vector<ll> cmp;
  for(int i=0;i<n;i++) cmp.push_back(v[i]);
  sort(cmp.begin(),cmp.end());
  for(int i=n-1;i>=0;i--){
    int pos=lower_bound(cmp.begin(),cmp.end(),v[i])-cmp.begin();
    cout<<pos+1<<" ";
  }
  cout<<endl;
}
signed main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if(a*b<n||a+b-1>n){
    cout<<-1<<endl;
    return 0;
  }
  ll fn=n;
  n=a*b;
  ll dec=n-fn;
  vector<ll> ans;
  for(int i=a;i>0;i--){
    ans.push_back(i);
    if(i==1){
      for(int j=1;j<b;j++) ans.push_back(j*a+i);
    }
    else{
      ll mns=min(dec,b-1);
      dec-=mns;
      ll kb=b-mns;
      for(int j=1;j<kb;j++) ans.push_back(j*a+i);
    }
  }

  out(ans,fn);
}


Measured memory_bytes: 14572
import sys
n = int(input())
count = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        if count >= 3:
            print('Yes')
            sys.exit()
        else:
            count = 0

if count >= 3:
    print('Yes')     
else:
    print('No')

Measured memory_bytes: 9176
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let pss = Array.init m @@ fun _ -> Scanf.scanf "%d %s\n" @@ fun p s -> p, s in
  let ac = Array.make n false in
  let wa = Array.make n 0 in
  Array.iter (fun (p, s) ->
    if not ac.(p - 1) then begin
      if s = "AC"
      then ac.(p - 1) <- true
      else wa.(p - 1) <- 1 + wa.(p - 1)
    end) pss;
  Printf.printf "%d %d\n"
  (Array.fold_right (fun b -> ( + ) @@ if b then 1 else 0) ac 0) @@
  Array.fold_left ( + ) 0 @@
  Array.init n @@ fun i -> if ac.(i) then wa.(i) else 0


Measured memory_bytes: 10112
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("error.txt", "w", stderr);
// #endif
	crap;

	int L;
	cin>>L;
 	
 	float am_gm_hm = (float)L/3;

 	float ans = (am_gm_hm*am_gm_hm*am_gm_hm);
 	cout << fixed << showpoint << setprecision(12) << ans << endl;
	 

	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,D;
    cin >> N >> D;
    vector<vector<int>> x(N,vector<int> (D));
    for (int i = 0 ; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> x.at(i).at(j);
        }
    }
    int count = 0;
    count -= N;
    int dist = 0;
    vector<int> check(160);
    for(int i = 0; i < 160; i++){
        check.at(i) = i*i;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            dist = 0;
            for(int k = 0; k < D; k++){
                dist += (x.at(i).at(k) - x.at(j).at(k))*(x.at(i).at(k) - x.at(j).at(k));
            }
            for(int l = 0; l < 160; l++){
                if(dist == check.at(l)){
                    count++;
                }
            }
        }
    }
    printf("%d",count/2);
}

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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);//读入优化 
  
  ll n;
  cin >> n;//读入 
  
  vector<ll> v(n+1), w(n+1);//把它当成普通数组就可以啦 
  
  for (int i = 1; i <= n; i++) 
     cin >> v[i] >> w[i];//读入 

  ll MAX_W = 100001LL;//所有询问的L值的最大值 
  vector<vector<ll> > dp(1LL<<10, vector<ll>(MAX_W, 0));//建立dp数组，向量套向量 

  for (ll i = 1; i < 1LL<<10; i++)//预处理出深度在(n/2)向下取整的节点的dp值(一行)，就是经典的01背包 
  {
    if (i > n) break;//如果它不是这棵树的节点，跳出 
    for (ll j = 1; j < MAX_W; j++)
	{
      dp[i][j] = max(dp[i][j-1], dp[i/2][j]);//dp[i/2][j]表示它父亲的dp值；即这个节点不选，直接继承上面的状态 
      if (j - w[i] >= 0) {//如果它是可以通过取该节点与其他一些东西所得到的 
        dp[i][j] = max(dp[i][j], dp[i/2][j-w[i]] + v[i]);
        //用dp[i/2][j-w[i]]+v[i]来更新答案
		//dp[i/2]表示其父节点的dp值。之所以不是dp[i]，是因为这不是无限背包 
      }
    }
  }
  ll query;//询问次数 
  cin >> query;//输入 
 
  for (ll q = 0; q < query; q++)//q次询问 
  {
    ll val, lim;
    cin >> val >> lim;//val:value,询问的节点编号 lim:limit,最大值，即题面中的L 
    if (val < (1LL<<10))//如果它已经被预处理过了，直接打印输出 
	{
      cout << dp[val][lim] << endl;
      continue;//别忘记continue 
    }
    
    ll ans = 0;
    int len = (int)(log2(val)) - 10 + 1;//记录下从len及它自己向上，有多少个节点没有被预处理过 
    for (int i = 0; i < (1<<len); i++)//01枚举上面未被预处理的len个节点的状态，即选或不选(与状压dp有些像) 
    { 
      ll vtemp = 0, wtemp = 0, index = val;
      //vtemp记录下当前被枚举选到的节点的value之和，wtemp同理记录下weight之和，方便转移 
      for (int j = 0; j < len; j++)
	  {
        if ((i>>j) & 1)//对于所有被选择的
		{
          vtemp += v[index];
          wtemp += w[index];
        }//求出vtemp,wtemp 
        index /= 2;//它的父亲 
        if (index < 1LL<<10)//如果index的这个节点已经被预处理过，尝试转移 
		{
          if (lim - wtemp < 0) break;//根本挤不下去，选这些都超过上限limit了，直接跳出 
          ans = max(ans, vtemp + dp[index][lim-wtemp]);
          //全篇最最核心的代码
		  //用vtemp+dp[intex][lim-wtemp]更新答案。即，vtemp表示当前的价值，还要加上之前预处理过的值，就是节点为index，上限为lim-wtemp所能得到的价值和的最大值 
          break;//转移成功，溜掉 
        }
      }
    }
    cout << ans << endl;//打印输出 
  }
  return 0; 
}
//完结撒花 

Measured memory_bytes: 811036
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

int main() {
	char c;
	cin >> c;
	if (c == 'a' ||c== 'e' || c=='i' ||c== 'u' || c=='o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}


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

void solve(long long N, long long R)
{
    cout << (R + 100 * max(10LL - N, 0LL)) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long R;
    scanf("%lld", &R);
    solve(N, R);
    return 0;
}


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

using namespace std;

struct Vector{
    double x,y;
    Vector(double x=0,double y=0):x(x),y(y){}
};
typedef Vector Point;

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double abs(Vector a){
    return sqrt(a.x*a.x+a.y*a.y);
}
int main(){
    int T;
    cin>>T;
    while(T--){
        Point p0,p1,p2,p3;
        cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
        Vector a,b;
        a.x=p1.x-p0.x;
        a.y=p1.y-p0.y;
        b.x=p3.x-p2.x;
        b.y=p3.y-p2.y;
        double f1=dot(a,b);
        double f2=cross(a,b);

        if(fabs(f1)<1e-7){
            cout<<1<<endl;
        }
        else {
            if(fabs(f2)<1e-7)
                cout<<2<<endl;
            else
                cout<<0<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int main() {

	map<string, int>T ;
	int N, M, ans=0;
	string s, t;
	cin >> N;
	for (int i = 0;i < N;++i) {
		cin >> s;
		T[s]++;
	}
	cin >> M;
	for (int i = 0;i < M;++i) {
		cin >> t;
		T[t]--;
	}
	map<string, int>::iterator it;
	for (it = T.begin();it != T.end();++it) {
		pair<string, int>item = *it;
		ans = max(ans, item.second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
 	cout << "vowel" <<endl;
 }else{
 	cout << "consonant" << endl;
 }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b;  scanf("%d %d", &a, &b);

  if(a > b){
    for(int i=0; i<a; i++)
      printf("%d", b);
  }else{
    for(int i=0; i<b; i++)
      printf("%d", a);
  }
  puts("");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
ll m;
const ll mod = 1e9+7;
const ll maxn = 500005;
ll inv[maxn+3];
ll fac[maxn+3];

inline ll A(ll n,ll m){
    return fac[n]*inv[n-m]%mod;
}
inline ll C(ll n,ll m){
	return A(n,m)*inv[m]%mod;
}

int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>m;
	fac[0] = 1;
	fac[1] = 1;
	for(ll i=2;i<maxn;i++){
		fac[i] = i * fac[i-1];
		fac[i] %= mod;
	}
	inv[0]=1;inv[1]=1;      //inv[0]=1 !!! 
    for(ll i=2;i<=maxn;i++){
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    }
    for(ll i=2;i<=maxn;i++){
        inv[i]=(inv[i]*inv[i-1])%mod;
    }
    ll ans =0;
    for(ll i=0;i<=n;i++){
    	ll tmp = C(n,i) * A(m-i,n-i);
    	tmp %= mod;
    	if(i%2==0){
    		ans += tmp;
		}else ans -= tmp;
		ans += mod;
		ans %= mod;
	}
	ans *= A(m,n);
	ans += mod;
	ans %= mod;
	cout<<ans<<endl;
	//cout<<tmp<<endl;
	return 0;
}


Measured memory_bytes: 11436
#include <iostream>

int main(int argc, char* argv[])
{
	int a = 0;
	int b = 0;
	std::cin >> a;
	std::cin >> b;

	const char* s = 0;
	if ( a > b )
		s = ">";
	else if ( a < b )
		s = "<";
	else
		s = "==";
	std::cout << "a " << s << " b" << std::endl;

	return 0;
}

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

const int N = 200005;

int T[N << 2], lz[N << 2];

// SEGMENT TREE
#define mid ((l + r) >> 1)
void push(int v, int l, int r) {
	if (lz[v] == 0) return;
	if (l < r) lz[v << 1] += lz[v], lz[v << 1 | 1] += lz[v];
	T[v] += lz[v];
	lz[v] = 0;
}

void upd(int v, int l, int r, int L, int R, int val) {
	push(v, l, r);
	if (l > r || R < l || L > r) return;
	if (L <= l && r <= R) { lz[v] = val; push(v, l, r); return; }
	upd(v << 1, l, mid, L, R, val); upd(v << 1 | 1, mid + 1, r, L, R, val);
	T[v] = max(T[v << 1], T[v << 1 | 1]);
}

int get(int v, int l, int r, int L, int R) {
	push(v, l, r);
	if (l > r || R < l || L > r) return 0;
	if (L <= l && r <= R) return T[v];
	return max(get(v << 1, l, mid, L, R), get(v << 1 | 1, mid + 1, r, L, R));
}
#undef mid
// END OF SEGMENT TREE

int n, m;
vector<int> seg[N];
int ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		int l, r; cin >> l >> r;
		seg[r].push_back(l);
	}

	for (int i = 1; i <= m; ++i) upd(1, 0, m + 1, i, i, -i);

	for (int rig = m + 1; rig >= 1; --rig) {
		for (int lef : seg[rig]) {
			upd(1, 0, m + 1, lef, m + 1, +1);
		}
		int mx = get(1, 0, m + 1, 0, rig - 1);
		//cerr << rig << ' ' << mx << endl;
		ans = max(ans, mx - m - 1 + rig);
	}

	cout << max(ans, n - m) << endl;
}

Measured memory_bytes: 14080
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs64 l(n);
    rep (i, n) cin >> l[i];


    sort(l.begin(), l.end());
    int ans = 0;
    rep (i, n)
    {
        for (int j = i + 1; j < n; ++j)
        {
            for (int k = j + 1; k < n; ++k)
            {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if (l[k] < l[i] + l[j]) ++ans;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



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

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(string, S);

    int o = 0;
    int x = 0;
    for (int i = 0; i < S.size(); i++) {
        if ( S[i] == 'o' ) {
            o++;
        } else {
            x++;
        }
    }

    string ans = "NO";
    if ( x < 8 ) {
        ans = "YES";
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a, b=0;
	REP(i, 5) {
		in >> a;
		if (a <= 40)a = 40;
		b += a;
	}

	
	out << b/5 << endl;
	return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> a(3*N);
  for(int i = 0; i < 3*N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int64_t ans = 0;
  for(int i = 0; i < 2*N; i++){
    if(i % 2 == 1){
      ans += a.at(i);
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
const int T = 1000000001;
int main() {
	int a, b;
	cin >> a >> b;
	int tmp = abs(a - b);
	if (tmp % 2) {
		cout << "IMPOSSIBLE";
	}
	else {
		cout << max(a, b) - tmp / 2;
	}
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(10));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            cin >> f[i][j];
        }
    }
    vector<vector<int>> p(n,vector<int>(11));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 11; j++)
        {
            cin >> p[i][j];
        }
    }
    int ans = -1000000000;
    for(int bit = 1; bit < (1<<10); bit++)
    {
        vector<int> c(n, 0);
        for(int i = 0; i < 10; i++)
        {
            if (bit & (1<<i)) {
                for(int j = 0; j < n; j++)
                {
                    if (f[j][i] == 1) {
                        c[j]++;
                    }
                }
            }
        }
        int gain = 0;
        for(int i = 0; i < n; i++)
        {
            gain += p[i][c[i]];
        }
        ans = max(ans, gain);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int F(int, int [],int);
int main()
{
  int sum=0,i,mid,l,r,n,k,w[1000000];
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
  }
  w[n]=-1;
  l=0;
  r=2000000000;
  while(l<r){
    mid=(l+r)/2;
    sum=F(mid,w,k);
    if(sum==n && F(mid-1,w,k)!=sum)break;   
    if(sum<n){
      l=mid+1;
    }
    else if(sum==n &&F(mid-1,w,k)==sum){
      r=mid;
    }
  }
 
  printf("%d\n",mid);
  return 0;
}
 
int F(int P,int w[],int k){
  int i,sum=0,a=0;
  for(i=0;i<k;i++){
    if(w[a]<=P){
      while(sum+w[a]<=P && w[a]!=-1){
    sum+=w[a];
    a++;
      }
    }
    sum=0;
  }
  return a;
}


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

vector<pair<int,int> > e[131073];
vector<pair<long long int,long long int> > v[131072];

void dfs(int x,long long int m){
	v[x].clear();
	if(e[x].empty()){
		v[x].emplace_back(0,0);
		return;
	}
	dfs(e[x][0].first,m);
	for(auto& it:v[e[x][0].first])
		it.first+=e[x][0].second,it.second+=e[x][0].second;
	dfs(e[x][1].first,m);
	for(auto& it:v[e[x][1].first])
		it.first+=e[x][1].second,it.second+=e[x][1].second;
	vector<pair<long long int,long long int> > vv[2];
	if(!v[e[x][1].first].empty())
		for(int i=0,j=0;i<v[e[x][0].first].size();i++){
			while(j+1<v[e[x][1].first].size()&&v[e[x][1].first][j+1].first+v[e[x][0].first][i].second<=m)	j++;
			if(v[e[x][0].first][i].second+v[e[x][1].first][j].first<=m)
				vv[0].emplace_back(v[e[x][0].first][i].first,v[e[x][1].first][j].second);
		}
	if(!v[e[x][0].first].empty())
		for(int i=0,j=0;i<v[e[x][1].first].size();i++){
			while(j+1<v[e[x][0].first].size()&&v[e[x][0].first][j+1].first+v[e[x][1].first][i].second<=m)	j++;
			if(v[e[x][1].first][i].second+v[e[x][0].first][j].first<=m)
				vv[1].emplace_back(v[e[x][1].first][i].first,v[e[x][0].first][j].second);
		}
	int lidx=0,ridx=0;
	while(lidx<vv[0].size()&&ridx<vv[1].size()){
		if(vv[0][lidx]<vv[1][ridx]){
			if(v[x].empty()||v[x].back().second>vv[0][lidx].second)
				v[x].emplace_back(vv[0][lidx]);
			lidx++;
		}
		else{
			if(v[x].empty()||v[x].back().second>vv[1][ridx].second)
				v[x].emplace_back(vv[1][ridx]);
			ridx++;
		}
	}
	while(lidx<vv[0].size()){
		if(v[x].empty()||v[x].back().second>vv[0][lidx].second)
			v[x].emplace_back(vv[0][lidx]);
		lidx++;
	}
	while(ridx<vv[1].size()){
		if(v[x].empty()||v[x].back().second>vv[1][ridx].second)
			v[x].emplace_back(vv[1][ridx]);
		ridx++;
	}
}

bool check(long long int m){
	dfs(1,m);
	return v[1].size();
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=2,p,w;i<=n;i++){
		cin>>p>>w;
		e[p].emplace_back(i,w);
	}
	long long int l=0,r=1e15;
	while(l<r){
		long long int mid=(l+r)>>1;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<l<<endl;
}


Measured memory_bytes: 33692
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
  
  	public static long maxVal(int n, int w, int wi[], int vi[]) {
      	long dp[][] = new long[n+1][w+1];
      	for (int i = 0 ; i <= w ; ++i) {
         	dp[0][i] = 0;
        }
      
      	for (int i = 1 ; i <= n ; ++i) {
         	dp[i][0] = 0;
        }
      
      	for (int i = 1 ; i <= n ; ++i) {
         	for (int j = 1 ; j <= w ; ++j) {
             	if (wi[i-1] <= j) {
                 	dp[i][j] = Math.max(vi[i-1] + dp[i-1][j-wi[i-1]], dp[i-1][j]); 
                } else {
                	dp[i][j] = dp[i-1][j];
                }
            }
        }
      	return dp[n][w];
    }
      
	public static void main(String args[]) throws IOException {
     	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	String nw[] = br.readLine().split(" ");
      	int n = Integer.parseInt(nw[0]);
      	int w = Integer.parseInt(nw[1]);
      	int wi[] = new int[n];
      	int vi[] = new int[n];
        for (int i = 0 ; i < n ; ++i) {
         	String in[] = br.readLine().split(" ");
          	wi[i] = Integer.parseInt(in[0]);
          	vi[i] = Integer.parseInt(in[1]);
        }
      	
      	long val = maxVal(n, w, wi, vi);
      	System.out.println(val);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N;i++) {
    cin >> vec.at(i);
  }
  
  int A = vec.at(0);
  int B = 0;
  int j;
  
  for (j = 0;j < N - 1;j++) {
    B++;
    if (A == 2) {
      break;
    }
    A = vec.at(A - 1);
  }
  
  if (j == N - 1) {
    cout << -1 << endl;
  } else {
    cout << B << endl;
  }
}


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


int main() {
    int n;
    cin >> n;
    int a[n-1];
    rep(i,n-1) cin >> a[i];

    int bucket[n+1] = {0};
   
    rep(i,n-1) {
        ++bucket[a[i]];
    }
    rep(i,n) {
        cout << bucket[i+1] << endl;
    }
    


    
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;

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

    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    a.push_back(INF);
    a.push_back(0);
    sort(a.begin(),a.end(),greater<int>());
    int l1=0,u1=n+1;
    while(u1-l1>1){
        int m1=(u1+l1)/2;
        if(a[m1]<=m1)u1=m1;
        else l1=m1;
    }
    int l2=u1,u2=n+1;
    while(u2-l2>1){
        int m2=(l2+u2)/2;
        if(a[m2]==a[u1])l2=m2;
        else u2=m2;
    }
    bool ans;
    if(a[u1]==u1){
        ans=(l2-u1)%2==1;
    }else if(a[u1]-u1==-1){
        ans=((l2-u1)%2==0)||((a[u1-1]-a[u1])%2==1);
    }else{
        ans=((a[u1-1]-(u1-1))%2==1);
    }
    cout << (ans?"First":"Second") <<"\n";

    return 0;
}



Measured memory_bytes: 1024