akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        string S = cin.next();

        int count = 0;

        for (int i = 0; i < S.Length; ++i)
        {
            if (S[i] == 'o')
            {
                ++count;
            }
        }

        int tmp = 15 - S.Length;
        WriteLine((count + tmp>= 8)? "YES" : "NO");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
(* O(t) *)
let solve a b t =
  let rec loop sum_a sum_b =
    if sum_a > t then
      sum_b
    else
      loop (sum_a + a) (sum_b + b)
  in
    loop a 0

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [a; b; c] -> solve a b c |> string_of_int |> print_endline
  | _ -> ()

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

#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define M 1000000007
#define pb push_back
#define mp make_pair

#define f(i,n) for(int i=0;i<n;i++)
#define bf(i,n) for(int i=n-1;i>=0;i--)

#define all(v) v.begin(), v.end()
#define p0(a) cout<<a<<" "<<'\n'
#define p1(a) cout<<a<<'\n'
#define p2(a,b) cot<<a<<" "<<b<<'\n'
#define p3(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define p4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<d<<'\n'

#define bl '\n'


int main() {
	// your code goes here
	FIO;
	ll test = 1;
	//cin>>test;
	while(test--){
	    int n,k;
	    cin>>n>>k;
	    ll a[n];
	    for(int i=0;i<n;i++) cin>>a[i];
	    for(int i=k;i<n;i++){
	        if(a[i]>a[i-k]) cout<<"Yes"<<bl;
	        else cout<<"No"<<bl;
	    }
	}
	return 0;
}


Measured memory_bytes: 5212
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

H,W,D = inpl()

dd = defaultdict(int)
for y in range(H):
	row = inpl()
	for x,n in enumerate(row):
		dd[n] = [x,y]

S = [0]*D
for k in range(1,D+1):
	i = k+D
	tmpli = [0]
	tmp = 0
	while i <= H*W:
		x1,y1 = dd[i-D]
		x2,y2 = dd[i]
		tmp += abs(x1-x2)+abs(y1-y2)
		tmpli.append(tmp)
		i += D
	S[i%D] = tmpli


Q = int(input())
for _ in range(Q):
	L,R = inpl()
	k = L%D
	l,r = (L-k)//D, (R-k)//D
	if k==0:
		l -= 1
		r -= 1
	print(S[k][r]-S[k][l])


Measured memory_bytes: 31508
#include <stdio.h>
#include <stdint.h>
#include <string.h>

int main(void)
{
    uint8_t cnt[26];
    int n;
    memset(cnt, 0xff, sizeof(cnt));
    scanf("%d\n", &n);
    for (int i = 0; i < n; i++) {
        uint8_t tmp_cnt[26];
        char c;
        memset(tmp_cnt, 0x00, sizeof(tmp_cnt));
        while ((c = getchar()) != '\n') {
            int index = c - 'a';
            tmp_cnt[index]++;
        }
        for (int j = 0; j < 26; j++) {
            if (cnt[j] > tmp_cnt[j]) {
                cnt[j] = tmp_cnt[j];
            }
        }
    }
    for (int j = 0; j < 26; j++) {
        for (int x = 0; x < cnt[j]; x++) {
            char c = 'a' + j;
            putchar(c);
        }
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

using ps = pair<string,string>;
map<ps,ll> binary(string &s,int n) {
    map<ps,ll> ans;
    rep(bit,1<<n) {
        string a,b;
        rep(i,n) {
            if ((bit>>i)&1) a += s[i];
            else b += s[i];
        }
        ans[make_pair(a,b)]++;
    }
    return ans;
}

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

    int N; cin >> N;
    string s; cin >> s;
    string t = s.substr(N,N);
    reverse(t.begin(),t.end());
    s = s.substr(0,N);

    auto x = binary(s,N),y = binary(t,N);
    ll ans = 0;
    for (auto itr = x.begin(); itr != x.end(); ++itr) {
        ll n = itr->second;
        ps p = itr->first;
        ans += n * y[p];
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
	int N,a;
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> a;
		ans+=(a-1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<pii> A,B;
const int MAX = 210;
struct edge { int to, cap, rev; };

vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, int(G[to].size())});
    G[to].push_back((edge){from, 0, int(G[from].size()-1)});
}

int dfs(int v, int t, int f) {
    if(v == t) return f;
    used[v] = 1;
    for(int i = 0 ; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(used[e.to] or e.cap <= 0) continue;
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0){
            e.cap -= d;
            G[e.to][e.rev].cap += d;
            return d;
        }
    }
    return 0;
}

