akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int rank[6], n;
	double body_length;
	cin >> n;
	for(int i=0; i<6; i++)
		rank[i] = 0;
	
	for(int i=0; i<n; i++){
		cin >> body_length;
		if(body_length < 165)
			rank[0]++;
		if(body_length >= 165 && body_length < 170)
			rank[1]++;
		if(body_length >= 170 && body_length < 175)
			rank[2]++;
		if(body_length >= 175 && body_length < 180)
			rank[3]++;
		if(body_length >= 180 && body_length < 185)
			rank[4]++;
		if(body_length >= 185)
			rank[5]++;
	}
	
	for(int i=0; i<6; i++){
		cout << i+1 << ":";
		for(int j=0; j<rank[i]; j++)
			cout << "*";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        if (i % 2 == 0)
            cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3636
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 1

if X >= Y:
    ans = 1
elif X < Y:
    z = list(range(X+1, Y+1))
    for i in z:
        if max(x) < i and i <= min(y):
            ans = 0
     
    
if ans == 0:
     print('No War')
        
else:
    print('War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,a,b) for(i=a;i<b;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
using namespace std;

int main() {

int a,b,c,k,i,j;
cin>>a>>b>>c>>k;

for(i=1;i<k;i++)
{
    if(b<=a)b*=2;
    else break;
}

if(b<=a)cout<<"No";

else
{
    for(j=i;j<=k;j++)
    {
        if(c<=b)c*=2;
        else break;
    }
    if(c<=b)cout<<"No";
    else cout<<"Yes";
}
}

Measured memory_bytes: 3632
#include <stdio.h>

long min(long x, long y) {
  if(x >= y) return y;
  else return x;
}

int main() {
  long q, h, s, d, n;
  scanf("%ld %ld %ld %ld", &q, &h, &s, &d);
  scanf("%ld", &n);

  long sbyq = q * 4;
  long sbyh = h * 2;
  long dbyq = sbyq * 2;
  long dbyh = sbyh * 2;
  long dbys = s * 2;

  long s_best = min(min(s, sbyq), sbyh);
  long d_best = min(min(d, dbyq), min(dbyh, dbys));

  long price = n / 2 * d_best;
  if(n % 2 != 0) price += s_best;

  printf("%ld", price);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

void Swap(int *a, int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int Gcd(int a, int b, int c){
    int r, s;
    if(a < b){
        Swap(&a, &b);
    }
    while(b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    if(a < c){
        Swap(&a, &c);
    }
    while(c != 0){
        s = a % c;
        a = c;
        c = s;
    }
    return a;
}

int main(void){
    int K,Sum = 0;

    scanf("%d",&K);
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                Sum += Gcd(i, j, k);                    
            }
        }
    }
    printf("%d\n",Sum);
    return 0;
}

Measured memory_bytes: 1708
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
int main(){
	int dat[11]={};
	for(int i=0;i<10;i++){
		cin>>dat[i];
	}
	sort(dat,dat+10,greater<int>());
	cout<<dat[0]<<endl<<dat[1]<<endl<<dat[2]<<endl;
	return 0;
}

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

using namespace std;

int main(){
        int c[3];
        while(cin >> c[0] >> c[1] >> c[2]){
                bool list[10];
                for(int i = 0; i < 10; i++){
                        list[i] = false;
                        for(int j = 0; j < 3; j++) list[i] |= i == c[j]-1;
                }   
                int m = 0;
                int count = 0;
                int idx = 0;
                while(idx < 10 && count < 4 ){
                        if(!list[idx]) count++;
                        if(count == 4) m = idx+1;
                        idx++;
                }   
                if(c[0]+c[1]+m <= 20) cout << "YES";
                else cout << "NO";
                cout << endl;
        }   
}

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

int a,b,c;
map<int,int> cnt;

int main(){
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);

    cin>>a>>b>>c;
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;

    cout<<(cnt[a]==2||cnt[b]==2||cnt[c]==2?"Yes":"No");
}


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.nextInt();
        long m = sc.nextInt();
        long k = n * m;
        char s[] = sc.next().toCharArray();
        char t[] = sc.next().toCharArray();
        while (n != m){
            if(n > m)n -= m;
            else m -= n;
        }
        k /= n;
        int q = (int)(k / n);
        int ss = (int)(k / s.length);
        int tt = (int)(k / t.length);
        for (int i = 0;i < n;++i){
            int x = i * q;
            if(s[x / ss] != t[x / tt]){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(k);

    }

}





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

void code()
{
    ll n,m;
    cin>>n>>m;
    vector<vector<ll> > v(n+1);
    ll a,b;
    for(ll i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    bool visitd[n+1]={0};
    ll ans[n+1]={0};
    queue<ll> q;
    q.push(1);
    visitd[1]=1;
    // cout<<"hr";
    while(!q.empty())
    {
        // cout<<"hr";
        ll k=q.front();
        // cout<<k<<endl;
        for(auto j:v[k])
        {
            // cout<<k<<" "<<j<<endl;
            if(!visitd[j])
            {
              ans[j]=k;
              q.push(j);
              visitd[j]=1;
            }
        }
        q.pop();
    }
    ll i=2;
    for(;i<=n;i++)
    {
        if(ans[i]==0)
            break;
    }
    if(i==n+1)
    {
        cout<<"Yes"<<endl;
     for(ll i=2;i<=n;i++)
     {
        cout<<ans[i]<<endl;
     }
    }
    else
        cout<<"No"<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        // cout<<"hr";
        code();
    }
}

Measured memory_bytes: 13036
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n;
  cin >> n;
  vi p(n);
  vi index2order(n);
  rep (i, n) {
    cin >> p[i];
    p[i] -= 1;
    index2order[p[i]] = i;
  }
  vi dp(n-1);
  rep (i, n-1) {
    dp[i] = index2order[i+1] - index2order[i];
  }

  vi da(n-1), db(n-1);
  rep (i, n-1) {
    if (dp[i] > 0) {
      db[i] = -1;
      da[i] = dp[i] + 1;
    } else {
      da[i] = 1;
      db[i] = dp[i] - 1;
    }
  }

  vi a(n), b(n);
  a[0] = 1;
  b[n-1] = 1;
  FOR (i, 1, n) {
    a[i] = a[i-1] + da[i-1];
  }
  for (int i = n-2; i >= 0; --i) {
    b[i] = b[i+1] - db[i];
  }

  rep (i, n-1) {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[n-1]);
  rep (i, n-1) {
    printf("%d ", b[i]);
  }
  printf("%d\n", b[n-1]);

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long
# define INF 1000005
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}


