akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

long long pow(long long x,long long n){
	long long re=1;
	for(int i=0;i<n;i++)re*=x;
	return re;
}

int main(){
	int k=0;
	while(k<10){
		cout<<"? "<<pow(10,k+1)<<endl;
		cout.flush();
		string ans;
		cin>>ans;
		if(ans=="N")break;
		k++;
	}
	if(k==10){
		k=0;
		while(k<10){
			cout<<"? "<<2*pow(10,k)<<endl;
			cout.flush();
			string ans;
			cin>>ans;
			if(ans=="Y")break;
			k++;
		}
		cout<<"! "<<pow(10,k)<<endl;
	}
	else{
		long long l=pow(10,k),r=pow(10,k+1)-1;
		while(r-l>0){
			long long m=(r+l)/2;
			cout<<"? "<<10*m<<endl;
			cout.flush();
			string ans;
			cin>>ans;
			if(ans=="Y")r=m;
			else l=m+1;
		}
		cout<<"! "<<r<<endl;
	}
	cout.flush();
}


Measured memory_bytes: 596
#include<stdio.h>

int n, G[110][110], d[110], f[110], c[110];
int t = 0;

void visit(int u){

  int i, j, v;

  c[u] = 1;
  d[u] = ++t;
  
  for(i = 1; i <= n; i++)
    if(G[u][i] == 1 && c[i] == 0) visit(i);

  c[u] = 2;
  f[u] = ++t;
  
}

int main(){
   
  int i, j, k, u, v; 

  scanf("%d", &n);
  
  for(i = 1; i <= n; i++){
   c[i] = 0;
    for(j = 1; j <= n; j++){
      G[i][j] = 0;
    }
  }
  
  t = 0;

  for(i = 1; i <= n; i++){
    
    scanf("%d%d", &u, &k);
    
    for(j = 1; j <= k; j++){
      
      scanf("%d", &v);
      
      G[u][v] = 1;
    
    }
    
  }
  
  for(i = 1; i <= n; i++)
    if(c[i] == 0) visit(i);
  
  for(i = 1; i <= n; i++)
    printf("%d %d %d\n", i, d[i], f[i]);
  
  return 0;
  
}

Measured memory_bytes: 648
solve :: [String] -> [Int]
solve (a:op:b:xs)
  | op == "?" =	[]
  | op == "+" =	(read a + read b) : solve xs
  | op == "-" = (read a - read b) : solve xs
  | op == "*" =	(read a * read b) : solve xs
  | op == "/" = floor (read a / read b) : solve xs

main = getContents >>= mapM_ print . solve . words

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

int cnt[510];

int main(){
	int k; cin >> k;
	if (k == 1){
		printf("1\n1\n");
		return 0;
	}
	int n = (k + 3) / 4 * 2;
	cout << n << endl;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			int x = (i + j) % n ? (i + j) % n : n;
			if (i % 2 == 0) x = x + n > k ? x : x + n;
			printf("%d ", x);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,K;
    cin>>N>>K;
    vector<double> S(N+1,0.0);
    double ans=0;
    REP(i,N){
        int p;cin>>p;
        double E=p*(1+p)/(2.0*p);
        S[i+1]=S[i]+E;
        if(i>=K-1) ans=max(ans,S[i+1]-S[i-K+1]);
    }
    printf("%.16f",ans);
}


Measured memory_bytes: 1792
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

fetch_one_line()
nums = fetch_int_input()
now_num = 1
remove_num = 0

for n in nums:
    if n == now_num:
        now_num += 1
    else:
        remove_num += 1


if now_num == 1:
    remove_num = -1

print(remove_num)




Measured memory_bytes: 71324
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;
int a[N];
int boom[N];
vector <int> v;
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }

    for(int i=n; i>=1; i--)
    {
        ll sum=0;
        for(int j=1; j*i<=n; j++)
        {
            sum+=boom[i*j];
        }
        sum%=2;
        if(a[i]!=sum) v.push_back(i),boom[i]=1;

    }
    cout<<v.size()<<endl;
    for(int i:v) cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 5340
package main

import (
	"fmt"
)

