akhauriyash/Code-Regression huggingface dataset:
/**
*    author:  souzai32
*    created: 12.08.2020 12:09:20
**/

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

int main() {

    int n;
    cin >> n;
    int num=1;

    while(true){
        if(num*(num+1)/2>=n){
            cout << num << endl;
            n-=num;
            break;
        }
        else num++;
    }

    while(n>0){
        num--;
        if(num>=n){
            cout << n << endl;
            n=0;
        }
        else{
            cout << num << endl;
            n-=num;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll T = X / D;
    ll t = min(T, K);
    K -= t;
    X -= D * t;
    K %= 2;
    while(K--) {
        if(X < 0) X += D;
        else X -= D;
    }
    cout << abs(X) << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

string s;
int d[70000000];
int a[200010];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> s;
	int n = (int)s.size();
	for (int i = 1; i <= n; i++)a[i] = a[i - 1] ^ (1 << (s[i - 1] - 'a'));
	fill(d + 1, d + 70000000, 1000000000);
	for (int i = 1; i <= n; i++) {
		int mi = d[a[i]];
		for (int j = 0; j < 26; j++)mi = min(mi, d[a[i] ^ (1 << j)]);
		if (i == n)d[a[i]] = mi + 1;
		else d[a[i]] = min(d[a[i]], mi + 1);
	}
	cout << d[a[n]] << endl;
}

Measured memory_bytes: 277980
program atcoder
    implicit none
    integer(8) :: i,j,n,m,ans=0,k,mincost=-1,use2max=-1
    integer(8),allocatable,dimension(:) :: a,canuse,cost
    character(len=10000),allocatable,dimension(:) :: dp,x
    read*,n,m
    allocate(a(m))
    allocate(canuse(9))
    allocate(cost(9))
    allocate(dp(0:n))
    dp = "-"
    x = (/"1","2","3","4","5","6","7","8","9"/);
    cost = (/2,5,5,4,5,6,3,7,6/)
    read(*,*)(a(j),j=1,m)
    dp(0) = ""
    do i=0,N
        if(trim(dp(i))=="-")then
            cycle
        endif
        do j=1,m
            if(i+cost(a(j)) > N )then
                cycle
            endif
           dp(i+cost(a(j))) = maxst( dp(i+cost(a(j))) , trim(dp(i))//x(a(j)) )
        enddo
    enddo
    write(*,'(a)')trim(dp(n))
    stop 
contains
function maxst(x,y)
    character maxst*10000,x*10000,y*10000
    if(x=="-")then
        maxst = y
    else if(y=="-")then
        maxst = x
    else if(len(trim(x))>len(trim(y)))then
        maxst = x
    else if(len(trim(x))<len(trim(y)))then
        maxst = y
    else if(x>=y)then
        maxst = x
    else
        maxst = y
    endif
end function maxst
end program atcoder

Measured memory_bytes: 98280
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

ll a, b;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> a >> b;
    cout << (a*b)/(__gcd(a,b)) << endl;;

    return 0;
}

//cikisir



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[88],a[88];

int main(void){
	int n,i,j,k;
	dp[0] = 1000ll;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	for(i=0; i<n; ++i){
		dp[i+1] = dp[i];
		for(j=0; j<i; ++j){
			dp[i+1] = std::max(dp[i+1],dp[j]%a[j]+a[i]*(dp[j]/a[j]));
		}
	}
	std::cout << dp[n] << std::endl; 
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=8 && b<=8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(input()) for i in range(n)]

def segfunc(x,y):
  return max(x,y)

def init(init_val):
  for i in range(n):
    seg[i+num-1]=init_val[i]
  for i in range(num-2,-1,-1):
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
  k+=num-1
  seg[k]=x
  while k:
    k=(k-1)//2
    seg[k]=segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
  if q<=p:
    return ide_ele
  p+=num-1
  q+=num-2
  res=ide_ele
  while q-p>1:
    if p&1==0:
      res=segfunc(res,seg[p])
    if q&1==1:
      res=segfunc(res,seg[q])
      q-=1
    p=p//2
    q=(q-1)//2
  if p==q:
    res=segfunc(res,seg[p])
  else:
    res=segfunc(segfunc(res,seg[p]),seg[q])
  return res

ide_ele=0

num=3*10**5+1
seg=[ide_ele]*2*num

dp=[0]*(max(a)+1)
dp[a[0]]=1
update(a[0],1)
for i in range(1,n):
  dp[a[i]]=query(max(a[i]-k,0),min(a[i]+k+1,3*10**5+1))+1
  update(a[i],dp[a[i]])
print(max(dp))

Measured memory_bytes: 111684
#include <iostream>
using namespace std;
int main() {
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if (op == '+'){
            cout << a + b << endl;
        }
        else if (op == '-'){
            cout << a - b << endl;
        }
        else if (op == '*'){
            cout << a*b << endl;
        }
        else if (op == '/'){
            cout << a/b << endl;
        }
        else{
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3100
from bisect import bisect_left

class SegmentTree:
    def __init__(self, N):
        self.N = 2 * pow(2, N.bit_length()) - 1
        self.data = [0 for _ in range(2*self.N)]
    
    def update(self, k, x):
        k += self.N-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = sum([self.data[2*k+1], self.data[2*k+2]])
    
    # [l,r)
    def query(self, l, r):
        L = l + self.N
        R = r + self.N
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = sum([s, self.data[R-1]])
            if L & 1:
                s = sum([s, self. data[L-1]])
                L += 1
            L >>= 1; R >>= 1
        return s

    def node(self, k):
        return st.query(k, k+1)

def compress(arr):
    N = len(arr)
    narr = sorted(arr)
    pressed = [-1] * N
    for i in range(N):
        pressed[i] = bisect_left(narr, arr[i])
    return pressed
    

def accmulate(arr):
    N = len(arr)
    cs = [0]*(N+1)
    for i in range(N):
        cs[i+1] = cs[i] + arr[i]
    return cs

# [l,r)
def query(cs, l, r):
    return cs[r] - cs[l]

N, K = map(int,input().split())
A = [int(input()) - K for _ in range(N)]

cs = accmulate(A)
cs = compress(cs)
st = SegmentTree(N)

ans = 0

for i in range(N+1):
    ans += st.query(0, cs[i] + 1)
    st.update(cs[i], st.node(cs[i]) + 1)

print(ans)

Measured memory_bytes: 117080
N = int(input())
eval_list = []
for i in range(N):
  eval_list.append(input())
print('AC x ' + str(eval_list.count('AC')))
print('WA x ' + str(eval_list.count('WA')))
print('TLE x ' + str(eval_list.count('TLE')))
print('RE x ' + str(eval_list.count('RE')))

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

int main() {
	string S, T;
	cin >> S >> T;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == T[i]) {
			if (i == S.size() - 1)
				cout << "Yes" << "\n";
			continue;
		}
		else if (S[i] != T[i])
			cout << "No" << "\n";
		break;
	}

	return 0;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	a := nextInt()
	b := nextInt()

	if a*b%2 == 0 {
		fmt.Printf("Even")
	} else {
		fmt.Printf("Odd")
	}
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] a = new int[3];
            for (int i = 0; i < 3; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            out.println((a[0] == 5 && a[1] == 5 && a[2] == 7) ? "YES" : "NO");
        }

    }
}


