akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define sc1(name) scanf("%d",&name)
#define sc2(name1,name2) scanf("%d%d",&name1,&name2)
#define sc3(name1,name2,name3) scanf("%d%d%d",&name1,&name2,&name3)
#define scl1(name) scanf("%lld",&name)
#define scl2(name1,name2) scanf("%lld%lld",&name1,&name2)
#define scl3(name1,name2,name3) scanf("%lld%lld%lld",&name1,&name2,&name3)
#define Sort(name) sort(name.begin(),name.end())
#define SSort(name) sort(name.rbegin(),name.rend())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define Forr(name,start,finish) for(int name=start;name>=finish;name--)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int row[]={0,1,0,-1,-1,-1,1,1};
int col[]={1,0,-1,0,1,-1,-1,1};

const ll N=2e5+10;
const ll M=1e18+7;
const ll H=1e9+7;
const ll base=131;

ll logx(ll a,ll bs){return log(a)/log(bs);}
ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m
ll GCD(ll a,ll b){if(!a)return b;return GCD(b%a,a);}



int main()
{
    fast_in_out;


    int n;
    cin>>n;

    if(n>=30)
        cout<<"Yes"<<endl;

    else
        cout<<"No"<<endl;



    return 0;
}



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

typedef long long int ll;

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

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if (a-b > 1000000000000000000) {
    cout << "Unfair" << endl;
  }
  else if (k%2 == 1) {
    cout << b - a << endl;
  }
  else {
    cout << a - b << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; ++i) cin >> d[i];
	bool flag[10000] = {};
	for (int i = 0; i < n; ++i) {
		int tmp = 0;
		for (int j = i; j < i + 4 && j < n; ++j) {
			tmp = tmp * 10 + d[j];
			flag[tmp] = true;
		}
	}
	for (int i = 0; i < 2000; ++i) {
		if (!flag[i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3120
/* Author rumoisen */
/* created 2018/11/08 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll) 1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int n,ans=200;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int cnt=0;
        while(a%2==0){
            a/=2;
            cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

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

import sys


def get_parent(index):
    return index // 2


def get_left(index):
    return 2 * index


def get_right(index):
    return get_left(index) + 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    array.insert(0, None)
    for i in range(1, array_length + 1):
        parent, left, right = get_parent(i), get_left(i), get_right(i)
        print('node ' + str(i) + ':', end='')
        print(' key = ' + str(array[i]) + ',', end='')
        if parent:
            print(' parent key = ' + str(array[parent]) + ',', end='')
        if left <= array_length:
            print(' left key = ' + str(array[left]) + ',', end='')
        if right <= array_length:
            print(' right key = ' + str(array[right]) + ',', end='')
        print(' ')

Measured memory_bytes: 7752
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int A, B, C;
void input() { cin >> A >> B >> C; }
void solve() {
  cout << ((C >= A && C <= B) ? "Yes" : "No") << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
	int i,j,k,n,an[6];
	char c;
	string s,as[6];
	map<string,int> mp;
	map<string,int>::iterator it;
	while(cin >> n && n>0) {
	  mp.clear();	
	  for (i=0;i<n;i++) {	
	   cin >> s ;
	     while(true) { 
		   	it=mp.find(s);
			if (it==mp.end()) mp.insert(make_pair(s,1)); else (*it).second++;
	  	    if (cin.peek()==10) break; else cin >> s;
		 }
	  }
	  cin >> c;
	  for (i=0;i<6;i++) { an[i]=0; as[i]="aaaaaaaaaaaaa";}
	  for (it=mp.begin();it!=mp.end();it++) {
		  if (((*it).first)[0]==c) {
			for (j=0;j<5;j++) {
				if ((*it).second>an[j] || ((*it).first<as[j] && (*it).second==an[j])) { 
				for (k=4;k>j;k--) {an[k]=an[k-1]; as[k]=as[k-1];}
				as[j]=(*it).first; an[j]=(*it).second; break;
			    }
		  }  
		}
	  }
	  if (an[0]==0) cout << "NA"; else 
	  for (i=0;i<5;i++) { cout << as[i]; if (an[i+1]==0) break; else cout << ' ';}
	  cout << endl;	
   	  }
	return 0;
} 

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

struct Node{
    long long num;
    bool h3 = false;
    bool h5 = false;
    bool h7 = false;
};

int main()
{
    long long n;
    cin >> n;
    long long res = 0;

    queue<Node> q;
    q.push(Node{3, true, false, false});
    q.push(Node{5, false, true, false});
    q.push(Node{7, false, false, true});

    while(!q.empty()){
        Node cur = q.front();
        q.pop();

        if(cur.h3 && cur.h5 && cur.h7){
            res++;
        }

        if(cur.num * 10 + 3 <= n){
            q.push(Node{cur.num * 10 + 3, true, cur.h5, cur.h7});
        }
        if(cur.num * 10 + 5 <= n){
            q.push(Node{cur.num * 10 + 5, cur.h3, true, cur.h7});
        }
        if(cur.num * 10 + 7 <= n){
            q.push(Node{cur.num * 10 + 7, cur.h3, cur.h5, true});
        }
    }

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


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[10000005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(P, 0, sizeof(P));
    REP(i, N) {
        ll n = i + 1;
        for (ll j = n; j <= N; j += n) {
            P[j]++;
        }
    }

    ll ans = 0;
    REP(i, N) {
        ans += (i + 1) * P[i + 1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81760
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;

struct Road{
	int e,next;
}r[410000];int R[210000],num;
int n,f[210000];

void addr(int x,int y){
	r[++num]=(Road){y,R[x]};
	R[x]=num;
}

void dp(int u,int fa){
	for(int i=R[u];i;i=r[i].next){
		int v=r[i].e;
		if(v==fa)continue;
		dp(v,u);
		if(f[u]==0&&f[v]==0)f[v]=f[u]=1;
	}
}

int main(){
	int x,y;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		addr(x,y);addr(y,x);
	}dp(1,0);
	for(int i=1;i<=n;i++){
		if(f[i]==0){
			printf("First\n");
			return 0;
		}
	}printf("Second\n");
	return 0;
}

Measured memory_bytes: 3456
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

const MOD: i64 = 1e9 as i64 + 7;

fn mat_mul(a: &Vec<Vec<i64>>, b: &Vec<Vec<i64>>) -> Vec<Vec<i64>> {
  let n = a.len();
  let mut x = vec![vec![0i64; n]; n];
  for i in 0 .. n {
    for j in 0 .. n {
      for k in 0 .. n {
        x[i][j] += a[i][k] * b[k][j];
        x[i][j] %= MOD;
      }
    }
  }
  x
}

fn mat_pow(a: &Vec<Vec<i64>>, e: i64) -> Vec<Vec<i64>> {
  if e == 1 {
    a.clone()
  } else if e % 2 == 0 {
    let x = mat_pow(a, e / 2);
    mat_mul(&x, &x)
  } else {
    let x = mat_pow(a, e - 1);
    mat_mul(&x, &a)
  }
}

fn main() {
  input! {
    n: usize,
    k: i64,
    a: [[i64; n]; n]
  }
  let x = mat_pow(&a, k);
  let sum: i64 = x.iter().map::<i64, _>(|v| v.iter().sum()).sum();
  println!("{}", sum % MOD);
}


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

int main()
{
    int N;
    cin >> N;
    if(N == 25)
    {
        cout<<"Christmas"<<endl;
    }
    if(N == 24)
    {
        cout<<"Christmas Eve"<<endl;
    }
     if(N == 23)
    {
        cout<<"Christmas Eve Eve"<<endl;
    }
     if(N == 22)
    {
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd


n = int(input())
As = list(map(int, input().split()))

ls = [0 for i in range(n + 1)]
rs = [0 for i in range(n + 1)]

for i in range(1, n + 1):
    ls[i] = gcd(As[i - 1], ls[i - 1])
for i in range(n - 1, -1, -1):
    rs[i] = gcd(As[i], rs[i + 1])
# print(ls)
# print(rs)
ret = - float('inf')
for i in range(n):
    ret = max(ret, gcd(ls[i], rs[i + 1]))
print(ret)


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;
vector<ll> A;

int main(){
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];

    ll nxt = 1;
    ll ans = 0;
    rep(i,N){
        if(A[i] == nxt){
            nxt++;
        }else{
            ll cnt = (A[i]-1)/nxt;
            ans += cnt;
            A[i] = 1;
            if(A[i]==nxt) nxt++;
        }
    }

    cout << ans << endl;
    //cout << A << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e3+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
string s;

ll dp[MAXN][MAXN];
ll pre[MAXN][MAXN];

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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>s;
    dp[0][1] = 1; 
    for(int i = 1; i <= n; i++){
        pre[0][i] = 1;
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= i + 1; j++){
            if(s[i - 1] == '<'){
                dp[i][j] = pre[i - 1][j - 1];
                pre[i][j] = (pre[i][j - 1] + dp[i][j])%mod;
            }else{
                dp[i][j] = (pre[i - 1][i] - pre[i - 1][j - 1] + mod) %mod;
                pre[i][j] = (pre[i][j - 1] + dp[i][j])%mod;
            }
        }
    }
    cout<<pre[n - 1][n]<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 139648
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int h,w;
string a[51];
bool v[2][51][51];
int d[]={1,0,-1,0,1};

void dfs(int i,int j,int t){
    rep(k,4){
        int ni=i+d[k],nj=j+d[k+1];
        if(ni<0||ni>=h||nj<0||nj>=w||a[ni][nj]!='.'||v[t][ni][nj])continue;
        v[t][ni][nj]=true;
        dfs(ni,nj,t);
    }
}

void run(){
    cin>>w>>h;
    if(!w)return;
    MEMSET(v);
    rep(i,h)cin>>a[i];
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='B')dfs(i,j,0);
            else if(a[i][j]=='W')dfs(i,j,1);
        }
    }
    int ansb=0,answ=0;
    rep(i,h){
        rep(j,w){
            if(v[0][i][j]==v[1][i][j])continue;
            if(v[0][i][j])ansb++;
            if(v[1][i][j])answ++;
        }
    }
    cout<<ansb<<" "<<answ<<endl;
    run();
}


Measured memory_bytes: 3120
alp = "abcdefghijklmnopqrstyvwxyz"
alp = (list(alp))
w = list(input())
flag = 0
for i in range(26):
    if w.count(alp[i]) % 2 == 0:
        continue
    else:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var result = hoge(N).ToLower();
            Console.WriteLine(result);
        }

        static string hoge(long self)
        {
            long n = self % 26;
            n = (n == 0) ? 26 : n;

            string s = ((char)(n + 64)).ToString();
            if (self == n) return s;
            return hoge((self - n) / 26) + s;
        }
    }
}


Measured memory_bytes: 27828
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>



int main(void){
    long L,R,d;
    std::cin >> L >> R >> d;
    std::cout << R/d-(L-1)/d << std::endl;
    return 0;
}

Measured memory_bytes: 3548
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();
    vector<pair<ll,ll>>a(n);
    for(ll i=0;i<n;++i)a[i]=make_pair(in(),i+1);
    sort(a.begin(),a.end());
    for(ll i=0;i<n;++i){
        if(i!=0)cout<<' ';
        cout<<a[i].second;
    }
    cout<<endl;
}


Measured memory_bytes: 2432
$mod = 1_000_000_007
io = STDIN
n=io.gets.to_i
s=[]
s<<io.gets.chomp.split(//)
s<<io.gets.chomp.split(//)
if s[0][0]==s[1][0]
  stat=:tate
  i=1
  ans=3
else
  stat=:yoko
  i=2
  ans=6
end
while i<n
  if s[0][i]==s[1][i]
    nstat=:tate
    i+=1
  else
    nstat=:yoko
    i+=2
  end
  case [stat,nstat]
  when [:tate,:tate]
    ans*=2
    ans%=$mod
  when [:yoko,:yoko]
    ans*=3
    ans%=$mod
  when [:tate,:yoko]
    ans*=2
    ans%=$mod
  when [:yoko,:tate]
  end
  stat=nstat
end
puts ans


Measured memory_bytes: 1788
n = list(map(int, input().split()))

if n[2] + n[4] > n[0] or n[2] - n[4] < 0:
    print("No")
elif n[3] + n[4] > n[1] or n[3] - n[4] < 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5596
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n; scanf(" %d", &n), n;) {
		int sums[3] = {0};
		int ok[3] = {0};
		rep(i,n) {
			int hh, mm, cc;
			scanf(" %d:%d %d", &hh, &mm, &cc);
			if(cc < mm) {
				cc = cc + 60 - mm;
			} else {
				cc = cc - mm;
			}
			
			if(11 <= hh && hh < 15) {
				sums[0]++;
				if(cc <= 8) ok[0]++;
			} else if(18 <= hh && hh < 21) {
				sums[1]++;
				if(cc <= 8) ok[1]++;
			} else if(hh < 2 || 21 <= hh) {
				sums[2]++;
				if(cc <= 8) ok[2]++;
			}
		}
		cout << "lunch ";
		if(sums[0]) cout << ok[0] * 100 / sums[0] << endl;
		else cout << "no guest" << endl;
		cout << "dinner ";
		if(sums[1]) cout << ok[1] * 100 / sums[1] << endl;
		else cout << "no guest" << endl;
		cout << "midnight ";
		if(sums[2]) cout << ok[2] * 100 / sums[2] << endl;
		else cout << "no guest" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int akkari___n( int n, int m ){
  int counter = 0;
  while( !( n % m ) ){
      counter++;
      n /= m;
    }
  return counter;
}

int min( int x, int y ){
  return ( x < y ) ? x : y;
}

int main( void ){
  int n, i, c2, c5;
  while( 1 ){
    scanf( "%d", &n );
    if( !n ){ return 0; }
    c2 = 0;
    c5 = 0;
    for( i = n; i >= 2; i-- ){
      c2 += akkari___n( i, 2 );
      c5 += akkari___n( i, 5 );
    }
    printf( "%d\n", min( c2, c5 ) );
  }
}

Measured memory_bytes: 0
N = int(input())
A = [int(input()) for i in range(N)]

A_sorted = sorted(A)
coefficient_yama = [1 for i in range(N)]#上から
coefficient_tani = [-1 for i in range(N)]#下から

for i in range(1,N):
    if i  % 2 == 0:#even
        if N-i >= 2:
            coefficient_yama[i] = +2
            coefficient_tani[i] = -2
        else:
            coefficient_yama[i] = +1
            coefficient_tani[i] = -1
    else:#odd
        if N-i >= 2:
            coefficient_yama[i] = -2
            coefficient_tani[i] = +2
        else:
            coefficient_yama[i] = -1
            coefficient_tani[i] = +1

import numpy as np

ans_tani = np.sum(np.array(A_sorted) * np.array(sorted(coefficient_tani)))
ans_yama = np.sum(np.array(A_sorted) * np.array(sorted(coefficient_yama)))
#print(coefficient_tani)
#print(coefficient_yama)

if ans_tani >= ans_yama:
    print(ans_tani)
else:
    print(ans_yama)


Measured memory_bytes: 21252
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
 //     freopen("q.gir","r",stdin);
 //     freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      vector<int>A(n+1),B(n+1),C(n+1);
      vector<vector<int> >dp(n+1,vector<int>(3,0));
      for(int i=1;i<=n;i++)cin>>A[i]>>B[i]>>C[i];
      for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++){
                  for(int k=0;k<3;k++){
                        if(k==j)continue;
                        if(k==0){
                              dp[i][k]=max(dp[i][k],dp[i-1][j]+A[i]);
                        }
                        if(k==1){
                              dp[i][k]=max(dp[i][k],dp[i-1][j]+B[i]);
                        }
                        if(k==2){
                              dp[i][k]=max(dp[i][k],dp[i-1][j]+C[i]);
                        }
                  }
            }
      }
      cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	vector<int> 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};

	int k;
	cin >> k;

	cout << vec[k - 1];

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#define int long long
using namespace std;
int n,m;
string s,t;
map<int,char> M;

int gcd(int x,int y)
{
	if (x%y==0) return y;
	else return gcd(y,x%y);
}
int lcm(int x,int y)
{
	return x/gcd(x,y)*y;
}

main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n >> m >> s >> t;
	int step1=lcm(n,m)/n,step2=lcm(n,m)/m,vt1=1,vt2=1;
	
	for (int i=0; i<s.size(); i++)
	{
		M[vt1]=s[i];
		vt1+=step1;
	}
	
	for (int j=0; j<t.size(); j++)
	{
		if (M.count(vt2))
		{
			if (M[vt2]!=t[j])
			{
				cout << -1;
				return 0;
			}
		}
		vt2+=step2;
	}
	
	cout << lcm(n,m);
	
	return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>
int main(void){
int a[3][10][4] = {0};
int i, j, k;
int n, p;
int b, f, r, v; /* b棟f階r番目の部屋にv人 [階][部屋][棟] */scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d%d%d%d", &b, &f, &r, &v);
a[f-1][r-1][b-1] += v;}
for(k=0; k<4; k++){
for(i=0; i<3; i++){
for(j=0; j<10; j++){
if(a[i][j][k] == 0){
printf(" 0");
}
else{printf(" %d", a[i][j][k]);
}
}
printf("\n");
}
if(k != 3){
printf("####################\n");
}
}
return 0;
}
			
		
			

								


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

int main() {
    int N;
    cin >> N;
    
    int arr[3][N];
    int dp[3][N];
    
    for(int i=0;i<N;i++){
        cin >> arr[0][i] >> arr[1][i] >>arr[2][i];
    }
    
    dp[0][0] = arr[0][0];
    dp[1][0] = arr[1][0];
    dp[2][0] = arr[2][0];

	for(int i=1;i<N;i++){
	    dp[0][i] = arr[0][i] + max(dp[1][i-1], dp[2][i-1]);
	    dp[1][i] = arr[1][i] + max(dp[0][i-1], dp[2][i-1]);
	    dp[2][i] = arr[2][i] + max(dp[1][i-1], dp[0][i-1]);
	}
	
	cout << max(max(dp[0][N-1], dp[1][N-1]),dp[2][N-1]) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=1e6+5;

ll m=1e9+7,f[N],inv[N];

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

ll ncr(ll n,ll r)
{
	if(r>n||r<0)return 0;
	ll ans=(f[n]*inv[r])%m;
	return (ans*inv[n-r])%m;
}

int main()
{ios_base::sync_with_stdio(false);
f[0]=1;
rep(i,1,N-1)f[i]=(f[i-1]*1ll*i)%m;
inv[N-1]=p(f[N-1],m-2);
ren(i,N-2,0)inv[i]=(inv[i+1]*1ll*(i+1))%m;

ll n,k,ans=0;
cin>>n>>k;
rep(i,0,n)
{
	if(i<=k)
	{
		ans=(ans+(ncr(n,i)*ncr(n-1,n-i-1))%m)%m;
	}

}
ol(ans);
return 0;
}



Measured memory_bytes: 15872
s = input()
a = int(s[:2])
b = int(s[2:])
af = 1 <= a and a <= 12
bf = 1 <= b and b <= 12
if af and not bf:
    print('MMYY')
elif not af and bf:
    print('YYMM')
elif af and bf:
    print('AMBIGUOUS')
else:
    print('NA')


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int N;
  LL X;
  cin >> N >> X;
  vector<LL> v(N);
  REP(i, N) {
    cin >> v[i];
  }
  LL ret = accumulate(v.begin(), v.end(), 0LL);
  for(int i=1; i<N; ++i) {
    vector<LL> nv(N);
    REP(j, N) {
      nv[j] = min(v[j], v[(j-1+N)%N]);
    }
    v = nv;
    ret = min(ret, accumulate(v.begin(), v.end(), 0LL) + X * i);
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
! 2019.9.28 
!
      program answer
      implicit none
      integer :: N_i, K_i
      integer,allocatable,dimension(:) :: hi_i
      integer :: i
      integer :: ans_i
!
      ans_i = 0
      read(*,*) N_i,K_i
      allocate(hi_i(N_i))
      read(*,*) (hi_i(i),i=1,N_i)
!
      do i=1,N_i
        if(hi_i(i) .ge. K_i) ans_i = ans_i + 1
      end do
      write(*,*) ans_i
      end program answer

Measured memory_bytes: 1024
#include<iostream>
#include<map>
using namespace std;
int t[100005];
int main(){
	int n;
	int i,j,k;
	int a,b;
	int s=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		if(a>n)s++;
		else t[a]++;
	}
	for(i=0;i<=n;i++){
		if(t[i]>=i)s+=t[i]-i;
		else s+=t[i];
	}
	cout<<s<<endl;
	return 0;
}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
 
struct segtree{
    static const int SEG=1<<19;
    vint ma,put;
    segtree():ma(SEG*2),put(SEG*2){}
    inline void push(int k){
        ma[k]+=put[k];
        if(k<SEG-1){
            put[k*2+1]+=put[k];
            put[k*2+2]+=put[k];
        }
        put[k]=0;
    }
    void add(int a,int b,int x=0,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]+=x;
            push(k);
            return;
        }
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
        ma[k]=max(ma[k*2+1],ma[k*2+2]);
    }
    int get(int a,int b,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return LLONG_MIN;
        if(a<=l&&r<=b)return ma[k];
        return max(get(a,b,k*2+1,l,(l+r)/2),get(a,b,k*2+2,(l+r)/2,r));
    }
};
 