int ford_fulkerson(int s, int t) {
    int flow = 0, f;
    while(1){
        memset(used, 0, sizeof(used));
        f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++){
    int a,b;
    cin >> a >> b;
    A.emplace_back(mp(a, b));
  }
  for (int i = 0; i < N; i++){
    int a,b;
    cin >> a >> b;
    B.emplace_back(mp(a, b));
  }
  int src = 0;
  int tar = 2 * N + 1;

  for (int i = 0; i < A.size(); i++){
    for (int j = 0; j < B.size(); j++){
      int a = i + 1;
      int b = N + j + 1;
      if (A[i].first < B[j].first and A[i].second < B[j].second){
	add_edge(a, b, 1);
      }
    }
  }

  for (int i = 0; i < N; i++){
    int a = i + 1;
    int b = N + i + 1;
    add_edge(src, a, 1);
    add_edge(b, tar, 1);
  }
  int res = ford_fulkerson(src, tar);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
import sys
N, K = map(int, sys.stdin.readline().split())
MOD = 10 ** 9 + 7
m = sum(range(K))
M = sum(range(N - K + 1, N + 1))
ans = (M - m + 1) % MOD
for i in range(K + 1, N + 2):
    m += i - 1
    M += N - i + 1
    p = M - m + 1
    ans += p % MOD
print(ans % MOD)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	string s;
	int q;
	vector<int> reverseTimes;
	reverseTimes.pb(0);
	vector<char> addChar;
	addChar.pb('A'); //dummy
	vector<int> whereToAdd; //1->top, 2->bottom;
	whereToAdd.pb(0); //dummy
	/*for(int i=1; i<=q; i++) {
		cout << i;
		reverseTimes[i] = 0;
		addChar[i] = 'A';
		whereToAdd[i] = 0;
	}*/
	int t;
	char c;
	int f;
	cin >> s >> q;
	s.reserve(q);
	for(int i=1; i<=q; i++) {
		cin >> t;
		if(t == 1) {
			reverseTimes.pb(reverseTimes[i-1] + 1);
			addChar.pb('A');
			whereToAdd.pb(0);
		}
		else { 
			reverseTimes.pb(reverseTimes[i-1]);
			cin >> f >> c;
			addChar.pb(c);
			whereToAdd.pb(f);
		}
	}
	for(int i=1; i<=q; i++) {
		//cout << reverseTimes[i+1] << " " << endl;
		if (reverseTimes[i] % 2 == 0 && whereToAdd[i] == 1) {
			s.insert(s.begin(), addChar[i]);
		}
		else if(reverseTimes[i] % 2 == 0 && whereToAdd[i] == 2) {
			s.pb(addChar[i]);
		}
		else if(reverseTimes[i] % 2 == 1 && whereToAdd[i] == 1) {
			s.pb(addChar[i]);
		}
		else if(reverseTimes[i] % 2 == 1 && whereToAdd[i] == 2) {
			s.insert(s.begin(), addChar[i]);
		}
	}

	if (reverseTimes[q] % 2 == 1) {
		std::reverse(s.begin(), s.end());
	}
	/*rep(i,1) {
		s.erase (remove(s.begin(), s.end(), 'A'), s.end());
	}*/
	cout << s << endl;
	
  return 0;
}


Measured memory_bytes: 2884
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

function<void(int,int)> tensi_no_3p=[&](int v,int d){
};

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N;
	cin >> N;
	vector<string> s(N);
	rep(i,N) cin >> s[i];
	int ans = 0;
	rep(A,N) {
		bool ok = true;
		rep(i,N)rep(k,N) {
			if (s[(i + A) % N][k] != s[(k + A) % N][i]) {
				ok = false;
				goto END;
			}
		}
		END:;
		if (ok) ans++;
	}
	cout << ans * N << endl;
	return 0;
}


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