Measured memory_bytes: 21716
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
pair<int,int> a[11000],b[11000];
int sm,l;
int fi(int i,int p){
  for(;sm<p;++i)
    sm+=a[i].second;
  if(sm>p){
    copy_backward(a+i,a+l,a+l+1);
    ++l;
    a[i-1].second-=sm-p;
    a[i]=make_pair(a[i-1].first+a[i-1].second,sm-p);
    sm=p;
  }
  return i;
}
int main(){
  int i,j,k;
  int n;
  while(scanf("%d",&n),n){
    int m,p,q,r;
    scanf("%d%d%d%d",&m,&p,&q,&r);
    if(r==n){
      for(i=0;i<m;++i){
	int x,y;
	scanf("%d%d",&x,&y);
      }
      printf("%d\n",q-p+1);
      continue;
    }else{
      a[0]=make_pair(1,r);
      a[1]=make_pair(r+1,n-r);
      l=2;
    }
    for(i=0;i<m;++i){
      int x,y;
      scanf("%d%d",&x,&y);
      sm=0;
      j=fi(0,x);
      k=fi(j,y);
      copy(a+k,a+l,b);
      copy(a+j,a+k,b+l-k);
      copy_backward(a,a+j,a+l);
      copy(b,b+l-j,a);
    }
    sm=0;
    j=fi(0,p-1);
    k=fi(j,q);
    int ct=0;
    for(i=j;i<k;++i){
      if(a[i].first<=r)
	ct+=a[i].second;
    }
    printf("%d\n",ct);
  }
  return 0;
}