int N;
int A[555555];
segtree segA,segB;
 
signed main(){
    scanf("%lld",&N);
    rep(i,N)scanf("%lld",&A[i]);
 
    rep(i,N/2){
        int d=A[i]-A[N-1-i];
        segA.add(i,i+1,d);
        segB.add(i,i+1,-d);
    }
 
    int Q;scanf("%lld",&Q);
    while(Q--){
        int l,r,x;
        scanf("%lld%lld%lld",&l,&r,&x);
        l--;
        if(l<=N/2-1&&N/2<r){
            int llen=N/2-l,rlen=r-N/2;
            if(llen<rlen){
                l=N/2+llen;
            }
            else if(llen>rlen){
                r=N/2-rlen;
            }
            else{
                l=r=0;
            }
        }
        if(N/2<=l){
            int ll=N-r;
            int rr=N-l;
            l=ll;r=rr;x*=-1;
        }
        segA.add(l,r,x);
        segB.add(l,r,-x);
 
        if(segA.get(0,N/2)==0&&segB.get(0,N/2)==0)puts("1");
        else puts("0");
 
        //rep(i,N/2)cout<<segA.get(i,i+1)<<" ";cout<<endl;
        //rep(i,N/2)cout<<segB.get(i,i+1)<<" ";cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 39500
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int x[5];
    for(int i=0;i<5;i++)cin>>x[i];
    for(int i=0;i<5;i++){
        if(x[i]==0){
            cout<<i+1<<endl;
        }
    }
    //-------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


















































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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w;
  cin >> h >> w;
  string tmp;
  REP(i,w+2)cout << '#';
  cout << "\n";
  REP(i,h){
    cout << '#';
    cin >> tmp;
    cout << tmp;
    cout << "#\n";
  }
  REP(i,w+2)cout << '#';
  cout << "\n";
  return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <stdio.h>


int main(int argc, char** argv) {

int a,b,n1,n2;
int i,j;
int arr[2001]={1};

scanf("%d",&n1);
for(i=0;i<n1;i++){
  scanf("%d", &a);
  for(j=2000-a; j>=0; j--){
  if(arr[j])arr[j+a]=1;
  }
}

scanf("%d",&n2);
for(j=0;j<n2;j++){
  scanf("%d", &b);
  if(arr[b]) printf("yes\n");
  else printf("no\n");
  }
  return 0;
  
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int X, Y;
	int ans = 0;
	cin >> X >> Y;
	if (X == 1) {
		ans += 300000;
	}
	else if (X == 2) {
		ans += 200000;
	}
	else if (X == 3) {
		ans += 100000;
	}
	if (Y == 1) {
		ans += 300000;
	}
	else if (Y == 2) {
		ans += 200000;
	}
	else if (Y == 3) {
		ans += 100000;
	}
	if (X + Y <= 2) {
		ans += 400000;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;

int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	long long int t;
	ll n;
	cin>>n;
	ll a[n];
	for(ll i = 0;i<n;i++) cin>>a[i];
	ll dp[n+1];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for(ll i = 2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i-2] - a[i]));
	}
	cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 5116
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;

void input(vector<int> & V);

int main()
{
    vector<int> V;
    input(V);

    int q, k;
    cin >> q;

    pair<vector<int>::iterator, vector<int>::iterator> pr;
    while (q--)
    {
        cin >> k;
        pr = equal_range(V.begin(), V.end(), k);
        cout << pr.first - V.begin() << " " << pr.second - V.begin() << endl;
    }
}


void input(vector<int> & V)
{
    int n;
    cin >> n;

    int a;
    while (n--)
    {
        cin >> a;
        V.push_back(a);
    }
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------


int main(void) {
  ll ***dp = new ll**[3010];
  for (int i = 0; i < 3010; i++) {
    dp[i] = new ll*[3010];
    for (int j = 0; j < 3010; j++) {
        dp[i][j] = new ll[8];
    }
  }

  int R, C, K;
  cin >> R >> C >> K;
  vll2(item, R+1, C+1, -1);
  rep(i,K){
    int a, b;
    ll v;
    cin >> a >> b >> v;
    item[a][b] = v;
  }

  rep(i,3010){
    rep(j,3010){
      rep(k,8){
        dp[i][j][k] = 0;
      }
    }
  }

  REP(i,1,R+1){
    REP(j,1,C+1){
      ll tmp=0;
      rep(k,4){chmax(tmp, dp[i-1][j][k]);}
      chmax(dp[i][j][0], tmp);
      if(item[i][j]>0) chmax(dp[i][j][1], tmp+item[i][j]);

      rep(k,4){
        chmax(dp[i][j][k], dp[i][j-1][k]);
        if(k!=0 && item[i][j]>0){
          chmax(dp[i][j][k], dp[i][j-1][k-1]+item[i][j]);
        }
      }
    }
  }

  ll ans=0;
  rep(i,4){
    chmax(ans, dp[R][C][i]);
  }
  prt(ans);
}


Measured memory_bytes: 852236
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll N,M;
ll A[100010], B[100010];
vector<ll> tree[100010];
ll d[100010];
ll check[100010] = {};
bool is_two = true;
void dfs(ll cur, ll val){
    if(!check[cur]){
        check[cur] = 1;
        d[cur] = val;
    }else{
        if(d[cur] != val){
            is_two = false;
        }
        return;
    }
    for(auto &e: tree[cur]){
        if(val == 0){
            dfs(e, 1);
        }else{
            dfs(e, 0);
        }
    }

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,0,M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        tree[A[i]].push_back(B[i]);
        tree[B[i]].push_back(A[i]);
    }
    memset(d, -1, sizeof(d));
    dfs(0, 0);
    if(!is_two){
        print(N * (N-1) / 2 - M);
    }else{
        ll cnt = 0;
        rep(i,0,N){
            if(d[i] == 1) cnt++;
        }
        print(cnt * (N - cnt) - M);
    }


}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

int main()
{
	string s;
	cin >> s;
	string temp;
	for (int i = 0; i < s.length() / 2; i++)
		temp += "hi";
	if (s == temp)cout << "Yes";
	else
		cout << "No";
		
			
}

Measured memory_bytes: 256
typedef long long llong;

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

int main(void) {
	int n; cin >> n;
	vector<llong> A(n), B(n), C(n);
	for (int i = 0; i < n; i++) scanf("%lld", &A[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &B[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &C[i]);

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	llong res = 0;
	for (int j = 0; j < n; j++) {
		llong key = B[j];
		llong low_pos = (lower_bound(A.begin(), A.end(), key) == A.end() ? A.size() : lower_bound(A.begin(), A.end(), key) - A.begin());
		llong up_pos = (upper_bound(C.begin(), C.end(), key) == C.end() ? C.size() : upper_bound(C.begin(), C.end(), key) - C.begin());
		res += low_pos * (n-up_pos);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2560
class SegmentTree
  def initialize(n)
    @sz=2**(Math.log(n)/Math.log(2)).ceil
    @seg=Array.new(2*@sz-1){0}
    @root=0
    @nil=-1
  end

  attr_accessor :seg

  def max(a, b, i=@root, l=0, r=@sz)
    if b<=l or r<=a
      @nil
    elsif a<=l and r<=b
      @seg[i]
    else
      m=(r+l)/2
      vl=max(a, b, 2*i+1, l, m)
      vr=max(a, b, 2*i+2, m, r)
      [vl, vr].max
    end
  end

  def update(i, data)
    i+=@sz-1
    @seg[i]=data
    while i.nonzero?
      i=(i-1)/2
      @seg[i]=[@seg[2*i+1], @seg[2*i+2]].max
    end
  end

  def answer
    @seg[@root]
  end
end

Hoge=Struct.new(:val, :id)

n=gets.to_i
a=[]
n.times do |i|
  v=gets.to_i
  a<< Hoge.new(v, i)
end

b=a.sort do |el, er|
  el.val!=er.val ? el.val<=>er.val : er.id<=>el.id
end

st=SegmentTree.new(n)
b.each do |e|
  i=e.id
  st.update(i, st.max(0, i+1)+1)
end

puts st.answer

Measured memory_bytes: 19356
import bisect
N, M, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
for i in range(1, N):
    A[i] += A[i-1]
for i in range(1, M):
    B[i] += B[i-1]

A = [0]+A
ans = 0
for i in range(N+1):
    b = K-A[i]
    if b < 0:
        break
    j = bisect.bisect_right(B, b)
    if ans < (i+j):
        ans = i+j

print(ans)


Measured memory_bytes: 122220
class Array
  def tally
    self.inject(Hash.new(0)) { |res, e| res[e] += 1; res }
  end
end

s = gets.chomp.split("")

tally = s.tally
counts = [tally["a"], tally["b"], tally["c"]]
if counts.max - counts.min < 2
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 6908
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

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

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    cnt = [[0] * 10 for _ in range(10)]
    for i in range(1, n + 1):
        head = int(str(i)[0])
        tale = int(str(i)[-1])
        cnt[head][tale] += 1
        
    res = 0
    for i in range(1, n + 1):
        head = int(str(i)[0])
        tale = int(str(i)[-1])
        res += cnt[tale][head]

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	// freopen("inf.txt", "r", stdin); 
	// freopen("out.txt", "w", stdout);
	
	int a,b;
	cin>>a>>b;
	int curr = 1;
	int cnt=0;
	while(curr<b)
	{
		curr += a-1;
		cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
import sys
import copy
def input():
	return sys.stdin.readline().rstrip()
def main():
	N = int(input())
	A = [int(input()) for _ in range(N)]
	B = list(set(A))
	if (len(B) == 1) or (A.count(B[-1]) > 1):
		for i in range(N):
			print(B[-1])
	else :
		for i in range(N):
			if A[i] == B[-1]:
				print(B[-2])
			else:
				print(B[-1])
if __name__ == '__main__':
	main()

Measured memory_bytes: 17676
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        mut l: [usize;n],
    }
    l.sort();
    let mut cnt = 0;
    for i in 0..n-2 {
        for j in i+1..n-1 {
            for k in j+1..n {
                if l[i] < l[j]+l[k] && l[j] < l[k]+l[i] && l[k] < l[i]+l[j] {
                    cnt += 1;
                } else {
                    break;
                }
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2236
import math
inf=0
def segtree(a): #RMQ(Range Minimum Query)
    #bi=高さ　bi2=最下段の個数
    global bi 
    bi=math.ceil(math.log2(len(a)))+1
    global bi2
    bi2=2**(bi-1)
    seg=[inf]*(2*bi2-1)
    for i in range(len(a)):
        seg[bi2+i-1]=a[i]
    for i in range(bi-1):
        for j in range(2**(bi-i-2)):
            b=2**(bi-i-2)-1+j
            seg[b]=math.gcd(seg[2*b+1],seg[2*b+2])
    return seg

def seg_update(loc,val): #locの値をvalueに更新
    loc+=bi2-1
    seg[loc]=val
    while True:
        seg[loc]=math.gcd(val,seg[loc])
        if loc==0:
            break
        loc=(loc-1)//2

def seg_find(l,r,tmp=0): #[l,r)の最小値を求める
    a=bi-math.ceil(math.log2(tmp+2))+1
    nl=2**(a-1)*(tmp-(2**(bi-a))+1)
    nr=nl+2**(a-1)
    if nr<=l or nl>=r:
        return inf
    elif l<=nl and nr<=r:
        return seg[tmp]
    else:
        return math.gcd(seg_find(l,r,tmp*2+1),seg_find(l,r,tmp*2+2))

n=int(input())
seg=segtree(list(map(int,input().split())))
ans=0
for i in range(n):
    ans=max(ans,math.gcd(seg_find(0,i),seg_find(i+1,n)))
print(ans)

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

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

    int s[4];
    
    s[0] = a%10;
    s[1] = (a%100) / 10;
    s[2] = (a%1000) / 100;
    s[3] = a / 1000;
    
    if( (s[0] == s[1] && s[1] == s[2]) || 
        (s[1] == s[2] && s[2] == s[3]) ) cout << "Yes" << endl; 
    else	 cout << "No" << endl; 
  }

Measured memory_bytes: 256