int main()
{
  int A, B, C, tmp;

  cin >> A >> B >> C;
  tmp = A;
  for (int i = 0; i < B; i++)
  {
    if (tmp % B == C)
    {
      cout << "YES" <<  endl;
      return 0;
    }
    tmp += A;
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3588
N,Q=map(int,input().split())
s=input()

tdlist = []
for i in range(Q):
  t,d=input().split()
  tdlist.append((t,d))
#print(tdlist)

def isAlive(pos):
  for t,d in tdlist:
    if t == s[pos]:
      if d == 'L':
        pos -= 1
        if pos == -1:
          return -1
      elif d == 'R':
        pos += 1
        if pos == N:
          return 1
        
  return 0

#res_list = []
#for i in range(N):
#  res_list.append(isAlive(i))
#print(res_list)

max_L = -1
if isAlive(0) == -1:
  intv_L = [0, N-1]
  while (True):
    if intv_L[1]-intv_L[0] < 10:
      break
      
    center = (intv_L[0]+intv_L[1])//2    
    if isAlive(center) == -1:
      intv_L = [center, intv_L[1]]
    else:
      intv_L = [intv_L[0], center]

  max_L = intv_L[1]+1
  for i in reversed(range(intv_L[0],intv_L[1]+1)):
    if isAlive(i) == -1:
      max_L = i
      break

min_R = N
if isAlive(N-1) == 1:
  intv_R = [max_L+1, N-1]
  while (True):
    if intv_R[1]-intv_R[0] < 10:
      break
      
    center = (intv_R[0]+intv_R[1])//2    
    if isAlive(center) == 1:
      intv_R = [intv_R[0], center]
    else:
      intv_R = [center, intv_R[1]]

  for i in range(intv_R[0],intv_R[1]+1):
    if isAlive(i) == 1:
      min_R = i
      break

#print((max_L,min_R))
print(-max_L+min_R-1)

Measured memory_bytes: 19548
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

use proconio::input;
use itertools::Itertools;

fn main() {
    input! {
        n: usize,
    }
    let mut cnt = vec![0; 10001];
    for ((x, y), z) in (1..=100).cartesian_product(1..=100).cartesian_product(1..100) {
        let ans = x*x + y*y + z*z + x*y + y*z + z*x;
        if ans <= 10000 {
            cnt[ans] += 1;
        }
    }
    for ans in &cnt[1..=n] {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2220
//#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	int n,a=0;
	cin>>n;
	int minp=INF;
	rep(i,n){
		int p;
		cin>>p;
		if(p<minp){
			minp=p;a++;
		}
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)



int main(){
	
	int N,K;
	cin>>N>>K;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	
	vector<vector<int>> dp(N,vector<int>(K+1,0));//dp[i][j] i番目までの子供に計j個の飴
	vector<vector<int>> sum(N,vector<int>(K+1,0));//dp[i][j] i番目までの子供に計j個の飴
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			if(i==0){
				if(a[i]>=j)dp[i][j]=1;
			}
			else{
				if(j-a[i]<=0)dp[i][j] = sum[i-1][j];
				else{
					dp[i][j] = mod(sum[i-1][j] - sum[i-1][j-a[i]-1]);
				}
			}
			sum[i][j] = dp[i][j];
			if(j!=0)sum[i][j] = mod(sum[i][j] + sum[i][j-1]);
		}
	}
	
	cout<<dp[N-1][K]<<endl;
	
	
	return 0;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}

   public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long A = inputArray[0];
			long B = inputArray[1];
			long C = inputArray[2];

			var K = retreiveLongArray()[0];

			var pattensNum = Math.Pow(3, K);

			//3^Kの全通り試す
			for (int i = 0; i < pattensNum; i++) {
				var cases = i;
				var a = A;
				var b = B;
				var c = C;

				for (int j = 0; j < K; j++) {
					var target = cases % 3;
					if (target==0) {
						a *= 2;
					}else if (target==1) {
						b *= 2;
					}
					else {
						c *= 2;
					}
					cases /= 3;
				}
				if (a < b && b <c) {
					Console.WriteLine("Yes");
					return;
				}

			}


			//答えの出力
			var ans = "No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    while(true){
        int m,f,r;
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        
        if(m==-1 || f==-1) cout << "F" << endl;
        else if(m+f>=80) cout << "A" << endl;
        else if(m+f>=65) cout << "B" << endl;
        else if(m+f>=50) cout << "C" << endl;
        else if(m+f>=30) cout << (r>=50?"C":"D") << endl;
        else cout << "F" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ulli;
using namespace std;

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

/* MAIN CODE */
int main() {
	// your code goes here
	fastIO
	map<string, int> mp;
	mp["AC"]=0;
	mp["WA"]=0;
	mp["TLE"]=0;
	mp["RE"]=0;
	int n;
	cin >> n;
	string s;
	for(int i=0;i<n;i++){
	    cin >> s;
	    mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}


Measured memory_bytes: 3664
// https://atcoder.jp/contests/abc137/tasks/abc137_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, m: usize,
        jobs: [(usize, i64); n]
    };

    let mut bucket = vec![vec![]; m];
    for (day, profit) in jobs {
        if m >= day {
            bucket[m-day].push(profit);
        }
    }

    let mut total = 0;
    let mut pq = BinaryHeap::new();
    for i in (0..m).rev() {
        for &p in &bucket[i] {
            pq.push(p);
        }
        if let Some(x) = pq.pop() {
            total += x;
        }
    }
    println!("{}", total);
}


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

signed main(){
    string s;
    int n;cin>>n>>s;
    int r[n];
    int m[10][10];
    fill(m[0],m[10],0);
    fill(r,r+n,0);
    set<char> t;
    for(int i=n-1;i>=0;i--){
        t.insert(s[i]);
        r[i]=t.size();
    }
    int ans=0;
    for(int i=n-3;i>=0;i--){
        for(int j=n-2;j>i;j--){
            ans+=(r[j+1]-m[s[i]-'0'][s[j]-'0']);
            m[s[i]-'0'][s[j]-'0']=r[j+1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    for (int i = 0; i < N - 1; i++) {
        ans *= K - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

/*
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)
*/

func dvector(x1, y1, x2, y2 int) (int, int) {
	return -(y2 - y1), x2 - x1
}

func main() {
	var wtr = bufio.NewWriter(os.Stdout)

	var x1, y1, x2, y2, x3, y3, x4, y4 int

	fmt.Scan(&x1, &y1, &x2, &y2)
	dx, dy := dvector(x1, y1, x2, y2)
	x3, y3 = dx+x2, dy+y2
	dx, dy = dvector(x2, y2, x3, y3)
	x4, y4 = dx+x3, dy+y3
	fmt.Fprintln(wtr, x3, y3, x4, y4)
	_ = wtr.Flush()
}


Measured memory_bytes: 1840
N, K = map(int, input().split())
M = (N - 1) * (N - 2) // 2

if K <= M:
    edges = []
    for i in range(2, N + 1):
        edges.append((1, i))
    dis = M - K
    for i in range(2, N + 1):
        for j in range(i + 1, N + 1):
            if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
        else:
            continue
        break
    print(len(edges))
    for fr, to in edges:
        print(fr, to)
else:
    print(-1)


Measured memory_bytes: 3992
from collections import defaultdict, Counter, deque

A = [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
]
N, = list(map(int, input().split()))
print(A[N - 1])


Measured memory_bytes: 38256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


vector<pair<int,int>> vectorCnt(vector<int> a) {
    sort(a.begin(),a.end());
    int n=a.size();
    vector<pair<int,int>> b;
    int cnt=1;
    rep(i,n-1) {
            if (a[i+1]!=a[i]) {
                b.push_back(make_pair(cnt,a[i]));
                cnt=1;
            } else {
                ++cnt;
            }
    }
    b.push_back(make_pair(cnt,a[n-1]));
    return b;
}


int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i]; 
    vector<P> b=vectorCnt(a);
    int m=b.size();
    sort(b.begin(),b.end());
    int ans=0;
    rep(i,m-k) {
        ans+=b[i].first;
    }
    cout << ans << endl;
    
    return 0;   
}

Measured memory_bytes: 6900
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#include <bitset> 
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define ld long double
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int INF=0x7ffffff;

int ans=INF;
int movee[5][3];
bool visited[848][848];
int r,c,k;
int sx,sy;
int a[848][848];
char s[1000];
queue<int> q;

void bfs(int x,int y,int step)
{
	q.push(x);q.push(y);q.push(0);
	int cur_ans,cx,cy,cd,xx,yy,dd;
	visited[x][y]=true;
	while (!q.empty())
	{
		cx=q.front();q.pop();
		cy=q.front();q.pop();
		cd=q.front();q.pop();
		cur_ans=cx-1;
		cur_ans=min(cur_ans,cy-1);
		cur_ans=min(cur_ans,r-cx);
		cur_ans=min(cur_ans,c-cy);
		ans=min(ans,cur_ans);
		if (cd==k) continue;
		for (int i=1;i<=4;i++)
		{
			xx=cx+movee[i][1];yy=cy+movee[i][2];
			if (xx<1 || xx>r || yy<1 || yy>c) continue;
			if (a[xx][yy]==1 || visited[xx][yy]) continue;
			visited[xx][yy]=true;q.push(xx);q.push(yy);q.push(cd+1);
		}
	}
}

int main ()
{
	int i,j;
	movee[1][1]=1;movee[1][2]=0;
	movee[2][1]=0;movee[2][2]=1;
	movee[3][1]=-1;movee[3][2]=0;
	movee[4][1]=0;movee[4][2]=-1;
	scanf("%d%d%d",&r,&c,&k);
	for (i=1;i<=r;i++)
	{
		scanf("%s",s);
		for (j=1;j<=c;j++)
		{
			if (s[j-1]=='#') a[i][j]=1;
			if (s[j-1]=='.') a[i][j]=2;
			if (s[j-1]=='S')
			{
				sx=i;sy=j;
				a[i][j]=2;
			}
		}
	}
	bfs(sx,sy,0);
	int fans=1+(ans+k-1)/k;
	printf("%d\n",fans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> buttons;
  
  for(int i=0; i<N; i++)
  {
    int b;
    cin >> b;
    buttons.push_back(b);
  }
  
  int count = 0;
  int index = buttons[0] - 1;
  while(count < N)
  {
//    cout << index << endl;
    if(index == 1) break;
    count++;
    
    index = buttons[index] - 1;
  }
  
  //count++;
  
  if(count < N)
  {
    cout << count + 1<< endl;
  }else{
    cout << -1 << endl;
  }
  
}


Measured memory_bytes: 892
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<map>
    #include<vector>
    using namespace std;
    int main(void)
    {
        int k,x[5],ans;
        cin>>x[0]>>x[1]>>x[2]>>k;
        sort(x,x+3,greater<int>());
        int max=x[0];
        for(int i=0;i<k;i++){
            max*=2;
        }
        ans=max+x[1]+x[2];
        cout<<ans<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
const int R = 2, H = 10'000;
const ll INF = H * 10'000 + 1;
ll opt[R][H+1];
void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B) {
    for(int i = N; i >= 0; i--) {
        for(int h = 0; h <= H; h++) {
            ll& ans = opt[i % R][h];
            if(i == N) {
                ans = h == 0 ? 0 : INF;
            } else {
                ans = min(opt[(i + 1) % R][h], opt[i % R][max(h - A[i], 0ll)] + B[i]);
            }
        }
    }
    cout << opt[0][H] << endl;
}
int main() {
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(H, N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
long long ans;
int n;
char le[6] = {"MARCH"};
long long cnt[5];
int main()
{
   string s;

   while (cin >> n) {
      memset(cnt, 0,  sizeof cnt);

      for (int i = 0; i < n; i++) {
         cin >> s;

         for (int i = 0; i < 5; i++) {
            if (le[i] == s[0])
               cnt[i]++;
         }
      }

      ans = 0;

      for (int i = 0; i < 5; i++) {
         for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
               ans += cnt[i] * cnt[j] * cnt[k];

            }
         }

      }

      cout << ans << endl;

   }


}


Measured memory_bytes: 256
import sys,collections
p=[s.split()for s in sys.stdin]
p=collections.deque([[s[0],int(s[1])]for s in p])
q=int(p.popleft()[1])
t=0
while len(p)>0:
 if p[0][1]>q:
  p[0][1]-=q
  p+=[p.popleft()]
  t+=q
 else:
  t+=p[0][1]
  print(p.popleft()[0],t)


Measured memory_bytes: 21660
#include <stdio.h>

#define MOD 1000000007

int rec(int m, int n) {
    if (n == 0) return 1;
    long long t = rec(m, n/2);
    if (n % 2 == 0) return (t * t) % MOD;
    else return (((t * t) % MOD) * m) % MOD;
}

int main()
{
    int n, m;
    scanf("%d %d", &m, &n);
    printf("%d\n", rec(m, n));
    return 0;
}



Measured memory_bytes: 2748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x=scan.nextInt();
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(Math.abs(x-a)<Math.abs(x-b)) System.out.println("A");
		else System.out.println("B");

	}

}


Measured memory_bytes: 26960
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());

    let s = scan.chars();
    let w = scan.read::<usize>();
    let mut t = vec![];
    for i in 0..s.len() {if i % w == 0 {t.push(s[i])}}
    println!("{}", t.into_iter().collect::<String>());
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut ret = vec![];
        for _ in 0..n { ret.push(self.read::<T>()) }
        ret
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
        int A,B;
        scanf("%d",&A);
        scanf("%d",&B);

        int add,sub,sqar;
        add  = A + B;
        sub  = A - B;
        sqar = A * B;

        int i,array[] = {add,sub,sqar},max;
        max = array[0];
        for (i = 0; i < 3; i++){
                if(max < array[i]){
                        max = array[i];
                }
        }
        printf("%d",max);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				int n = int.Parse(Console.ReadLine());
				if (n == 0) break;
				var l = new List<int>();
				while (n-- != 0)
				{
					l.Add(int.Parse(Console.ReadLine()));
				}
				l.Sort();
				long r = 0, mati = 0;
				for (int i = 0; i < l.Count; i++)
				{
					r += mati;
					mati += l[i];
				}
				Console.WriteLine(r);
			}
		}
	}
}