int32_t main()
{
    c_p_c();
    
       int n,k;
       cin>>n>>k;
       int s=0;
       vector<int>a(n);
       for(int i=0;i<n;i++)cin>>a[i];
       nth_element(a.begin(),a.begin()+k,a.end());
       for(int i=0;i<k;i++){
        s+=a[i];
       }
       cout<<s;


 
    
      return 0;
       }
        
        

        























Measured memory_bytes: 3592
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let v = vec![1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    let k = read1::<usize>();
    println!("{}", v[k-1]);
}

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

int main (){
  ll n;cin>>n;
  set<string> S;
  rep(i,n){
    string s;cin>>s;
    S.insert(s);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 19224
# ABC135C - City Savers
# greedy algorithm
def main():
    N, *AB = map(int, open(0).read().split())
    ans, a1 = 0, AB[0]
    for a2, b in zip(AB[1 : N + 1], AB[N + 1 :]):
        cnt1 = min(a1, b)
        cnt2 = min(a2, b - cnt1)
        ans += cnt1 + cnt2
        a1 = a2 - cnt2  # a2 becomes a1 in next turn
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25180
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		VI a(n);
		rep(i, n)cin >> a[i];
		int ave = accumulate(all(a), 0) / n;
		SORT(a);
		auto it = upper_bound(all(a), ave);
		size_t pos = distance(a.begin(), it);

		cout << pos << endl;
	}
}