Measured memory_bytes: 0
n, m, x, y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = max(a)+1
d = min(b)
e = 0

if c > d:
    print("War")
else:
    for i in range(c,d+1):
        if x < i and i <= y:
            print("No War")
            e = 1
            break
    if e == 0:
        print("War")

Measured memory_bytes: 3064
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-03 17:07:09
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=2000010,mod=1000000007;
i64 n,m,flag,l,Flag;
i64 f[N],F[N],ans;
char s[N];
namespace std
{
	int main()
	{
		i64 i,j,t;
		for(i=1;i<=m;i++) if(s[i]!=s[1]) break;
		l=i-1;
		if(l%2==0) l++;
		for(t=0;i<=m;i++)
		{
			if(s[i]==s[1]) t++;
			else
			{
				if(t&1) l=min(l,t);
				t=0;
			}
		}
		n/=2,l=(l+1)/2;
		return 0;
	}
}
int main()
{
	n=read(); m=read();
	scanf("%s",s+1);
	fr(i,2,m) if(s[i]!=s[1]) flag=1;
	if(!flag)
	{
		f[0]=1; f[1]=1; f[2]=2;
		fr(i,3,n) f[i]=(f[i-1]+f[i-2])%mod;
		printf("%d\n",int((f[n]+f[n-2])%mod));
		return 0;
	}
	for(int i=1,j;i<=m;)
		if(s[i]==s[1])
		{
			j=i;
			while(s[j]==s[1]) j++;
			if(j>n) break;
			if(!Flag) l=j-i+((j-i)%2==0);
			else if((j-i)&1) l=std::min(l,(i64)(j-i));
			i=j+1; Flag=1;
		}
		else i++;
	if(n&1){ printf("0\n"); return 0; }
	std::main();
//	printf("%d %d\n",int(n),int(l));
	f[0]=F[0]=1;
	fr(i,1,n)
	{
		f[i]=(F[i-1]+mod-(i-l-1>=0?F[i-l-1]:0))%mod;
		F[i]=(F[i-1]+f[i])%mod;
//		printf("%d%c",int(f[i]),i==n?'\n':' ');
	}
	ans=f[n];
	fr(i,1,l) ans=(ans+f[n-i]*(2*i-1))%mod;
	printf("%d\n",int(ans));
	return 0;
}

Measured memory_bytes: 4608
#include<cstdio>
#include<algorithm>
using namespace std;
int n, K, P[610];
long long C[610], Mod = 1000000007, D[610][610], T[610][610], res;
int main() {
	int i, a, b, j, k;
	C[0] = 1;
	for (i = 1; i <= 300; i++)C[i] = C[i - 1] * (2 * i - 1) % Mod;
	scanf("%d%d", &n, &K);
	n *= 2;
	for (i = 0; i < K; i++) {
		scanf("%d%d", &a, &b);
		P[a] = b, P[b] = a;
	}
	for (i = 1; i <= n; i++) {
		int c = 0, c2 = 0;
		for (j = i; j <= n; j++) {
			if (P[j] < j && P[j] >= i)c++;
			if (P[j])c2++;
			if ((j - i) & 1) {
				if (c * 2 == c2) {
					T[i][j] = C[(j - i + 1) / 2 - c];
					T[j][i] = C[(n - (j-i+1)) / 2 - (K - c)];
				}
			}
		}
	}
	for (i = 2; i <= n; i += 2) {
		for (j = 1; j <= n-i+1; j++) {
			int b = j, e = j + i - 1;
			D[b][e] = T[b][e];
			long long s = 0;
			for (k = b + 1; k < e; k += 2) {
				s += D[b][k] * T[k + 1][e] % Mod;
			}
			D[b][e] = (D[b][e] - s%Mod + Mod) % Mod;
			res += D[b][e] * T[e][b] % Mod;
		}
	}
	printf("%lld\n", res%Mod);
}

Measured memory_bytes: 5888
import java.util.Scanner;

//Get Many Persimmon Trees
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int w = sc.nextInt();
			int h = sc.nextInt();
			boolean[][] p = new boolean[h][w];
			while(n--!=0){
				int x = sc.nextInt()-1;
				int y = sc.nextInt()-1;
				p[y][x] = true;
			}
			int s = sc.nextInt();
			int t = sc.nextInt();
			int max = 0;
			for(int i=0;i+t<=h;i++)for(int j=0;j+s<=w;j++){
				int c = 0;
				for(int a=i;a<i+t;a++)for(int b=j;b<j+s;b++)c+=p[a][b]?1:0;
				max = Math.max(max, c);
			}
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if a.count(x) != 0 and a.count(y) != 0:
    print('Yes')