Measured memory_bytes: 6084
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

LL modExp(LL base, LL N){
  LL value = 1;
  while(N){
    if(N & 1) value = (base * value) % INF;
    base = (base * base) % INF;
    N >>= 1;
  }

  return value;
}

int main(){
  FAST_IO
  int N; cin >> N;
  if(N < 2) cout << 0 << '\n';
  else{
    LL result = modExp(10, N) + modExp(8, N);
    result %= INF;
    result -= modExp(9, N);
    result %= INF;
    result -= modExp(9, N);
    result %= INF;
    if(result < 0) result += INF;
    cout << result;
  }
  return 0;
}



Measured memory_bytes: 3664
import sys
import heapq

input = sys.stdin.readline
N = int(input())

dp = [[0,0,0] for _ in range(N)]
for i in range(N):
  a, b, c = map(int, input().split())
  if i == 0:
    dp[i] = [a, b, c]
  else:
    dp[i][0] = max(dp[i-1][1]+a, dp[i-1][2]+a)
    dp[i][1] = max(dp[i-1][0]+b, dp[i-1][2]+b)
    dp[i][2] = max(dp[i-1][0]+c, dp[i-1][1]+c)
print(max(dp[-1]))

Measured memory_bytes: 54192
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
        string S;
        int N;
        int K;
        cin >> K >> N;
        cin >> S;

        S[N-1] = S[N-1] - 'A' + 'a';

        for(int i = 0; i < S.size(); i++) cout << S[i];
        cout << endl;

        return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    ll k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK\n";
            return;
        }
    }
    cout << "NG\n";
}

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


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int N;
string input;
char Ch[4]={'P', 'G', 'W', 'Y'};
int Cnt[4]={0, 0, 0, 0};
int Ans=0;