Measured memory_bytes: 3184
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){

    int N, L;
    cin>> N>> L;

    string S[N];
    for(int i=0; i<N; i++){
        cin>> S[i];
    }

    sort(S, S+N);

    string s;
    for(int i=0; i<N; i++){
        s+=S[i];
    }
    cout<< s<< endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <new>

int main(void)
{
  int r,c;
  int i,j;
  int ra,ca;
  
  scanf("%d%d",&r,&c); //??\??????????????¨????????????????±????

  ra = r+1;
  ca = c+1;

  int** da = new int*[ra]; //??????????????¨?????????????¢????
  for(i=0; i<ra; i++){
    da[i] = new int[ca];
  }

  for(i=0; i<ra; i++){ //??¨???????????¨???0???
    for(j=0; j<ca; j++){
      da[i][j] = 0;
    }
  }

  for(i=0; i<r; i++){ 
    for(j=0; j<c; j++){
      scanf("%d",&da[i][j]); //??\?????????
      da[i][c] = da[i][c] + da[i][j];
      da[r][j] = da[r][j] + da[i][j];
      da[r][c] = da[r][c] + da[i][j]; //???????¨????????????????
    }
  }

  for(i=0; i<ra; i++){ //??¨?????????
    for(j=0; j<ca; j++){
      printf("%d",da[i][j]);
      if(j==c)
	puts("");
      else
	printf(" ");
    }
  }

  for(i=0; i<ra; i++){ //?¢??????????????????????????¢????
    delete[] da[i];
  }
  delete[] da;

  
  return(0);

}

Measured memory_bytes: 1088
import java.util.Scanner;

public class Main{
  static int A,B,Q;
  static Long[] S,T,X;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    A = sc.nextInt();
    B = sc.nextInt();
    Q = sc.nextInt();
    S = new Long[A+2];
    T = new Long[B+2];
    X = new Long[Q];
    for(int i=1;i<=A;i++){
      S[i]=sc.nextLong();
    }
    S[0]=-100000000000000000L;
    S[A + 1]=100000000000000000L;
    for(int i=1;i<=B;i++){
      T[i]=sc.nextLong();
    }
    T[0]=-100000000000000000L;
    T[B + 1]=100000000000000000L;
    for(int i=0;i<Q;i++){
      X[i]=sc.nextLong();
    }
    for(int i=0;i<Q;i++){
      System.out.println(Qanswer(i));
    }
  }

  static int binary_search(Long[] a, Long x) {
    int lb = 0, ub = a.length - 1;
    while (ub - lb > 1) {
      int mid = (lb + ub) / 2;
      if (a[mid] <= x) lb = mid;
      else ub = mid;
    }
    return lb;
  }

  static Long Qanswer(int i){
    int Snear = binary_search(S,X[i]);
    int Tnear = binary_search(T,X[i]);

    /* ======== DEBUG ======== */
    //System.out.println("[" + S[Snear] + ", " + X[i] + ", " + S[Snear + 1] + "]");
    //System.out.println("[" + T[Tnear] + ", " + X[i] + ", " + T[Tnear + 1] + "]");
    /* ======== /DEBUG ======== */

    return minimum(caliculate(i,Snear,Tnear),caliculate(i,Snear,Tnear+1),caliculate(i,Snear+1,Tnear),caliculate(i,Snear+1,Tnear+1));
    /*if((Snear<=X[i] && Tnear<=X[i]) || (Snear>=X[i] && Tnear>=X[i])){
      return Math.max(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear));
    }
    else{
    return Math.max(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear))+2*Math.min(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear));
    }
    */
  }

  static Long caliculate(int i,int r,int l){
    if((S[r]<=X[i] && T[l]<=X[i]) || (S[r]>=X[i] && T[l]>=X[i])){
      /* ======== DEBUG ======== */
      //System.out.println("1: " + Math.abs(X[i] - S[r]) + ", " + Math.abs(X[i] - T[l]));
      /* ======== /DEBUG ======== */
      return Math.max(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]));
    }
    else{
      /* ======== DEBUG ======== */
      //Long t = Math.max(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l])) + 2*Math.min(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]));
      //System.out.println("2: " + t);
      /* ======== /DEBUG ======== */
      return Math.max(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]))+2*Math.min(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]));
    }
  }

  static Long minimum(Long a,Long b,Long c,Long d){
    Long ans = 100000000000000000L;
    Long[] Arra= new Long[4];
    Arra[0] = a;
    Arra[1] = b;
    Arra[2] = c;
    Arra[3] = d;
    for(int i=0;i<4;i++){
      if(ans>=Arra[i]){
        ans = Arra[i];
      }
    }
    return ans;
  }

}

Measured memory_bytes: 102884
a, b, x = map(int, input().split())
if a%x == 0 and b%x == 0:
  ans = b//x -a//x +1
elif a%x != 0 and b%x == 0:
  ans = b//x -a//x
elif a%x == 0 and b%x != 0:
  ans = b//x -a//x +1
else:
  ans = b//x -a//x
print(ans)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
 
	public static void main(String[] args) {
		new Main();	
	}
 
	public Main() {
		new aoj510().doIt();
	}
	class aoj510{
		void alf(char ctr[]){
			for(char c = 'A';c <= 'Z';c++){
				if(c < 'D')ctr[c] = (char)(c+23);
				else ctr[c] = (char)(c-3);
			}
		}
		void doIt(){
			char ctr[] = new char[128];
			alf(ctr);
			char str[] = sc.next().toCharArray();
			int length = str.length;
			StringBuilder sb = new StringBuilder();
			for(int i = 0;i < length;i++){
				sb.append(ctr[str[i]]);
			}
			System.out.println(sb);
		}
	}
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int k,x;cn(k,x)
  if (k*500>=x){
    puts("Yes");
  }else{
    puts("No");
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101],b[101];
int main(){
	int i,n,ans=0,mn=101;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		ans+=a[i];
		if(a[i]%10!=0&&a[i]<mn) mn=a[i];
	}
	if(ans%10!=0){
		cout<<ans;
		return 0;
	}else{
		if(mn==101) 
			cout<<0;
		else 
			cout<<ans-mn;	
	}
	return 0;
} 

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif



int main(void)
{
	ll n; cin >> n;
	vector<double> v(n);

	rep(i, 0, n)
		cin >> v[i];

	sort(all(v));

	ll i = 0;
	double ans = 0;
	while (1)
	{
		if (i == n - 1)
			break;
		v[i + 1] = (v[i] + v[i + 1]) / 2;
		i++;
	}

	cout << v[n - 1];

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

VI ans(200001, 0);
VI add(200001, 0);
vector<vector<int>> edge(200001, vector<int>(0));

void dfs(int v, int p) {
	ans[v] = ans[p] + add[v];
	for (int i = 0; i < edge[v].size(); i++) {
		if (edge[v][i] != p) {
			dfs(edge[v][i], v);
		}
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	int a, b;
	REP(i, n - 1) {
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	int p, x;
	REP(i, q) {
		cin >> p >> x;
		add[p] += x;
	}
	dfs(1, 0);
	REP(i, n) {
		cout << ans[i + 1] << ' ';
	}
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W; cin>>n>>W;
    ll v[n+1],u[n+1],dp[n+1][W+1];
    dp[0][0]=v[0]=u[0]=0;
    for (int in=1;in<=n;in++)
        cin>>u[in]>>v[in];
    for (int i1=1;i1<=W;i1++)
        dp[0][i1]=0;
    for (int i2=1;i2<=n;i2++)
        dp[i2][0]=0;
    for (int i=1;i<=n;i++) {
        for (int w=1;w<=W;w++) {
            if (u[i]>w)
                dp[i][w]=dp[i-1][w];
            else
                dp[i][w]=max(v[i]+dp[i-1][w-u[i]], dp[i-1][w]);
        }
    }
    cout<<dp[n][W]<<"\n";
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N,M; cin>>N>>M;
    vec H(N), out(N,0);
    rep(i,N){
        cin>>H[i];
    }
    rep(i,M){
        int A, B; cin>>A>>B;
        A--; B--;
        if(H[A] > H[B]) out[B]++;
        else if(H[A] < H[B]) out[A]++;
        else{
            out[A]++; out[B]++;
        }
    }
    int ans = 0;
    rep(i,N){
        if(out[i] == 0) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<bitset<10>> f(101);
vector<vector<int>> p(101, vector<int>(11, 0));

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) for(int j = 0; j < 10; ++j){ int a; scanf("%d", &a); f[i][j] = a; }
    for(int i = 0; i < N; ++i) for(int j = 0; j < 11; ++j) scanf("%d", &p[i][j]);
    
    int ans = -INT_MAX;
    for(int m = 1; m < (1 << 10); ++m){
        int sum = 0;
        for(int i = 0; i < N; ++i){
            int cnt = 0;
            for(int j = 0; j < 10; ++j) if((m & (1 << j)) && f[i][j]) ++cnt;
            sum += p[i][cnt];
        }
        ans = max(ans, sum);
    }
    printf("%d\n", ans);
    
    return 0;
}



Measured memory_bytes: 256
n = int(input())

sl = []
for _ in range(n):
    s = int(input())
    sl.append(s)

sl = sorted(sl)

if sum(sl) % 10 != 0:
    print(sum(sl))
    exit()
else:
    for s in sl:
        if s % 10 != 0:
            print(sum(sl) - s)
            exit()
    else:
        print(0)


Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

int main(){
	
	int moto,sum,a,b;
	
	while(1){
	
		cin >> a;
	
		if(a==-1) break;
		
		sum=1150;
		moto=4280;
		
		for(int i=11;i<=a;i++){
			if(20>=i){
				sum+=125;
			}else if(20<i && 30>=i){
				sum+=140;
			}else sum+=160;
		}
		
		b=moto-sum;
		
		printf("%d\n",b);
		
	}
	
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int total = 0;
  rep(i, n)
  {
    cin >> a[i];
    total += a[i];
  }

  int count = 0;
  rep(i, n)
  {
    if (a[i] >= total * (double(1)/double(4*m))) {
      count++;
    }
  }

  string ans;
  if (count >= m)
    ans = "Yes";
  else
    ans = "No";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = []
temp = [0]*n
for i in range(n):
    x = n-i
    y = 0
    for j in range(n):
        if x*(j+2) <= n:
            if temp[x*(j+2)-1] == 1:
                y += 1
        else:
            break
    if not y%2 == a[x-1]:
        ans.append(x)
        temp[x-1] += 1
s = len(ans)
print(s)
if s > 0:
    print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 19848
#include<iostream>
#include<string>
using namespace std;
string a,b;
int a_i,b_i;
int main()
{
  cin>>a>>b;
  while(1)
  {
    if(a_i!=a.size()){cout<<a[a_i];a_i++;}
    if(b_i!=b.size()){cout<<b[b_i];b_i++;}
    if(a_i==a.size()&&b_i==b.size())break;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.pop();
    let mut t = String::new();
    stdin().read_line(&mut t).ok();
    t.pop();
    t.pop();

    println!("{}", if s == t { "Yes" } else { "No" });
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

ll n,m;
string s,t;

int main() {
  cin >> n;
  cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
a, b, c = [int(i) for i in input().split()]
if a == b == c and a % 2 == 0:
    print(-1)
    exit()
if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
    exit()
cnt = 0
while True:
    ta, tb, tc = a, b, c
    ta = (b + c) // 2
    tb = (a + c) // 2
    tc = (a + b) // 2
    cnt += 1
    if ta % 2 == 1 or tb % 2 == 1 or tc % 2 == 1:
        print(cnt)
        break
    a, b, c = ta, tb ,tc

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size())
    {
        cout << "GREATER" << endl;
        return 0;
    }
    if (a.size() < b.size())
    {
        cout << "LESS" << endl;
        return 0;
    }
    rep(0, i, a.size())
    {
        if (a.at(i) > b.at(i))
        {
            cout << "GREATER" << endl;
            return 0;
        }
        if (a.at(i) < b.at(i))
        {
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        System.out.println(Math.min(p + q, Math.min(q + r, r + p)));
    }

}


Measured memory_bytes: 21716
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;
constexpr int M = 1'000'000'007;
enum { A, C, G, T };

int pack(int x, int y, int z) {
    return x * 16 + y * 4 + z;
}


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

    auto dp = vector<array<large, 64>>(n + 1);
    for (auto& x : dp[3])
        x = 1;
    dp[3][pack(A, G, C)] = 0;
    dp[3][pack(A, C, G)] = 0;
    dp[3][pack(G, A, C)] = 0;
    
    for (int i = 3; i <= n; ++i) {
        assert(dp[i][pack(A, G, C)] == 0);
        assert(dp[i][pack(A, C, G)] == 0);
        assert(dp[i][pack(G, A, C)] == 0);
        if (i == n) break;

        // Add 'A'
        for (auto x : {A, C, G, T}) {
            for (auto y : {A, C, G, T}) {
                for (auto z : {A, C, G, T}) {
                    dp[i + 1][pack(y, x, A)] += dp[i][pack(z, y, x)];
                }
                dp[i + 1][pack(y, x, A)] %= M;
            }
        }

        // Add 'C'
        for (auto x : {A, C, G, T}) {
            for (auto y : {A, C, G, T}) {
                if ((x == A && y == G) || (x == G && y == A)) {
                    continue;
                }
                for (auto z : {A, C, G, T}) {
                    if (z == A && (x == G || y == G))
                        continue;
                    dp[i + 1][pack(y, x, C)] += dp[i][pack(z, y, x)];
                }
                dp[i + 1][pack(y, x, C)] %= M;
            }
        }

        // Add 'G'
        for (auto x : {A, C, G, T}) {
            for (auto y : {A, C, G, T}) {
                if (x == C && y == A) {
                    continue;
                }
                for (auto z : {A, C, G, T}) {
                    dp[i + 1][pack(y, x, G)] += dp[i][pack(z, y, x)];
                }
                dp[i + 1][pack(y, x, G)] %= M;
            }
        }

        // Add 'T'
        for (auto x : {A, C, G, T}) {
            for (auto y : {A, C, G, T}) {
                for (auto z : {A, C, G, T}) {
                    dp[i + 1][pack(y, x, T)] += dp[i][pack(z, y, x)];
                }
                dp[i + 1][pack(y, x, T)] %= M;
            }
        }
   }

    cout << (accumulate(dp[n].begin(), dp[n].end(), 0LL) % M) << endl;
    return 0;
}


Measured memory_bytes: 3652
def how_many_ways(n, x):

    count = 0
   
    for i in range(1, n + 1):
        s = x
        s = s - i
        for j in range( 1, n + 1):
                s = s - j
                for k in range( 1 , n + 1 ):
                    s = s - k
                    if s == 0:
                        count += 1

def how_many_ways2(n, x):

    count = 0

    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if i < j < k and i + j + k == x:
                    count += 1

    print(count)
                        

if __name__ == "__main__":
    
    while(True):

        param = input().split(" ")
        n = int(param[0])
        x = int(param[1])

        if n == 0 and x == 0:
            break
        else:
            how_many_ways2(n, x)



Measured memory_bytes: 5600
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

class team{
public:
	int ans[10][2];
	int id;
	int num;
	int total;
	void format(int id){
		memset(ans,0,sizeof(ans));
		this->id=id;
		total=0;
		num=0;
	}
	void set(int p,int time,int f){
		if(f!=0) ans[p][1]=time;
		else ans[p][0]++;
	}
	void set(){
		for(int i=0;i<10;i++){
			if(ans[i][1]>0){
				total+=(ans[i][0]*1200+ans[i][1]);
				num++;
			}
		}
	}
	bool operator<(team &obj){
		if(this->num<obj.num) return true;
		else if(this->num==obj.num){
			if(this->total<obj.total) return true;
			else if(this->total==obj.total){
				if(this->id<obj.id) return true;
			}
		}
		return false;
	}
	bool operator>(team &obj){
		if(this->num>obj.num) return true;
		else if(this->num==obj.num){
			if(this->total<obj.total) return true;
			else if(this->total==obj.total){
				if(this->id<obj.id) return true;
			}
		}
		return false;
	}
	team& operator=(team &obj){
		for(int i=0;i<10;i++){
			this->ans[i][0]=obj.ans[i][0];
			this->ans[i][1]=obj.ans[i][1];
		}
		this->id=obj.id;
		this->num=obj.num;
		this->total=obj.total;
		return *this;
	}
};

int c_cmp(const void *a,const void *b){
	return (*(team*)a>*(team*)b);
}

template<typename T> void qsort_s(int l,int r,T *data,int(*cmp)(const void*,const void*)){
	int i,j;
	T p;
	T buf;

	i=l;j=r;
	p=data[(l+r)/2];

	while(1) {
		while(cmp(&data[i],&p)) i++;
		while(cmp(&p,&data[j])) j--;
		if(i>=j) break;
		buf=data[i];
		data[i]=data[j];
		data[j]=buf;
		i++;
		j--;
	}

	if(l<i-1) qsort_s<T>(l,i-1,data,cmp);
	if(j+1<r) qsort_s<T>(j+1,r,data,cmp);
}

template<typename T> void qsort(T *data,int n,int(*cmp)(const void*,const void*)){
	qsort_s<T>(0,n-1,data,cmp);
}

team teams[50];

int main(){
	int t,r,p;
	int tid,pid,time;
	char message[10];
	while(cin>>t>>p>>r){
		if(t==0 && r==0 && p==0) break;
		for(int i=0;i<t;i++) teams[i].format(i);
		for(int i=0;i<r;i++){
			cin>>tid>>pid>>time>>message;
			teams[tid-1].set(pid-1,time,strcmp(message,"WRONG"));
		}
		for(int i=0;i<t;i++) teams[i].set();
		qsort<team>(teams,t,c_cmp);
		for(int i=0;i<t;i++) cout<<teams[i].id+1<<" "<<teams[i].num<<" "<<teams[i].total<<endl;
	}
	return 0;
}

Measured memory_bytes: 880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5+5;
const int mod = 998244353;

int n,id[257];
int a[3][N],type[N],cnt[4];
char s[N];

int main(){
	id['R']=0;id['G']=1;id['B']=2;
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n*3;++i){
		int x=id[s[i]];
		a[x][++a[x][0]]=i;
	}
	for(int i=1;i<=n;++i){
		int x=0,y=1,z=2; 
		if(a[y][i]>a[x][i])swap(x,y);
		if(a[z][i]>a[x][i])swap(x,z);
		if(a[z][i]>a[y][i])swap(y,z);
		type[a[z][i]]=0;
		type[a[y][i]]=1;
		type[a[x][i]]=2;
	}
	ll ans=1;
	cnt[0]=n;
	for(int i=1;i<=3*n;++i){
		int x=type[i];
		ans=ans*cnt[x]%mod;
		cnt[x]--;
		cnt[x+1]++;
	}
	printf("%lld\n",ans);
} 

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<61LL;
static const int MAX_N = 10000;
typedef pair<int,int> PII;

PII P[MAX_N];
int par[MAX_N];
int rank[MAX_N];
int city[MAX_N];
int t[MAX_N];
int temp[MAX_N];
int n,m;
int ans;

class UF{
    public:
        void init(int n){
            rep(i,n){
                par[i]=i;
                rank[i]=0;
            }
        }

        int find(int x){
            if(par[x]==x){
                return x;
            }
            return par[x]=find(par[x]);
        }
        void unite(int x,int y){
            x=find(x);
            y=find(y);
            if(x==y)return;
            if(rank[x]<rank[y])par[x]=y;
            else {
                par[y]=x;
                if(rank[x]==rank[y])rank[x]++;
            }
        }

        bool same(int x,int y){
            return (find(x)==find(y));
        }
};

int main(){
    cin>>n>>m;
    UF uf;
    int V=n;
    uf.init(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        if(!t[a])V--;
        if(!t[b])V--;
        t[a]=t[b]=1;
        uf.unite(a,b);
    }
    int val=0;
    rep(i,n+1){
        if(t[i])temp[uf.find(i)]=1;
    }
    rep(i,n+1){
        if(temp[i])val++;
    }
    ans=abs(val-V);
    cout<<ans<<endl;
}

Measured memory_bytes: 1268
#include <stdio.h>
int main(){
    int a, b, sum, dif, mult;
    int maior;
    
    scanf("%d %d", &a, &b);
    
    sum=a+b;
    dif=a-b;
    mult=a*b;
    maior=sum;
    
    if(dif>maior)
        maior=dif;
        
    if(mult>maior)
        maior=mult;
    
    printf("%d\n", maior);
    
    return 0;
}

Measured memory_bytes: 128
//11:01
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

int cnt[1001];

int N;
int main(){
        scanf("%d",&N);
        memset(cnt,0,sizeof(cnt));

        for(int i = 1; i <= N; i++){
                int tmpi = i;
                for(int j = 2; j <= N; j++){
                        while(tmpi % j == 0 && tmpi >= 2){
                                tmpi /= j;
                                cnt[j]++;
                        }
                }
                //printf("after=%d,",i);
                //for(int j = 1; j <= N; j++) printf("%d,",cnt[j]);
                //puts("");

        }

        ll ans=1;
        for(int j = 1; j <= N; j++){
                ans *= (cnt[j]+1);
                ans %= (1000000000+7);
        }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int h,w;
  cin >> h >> w;
  if(h == 1 || w == 1){
    printf("1");
    exit(0);
  }
  printf("%lld",(h+w) % 2 ? ((h*w)/2) : (((h*w)+1)/2));
}


Measured memory_bytes: 256
A, B, C, D, E, F = gets.chomp.split(" ").map(&:to_i)

dp = Array.new(F/100+1)
dp[0] = 0
bef = [0]
until bef.empty? do
  nxt = []
  bef.each{|b|
    nxt << b+A if (b+A) * 100 <= F && dp[b+A].nil?
    nxt << b+B if (b+B) * 100 <= F && dp[b+B].nil?
  }
  bef = nxt.uniq
  bef.each{|b| dp[b] = b}
end
w = dp.compact
tmp = F/100*E
dp = Array.new(F+1)
dp[0] = 0
bef = [0]
until bef.empty? do
  nxt = []
  bef.each{|b|
    nxt << b+C if (b+C) <= tmp && dp[b+C].nil?
    nxt << b+D if (b+D) <= tmp && dp[b+D].nil?
  }
  bef = nxt.uniq
  bef.each{|b| dp[b] = b}
end
s = dp.compact
ans = [-1, 0, 0]
w.each{|wa|
  idx = s.bsearch_index{|x| x > [wa * E, F-wa*100].min}
  next if idx == 0
  idx = s.size if idx.nil?
  next if (wa * 100 + s[idx-1]) > F
  wk = s[idx-1].to_f / (wa * 100 + s[idx-1])
  ans = [wk, wa*100 + s[idx-1], s[idx-1]] if ans[0] < wk
}

ans.shift
puts ans.join(" ")


Measured memory_bytes: 1916
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	
      	String n = (a + b + c >= 22) ? "bust" : "win";
      	
      	System.out.println(n); 
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
long long count(long long x){
  long long ans = x / 15 * 8;
  for (int i = 1; i < x % 15; i++){
    if (i % 3 != 0 && i % 5 != 0){
      ans++;
    }
  }
  return ans;
}
long long digitcount(long long x){
  long long ans = 0;
  long long X = 1;
  int d = 1;
  while (X * 10 <= x){
    ans += (count(X * 10) - count(X)) * d;
    X *= 10;
    d++;
  }
  ans += (count(x) - count(X)) * d;
  return ans;
}
long long length(long long x){
  return digitcount(x) + (x - 1) / 3 * 4 + (x - 1) / 5 * 4;
}
char fizzbuzz(long long x){
  long long tv = 0;
  long long fv = 100000000000000000;
  while (fv - tv > 1){
    long long mid = (tv + fv) / 2;
    if (length(mid) < x){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  x -= length(tv) + 1;
  if (tv % 15 == 0){
    return "FizzBuzz"[x];
  } else if (tv % 5 == 0){
    return "Buzz"[x];
  } else if (tv % 3 == 0){
    return "Fizz"[x];
  } else {
    return to_string(tv)[x];
  }
}
int main(){
  long long s;
  cin >> s;
  for (int i = 0; i < 20; i++){
    cout << (char)fizzbuzz(s + i);
  }
  cout << endl;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
#include<cctype>
#define For(i,a,b) for(i=(a),i##end=(b);i<=i##end;++i)
#define Forward(i,a,b) for(i=(a),i##end=(b);i>=i##end;--i)
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
using namespace std;
template<typename T>inline void read(T &x){
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&k^'-')k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
const int MAXN=2011;
static int n,k;
static long long sum[MAXN][MAXN][2];
inline void get(char &x){for(x=getchar();!isupper(x);x=getchar());}
inline void init()
{
    read(n);read(k);
    static int x,y;
    static char c;
    Rep(i,1,n)
    {
        read(x),read(y),get(c);
        if(c=='B')++sum[x%(2*k)][y%(2*k)][1];
        else ++sum[x%(2*k)][y%(2*k)][0];
    }
    Rep(i,0,2*k-1)Rep(j,0,2*k-1)Rep(l,0,1)
    {
        if(i>0)
        {
            sum[i][j][l]+=sum[i-1][j][l];
            if(j>0)sum[i][j][l]-=sum[i-1][j-1][l];
        }
        if(j>0)sum[i][j][l]+=sum[i][j-1][l];
    }
}
static long long ans;
#define D(a,b) sum[a][b]
#define Chkmax(a,b) a=a>b?a:b
inline void solve()
{
    static long long b;
    Rep(i,0,k-1)Rep(j,0,k-1)
    {
        b=2ll*D(i+k-1,j+k-1)[1]+D(2*k-1,2*k-1)[1]-D(i+k-1,2*k-1)[1]
            -D(2*k-1,j+k-1)[1];
        if(i>0)
        {
            b+=1ll*D(i-1,2*k-1)[1]-2*D(i-1,j+k-1)[1];
            if(j>0)b+=2ll*D(i-1,j-1)[1];
        }
        if(j>0)b+=1ll*D(2*k-1,j-1)[1]-2*D(i+k-1,j-1)[1];
        
        b+=1ll*D(i+k-1,2*k-1)[0]+D(2*k-1,j+k-1)[0]-2*D(i+k-1,j+k-1)[0];
        if(i>0)
        {
            b+=2ll*D(i-1,j+k-1)[0]-D(i-1,2*k-1)[0];
            if(j>0)b-=2ll*D(i-1,j-1)[0];
        }
        if(j>0)b+=2ll*D(i+k-1,j-1)[0]-D(2*k-1,j-1)[0];
        Chkmax(ans,b);
        Chkmax(ans,n-b);
    }
    printf("%lld\n",ans);
}
int main(void){
    init();
    solve();
	return 0;
}


Measured memory_bytes: 63104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    string S;
    cin >> S;
    int ans = 0;
    rep(i, S.size())
    {
        if (S[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

n = int(input())
A = [int(input()) for i in range(n)]

cnt = 0
G = [1]
for i in range(99):
    if n < 1 + 3*G[-1]:
        break
    G.append(1 + 3*G[-1])
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt)
print(*A, sep='\n')



Measured memory_bytes: 53280
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	char a[105];
	scanf("%s",a);
	for(int i=0;i<strlen(a);i++)
	if(a[i]=='C')
	for(int j=i+1;j<strlen(a);j++)
	if(a[j]=='F')
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H.at(i);
    }
    vector<int> A(M),B(M);
    vector<int> judge(N);
    for(int i=0; i<M; i++){
        cin >> A.at(i) >> B.at(i);
        if(H.at(A.at(i)-1)>=H.at(B.at(i)-1)){
            judge.at(B.at(i)-1)=1;
        }
        if(H.at(B.at(i)-1)>=H.at(A.at(i)-1)){
            judge.at(A.at(i)-1)=1;
        }
    }
    int count=0;
    for(int i=0; i<N; i++){
        if(judge.at(i)==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 4756
A,B,C = map(int,input().split())
K = int(input())
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if C*(2**k) > B*(2**j) and B*(2**j) > A*(2**i) and i+j+k<=K:
                print("Yes")
                exit(0)
print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n ;
	cout << n /3 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll n, k, a[MAXN], f[MAXN];
bool check(ll x)
{
	ll sum = 0;
	for (ll i = 1; i <= n; ++i)
	{
		ll tmp = a[i] - x / f[i];
		if (tmp > 0)
			sum += tmp;
	}
	return sum <= k;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> k)
	{
		for (ll i = 1; i <= n; ++i) cin >> a[i];
		for (ll i = 1; i <= n; ++i) cin >> f[i];
		sort(a + 1, a + 1 + n);
		sort(f + 1, f + 1 + n, greater<ll>());
		ll l = 0, r = ll(1e18), m, mi = ll(1e18);
		while (l <= r)
		{
			m = l + (r - l) / 2;
			if (check(m))
				r = m - 1, mi = min(mi, m);
			else
				l = m + 1;
		}
		cout << mi << endl;
	}
}
/*
3 5
4 2 1
2 3 1

3 8
4 2 1
2 3 1

11 14
3 1 4 1 5 9 2 6 5 3 5
8 9 7 9 3 2 3 8 4 6 2
*/

Measured memory_bytes: 3328
import sys
n, y = map(int, input().split())

for i in range(0, n+1):
    for j in range(0, n+1-i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n-i-j)
            sys.exit()


print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#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 D;
  cin >> D;
  
  vector<int> c(27), tmp(27);
  vector<vector<int>> s(D+1 , vector<int>(27));
  for (int i = 1; i <= 26; i++)  cin >> c.at(i);
  for (int i = 1; i <= D; i++)  for(int j = 1; j <= 26; j++)  {
    cin >> s.at(i).at(j);
  }
  
  vector<int> last(27);//最終開催日
  for (int i = 1; i <= 26; i++) last.at(i) = 0;
  
  vector<int> t(D+1);//開催テストタイプ
  for (int i = 1; i <= D; i++)  cin >> t.at(i);
  
  
  vector<int> dd(100*D+1), qq(100*D+1);
  for (int i = 1; i <= 100*D; i++) {
    qq.at(i) = rand()%26;
    dd.at(i) = rand()%D;
  }
  
  //初期計算
  for (int i = 1; i <= D; i++) {
    int typ = 0;
    int smax = 0,stf;
    for (int j = 1; j <= 26; j++) {
      stf = s.at(i).at(j) + (i-last.at(j)) * c.at(j);
      if (stf > smax) {
        smax = stf;
        typ = j;
      }
    }
    
    last.at(typ) = i;
    
    t.at(i) = typ;   
  }
  
  vector<int> stf(D+1);
  int sf = 0;
  for (int i = 1; i <= D; i++) {
    sf += s.at(i).at(t.at(i));
    last.at(t.at(i)) = i;
    
    for (int j = 1; j <= 26; j++) {
      sf -=c.at(j)*(i-last.at(j));
    }
    stf.at(i) = sf;
  }
  
  
  vector<int> dmaxtyp(D+1);
  for (int i = 1; i <= D; i++) {
    int mmax = 0, tmp = 0;
    for (int j = 1; j <= 26; j++) {
      if (mmax < s.at(i).at(j)) {
        tmp = j;
        mmax = s.at(i).at(j);
      }
    }
    dmaxtyp.at(i) = tmp;
    
  }
  
  //局所探索?
  for (int k = 1; k <= 100*D; k++) {
    int oldsf = sf;
    int oldtyp = t.at(dd.at(k));
    sf = 0;
    t.at(dd.at(k)) = qq.at(k);
    for (int i = 1; i <= 26; i++) last.at(i) = 0;
    
    for (int i = 1; i <= D; i++) {
      sf += s.at(i).at(t.at(i));
      last.at(t.at(i)) = i;

      for (int j = 1; j <= 26; j++) {
        sf -=c.at(j)*(i-last.at(j));
      }

    }
    if (oldsf > sf) {
      t.at(dd.at(k)) = oldtyp;
      sf = oldsf;
    }
  }
  //cout << sf << endl;
  for (int i = 1; i <= D; i++) cout << t.at(i) << endl;
}

Measured memory_bytes: 3692