func main() {
	x := make([]int, 5)
	answer := 0
	for i:=0; i < 5; i ++ {
		fmt.Scanf("%d", &x[i])
		if x[i] == 0 {
			answer = i + 1
		}
	}

	fmt.Printf("%d", answer)
}


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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N, K;
    string s;
    cin >> N >> K >> s;
    int ans = 0;
    rep(i, N-1) {
        if(s[i] == s[i+1]) ans++;
    }
    //N-ans人のRLRL...かLRLR...
    int rem = N-ans;
    int trial = 0;
    while(trial < K && rem >= 2){
        if(rem == 2){
            ans++;
            rem--;
        }
        else{
            ans += 2;
            rem -= 2;
        }
        trial++;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

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

int main()
{
    string str;
    cin >> str;
    set<char> s;
    for(auto c: str){
        s.insert(c);
    }
    
    for(int i=0; i<26; i++){
        if(s.count('a'+ i) == 0) {
            char c = 'a' + i;
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

INF = 10**9+7

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, m = rli()
    la = [False for _ in range(100001)]
    for _ in range(m):
        la[ri()] = True
    dp = [0 for _ in range(100001)]
    dp[0] = 1
    for i in range(1, n+1):
        if la[i]:
            dp[i] = 0
        else:
            dp[i] = (dp[i-1]+dp[i-2]) % INF
    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 7832
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

map<int, int> ma;
const int MAXN = 200005, MAXM = 800005;
struct node{
    int l, r;
    ll sum;
}tree[MAXM];
int n, c;
ll ans;
ll a[MAXN], b[MAXN];

void pushup(int q){
    tree[q].sum = tree[q << 1].sum + tree[q << 1 | 1].sum;
}

void build(int q, int l, int r){
    tree[q].l = l;
    tree[q].r = r;
    if(l == r){
        tree[q].sum = 0;
        return;
    }
    int mid = (l + r) >> 1;
    build(q << 1, l, mid);
    build(q << 1 | 1, mid + 1, r);
    pushup(q);
}

void update(int q, int x, int y){
    if(tree[q].l > x || tree[q].r < x) return;
    if(tree[q].l == x && tree[q].r == x){
        tree[q].sum += y;
        return;
    }
    update(q << 1, x, y);
    update(q << 1 | 1, x, y);
    pushup(q);
}

void query(int q, int l, int r){
    if(tree[q].l > r || tree[q].r < l) return;
    if(tree[q].l >= l && tree[q].r <= r){
        ans += tree[q].sum;
        return;
    }
    query(q << 1, l, r);
    query(q << 1 | 1, l, r);
}

void solve(){
    sort(b, b + n + 1);
    c = unique(b, b + n + 1) - b;
    for (int i = 0; i <= n; i++)
        a[i] = lower_bound(b, b + c + 1, a[i]) - b + 1;
}

int main(){
    int k, m = 0;
    scanf("%d%d", &n, &k);
    ll res = 0;
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        a[i] -= k; a[i] += a[i - 1];
        b[i] = a[i];
    }
    solve();
    build(1, 0, n);
    for(int i = 0; i <= n; i++){
        ans = 0;
        query(1, 0, a[i]);
        res += ans;
        update(1, a[i], 1);
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a) memset(a, 0x00, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("out.txt","w",stdout)
#define pb push_back
#define pp pop_back
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout << "hi" << endl
typedef long long ll;

using namespace std;

struct process
{
    string name;
    int time;
};

int main()
{
    //iDEBUG;
    queue<process> qq;

    int n, q;
    cin >> n >> q;
    for(int i=0; i<n; i++)
    {
        process tmp;
        cin >> tmp.name >> tmp.time;
        qq.push(tmp);
    }

    int T = 0;
    while(!qq.empty())
    {
        process tmp = qq.front();
        qq.pop();
        if(tmp.time <= q)
        {
            T += tmp.time;
            cout << tmp.name << " " << T << endl;
        }
        else
        {
            T += q;
            tmp.time -= q;
            qq.push(tmp);
        }

    }

    return 0;
}


Measured memory_bytes: 6328
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

ans = 0
for i in range(N):
    min_ = min(A[i], B[i])
    A[i] -= min_
    B[i] -= min_
    ans += min_
    min_ = min(A[i+1], B[i])
    A[i+1] -= min_
    B[i] -= min_
    ans += min_


print(ans)


Measured memory_bytes: 18624
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
#define sag (sol|1)
//#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
#define N (int)(1e5+10)
//#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;

vl vec ;
void func( ){
    ll a = (ll)1e14;
    ll tmp = 1;
    while(tmp < a){
        vec.pb(tmp);
        tmp*=2;
    }

}

signed main() {
    IOS
    func();
    int size = vec.size();
    ll h;
    cin >> h;

    size--;
    while(vec[size] > h){

        size--;
    }
    size+=1;

    cout<< vec[size]-1;
    return 0;

}



Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;
// use std::cmp::max;
// use std::cmp::min;

fn main() {
    input! {
        X: u64,
        Y: u64,
    }

    if X % Y == 0 {
        println!("-1");
        return;
    }

    if Y == 1_000_000_000u64 {
        println!("{}", X);
        return;
    }

    let ans: u64 = X * (Y + 1);
    println!("{}", ans);
}


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

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

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

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int x, y;
    cin >> x >> y;

    if(max(x,y)-min(x,y)<=1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,k = gets.chomp.split.map &:to_i
a = gets.chomp.split.map &:to_i

div = 10**9 + 7
ten = 0
bits = Array.new(2001,0)

a.each_with_index do |aa, i|
  ten += i - bits[0..aa].sum
  ten %= div
  bits[aa] += 1
end

ten2 = 0
a.each_with_index do |aa,i|
  ten2 += a.count{|v| v<aa}
end
tenk = ten * k % div
ten2k = ten2 * k * (k-1) / 2 % div
ans = tenk + ten2k

puts ans % div


Measured memory_bytes: 44888
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  cout<<(b+a-1)/a<<endl;
  return 0;
}



Measured memory_bytes: 3096
N = int(input())
h = list(map(int,input().split()))

ans = 0

while True:
    if not sum(h):
        break
    for l in range(N):
        if h[l]:
            break
    for r in range(l,N):
        if not h[r]:
            r -= 1
            break
    for i in range(l,r+1):
        h[i] -= 1
    ans += 1

print(ans)


Measured memory_bytes: 3060
import numpy as np
# 座標を入力
sx, sy, tx, ty = map(int, input().split())
S = np.array([sx, sy])
T = np.array([tx, ty])

# 2点の最短経路を返す関数を定義（左右移動優先かつ方向転換1回のみ） 
def shortest_path(start, end):
    if start[0] <= end[0]:
        lr_path = "R" * (end[0] - start[0])
    else:
        lr_path = "L" * (start[0] - end[0])
    if start[1] <= end[1]:
        ud_path = "U" * (end[1] - start[1])
    else:
        ud_path = "D" * (start[1] - end[1])
    return lr_path + ud_path

# 点Sから点Tまでの経路（1回目）
path_1 = shortest_path(S, T)
# 点Tから点Sまでの経路（1回目）
path_2 = shortest_path(T, S)
# 点Sから点Tまでの経路（2回目）
path_3 = "D" + shortest_path(S + np.array([0, -1]), T + np.array([1, 0])) + "L"
# 点Tから点Sまでの経路（2回目）
path_4 = "U" + shortest_path(T + np.array([0, 1]), S + np.array([-1, 0])) + "R"
# 全経路を出力
print(path_1 + path_2 + path_3 + path_4)

Measured memory_bytes: 12512
#include<bits/stdc++.h>
const int maxn=8e2+10;
using namespace std;
char a[maxn][maxn];
int stmp[maxn][maxn];
int direction[4][2]={1,0,-1,0,0,1,0,-1};
int n,m,k;
int ans=99999999;
bool check(int x,int y)
{
    if(x>=0&&x<n&&y>=0&&y<m&&stmp[x][y]==0&&a[x][y]=='.')
    {
       return 1;
    }
    return 0;
}
queue<pair<int,int> >po;
int main()
{
    cin>>n>>m>>k;
    int sx,sy;
    getchar();
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            scanf("%c",&a[i][j]);
            if(a[i][j]=='S')
            {
                sx=i;
                sy=j;
            }
        }
        getchar();
    }
    stmp[sx][sy]=1;
    po.push(make_pair(sx,sy));
    while(!po.empty())
    {
        int x=po.front().first;
        int y=po.front().second;
        ans=min(ans,min(min(x,n-x-1),min(y,m-y-1)));
        po.pop();
        for(int i=0;i<4;i++)
        {
            int xx=x+direction[i][0];
            int yy=y+direction[i][1];
            if(check(xx,yy)&&stmp[x][y]<=k)
            {
               stmp[xx][yy]=stmp[x][y]+1;
               po.push(make_pair(xx,yy));
            }
        }
    }
    int anss;
    anss=1+(ans+k-1)/k;
    cout<<anss<<endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str="";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}

int main() {
	int n, k; cin >> n >> k;
	int sum = 0, x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		sum += 2*min(k - x, x);
	}
	cout << sum;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vvll edges;
vll col;
ll bc = 0, wc = 0;

bool dfs(ll i, ll c) {
    if (col[i] != -1 && col[i] != c) return false;
    col[i] = c;
    if (c == 0) bc++;
    else wc++;
    REP(e, edges[i].size()) {
        if (edges[i][e] == 1) {
            if (col[e] == -1) {
                if (!dfs(e, c ^ 1)) return false;
            } else {
                if (col[i] == col[e]) return false;
            }
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    edges.resize(n, vll(n, 1));
    col.resize(n, -1);
    REP(i, n) edges[i][i] = 0;
    REP(i, m) {
        ll a, b; cin >> a >> b;
        edges[a - 1][b - 1] = 0;
        edges[b - 1][a - 1] = 0;
    }

    V< P<ll, ll> > stset;
    REP(i, n) {
        if (col[i] != -1) continue;
        if (!dfs(i, 0)) {
            cout << -1 << '\n';
            return 0;
        } else {
            stset.emplace_back(wc, bc);
            wc = 0, bc = 0;
        }
    }

    vll dp(n + 1, 0);
    dp[0] = 1;
    REP(i, stset.size()) {
        for (ll j = n; j >= 0; j--) {
            if (dp[j] == 1) {
                dp[j] = 0;
                dp[j + stset[i].first] = 1;
                dp[j + stset[i].second] = 1;
            }
        } 
    }

    ll ans = HIGHINF;
    REP(i, n + 1) {
        if (dp[i] == 1) chmin(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 4096
/* while(!cin.eof()) */

#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e18+100)
#define N 1000200 

int fre[N];

// Driver code to test above functions
int32_t main()
{
    
 
    

    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];

    int x = 1, ans = 1;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
            x++;
        else
        {
            ans = max(ans, x);
            x = 1;
        }
    }
    ans = max(ans, x);

    cout << ans-1;


    return 0;  
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll w, h, n;
  cin >> w >> h >> n;
  vector<vector<bool>> s(h, vector<bool>(w, true));
  rep(i, n){
    ll x, y, a;
    cin >> x >> y >> a;
    if(a==1){
      rep(j,h){
        rep(k,x){
          s[j][k] = false;
        }
      }
    }
    else if(a==2){
      rep(j,h){
        for (ll k = x; k < w;k++){
          s[j][k] = false;
        }
      }
    }
    else if(a==3){
      rep(j,y){
        rep(k,w){
          s[j][k] = false;
        }
      }
    }
    else if(a==4){
      for (ll j = y; j < h;j++){
        rep(k,w){
          s[j][k] = false;
        }
      }
    }
  }
  ll area=0;
  rep(i, h){
    rep(j,w){
      if(s[i][j]){
        area++;
      }
    }
  }
  print(area);
}

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

using namespace std;

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

    int t = 1;
    while (t * 2 < t + k and n) {
        t *= 2;
        n--;
    }

    t += k * n;

    cout << t << endl;

    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  int x = c-a, y = d-b;
  printf("%d %d %d %d\n", c-y, d+x, a-y, b+x);

  return 0;
}




Measured memory_bytes: 256
N, A = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
mat = {}
def dp(i: int, x: list) -> int:
  sumx = sum(x)
  lenx = len(x)
  if i == N:
    if lenx and sumx == A * lenx:
      return 1
    else:
      return 0
  if (i, sumx, lenx) in mat:
    return mat[(i, sumx, lenx)]
  ret = dp(i + 1, x[:]) + dp(i + 1, x[:] + [X[i]])
  mat[(i, sumx, lenx)] = ret
  return ret

print(dp(0, []))

Measured memory_bytes: 49244
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<i64>();
    for i in 0..n {
        a[i] -= i as i64 + 1;
    }
    a.sort();
    let mut ans = 0;
    let b = a[n/2];
    for i in 0..n {
        ans += (a[i] - b).abs();
    }
    println!("{}",ans);
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <string.h>
 
char map[22][22], mk[22][22];
int que[500][2], top, end;
int m[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};
 
int main()
{
    int w, h, i, r, c, r2, c2, ans;
     
    while (scanf("%d%d", &w, &h) && w) {
        memset(mk, 0, sizeof(mk));
        for (i = 0, r = 0; r < h; r++) {
            scanf("%s", map[r]);
            if (!i) for (c = 0; c < w; c++) if (map[r][c] == '@') {
                que[0][0] = r, que[0][1] = c; mk[r][c] = 1, top = 0, end = 1, i = 1;
            }
        }
        while (top < end) {
            r = que[top][0], c = que[top++][1];
            for (i = 0; i < 4; i++) {
                r2 = r + m[i][0], c2 = c + m[i][1];
                if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w || map[r2][c2] == '#') continue;
                if (mk[r2][c2]) continue;
                mk[r2][c2] = 1;
                que[end][0] = r2, que[end++][1] = c2;
            }
        }
        for (ans = 0, r = 0; r < h; r++) for (c = 0; c < w; c++) ans += mk[r][c];
        printf("%d\n", ans);
    }
    return 0;
}


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

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

  vector<LL> primeF(n + 1);
  for (LL i = 2; i <= n; i ++) {
    LL tmp = i;
    for (LL j = 2; j <= i; j ++) {
      while (tmp % j == 0 && tmp > 0) {
        primeF.at(j) ++;
        tmp /= j;
      }
    }
  }

  LL ans = 1;
  for (LL i = 0; i <= n; i ++) {
    if (primeF.at(i) != 0) {
      ans *= primeF.at(i) + 1;
      ans %= 1000000007;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	map<long long,long long> mp1, mp2;
	for(long long i=0; i<n; ++i){
		long long a;
		cin >> a;
		++mp1[i+a];
		++mp2[i-a];
	}

	long long ans=0;
	for(auto i: mp1){
		ans += i.second*mp2[i.first];
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 37756
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    as <- getIntList
    let zs = zipWith (<) as (drop k as)
    let ans = map (\t -> if t then "Yes" else "No") zs
    mapM_ putStrLn ans


Measured memory_bytes: 27072
n = gets.to_i
a = Array.new(n) { gets.to_i }
done = Array.new(n + 1, false)

i = 1
res = 0
n.times do |_|
  break if i == 2
  if done[i]
    res = -1
    break
  end
  
  done[i] = true
  i = a[i - 1]
  res += 1
end

puts res

Measured memory_bytes: 3708
#include <stdio.h>
#include <math.h>
typedef struct {
        double x;
        double y;
}Point;
#define PI 3.141592
void kock(int n,Point p1,Point p2){
        Point s,t,u;
        if(n==0) {
                return;
        }
        s.x=(2*p1.x+p2.x)/3;
        s.y=(2*p1.y+p2.y)/3;
        t.x=(p1.x+2*p2.x)/3;
        t.y=(p1.y+2*p2.y)/3;

        u.x=(t.x-s.x)*cos(60*M_PI/180)-(t.y-s.y)*sin(60*M_PI/180)+s.x;
        u.y=(t.x-s.x)*sin(60*M_PI/180)+(t.y-s.y)*cos(60*M_PI/180)+s.y;

        kock(n-1,p1,s);
        printf("%f %f\n",s.x,s.y);
        kock(n-1,s,u);
        printf("%f %f\n",u.x,u.y);
        kock(n-1,u,t);
        printf("%f %f\n",t.x,t.y);
        kock(n-1,t,p2);
}

int main(){
        int n;
        Point p1,p2;
        p1.x=0;
        p1.y=0;
        p2.x=100;
        p2.y=0;
        scanf("%d",&n);
        printf("%f %f\n",p1.x,p1.y);
        kock(n,p1,p2);
        printf("%f %f\n",p2.x,p2.y);
        return 0;

}

Measured memory_bytes: 636
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

int main()
{
	char C = 0;
	scanf("%c", &C);
	printf("%c\n", C+1);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    int n, r;
    in >> n, r;
    out(n >= 10 ? r : r + 100 * (10 - n));
}

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


Measured memory_bytes: 256
a,b,k = map(int,input().split())
w = 0
for i in range(k):
    if w %2 ==0:
        if a%2 == 1:
            a = a-1
        b += a//2
        a = a//2
    if w %2 == 1:
        if b %2 == 1:
            b = b-1
        a += b//2
        b = b//2
    w += 1
print(str(a)+' '+str(b))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    ll y[x];
    for (int i=0; i<x; i++)
        cin>>y[i];
    sort(y,y+x);
    ll sum=0,ans=1e9;
    for (int i=-100; i<=101; i++)
    {
        sum=0;
        for (int j=0; j<x; j++)
        {
            sum+=abs(i-y[j])*abs(i-y[j]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Tsuruga Castle
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] c = new int[7];
			while(n--!=0){
				int x = sc.nextInt();
				int k = 0;
				while(k<6&&x>=(k+1)*10)k++;
				c[k]++;
			}
			for(int a:c)System.out.println(a);
		}
	}
}

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

int mark_right[MAX],mark_left[MAX],a[MAX],n;
long long int res = 0;

int mark_greater(int ar[]){
	for (int i=0;i<=n;i++) mark_left[i] = mark_right[i] = -1;
	int s[n][2],top=0;
	s[0][0] = ar[0];
	s[0][1] = 0;
	int i=1;
	while(i<n){
		if (top==-1||s[top][0]<=ar[i]){
			s[++top][0] = ar[i];
			s[top][1] = i;
			i++;
		}
		else{
			mark_right[s[top][1]] = i;
			top--;
		}
	}
	top=0;
	s[0][0] = ar[n-1];
	s[0][1] = n-1;
	i=n-2;
	while(i>=0){
		if (top==-1||s[top][0]<ar[i]){
			s[++top][0] = ar[i];
			s[top][1] = i;
			i--;
		}
		else{
			mark_left[s[top][1]] = i;
			top--;
		}
	}

	for (int i=0;i<n;i++){
		long long int temp = ar[i];
		long long int l,r;
		l = mark_left[i];
		r = mark_right[i]==-1?n:mark_right[i];
		long long int temp1 = (i-l)*(r-i);
		res+=temp1*temp;
	}

	return 0;
}


int main(){
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	mark_greater(a);
	cout << res;
	return 0;
}


Measured memory_bytes: 4096
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n , h = IN()
	al=[]
	bl=[]
	for i in range(n):
		a,b=IN()
		al.append(a)
		bl.append(b)
		
	bl.sort(reverse=True)
	al.sort()
	a_max=al[-1]
	
	cc=0
	cc_h=h
	for v in bl:
		if v < a_max:
			break
		cc_h-=v
		cc+=1
		if cc_h<=0:
			return cc
	
	cc+=(cc_h + a_max - 1)//a_max
	return cc	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 59736
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{	
	int H, W;

	for (int i = 0;i < 10000;i++)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int j = 0; j < H; j++)
		{
			for (int k = 0; k < W; k++)
			{
				if ((j+k)%2==0) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 2996
#L,Rの境界の数だけで処理を済ませる
#⇒いちいち書いてあるとおりに実装しない。

#内側の不幸な人を(RLの人)を消せば幸福な人が2人増える (全部Rに変えていくイメージ)
# ⇒着目するのは RL でも LR　でもどっちでもいい。
#  LRに注目する場合はこのあとのコードのRとLに関連する部分が逆になるだけ
#端っこなら１人増える
#幸福な人の最大値は N - 1

N,K = map(int,input().split())
S = input()

#端以外の人のせいで不幸な人の数
count = 0
#端の人のせいで不幸な人の数
edge_count = 0

#端のせいで不幸な人
if S[0] == 'L':
    edge_count += 1
if S[N-1] == 'R':
    edge_count += 1 

#端以外のせいで不幸になっている人の数を数える (RLを探す)
for i in range(N-1):
    if S[i] == 'R':
        if S[i+1] == 'L':
            count += 1

#最初の時点で幸せになれる人の数
happy = N  - (count*2 + edge_count)

#操作回数KがRLの数より小さい
if count >= K:
    print(min(N-1, K * 2 + happy  ))
#操作回数K がRLの数より大きい
else:
    print(min(N-1, K * 2 + happy + (min(edge_count,K - count) )))


Measured memory_bytes: 39408
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    for i in reversed(range(5,10)):
        if n % i == 0:
            n = n // i
        break
    for i in range(1,10):
        if n % i == 0 and n // i <= 9:
            print("Yes")
            return
    print("No")
            
    
    
main()

Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}
//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(9);
    }
} All_init;


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


    


    
}


Measured memory_bytes: 384
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto w = RD!string;
	auto cnt = new long[](26);
	foreach (e; w)
		++cnt[e-'a'];

	bool ans = true;
	foreach (e; cnt)
		if (e % 2 != 0)
			ans = false;
	
	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    map<string,int> t;
    rep(i,n){
        string s;
        cin>>s;
        t[s]++;
    }
    int max=0;
    for(auto p:t){
        if(max<p.second)max=p.second;
    }
    for(auto p:t){
        if(p.second==max)cout<<p.first<<endl;
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int N,A[200];
    int temp = 0, cnt = 0;

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

    do{
        for(int i = 0; i < N; i++)
        {
            temp += A[i] % 2;
        }

        if(temp == 0){
            for(int i = 0; i < N; i++)
            {
                A[i] /= 2;
            }
            cnt++;
        }
    }while(temp == 0);

    cout << cnt << endl;

}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W;
long long A[200005] = {};
long long B[201][201] = {};
long long C[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;

char ch[100][100];

int main() {


	cin >> a>>b>>c;
	vl.push_back(a);
	vl.push_back(b);
	vl.push_back(c);
	sort(vl.begin(), vl.end());

	cout << vl[0] + vl[1] << endl;
	
	return 0;

}


Measured memory_bytes: 2304
#include <bits/stdc++.h> 
using namespace std;
int main()
{
  int x,y,i;
  cin>>x>>y;
    string ans;
  ans="No";
  if(y/2==x && y%2==0)
    ans="Yes";
  if(y/4==x && y%4==0)
    ans="Yes";
  else
  {
    for(i=1;i<=x;i++)
    {
      if((i*4)+((x-i)*2)==y)
        ans="Yes";
    }
  }
  cout<<ans;
  return 0;
}
  

Measured memory_bytes: 3620
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

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

    d n,a,b,c,f,e;
    cin>>n>>a>>b>>c>>f>>e;
    cout<<(int)(ceil(n/min({a,b,c,f,e}))+4);



    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
    cout << a*b << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    #b = [list(map(int,input().split())) for i in range(n)]
    for bingo in  (int(input()) for _ in range(n)):
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return
    for i in range(3):
        if (a[i][0] == a[i][1] == a[i][2] == 0) or (a[0][i] == a[1][i] == a[2][i] == 0):
            print("Yes")
            return
    print("No")
B()

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

int main()
{
    int n; cin >> n;
    int grid[2][100] = {0};
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> grid[i][j];
        }
    }

    int answer = 0;
    for(int i = 0; i < n; i++){
        int candies = 0;
        for(int j = 0; j < n; j++){
            if(j <= i) candies += grid[0][j];
            if(j >= i) candies += grid[1][j];
        }
        answer = max(answer, candies);
    }
    cout << answer << endl;
}


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

using namespace std;

#define sp << " " <<
#define mod 1000000007

/*mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long dice()
{
    uniform_int_distribution<long long> uid(1,2);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[11];
    buf[10] = '\n';
    int i = 9;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}
*/

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int d=0,p=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            d++;
        else
            p++;
    }
    if(d>p)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll x, y;
    cin >> x >> y;
    if (x % y == 0) {
        cout << -1 << endl;
    } else {
        cout << x << endl;
    }
    return 0;
}



Measured memory_bytes: 256