int main(){
	ios_base::sync_with_stdio(false);
	
	cin >> N;
	while(N--){
		cin >> input;
		for(int i=0;i<4;++i)
			if(input[0]==Ch[i])
				++Cnt[i];
	}
	
	for(int i=0;i<4;++i)
		if(Cnt[i]!=0)	++Ans;
	
	if(Ans<4)	cout << "Three" << endl;
	else	cout << "Four" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import heapq

N, K = list(map(int, input().split()))
td = []
td_ = []
group = set()
total = 0

for i in range(N):
    t, d = list(map(int, input().split()))
    heapq.heappush(td, (-d, t))

for i in range(K):
    d, t = heapq.heappop(td)
    total -= d
    if t not in group:
        group.add(t)
    else:
        heapq.heappush(td_, -d)

length = len(group)
ans = length**2 + total

while td and td_:
    d, t = heapq.heappop(td)

    if t not in group:
        group.add(t)
        d_ = heapq.heappop(td_)
        total = total - d_ - d
        length += 1
        ans = max(ans, length**2 + total)
print(ans)

Measured memory_bytes: 19252
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if A[0]*T[0]+A[1]*T[1] == B[0]*T[0]+B[1]*T[1]:
  print('infinity')
else:
  if A[0]*T[0]+A[1]*T[1] < B[0]*T[0]+B[1]*T[1]:
    C = A
    A = B
    B = C
  if A[0] > B[0]:
    print('0')
  else:
    bcover = (B[0]-A[0])*T[0]
    tcover = A[0]*T[0]+A[1]*T[1] - B[0]*T[0]-B[1]*T[1]
    if bcover%tcover == 0:
      print(int(bcover/tcover)*2)
    else:
      print(int(bcover/tcover)*2+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    
    vpair rl;
    rl.emplace_back(a[0], 1);
    for (int i = 1; i < n; ++i) {
        if (a[i] == rl.back().fi) rl.back().se++;
        else rl.emplace_back(a[i], 1);
    }

    int ans = 0;
    for(auto x : rl) {
        ans += x.se/2;    
    }

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

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main(){
    int N;
    cin >> N;
    vi a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    long long ans=a[0];
    for(int i=1;i<N-1;i++){
        ans+=a[(i+1)/2];
        //cout << a[(i+1)/2] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define x first
#define y second

using namespace std;

const string FILENAME = "input";

int main(int argc, char const *argv[])
{
	string s, t; cin >> s >> t;
	for (int i = 0; i < s.length(); i++)
	{
		char c = s[s.length() - 1];
		s.erase(s.length() - 1, s.length());
		s = c + s;
		if (s == t)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main() {

  int in0, in1, in2;

  while( cin >> in0 >> in1 >> in2 ) {

    int ans = 0;
    for ( int i = 1; i <= 10; i++ ) {
      if ( i != in0 && i != in1 && i != in2 && in0 + in1 + i <= 20 ) ans++;
    }
    if ( ans >= 4 ) {
      cout << "YES" << endl;
    }else {
      cout << "NO" << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 1152
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int D[N];
  for (int i = 0; i < N; i++)
    cin >> D[i];
  int M;
  cin >> M;
  int T[M];
  for (int i = 0; i < M; i++)
    cin >> T[i];
  map<int, int> md;
  for (int i = 0; i < N; i++)
    md[D[i]]++;
  map<int, int> mt;
  for (int i = 0; i < M; i++)
    mt[T[i]]++;
  string ans = "YES";
  for (auto t : mt)
  {
    int key = t.first;
    if (md[key] < mt[key])
      ans = "NO";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 20608
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	int x,y,z;
	cin >> x >> y >> z;
	if(x+y+z >= 22)
		cout << "bust\n";
	else
		cout << "win\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
string s;
std::cin >> x;
if(x==1)std::cout << 1 << '\n';
else if(x%2==0)std::cout << 0.5 << '\n';
else std::cout << double((x/2+1)/(double)x) << '\n';
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

vector<long long> Factrization(long long X);
    //////////////////////////////////////////
    //    因数分解する関数
    //    in   : 整数
    //    out  : 2次元のvector 
    //    ver  : 1.0
    //    概要 : 正の整数での使用のみを想定
    //    include: <vector>, <cmath>
    //////////////////////////////////////////

int main(){
    long long A, B, t_a, t_b;
    long long koyaku = 1;
    std::cin >> A >> B;

    vector<long long> fact_A, fact_B;
    fact_A = Factrization(A);
    fact_B = Factrization(B);

    for(long long i = 0; i < fact_A.size(); i ++){
        t_a = fact_A[i];
        // std::cout << t_a << " ";
        for(long long j = 0; j < fact_B.size(); j++){
            if(fact_B[j] == t_a){
                if(fact_B[j] > koyaku){
                    koyaku = fact_B[j];
                }
            }
        }
    }
    // std::cout << "\n";

    std::cout << A * B / koyaku;

}

vector<long long> Factrization(long long X){
    vector<long long> factors = {};
    int n_loop, a, b;

    n_loop = (long long)floor(sqrt((float)X));
    for(long long i =1; i <= n_loop; i++){
        if(X%i == 0){
            a = i;
            b = X/i;
            factors.push_back(a);
            factors.push_back(b);
        }
    }
    return factors;
}

Measured memory_bytes: 3576
import sys
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
for i in range(N-2):
  k = 0
  for j in range(3):
    if D[i+j][0] == D[i+j][1]:
      k += 1
  if k == 3:
    print('Yes')
    sys.exit()
print('No')    

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a==1&&b!=1)
        cout<<"Alice"<<endl;
    else if (a!=1&&b==1)
        cout<<"Bob"<<endl;
    else
    {
        if(a>b)
            cout<<"Alice"<<endl;
        else if (a<b)
            cout<<"Bob"<<endl;
        else
            cout<<"Draw"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256