elif b.count(x) != 0 and b.count(y) != 0:
    print('Yes')
elif c.count(x) != 0 and c.count(y) != 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
#define N 2005
int n, l[N];
ll ans;
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
        cin >> l[i];
    }
	sort(l + 1, l + n + 1);
	for(int i = 1; i <= n - 2; i++){
		for(int j = i + 1; j <= n - 1; j++){
			ans += (lower_bound(l + j + 1, l + n + 1, l[i] + l[j]) - l) - j - 1;
        }
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>

bool judge_tri(int x1, int x2, int x3);

int main()
{
	int data_num;
	std::cin >> data_num;
	while (data_num >= 1) {
		int x1, x2, x3;
		std::cin >> x1 >> x2 >> x3;
		if (judge_tri(x1, x2, x3)) {
			std::cout << "YES" << std::endl;
		} else {
			std::cout << "NO" << std::endl;
		}
		data_num--;
	}
	return 0;
}

bool judge_tri(int x1, int x2, int x3)
{
	bool result;
	if (x1 * x1 == x2 * x2 + x3 * x3) {
		result = true;
	} else if (x2 * x2 == x3 * x3 + x1 * x1) {
		result = true;
	} else if (x3 * x3 == x1 * x1 + x2 * x2) {
		result = true;
	} else {
		result = false;
	}
	return result;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+2,mod=1e9+7;
int n,m;
bool heng[N],lie[N];
int main(){
	cin>>n>>m;
	for(int i=1,l;i<=n;i++){
		scanf("%d",&l);
		if(heng[l]){
			cout<<0;
			return 0;
		}
		heng[l]=true;
	}
	for(int i=1,l;i<=m;i++){
		scanf("%d",&l);
		if(lie[l] ){
			cout<<0;
		    return 0;
		}
		lie[l]=true;
	}
	long long conta=0,contb=0,ans=1;
	for(int k=m*n;k;k--){
        int onta=conta,ontb=contb;
        if(heng[k]){
        	conta++;
        	onta=1;
        }
        if(lie[k]){
        	contb++;
        	ontb=1;
        }
        if(heng[k]||lie[k])ans=(ans*onta % mod) *ontb%mod;
        else ans=ans*(onta*ontb-m*n+k)%mod;
        ans=(ans+mod)%mod;
	}
	cout<<(ans+mod)%mod;
}

Measured memory_bytes: 256
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: *

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

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;
	cin >> n;
	map<string,int> mp1;
	vector<string> ans;
	rep(i,0,n) {
		string s;
		cin >> s;
		mp1[s]++;
	}
	
	int mx = 0;
	for (auto& e:mp1) {
		mx = max(mx, e.second);
	}
	for (auto& e:mp1) {
		if (e.second == mx ) {
			ans.emplace_back(e.first);
		}
	}
	
	sort(all(ans));
	for (auto& e:ans) cout << e<< '\n';
	return 0;
}


Measured memory_bytes: 27252
#include<bits/stdc++.h>                      
using namespace std;                         
#define FOR(i,a,b) for(int i=(a);i<(b);i++)  
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)      
#define RREP(i,n) for (int i=(n)-1;i>=0;i--) 
                                             
#define pb push_back                         
#define PII pair<int,int>                    
                                             
