akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef pair<int,int> pii;
const int N = 10000;

void compute(int i,int *buf){
  buf[0]=i/1000%10;
  buf[1]=i/100%10;
  buf[2]=i/10%10;
  buf[3]=i%10;
}

pii hitAndBlow(int n,int q){
  int hit=0,blow=0;
  int buf1[5],buf2[5];
  compute(n,buf1);
  compute(q,buf2);
  rep(i,4){
    rep(j,4){
      if (buf1[i] == buf2[j]){
	if (i == j)hit++;
	else blow++;
      }
    }
  }
  return make_pair(hit,blow);
}

int solve(vector<int> &a,vector<int> all){

  rep(i,all.size()){
    int buf[5];
    bool isok=true;
    int cnt[5][5]={0};
    rep(j,a.size()){
      pii tmp = hitAndBlow(a[j],all[i]);
      cnt[tmp.first][tmp.second]++;
      if (cnt[tmp.first][tmp.second] > 1)isok=false;
    }
    if (isok)return all[i];
  }
  return -1;
}

main(){
  int n;
  vector<int> all(N);
  rep(i,N){
    int buf[4];
    compute(i,buf);
    bool isok=true;
    rep(j,4)REP(k,j+1,4)if (buf[j] == buf[k]){isok=false;}
    all[i]=(isok?i:-1);
  }
  sort(all.begin(),all.end());
  all.erase(remove(all.begin(),all.end(),-1),all.end());
  while(cin>>n && n){
    vector<pii> in(n);
    vector<int> cand,query(n);
    rep(i,n)cin>>query[i]>>in[i].first>>in[i].second;
    rep(i,all.size()){
      bool isok=true;
      int buf[5];
      rep(j,n){
	pii tmp =hitAndBlow(all[i],query[j]);
	if (tmp.first == in[j].first && tmp.second == in[j].second);
	else {
	  isok=false;
	}
      }
      if (isok)cand.push_back(all[i]);
    }
    sort(cand.begin(),cand.end());
    int ans = cand.size() == 1?cand[0]:solve(cand,all);
    if (ans !=-1)printf("%04d\n",ans);
    else puts("????");
  }
  return false;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

int main() {
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  string res;
  REP(i,ty-sy) res.push_back('U');
  REP(i,tx-sx) res.push_back('R');
  REP(i,ty-sy) res.push_back('D');
  REP(i,tx-sx+1) res.push_back('L');
  REP(i,ty-sy+1) res.push_back('U');
  REP(i,tx-sx+1) res.push_back('R');
  res.push_back('D');
  res.push_back('R');
  REP(i,ty-sy+1) res.push_back('D');
  REP(i,tx-sx+1) res.push_back('L');
  res.push_back('U');
  OUT(res);

  return 0;
}

Measured memory_bytes: 256
s = input()

if int(s[:2]) >= 13 or s[:2] == '00':
    if int(s[2:]) >= 13 or s[2:] == '00':
        print('NA')
    elif int(s[2:]) <= 12:
        print('YYMM')
else:
    if int(s[2:]) >= 13 or s[2:] == '00':
        print('MMYY')
    elif int(s[2:]) <= 12:
        print('AMBIGUOUS')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    string s1,s2;
    cin >> s1 >> s2;
    ll ans=1;
    vector<ll>data;//0:縦,1:横
    for(ll i=0;i<n;i++){
        if(s1[i]!=s2[i]){
            data.push_back(1);
            i++;
        }else{
            data.push_back(0);
        }
    }
    if(data[0]==0) ans*=3;
    else ans*=6;
    for(ll i=1;i<data.size();i++){
        if(data[i]==0&&data[i-1]==0){
            ans*=2;
            ans%=MOD;
        }else if(data[i]==1&&data[i-1]==1){
            ans*=3;
            ans%=MOD;
        }else if(data[i]==1&&data[i-1]==0){
            ans*=2;
            ans%=MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstring>

using namespace std;

const int maxn = 2e5 + 7;
char flag[maxn];

int main(){
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	memset(flag, 0, sizeof(flag));
	char tmp;
	int score = 0;
	for(int i = 0; i < n; ++i){
		if(t[i] == 'r') tmp = 'p';
		if(t[i] == 's') tmp = 'r';
		if(t[i] == 'p') tmp = 's';

		if(i - k + 1 > 0){
			if(tmp == flag[i - k]) continue;
			else flag[i] = tmp;
		}
		else{
			flag[i] = tmp;
		}

		if(tmp == 'r') score += r;
		if(tmp == 's') score += s;
		if(tmp == 'p') score += p;
	}
	cout << score << endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 998244353;
//LLONG_MIN

//TLE

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}

ll test(ll a,ll n){
	ll ans=1;
	while(n>0){
		if(n&1)ans=(ans*a) % mod;
		a=(a*a) % mod;
		n>>=1;
	}
	return ans;
}


int main(void){
	ll N,A,B,K,ans=0;
	scanf("%lld%lld%lld%lld",&N,&A,&B,&K);
	ll fact[300010]={},inv[300010]={};
	fact[0]=1;
	reg(i,1,300000)fact[i]=(fact[i-1]*i) % mod;
	inv[300000] = test(fact[300000],mod-2);
	ireg(i,0,300000-1)inv[i]=(inv[i+1]*(i+1)) % mod;
	// reg(i,0,300000)if((fact[i]*inv[i])%mod!=1){
	// 	printf("破綻\n");
	// 	break;
	// }
	ll g = gcd(A,B);
	if(K%g!=0){
		printf("0\n");
	}else{
		K/=g;
		A/=g;
		B/=g;
		//1=aN+bM;
		ll n,m;
		reg(i,1,B){
			if((A*i)%B==1){
				n=i;
				break;
			}
		}
		m = -(A*n-1)/B;
		//K=aN+bM;
		n*=K;
		m*=K;
		if(n>0){
			ll offset = n/B+1;
			if(B>0){
				n -= offset*B;
				m += offset*A;
			}else{
				n += offset*B;
				m -= offset*A;
			}
		}
		//N<=0にして，増やしていき，M<=0になるまでやる
		while(m>0){
			if(n>=0 && m>=0 && N-n>=0 && N-m>=0){
				ll com = (fact[N]*inv[n]) % mod;
				com = (com*inv[N-n]) % mod;
				com = (com*fact[N]) % mod;
				com = (com*inv[m]) % mod;
				com = (com*inv[N-m]) % mod;
				ans = (ans+com) % mod;
			}
			n+=B;
			m-=A;
		}
	}
	if(ans==0)ans=1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	ll n,x,m;
	cin>>n>>x>>m;
	map<ll,int>vis;
	deque<ll>cycle;
	ll sum = 0;
	ll ans = 0;
	while(true){
		x%=m;
		vis[x]++;
		if(vis[x] > 1)break;
		cycle.pb(x);
		sum+=x;
		x*=x;
		x%=m;
	}
	while(n && vis[cycle.front()] == 1){
		ans+=cycle.front();
		sum-=cycle.front();
		cycle.pop_front();
		n--;
	}
	if(vis[0]){
		while(n && !cycle.empty()){
			ans+=cycle.front();
			cycle.pop_front();
			n--;
		}
		cout<<ans;
	}else{
	    if(!n){cout<<ans;return 0;}
		ll j = sz(cycle);
		ll r = n/j;
		ll q = n%j;
		ans+=r*sum;
		for(int i=0;i<q;i++)ans+=cycle[i];
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 7092
const input = require('fs').readFileSync('/dev/stdin', 'utf8')
const [W, H, x, y, r] = input.split(/\s/).map(s => parseInt(s, 10));

console.log(x + r <= W && y + r <= H && 0 <= x + r && 0 <= y + r && x - r >= 0 && y - r >= 0  ? 'Yes' : 'No');


Measured memory_bytes: 15428
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

const int MAX_V = 1e5+10;
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void DS(int s) {
	priority_queue<P,vector<P>,greater<P>> que;
	//for (int i = 0; i < MAX_V; i++) G[i].clear();
	for(int i = 0; i <= V; i++) d[i] = INF; d[s] = 0;
	que.push(P(0, s));
	while (que.size()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto e : G[v]) {
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int ans[2010];

int main() {
	int n,x,y;
	cin >> n >> x >> y;
	V = n+1;
	for(int i = 1; i < n; i++) G[i].push_back({i+1,1});
	for(int i = n; i > 1; i--) G[i].push_back({i-1,1});
	G[x].push_back({y,1});
	G[y].push_back({x,1});
	for(int i = 1; i <= n; i++){
		DS(i);
		for(int j = i+1; j <= n; j++){
			ans[d[j]]++;
		}
	}
	for(int i = 1; i < n; i++){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 2688
<?php
# 整数の入力
fscanf(STDIN, "%d", $n);

$ss = [];
$ana = 0;
while (fscanf(STDIN, "%s", $s)) {
  $s = str_split($s);
  sort($s);
  $s = implode($s);
  
  if (isset($ss[$s])) {
    $ana += $ss[$s];
    $ss[$s]++;
  } else {
	$ss[$s] = 1;
  }
}

echo $ana;


Measured memory_bytes: 13048
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y, ll mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

signed main() {
	string s;
	ll n, m, k, a, b, c, cnt = 0, ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (cnt > a) { ans += cnt - a; }
		cnt = max(cnt, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define trav(x,v) for(auto &x : (v))
#define all(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
typedef long long ll;

const ll md = 1e9+7;

ll f(ll n){
	ll ans = 1;
	rep(i,1,n+1) ans = ans*i % md;
	return ans;
}

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

	int n,m;
	cin >> n >> m;
	if(n > m) swap(n,m);
	if(n+1 < m){
		cout << 0 << endl;
	} else if(n == m){
		ll res = f(n);
		res = res * res % md;
		res = res * 2 % md;
		cout << res << endl;
	} else {
		ll res = f(n);
		res = res * res % md;
		res = res * m % md;
		cout << res << endl;

	}
}

Measured memory_bytes: 256
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import string

INF = 32768

def main():
    lines = map(lambda x: [int(i) for i in string.split(x)],
        sys.stdin.readlines())
    N, M = lines[0]

    d = [[INF]*N for x in range(N)]
    for i in range(N):
        for j in range(N):
            if(i == j): d[i][j] = 0

    for line in lines[1:]:
        d[line[0]-1][line[1]-1] = line[2]
        d[line[1]-1][line[0]-1] = line[2]

    # Warshall–Floyd Algorithm
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if(d[i][k] != INF and d[k][j] != INF):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    count = 0
    for line in lines[1:]:
        i, j, c = line
        #print("%s %s org:%s calc:%s" % (i,j,c,d[i-1][j-1]))
        if(d[i-1][j-1] != c):
            count += 1
            

    sys.stdout.write("%s" % count)

if __name__ == '__main__':
    main()


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

#include <tuple>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    int sum = 0;

    REP(i, N)
    {
        int l, r; cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int a,b,c;
		Scanner br=new Scanner(System.in);
		a=br.nextInt();
		b=br.nextInt();
		c=br.nextInt();
		if(a<b && b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 25984
#include<iostream>
using namespace std;
int main(){
  double time500,time1000;
  while( cin >> time500 >> time1000){
  if(time500<35.5&&time1000<71.0) cout << "AAA" << endl;
  else if(time500<37.5&&time1000<77.0) cout << "AA" << endl;
  else if(time500<40.0&&time1000<83.0) cout << 'A' << endl;
  else if(time500<43.0&&time1000<89.0) cout << 'B' << endl;
  else if(time500<50.0&&time1000<105.0) cout << 'C' << endl;
  else if(time500<55.0&&time1000<116.0) cout << 'D' << endl;
  else if(time500<70.0&&time1000<148.0) cout << 'E' << endl;
  else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int main() {
    int N, i; cin >> N;
    int ol = 0, key = 0;;
    string s, t; cin >> s >> t;
    for (i = 0; i < N; i++) {
        int index = i;
        for (int j = 0; j < N - i; j++) {
            if (s.at(index) == t.at(j)) {
                ol++; index++;
                key = ol;
                if (index == N) {
                    cout << 2 * N - key << endl;
                    return 0;
                }
            } else break;
        }
        ol = 0;
    }
    cout << 2 * N - key << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

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

// #include "beginner_138/beginner_138.h"
// Still dunno how to put linker 

using namespace std; 
typedef long long ll;

// Sort that saves index.
int n;
vector<int> P(n);

int secondHighest(int l, int r){

    return 0;
}


void f_sol01(){
    // Brute force
    // https://atcoder.jp/contests/abc140/submissions/7410886
    
    cin >> n;
    vector<long> S; // S[i] is the value of the health of the slimes.
    for(int i = 0; i < n*n; i++)cin >> S[i];

    
}

void f_sol02(){
    // Atcoder solution
    int n;
    cin >> n;
    int n2 = 1 << n;
    vector<int> a(n2);
    for(int i = 0; i < n2; i++)cin >> a[i];
    sort(a.begin(), a.end()); // Sort makes things easier here.
    vector<int> s;
    s.push_back(a.back());
    a.back() = -1; // Mark as -1 for value that has been used.

    for(int i = 0; i < n; i++){
        vector<int> p = s; // Create duplicate of s. The vector containing existing slimes health.
        sort(p.begin(), p.end());
        int ai = n2-1; // probably used for indexing of array with size n2-1
        while(p.size() > 0 && ai >= 0){ // Repeat until p is empty and ai finishes checking from n2-1 to 0
            if(a[ai] == -1){ // Checks if a[ai] has been used
                --ai;
                continue;
            }
            if(a[ai] < p.back()){ // if the health of slime in a is less than health of slime in p
                s.push_back(a[ai]);
                p.pop_back();
                a[ai] = -1;
            }
            --ai; // move on through a.
        }
        if(p.size() > 0){ // If p is not empty.
            puts("No");
            return;
        }
    }
    puts("Yes");
    return;
}

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

    f_sol02();
    
    
    return 0;
}

Measured memory_bytes: 2932
use std::io::prelude::*;
use std::str::FromStr;

fn main() {
    let stdin_ = std::io::stdin();
    let stdout_ = std::io::stdout();
    let mut stdin = stdin_.lock();
    let mut stdout = stdout_.lock();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let n = buffer
        .split_whitespace()
        .map(|s| usize::from_str(s).unwrap())
        .next()
        .unwrap();
    buffer.clear();
    stdin.read_line(&mut buffer).unwrap();
    let h = buffer
        .split_whitespace()
        .map(|s| u64::from_str(s).unwrap())
        .collect::<Vec<u64>>();

    let mut c = 0;
    for i in 0..n {
        if h[0..i].iter().all(|&j| j <= h[i]) {
            c += 1;
        }
    }

    write!(stdout, "{}\n", c).unwrap();
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 1e5 + 5;
int n;
int a[mxn];
int cnt[2][mxn];
pair <int, int> mx[2], mx0[2];

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	rep(i, n) cnt[i & 1][a[i]] ++;
	rep(i, 2) {
		mx[i] = mx0[i] = mp(0, -1);
		rep(j, mxn) {
			if (mp(cnt[i][j], j) > mx0[i]) mx0[i] = mp(cnt[i][j], j);
			if (mx0[i] > mx[i]) swap(mx[i], mx0[i]);
		}
	}
	int ans = n;
	if (mx[0].second != mx[1].second) ans = n - mx[0].first - mx[1].first;
	else ans = min(n - mx[0].first - mx0[1].first, n - mx0[0].first - mx[1].first);
	printf("%d\n", ans);
	return 0;
}


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

const int maxn = 5050;
string s;
int k, cnt[26];
set<string> Set;
string ans[maxn];
vector<int> pos, t;

int main()
{
    cin >> s >> k;
    int n = s.size();
    if(n < 50) {
        for(int i = 0; i < n; i ++) {
            for(int j = 1; j <= n - i; j ++) {
                if(Set.size() <= k)
                    Set.insert(s.substr(i, j));
                if(Set.size() > k) {
                    auto it = Set.end();
                    it --;
                    Set.erase(it);
                }
            }
        }
        cout << *(Set.rbegin());
    } else {
        int mn = 1e9;
        for(int i = 0; i < n; i ++)
            cnt[s[i] - 'a'] ++;
        for(int i = 0; i < 26; i ++) {
            if(!cnt[i])
                continue;
            Set.clear();
            bool flag = false;
            for(int j = 0; j < n; j ++) {
                if(s[j] - 'a' == i) {
                    for(int len = 1; len <= n - j; len ++) {
                        Set.insert(s.substr(j, len));
                        if(Set.size() >= k) {
                            flag = true;
                            goto finish;
                        }
                    }
                }
            }
finish:
            if(!flag) {
                k -= Set.size();
            } else {
                mn = i;
                break;
            }
        }

        for(int i = 0; i < n; i ++)
            if(s[i] - 'a' == mn)
                pos.push_back(i);
        bool flag = false;
        for(int i = 1; i <= k; i ++) {
            if(pos.size() == 1) {
                for(int j = pos[0] - i + 1; j <= pos[0] - i + k; j ++)
                    cout << s[j];
                flag = true;
                break;
            } else {
                t.clear();
                int mn = 1e9;
                for(int j = 0; j < pos.size(); j ++)
                    if(pos[j] + 1 < n)
                        mn = min(mn, s[pos[j] + 1] - 'a');
                for(int j = 0; j < pos.size(); j ++)
                    if(pos[j] + 1 < n && mn == s[pos[j] + 1] - 'a')
                        t.push_back(pos[j] + 1);
                pos.clear();
                for(int j = 0; j < t.size(); j ++)
                    pos.push_back(t[j]);
            }
        }
        if(!flag) {
            for(int j = pos[0] - k + 1; j <= pos[0] - k + k; j ++)
                cout << s[j];
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){

    int64_t L, R;
    cin >> L >> R;

    int64_t mod = 2019;

    if(R - L > mod){
        cout << 0 << endl;
        return 0;
    }

    int64_t ans = mod;
    for(int64_t i = L; i < R; i++){
        for(int64_t j = i + 1; j <= R; j++){
            int64_t x = (i * j) % mod;
            if(ans > x) ans = x;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    for i in 1..10 {
        if n % i == 0 && n / i < 10 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

int main(){
  long n, k;
  cin >> n >> k;
  long ans = 0, min = n * (n + 1) / 2, max = min;
  for(long i = n + 1; i >= k; i--){
    ans += max - min + 1;
    max -= n + 1 - i;
    min -= i - 1;
  }
  cout << ans % 1000000007 << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	int a[3]={};
	rep(i,s.size()){
		a[(int)(s[i]-'a')]++;
	}
	bool check=true;
	rep(i,3)if(a[i]==0)check=false;
	cout<<((check)?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    string a, b;
    cin >> a;
    cin >> b;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<char>());
    string ans = "No";

    if (a < b) ans = "Yes";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N;
    cin >> N;
    VL A(N + 1);
    rep(i, 2, N + 1) cin >> A[i];
    VL buka(N + 1);
    rep(i, 2, N + 1) buka[A[i]]++;

    rep(i, 1, N + 1){
        cout << buka[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6432
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	//input = input.split("\n");
	S = input.trim().split("\n")
	//tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
//	var a = parseInt(input[0], 10);
	
	if(S== 'A'){console.log('T');}
	if(S== 'C'){console.log('G');}
	if(S== 'G'){console.log('C');}
    if(S== 'T'){console.log('A');}//出力
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
temp=[int(i) for i in input().split()]
N=temp[0]
K=temp[1]
P=[input()[0] for i in range(N)]

alpha=[0 for i in range(26)]
for i in P:
	alpha[ord(i)-65]+=1

ans=0
while True:
	alpha.sort()
	alpha.reverse()
	for i in range(K):
		if alpha[i]>0:
			alpha[i]-=1
		else:
			break
	else:
		ans+=1
		continue
	break
print(ans)

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

void solve(){
  int n, m, c; cin >> n >> m >> c;
  int b[m], a[n][m], ans = 0;
  for(int i = 0; i < m; i++) cin >> b[i];
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> a[i][j];
  for(int i = 0; i < n; i++){
    int sum = 0;
    for(int j = 0; j < m; j++){
      sum += a[i][j] * b[j];
    }
    sum += c;
    if(sum > 0) ans++;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n];
    for(int j=0; j<n; j++)
    {
        cin >> arr[j];

    }
    for(int j=0; j<n; j++)
    {
        if(arr[j]%2 == 0)
        {
            if(arr[j]%3 != 0 && arr[j]%5 != 0)
            {
                cout << "DENIED\n";
                return 0;
            }
        }
    }
    cout << "APPROVED\n";
    return 0;
}



Measured memory_bytes: 256
//Only the Creator has given me strength!🖤
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635
#define pb push_back
#define vctr vector<int>
#define vvtr vector<vctr>
int mod=1e9+7;
using namespace std;
void fastio() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    fastio();
    int s;
    ll g=0;
    string a;
    cin>>s>>a;
    ll c[90]={0},k,l;
    for(int i=0; i<s; i++) {
        c[a[i]]++;
        for(int j=0; j<s; j++) {
            k=2*j+i;
            l=j+i;
            if(k>=s) break;
            if(a[i]!=a[l] && a[i]!=a[k] && a[l]!=a[k])
                g++;
        }
    }
    ll ans=c['R']*c['G']*c['B']-g;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var S, H, C, D [14]bool
	var n int
	fmt.Scanf("%d\n", &n)

	for i := 0; i < n; i++ {
		var s string
		var cardnum int
		fmt.Scanf("%s%d\n", &s, &cardnum)
		if s == "S" {
			S[cardnum] = true
		} else if s == "H" {
			H[cardnum] = true
		} else if s == "C" {
			C[cardnum] = true
		} else if s == "D" {
			D[cardnum] = true
		}

	}
	for i := 1; i <= 13; i++ {
		if S[i] != true {
			fmt.Println("S", i)
		}
	}
	for i := 1; i <= 13; i++ {
		if H[i] != true {
			fmt.Println("H", i)
		}
	}
	for i := 1; i <= 13; i++ {
		if C[i] != true {
			fmt.Println("C", i)
		}
	}
	for i := 1; i <= 13; i++ {
		if D[i] != true {
			fmt.Println("D", i)
		}
	}
}



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

#define FOR(i,b,e) for(ll i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(ll i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    int n = SIZE(s);
    
    FOR(i,0,n-2) if (s[i] == 'A' && s[i+1] == 'C') {
        cout << "Yes";
        return 0;
    }
    
    cout << "No";

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int n,cnt=0;
ll ret;
ll ans[20];
ll x[20],y[20],p[20],dist[20];
int mp[20];//yでsortした順番に出力してくれる
int train[20];//0:なし 1:東西 2:南北
void solve(){
    ret=0;
    For(i,0,n) dist[i]=min(abs(x[i]),abs(y[i]));
    int left=-1e8, down=-1e8;
    For(i,0,n){
        if(train[i]==2) left=x[i];
        if(train[mp[i]]==1) down=y[mp[i]];
        dist[i]=min(dist[i],x[i]-left);
        dist[mp[i]]=min(dist[mp[i]],y[mp[i]]-down);
    }
    int right=1e8, up=1e8;
    for(int i=n-1;i>-1;i--){
        if(train[i]==2) right=x[i];
        if(train[mp[i]]==1) up=y[mp[i]];
        dist[i]=min(dist[i],right-x[i]);
        dist[mp[i]]=min(dist[mp[i]],up-y[mp[i]]);
    }
    For(i,0,n) ret += dist[i]*p[i];
    ans[cnt] = min(ans[cnt],ret);
    return;
}
void Main(){
    cin >> n;
    vector<pair<int,pair<int,int>>> vec(n);
    For(i,0,n){
        cin >> vec[i].first >> vec[i].second.first >> vec[i].second.second;
    }
    sort(ALL(vec));
    //xでsortした順に入れる
    For(i,0,n){
        x[i]=vec[i].first;
        y[i]=vec[i].second.first;
        p[i]=vec[i].second.second;
    }
    //yでsortし直す
    sort(ALL(vec),[&](auto &l, auto &r){
        return l.second.first<r.second.first;
    });
    //xsortとysortの対応関係を作る
    For(i,0,n) For(j,0,n) if(vec[i].first==x[j] && vec[i].second.first==y[j]) mp[i]=j;
    int p3=1;
    fill(ans,ans+n+1,1e18);
    For(i,0,n)p3*=3;
    For(i,0,p3){
        int x=i;
        cnt=0;
        For(j,0,n){
            train[j]=x%3;
            x/=3;
            if(train[j]>0) cnt++;
        }
        solve();
    }
    For(i,0,n+1) cout << ans[i] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3580
from collections import defaultdict
import sys
input = sys.stdin.readline

N = int(input())
tree_dict = defaultdict(set)
cost_dict = dict()
for i in range(N-1):
    a, b, c = tuple(map(int, input().split()))
    tree_dict[a] |= {(b, c)}
    tree_dict[b] |= {(a, c)}
    cost_dict[(a, b)] = c
    cost_dict[(b, a)] = c

Q, K = list(map(int, input().split()))

# calc dist from K
dist = {K: 0}
q = [(to_node, K) for to_node, cost in tree_dict[K]]
for i in range(N - 1):
    to_node, from_node = q[i]
    dist[to_node] = dist[from_node] + cost_dict[(from_node, to_node)]
    for next_node, cost in tree_dict[to_node]:
        if next_node != from_node:
            q += [(next_node, to_node)]


for i in range(Q):
    x, y = list(map(int, input().split()))
    print(dist[x]+dist[y])


Measured memory_bytes: 122076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;
int n,a[200009],sum,b[200009],ans=0;
int main()
{
  scanf("%d",&n);
  for (int i=1;i<=n;i++)  scanf("%d",&a[i]);
  for (int i=n;i>=1;i--) 
  {
  	sum=0;
    for (int j=i;j<=n;j+=i)
    {
  	  sum=sum+b[j];
    }
    if ((sum%2)!=a[i]) b[i]=1,ans++;
  }
  printf("%d\n",ans);
  for (int i=1;i<=n;i++)
  if (b[i]==1) printf("%d ",i);
  return 0;
} 

Measured memory_bytes: 2432
<?php   

//8色より多いことはないのにきをつける
//3200以上の人数だけ色を足せばいい
//3200以上しかいない時は一色
       
fscanf(STDIN,"%s",$s);
fscanf(STDIN,"%d",$k);

$c=0;

for($i=0;$i<strlen($s);$i++){
 if($s[$i]!=1){
   break;
 }
  $c++;
}

if($k<=$c){
  echo "1\n";
}else{
  echo $s[$c]."\n";
}



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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

int main(){
    int a,b;cin>>a>>b;
    string s;cin>>s;
    REP(i,a){
        if('0'>s[i] or s[i]>'9'){
            cout<<"No\n";
            return 0;
        }
    }
    if(s[a]!='-'){
        cout<<"No\n";
        return 0;
    }
    REP(i,b){
        if('0'>s[a+i+1] or s[a+i+1]>'9'){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N, K;
  in(N, K);
  vector<int> s(N + 1);

  rep(i, 1, N + 1) {
    int pi;
    in(pi);
    s[i] = s[i - 1] + pi;
  }
  int mx = 0;
  rep(i, K , N + 1) {
    mx = max(mx, s[i] - s[i - K]);
  }
  printf("%.12f\n", (mx + K) * 1.0 / 2);
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
 const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;
// const ll MAX = 1e6 + 1;


void solve()
{
   int s;
   cin>>s;
   int dp[s+1];
       memset(dp,0,sizeof(dp));

    dp[0]=1;
    frf(i,3,s)
    {
        frf(j,3,i)
        {
            if(i-j>=0)
            dp[i]+=dp[i-j];
            dp[i]%=PRIME;
        }
    }
  cout<<dp[s];
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // int k = 1;
    // cin >> t;
    t = 1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    int now=0;
    rep(i,0,h){
        cin>>a[i];
        rep(j,now,w){
            if(a[i][j]=='.')break;
            a[i][j]='.';
            now++;
        }
        now--;
    }
    int ok=1;
    if(now==w-1){
        rep(i,0,h){
          rep(k,0,w) if(a[i][k]=='#')ok=0;
        }
    }
    else ok=0;
    if(ok)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    bool hoge = false;
    REP(i,n) if (a[i]%2 == 1) hoge = true;
    if(hoge) cout << "first" << std::endl;
    else cout << "second" << std::endl;
    return 0;
}

Measured memory_bytes: 1024
/**
  @file c.cpp
  @title C - Lower
  @url https://atcoder.jp/contests/abc139/tasks/abc139_c
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)


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

  vector<LL> H(N, 0);
  REP(i, N) {
    cin >> H[i];
  }

  vector<int> dp(N + 1, 0);
  int prev = H[0];
  for (int i = 1; i < N; i++) {
    if (H[i] <= prev) {
      dp[i] = dp[i - 1] + 1;
    }
    prev = H[i];
  }

  sort(ALL(dp));
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int[] arg =new int[100];
        int i=0,sum=0,num=0;
        int[] motor=null,cav=null,io=null,all=null;
        int[][] result=null;
        boolean first=true;

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	if(first){
            		String[] str=line.split(" ");
            		if(str[0].equals(str[1])&&str[2].equals(str[1])&&str[0].equals("0"))break;
            		io=new int[Integer.parseInt(str[0])];
            		motor=new int[Integer.parseInt(str[1])];
            		cav=new int[Integer.parseInt(str[2])];
            		all=new int[io.length+motor.length+cav.length+1];
            		for(int k=1;k<all.length;k++){
            			all[k]=2;
            		}
            		num=Integer.parseInt(br.readLine());
            		result=new int[num][4];
            		i=0;
            		first=false;
            	}else{
            		String[] str=line.split(" ");
            		for(int k=0;k<4;k++){
            			result[i][k]=Integer.parseInt(str[k]);
            		}
            		i++;
            		if(i==num){
            			for(int k=0;k<result.length;k++){
                			if(result[k][3]==1){
                				for(int j=0;j<3;j++){
                					all[result[k][j]]=1;
                				}
                			}
                		}
            			for(int k=0;k<result.length;k++){
                			if(result[k][3]==0){
                				if(all[result[k][0]]==1&&all[result[k][1]]==1){
                					all[result[k][2]]=0;
                				}else if(all[result[k][2]]==1&&all[result[k][1]]==1){
                					all[result[k][0]]=0;
                				}else if(all[result[k][0]]==1&&all[result[k][2]]==1){
                					all[result[k][1]]=0;
                				}
                			}
                		}
            			for(int k=1;k<all.length;k++){
            				System.out.println(all[k]);
            			}
            			first=true;
            		}
            	}
            }

        }
	}

}

Measured memory_bytes: 28344
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n;
	cin>>n;
	//ll sum=0;
	map<ll,ll>m;
	int sum=0;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i],sum^=a[i];
	for(int i=0;i<n;i++)
	a[i]^=sum;
	for(int i=0;i<n;i++)
	cout<<a[i]<<" ";
}

Measured memory_bytes: 4412
r, c = gets.chomp.split.map(&:to_i)

a = []
r.times do
  a << gets.chomp.split.map(&:to_i)
end

a.each do |a_i|
  a_i.push(a_i.sum)
end

a << []

(c + 1).times do |i|
  sum = 0
  r.times do |j|
    sum += a[j][i]
  end
  a.last.push(sum)
end

a.each do |a_i|
  puts a_i.join(' ')
end



Measured memory_bytes: 7132
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

// verified : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// 負辺があると動作しない?
// O(E log V)
vector<lint> h;

template<typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, int s, lint x){
     
  int n = g.size();
  // numeric_limits がうまく使えない場合は自分で INF を定義する.
  const auto inf = INF;
  vector<T> dist(n, inf);

  using P = pair<T, int>;
  // 小さい順に取り出せる
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()){
    T cost;
    int node;
    tie(cost, node) = que.top();
    que.pop();
    if(dist[node] < cost) continue;
    for(auto &e : g[node]){
      int next_node = e.first;

      // node -> next_node へ飛びたい
      // 現在の移動距離は cost
      // ってことは，今いる場所は
      lint curH = max(0LL, x - cost);

      lint next_cost;
      lint nxtH = curH - e.second;
      if (nxtH > h[next_node]) {
        next_cost = cost + e.second + nxtH - h[next_node];
      } else if (nxtH >= 0) {
        next_cost = cost + e.second;
      } else if (nxtH < 0) {
        if (curH - nxtH > h[node]) continue;
        next_cost = cost + e.second - nxtH;
      } else assert(false);
      // auto next_cost = cost + e.second;

      if(dist[next_node] <= next_cost) continue;
      dist[next_node] = next_cost;
      que.emplace(next_cost, next_node);
    }
  }

  return dist;
}

/* do your best */

int main() {

  lint n, m; cin >> n >> m;
  lint x; cin >> x;
  h.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  vector<vector<pair<int, lint>>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    lint t;
    cin >> a >> b >> t;
    a--;
    b--;

    g[a].push_back({b, t});
    g[b].push_back({a, t});
  }


  lint dist = dijkstra(g, 0, x)[n - 1];
  lint curH = max(0LL, x - dist);

  dist += h[n - 1] - curH;
  assert(h[n - 1] - curH >= 0);
  if (dist >= INF) dist = -1;

  cout << dist << endl;

  return 0;
}



Measured memory_bytes: 23160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int cnt = 0;
		int n = sc.nextInt();
		long high = sc.nextInt();
		for(int i = 1; i < n; i++) {
			long tmp = sc.nextLong();
			if(high >= tmp) {
				cnt++;
				high = tmp;
			} else {
				ans = Math.max(ans, cnt);
				cnt = 0;
				high = tmp;
			}
		}
		ans = Math.max(ans, cnt);
		System.out.println(ans);
	}

}


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

int main() {
	long long N, M;
	static long long A[1000], B[1000], C[1000], DP[1010][8200] = {}, INF = 1000000000;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		long long X;
		for (int j = 0; j < B[i]; j++) cin >> X, X--, C[i] += pow(2, X);
	}
	for (int i = 0; i <= M; i++) {
		for (int j = 0; j < 1 << N; j++) DP[i][j] = INF;
	}
	DP[0][0] = 0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < 1 << N; j++) {
			DP[i + 1][j] = min(DP[i + 1][j], DP[i][j]);
			DP[i + 1][j | C[i]] = min(DP[i + 1][j | C[i]], DP[i][j] + A[i]);
		}
	}
	if (DP[M][(1 << N) - 1] >= INF) cout << -1 << endl;
	else cout << DP[M][(1 << N) - 1] << endl;
}

Measured memory_bytes: 63232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pll pair<ll,ll>
#define lower_boundIDX(x,val) lower_bound(all(x),val)-x.begin();
#define upper_boundIDX(x,val) upper_bound(all(x),val)-x.begin();
#define mem(a,val)  memset(a,val,sizeof(a))
#define all(x) x.begin(),x.end()
#define need_for_speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD 1000000007
const int MAX  = 1e5+7;
int main(int argc, char const *argv[]) {
  need_for_speed
  int dp[MAX],h[MAX];
  mem(dp,0);
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>h[i];
  if(n==1) std::cout << "0" << '\n';
  else{
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++) dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    std::cout <<dp[n-1]<< '\n';
  }
  return 0;
}


Measured memory_bytes: 1024