#define VS vector<string>                    
#define VI vector<int>                       
#define ll long long int                     
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {                             
    string s;                                
    cin >> s;                                
    cout << s.substr(0,s.size() - 8) << endl;                                                                             
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;



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

	map<string, int> mp;
	rep(i, N)
	{
		string s;
		cin >> s;
		mp[s] += 1;
	}

	int max = 0;

	for (auto it : mp)
	{
		int v = it.second;
		if (v > max) max = v;
	}

	for (auto itr : mp)
	{
		if (itr.second == max)
			cout << itr.first << endl;
	}


	
	
	
	return 0;
}




Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	lli n;
	cin >> n;
	double p[n+1],dp[n+1],temp[n+1];
	for(lli i=1;i<=n;i++){
		cin >> p[i];
		dp[i]=0.00;
	}
	dp[0]=1-p[1];dp[1]=p[1];
	for(lli i=2;i<=n;i++){
		for(lli j=0;j<=n;j++){
			temp[j]=dp[j];
		}
		dp[0]=temp[0]*(1-p[i]);
		for(lli j=1;j<=i;j++){
			dp[j]=(temp[j-1]*p[i])+(temp[j]*(1-p[i]));
		}
	}
	lli a=n+1;a/=2;
	double ans=0;
	for(lli i=a;i<=n;i++){
		ans+=dp[i];
	}
	cout << fixed << setprecision(10);
	cout << ans;


	return 0;
}

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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template <typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	ll N, K;
	cin >> N >> K;
	vpll ab(N);
	cin >> ab;

	sortall(ab);

	ll num = 0;
	for (int i = 0; i < N; i++) {
		num += ab[i].second;
		if (num >= K) {
			say(ab[i].first);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1792
import numpy as np

N, M, Q = list(map(int, input().split()))

a = np.zeros((N+1, N+1), dtype=np.int)

for i in range(M):
    L, R = list(map(int, input().split()))
    a[N-L, R] += 1

a = np.cumsum(a, axis=0)
a = np.cumsum(a, axis=1)

for i in range(Q):
    p, q = list(map(int, input().split()))
    print(a[N-p, q])


Measured memory_bytes: 16676
a, b, c, d, e, f = [int(i) for i in input().split()]
max_density = 0.0
water = 0
sugar = 0
for i_1 in range(f//(a*100)+1):
    for i_2 in range((f-100*a*i_1)//(b*100)+1):
        for i_3 in range(min(((i_1*a+i_2*b)*e)//c , (f-(i_1*100*a+i_2*100*b))//c)+1):
            i_4 = min((((i_1*a+i_2*b)*e)-i_3*c)//d , (f-(i_1*100*a+i_2*100*b+i_3*c))//d)
            if i_1 == 0 and i_2 == 0:
                break
            if (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d) >= max_density:
                max_density = (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d)
                water = i_1*100*a+i_2*100*b
                sugar = i_3*c + i_4*d
print(water+sugar, sugar)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;

int main(){
  ll tmp;
  set<ll> cnt;
  rep(i, 3){
    cin >> tmp;

    cnt.insert(tmp);
  }

  if(cnt.size() == 2)
    cout << "Yes\n";
  else
    cout << "No\n";
  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>

using namespace std;

bool solve(long long x,long long  a,long long  b,vector<long long > h){
	vector<long long> h2;
	h2 = h;
	for(int i=0;i<h2.size();i++){
		h2[i] -= b*x;
	}
	long long count=0;
	for(int i=0;i<h2.size();i++){
		if(h2[i]>0){
			count += h2[i]/(a-b) + (h2[i]%(a-b)!=0);
		}
	}
	if(count > x) return 0;
	return 1;
}


int binary_search(long long  n,long long  a,long long  b,vector<long long> h){
	long long  ok = n;
	long long  ng = -1;
	while(abs(ok-ng)>1){
		long long mid = (ok+ng)/2;
		if(solve(mid,a,b,h)){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	return ok;
}

int main(){
	long long  n,a,b;
	cin >> n >> a >> b;
	vector<long long> h(n);
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	sort(h.begin(),h.end(),greater<long long>());
	long long ans;
	ans = binary_search(h[0]/b+2,a,b,h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3428
n, t = map(int, input().split())
cts = []
for _ in range(n):
    ct = list(map(int, input().split()))
    cts.append(ct)

min_cost = float("INF")
for ct in cts:
    temp_c = ct[0]
    temp_t = ct[1]
    if temp_t > t:
        continue
    if temp_c < min_cost:
        min_cost = temp_c

if min_cost == float("INF"):
    print("TLE")
else:
    print(min_cost)

Measured memory_bytes: 38384
/**
 *    author:  whohet
 *    created: 11-07-2020 16:54:33
**/

#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

signed main()
{
	fasterthanlight;
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1)*(n - w + 1) << endl;



	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int ans = 0;
    int count = 0;
    for(int i = 0; i < n-1; i++){
        if(h[i] >= h[i+1]){
            count++;
            if(ans < count){
                ans = count;
            }
        }else if(h[i] < h[i+1]){
            count = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin >> S;
  int x=S.size()-2;
  cout << S.at(0) << x << S.at(S.size()-1) << endl;
}

Measured memory_bytes: 384
n = int(input())
x = [[] for i in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    x[i].append(tuple(map(int,input().split())))
m = 0
for i in range(1,2**n):
  c = bin(i)[2:]
  c = '0'*(n-len(c)) + c
  f = 1
  co = 0
  for j in range(n):
    if c[j] == '1':
      co += 1
      for k,l in x[j]:
        if int(c[k-1]) != l:
          f = 0
          break
    if f == 0:
      break
  if f:
    m = max(m,co)
print(m)

Measured memory_bytes: 47724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


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

	ll a,b,c;
	cin >> a >> b >> c;
	cout << a+b+c-max({a,b,c}) << endl;
	
}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, Z, W, A):
    if N > 1:
        return max(abs(W-A[-1]), abs(A[-1] - A[-2]))
    else:
        return abs(W-A[-1])


def main():
    N, Z, W = read_int_n()
    A = read_int_n()
    print(slv(N, Z, W, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int a, b; cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int compare(long int *a, long int *b) {
    long int buf = *a - *b;
    if (buf < 0) return 1;
    if (buf == 0) return 0;
    return -1;
}

int main() {
    int x = 0, y = 0, z = 0, k = 0;
    scanf("%d %d %d %d\n", &x, &y, &z, &k);
    long int a_val[x];
    long int b_val[y];
    long int c_val[z];
    for (int i=0; i<x; i++) {
        scanf("%ld", &a_val[i]);
    }
    for (int i=0; i<y; i++) {
        scanf("%ld", &b_val[i]);
    }
    for (int i=0; i<z; i++) {
        scanf("%ld", &c_val[i]);
    }
    long int *val_a_b = (long int *)malloc(sizeof(long int )*x*y);
    long int count = 0;
    for (int i=0; i<x; i++) {
        for (int j=0; j<y; j++) {
            *(val_a_b+count) = a_val[i] + b_val[j];
            count++;
        }
    }
    qsort(val_a_b, x*y, sizeof(long int), compare);
    int max = (k > x*y) ? x*y : k;
    long int *val = (long int *)malloc(sizeof(long int) * max*z);
    count = 0;
    for (int i=0; i<max; i++) {
        for (int j=0; j<z; j++) {
            *(val+count) = val_a_b[i] + c_val[j];
            count++;
        }
    }
    qsort(val, max*z, sizeof(long int), compare);
    for (int i=0; i<k; i++) {
        printf("%ld\n", val[i]);
    }
    free(val);
    free(val_a_b);
    return 0;
}


Measured memory_bytes: 54920
#include<cstdio>

int main(){
    int H,W;
    for(int i = 0;; i++){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        char a[H][W];
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i + j) % 2 == 0){
                    a[i][j] = '#';
                }
                else if((i + j) % 2 == 1){
                    a[i][j] = '.';
                }
                printf("%c",a[i][j]);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2616
def main():
    N = int(input())
    txy = [
        tuple(map(int, input().split()))
        for _ in range(N)
    ]

    _t, _x, _y = 0, 0, 0
    for t, x, y in txy:
        ok = False
        diff_t = t - _t
        diff_x = x - _x
        diff_y = y - _y

        dx = abs(diff_x)
        dy = abs(diff_y)
        if diff_t >= dx + dy:
            rem = dx + dy - diff_t
            if rem % 2 == 0:
                ok = True
                _t, _x, _y = t, x, y

        if not ok:
            print("No")
            return

    print("Yes")

if __name__ == '__main__':
    main()


Measured memory_bytes: 17312
#include <iostream>

using namespace std;

int main() {
	int w, a, b;
	cin >> w >> a >> b;

	int ans = 0;
	if (a + w < b) {
		ans = b - (a + w);
	} else if (b + w < a) {
		ans = a - (b + w);
	}

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


Measured memory_bytes: 256
#ALDS1_5-B Merge Sort
from collections import deque

def merge(A,B):
    ans = [0]*(len(A)+len(B))
    count=i=j=0
    A+=[10**9+1]
    B+=[10**9+1]
    for k in range(len(ans)):
        if A[i]<B[j]:
            ans[k]=A[i]
            i+=1
        else:
            ans[k]=B[j]
            j+=1
        count+=1
    return (ans,count)

n = int(input())
S = [int(i) for i in input().split()]
div = deque([S])
mer = deque()
count = 0
while(len(div)>0):
    d = div.pop()
    if(len(d)>2):
        mid = len(d)//2
        div.appendleft(d[:mid])
        div.appendleft(d[mid:])
    elif(len(d)==2):
        if d[0] > d[1]:
            mer.appendleft(d[::-1])
        else:
            mer.appendleft(d)
        count+=2
    else:
        mer.appendleft(d)
        
while(len(mer)>1):
    A = mer.popleft()
    B = mer.popleft()
    ret = merge(A,B)
    mer.append(ret[0])
    count+=ret[1]
    
ans = ""
for i in ret[0]:
    ans += str(i) + " "
print(ans[:-1])
print(count)


Measured memory_bytes: 65968
#include<bits/stdc++.h>                          
using namespace std;
int n,x,a[105];
int main(){
	cin>>n>>x;
	for(int i=1;i<=n;i++)
		cin>>a[i],x-=a[i];
	sort(a+1,a+n+1);
	cout<<n+x/a[1];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define f first
 #define s second
 #define endl '\n'
 #define LL long long
 #define pb push_back
 #define sz(a) (int)a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define debug(x) cerr << #x << " is " << x << endl;
 using namespace std;
 int const MAXN = 2e6 + 9;
 int main(){
    ios_base::sync_with_stdio (0),cin.tie(0);
    LL n;
    cin >> n;
    LL ans = 0;
    vector<LL> div;
    for (LL i  = 1; i * i <= n; i++){
        if (n % i == 0){
            div.pb(i);
            LL x = n / i;
            if (x != i) div.pb(x);
        }
    }
    for (auto c : div){
        LL m = (n - c) / c;

        if (m && n/m == n % m) ans+= m;
    }
    cout << ans;
 }


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
string s[12];
bool ng=1;
void solve(ll h,ll w,vector<ll> v,vector<bool> use,ll num,ll mm){
  if(num==h){
    string ss[12];
    rep(i,w)rep(j,h)ss[i]+=s[v[j]][i];
    string sss[12];
    rep(i,w)rep(j,h)sss[i]+=s[v[h-1-j]][i];
    vector<bool> ch(w);
    rep(i,w)rep(j,w){
      if(i==j)continue;
      if(ch[i]==0&&ch[j]==0&&ss[i]==sss[j]){
        ch[i]=1;ch[j]=1;
      }
    }
    ll nu=0;
    rep(i,w)if(!ch[i])nu++;
    if(( w%2==1 && nu==1 )||( w%2==0 && nu==0) ){
      if(ng)cout << "YES" << endl;
      ng=0;
    }
  }
  else if(num==h-1){
    rep(i,h)if(use[i]==0)v[h/2]=i;
    solve(h,w,v,use,num+1,mm);
  }
  else{
    rep(i,h)if(use[i]==0 && i!=mm){v[num/2]=i;use[i]=1;break;}
    rep(i,h){
      vector<ll> vv=v;
      vector<bool> usee=use;
      if(use[i]==0){
        vv[h-1-num/2]=i;usee[i]=1;
        string a1=s[v[num/2]],a2=s[vv[h-1-num/2]];
        sort(a1.begin(),a1.end());
        sort(a2.begin(),a2.end());
        if(a1==a2)solve(h,w,vv,usee,num+2,mm);
      }
    }
  }
}

int main()
{
ll h , w ;
cin >> h >> w ;
rep(i,h){
  cin >> s[i];
}
vector<ll> v(h);
vector<bool> use(h);
if(h%2)rep(i,h)solve(h,w,v,use,0,i);
else solve(h,w,v,use,0,-1);
if(ng)cout << "NO" << endl;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,m,p;
vector<pair<int,int> >v[N];
int res[N],vis[N];
LL dis[N];
int dfs(int now){
    if(now==n)return 1;
    int sta=0;
    if(res[now])return res[now];
    for(auto k:v[now]){
        if(vis[k.fi])continue;
        vis[k.fi]=1;
        sta|=dfs(k.fi);
    }
    return sta;
}
int cnt[N],inq[N];
queue<int>q;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m>>p;
    for(int i=1;i<=m;i++){
        int s,t,w;
        cin>>s>>t>>w;
        v[s].pb({t,w-p});
    }  
    for(int i=1;i<=n;i++){
        memset(vis,0,sizeof vis);
        res[i]=dfs(i);
    }
    q.push(1);
    for(int i=2;i<=n;i++)dis[i]=-1e18;
    while(!q.empty()){
        int t=q.front();
        q.pop();
        inq[t]=0;
        for(auto k:v[t]){
            if(!res[k.fi])continue;
            if(dis[k.fi]<dis[t]+k.se){
                dis[k.fi]=dis[t]+k.se;
                if(++cnt[k.fi]==m+1)return cout<<-1<<'\n',0;
                if(!inq[k.fi]){
                    inq[k.fi]=1;
                    q.push(k.fi);
                }
            }
        }
    }
    cout<<max(dis[n],0ll)<<'\n';
    return 0;
}

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

using namespace std;

int n, r, b;
string s;

int main()
{
    cin>>n;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if (s[i]=='R')
            r++;
        else
            b++;
    }
    if (r>b)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    char f[11];
	cin >> f;
	string fstr = f;
	int N;
	cin >> N;
	vector<string> rings;
	for (int i = 0; i < N; i++) {
		char input[11];
		cin >> input;
		rings.push_back(input);
	}

	int result = 0;
	int flen = fstr.size();
	for (int i = 0; i < N; i++) {
		if (rings[i].find(fstr, 0) != string::npos) {
			result++;
		} else {
			for (int j = flen - 1; j >= 1; j--) {
				string fsubstr = fstr.substr(0, j);
				if (rings[i].substr(10 - j, j) == fsubstr) {
					if (rings[i].substr(0, flen - j) == fstr.substr(j, flen - j)) {
						result++;
						break;
					}
				}
			}
		}
	}
	
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1220
#import numpy as np
#dict = {}
N = int(input())
#def search(n):
#    if n == 1:
#        return
#    else:
#        s = int(np.sqrt(n)//1)
#        for i in range(2, s+1):
#            if n % i == 0:
#                global dict
#                dict[i] = dict.get(i, 0) + 1
#                search(int(n/i))
#                break
#        else:
#            dict[n] = dict.get(n, 0) + 1
#search(N)
p = 2
dict = {}
while p**2 <= N:
    if N % p == 0:
        now = 0
        while N % p == 0:
            N //= p
            now += 1
        dict[p] = now
    p += 1
if N != 1:
    dict[N] = 1
ans = 0
for i in dict.keys():
    n = dict[i]
    j = 1
    while j <= n:
        n -= j
        j += 1
        ans += 1
print(ans)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() cin.tie(0), ios::sync_with_stdio(false)

int N, C;

int main()
{
    cin >> N >> C;
    vector<pair<int, pair<int, int>>> v, u;
    for (int i = 0; i < N; i++)
    {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        v.push_back({c, {s, t}});
    }
    sort(v.begin(), v.end());

    int chan = v[0].first, s = v[0].second.first, t = v[0].second.second;

    for (int i = 1; i < N; i++)
    {
        if (chan == v[i].first && t == v[i].second.first)
            t = v[i].second.second;
        else
        {
            u.push_back({chan, {s, t}});
            s = v[i].second.first, t = v[i].second.second;
            chan = v[i].first;
        }
    }

    u.push_back({chan, {s, t}});

    N = u.size();

    int T = 1e5 + 1;
    vector<int> imos(T + 2);

    for (int i = 0; i < N; i++)
    {
        imos[u[i].second.first]++, imos[u[i].second.second + 1]--;
    }

    int ans = 0;

    for (int i = 0; i < T; i++)
    {
        ans = max(imos[i], ans);
        imos[i + 1] += imos[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int a[3];
    int m = 0;
    int ans;
    cin >> a[0] >> a[1] >> a[2];
    rep (i, 3) {
        if (m < a[i]) {
            m = a[i];
        }
        ans += a[i];
    }
    cout << ans + m * 9 << endl;
    return 0;
    
}


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

int main(void)
{
    int a, b, c, dis, flag;

    scanf("%d %d %d", &a, &b, &c);

    dis = abs(a - b);
    if (a < b)
    {
        flag = (a < c) && (c < a + dis);
    }
    else
    {
        flag = (a > c) && (c > a - dis);
    }

    if (flag)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
//Bismillahir Rahmanir Rahim 
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	/*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	int n, m;
	cin >> n >> m;

	vector<pair<int,int>>v(n);

	for(int i=0; i<n; i++)
		cin >> v[i].first >> v[i].second;

	sort(v.begin(), v.end());
	priority_queue<int>q;
	int ans=0;

	for(int i=0, j=1; j<=m; j++)
	{
		while(v[i].first<=j && i<n)
		{
			q.push(v[i].second);
			i++;
		}

		if(!q.empty())
		{
			ans+=q.top();
			q.pop();
		}
	}

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

Measured memory_bytes: 1660
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int product = a * 100 + b * 10 + c;
    if(product % 4 == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 H, W;
    cin >> H >> W;
    if (H > 1 && W > 1) {
        cout << (H * W + 1) / 2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256