akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(100000000)




def main():
    n = int(input())
    x_ls = list(map(int, input().split()))

    sumx = sum(x_ls)
    sumx2 = sum([x**2 for x in x_ls])

    res = 10000000
    for p in range(1, 101):
        z = n* (p**2) -2*sumx*p + sumx2
        if z < res:
            res = z

    print(res)


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string a, b;
int bio[3001][3001];
pair <int, int> d[3001][3001];
int main() 
{ 
    cin >> a >> b;
    int m = a.size(); 
    int n = b.size();
	for(int i = 0; i <= m; i++)
	{
		for(int j = 0; j <= n; j++)
		{
		    if(i == 0 || j == 0)
		    { 
		        bio[i][j] = 0; 
		    }
		    else if(a[i-1] == b[j-1]) 
		    {
		        bio[i][j] = bio[i-1][j-1] + 1; 
		        d[i][j] = make_pair(i-1, j-1);
		    }
		    else
		    {
		    	if(bio[i][j-1] > bio[i-1][j])
		    	{
		    		bio[i][j] = bio[i][j-1];
		    		d[i][j] = make_pair(i, j-1);
				}
				else
				{
					bio[i][j] = bio[i-1][j];
					d[i][j] = make_pair(i-1, j);
				}
		    }
	    }
	}
	int x = m;
	int y = n;
	string t = "";
    while(x > 0 && y > 0)
    {
    	if(bio[x][y] == bio[x-1][y])
    	{
    		x--;
		}
		else if(bio[x][y] == bio[x][y-1])
		{
			y--;
		}
		else
		{
			t += a[x-1];
			x--;
			y--;
		}
    }
	for(int i = t.size()-1; i >= 0; i--)
	{
		cout << t[i];
	}
	cout <<endl;
    return 0; 
}


Measured memory_bytes: 105728
import collections
# from typing import List, Tuple

n, m = map(int, input().split())
graph = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b-1)
    graph[b - 1].append(a-1)


def is_connected_graph(graph):  # (graph: List[List[int]]) -> bool:
    """グラフが連結か判定する。

    Args:
        - graph: 隣接リスト形式
    """
    graph_size = len(graph)
    if graph_size == 0:
        return True
    connected = [False] * graph_size
    dq = collections.deque([0])  # 暗黙的に0をrootとして探索する。
    connected[0] = True
    while dq:
        node = dq.popleft()
        for adjacent_node in graph[node]:
            if connected[adjacent_node]:
                continue
            connected[adjacent_node] = True
            dq.append(adjacent_node)
    return all(connected)


def enumerate_bridge(graph):  # (graph: List[List[int]]) -> List[Tuple[int, int]]:
    """グラフの橋を列挙する。

    Args:
        - graph: 隣接リスト形式

    Returns:
        - 橋の配列。ソートしていない。
    """
    graph_size = len(graph)
    if graph_size == 0:
        return True

    bridges = []

    visited = [False] * graph_size
    order = [-1] * graph_size
    lowlink = [float('inf')] * graph_size
    k = 0

    def __dfs(node, pre_node):
        nonlocal k
        visited[node] = True

        order[node] = k
        lowlink[node] = order[node]
        k += 1

        ct = 0

        for next_node in graph[node]:
            if not visited[next_node]:
                ct += 1
                __dfs(next_node, node)
                lowlink[node] = min(lowlink[node], lowlink[next_node])
                if order[node] < lowlink[next_node]:
                    bridges.append(
                        (min(node, next_node), max(node, next_node)))
            elif next_node != pre_node:
                lowlink[node] = min(lowlink[node], order[next_node])

    for i in range(graph_size):
        if not visited[i]:
            __dfs(i, -1)
    return bridges


print(len(enumerate_bridge(graph)))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pii pair<int, int>
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) x.begin(),x.end()
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)
//#define int ll

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //freopen("input.txt","w",stdout);
    double r; cin >> r;
    cout << 6.283*r << '\n';


    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int X; cin>>X;
	int y=X%100;
	int n=X/100;
	// ote(y);//
	// ote(n);//
	if(n>0) ote((y+n-1)/n<=5?1:0);
	else ote(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=2e5+3,du=1e9+7;
string a,b;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>a>>b;
    int ans=du;
    for (int i=0;i<a.size()-b.size()+1;i++)
    {
        int cnt=0;
        for (int j=0;j<b.size();j++)
        {
            if (a[i+j]==b[j]) cnt++;
        }
        ans=min(ans,(int)b.size()-cnt);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
	"strings"
)

func main() {

	for {
		var H, W int
		fmt.Scan(&H)
		fmt.Scan(&W)

		if H == 0 && W == 0 {
			break
		}
		fmt.Println(strings.Repeat("#", W))
		for h := 0; h < H - 2; h++ {
			fmt.Println("#" + strings.Repeat(".", W - 2) + "#")
		}
		fmt.Println(strings.Repeat("#", W) + "\n")
	}
}



Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, a, b, ans = 0;
    cin >> n;
    string s, t1, t2;
    cin >> s;
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    } else {
        for (int i = 0; i < n / 2; i++) {
            t1.push_back(s[i]);
        }
        for (int i = n / 2; i < n; i++) {
            t2.push_back(s[i]);
        }
    }
    if (t1 == t2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> student; 
	for (int i = 0; i < N; i++) {
		int tmp1, tmp2; cin >> tmp1 >> tmp2;
		student.push_back((make_pair(tmp1, tmp2)));
	}
	vector<pair<int, int>> point;
	for (int i = 0; i < M; i++) {
		int tmp1, tmp2; cin >> tmp1 >> tmp2;
		point.push_back((make_pair(tmp1, tmp2)));
	}

	for (int i = 0; i < N; i++) {
		int check = 0;
		int mini = (int)1e9;
		for (int j = 0; j < M; j++) {
			if (mini >
				min(mini, abs(student[i].first - point[j].first)
					+ abs(student[i].second - point[j].second))) {
				mini = min(mini, abs(student[i].first - point[j].first)
					+ abs(student[i].second - point[j].second));
				check = j + 1;
			}
		}
		cout << check << endl;
	}


	return 0;
}

Measured memory_bytes: 256
def prime_factor(n):
    if n == 1:
        return [[1, 0]]
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


MOD = 10**9+7
lim = 200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]


def set_inv(max=lim):
    inv_t[0] = 0
    for i in range(1, max):
        inv_t[i] == mod_inv(i)


def mod_inv(x, mod=MOD):
    y, u, v, _x = mod, 1, 0, x
    while y:
        t = _x//y
        _x -= t*y
        _x, y = y, _x
        u -= t*v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u


def mod_pow(a, n, mod=MOD):
    res = 1
    while n:
        if n & 1:
            res = res*a % mod
        a = a*a % mod
        n >>= 1
    return res


def set_factrial(max=lim, mod=MOD):
    c = 1
    factrial[0] = factrial_inv[0] = 1
    for i in range(1, max):
        c *= i
        c %= mod
        factrial[i] = c
        factrial_inv[i] = mod_inv(c, mod)


def comb(a, b, mod=MOD):
    if factrial[0] == -1:
        set_factrial()
    return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod


n, m = [int(_) for _ in input().split()]
ans = 1
for p, e in prime_factor(m):
    ans *= comb(n-1+e, e)
    ans %= MOD
print(ans)


Measured memory_bytes: 20580
n = int(input())
divisors = []
for i in range(1, int(n**0.5)+1):
  if n % i == 0:
    divisors.append(i)
    if i != n // i:
      divisors.append(n//i)
divisors.sort()
p = len(divisors)//2


if len(divisors)%2 > 0:
  print (divisors[p] + divisors[p] -2)
else:
  print (divisors[p] + divisors[p -1] -2)
      

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  stack<pii> Q;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  reverse(ALL(A));
  Q.push(mp(0,N));
  REP(i,1,N){
    if(Q.top()<mp(A[N-i],N-i)) Q.push(mp(A[N-i],N-i));
  }
  map<int,int,greater<int>> M;
  vi ans(N);
  int memo=0,cnt=0;
  while(Q.size()>0){
    int X=Q.top().first,Y=Q.top().second; Q.pop();
    for(cnt;cnt<Y;cnt++){
      M[A[cnt]]++;
    }
    for(auto p:M){
      if(p.first<=X) break;
      M[X]+=p.second;
      ans[memo]+=p.second*(p.first-X);
      M.erase(p.first);
    }
    memo=Y;
  }
  reverse(ALL(ans));
  rep(i,0,N) cout<<ans[i]<<endl;
  }



Measured memory_bytes: 8320
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
total = 0
lowest = 100001
for i in range(n):
    m = ii()
    total += m
    lowest = min(lowest,m)
print(n+(x-total)//lowest)

Measured memory_bytes: 3064
fun main() {
    val (x1, x2, x3, x4, x5) = readLine()!!.split(" ").map{it.toInt()}

    if (x1 == 0){
        println("1")
    } else if (x2 == 0){
        println("2")
    } else if (x3 == 0){
        println("3")
    } else if (x4 == 0){
        println("4")
    } else if (x5 == 0){
        println("5")
    }

}

Measured memory_bytes: 36444
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;
#define MAX_N 100000

int n;
string a[MAX_N];

void solve()
{
    ll ans = 1;
    int count_ac = 0;
    int count_wa = 0;
    int count_tle = 0;
    int conut_re = 0;

    for (int i = 0; i < n; i++)
    {
        string s = a[i];
        if (s == "AC")
            count_ac++;
        else if (s == "WA")
            count_wa++;
        else if (s == "TLE")
            count_tle++;
        else if (s == "RE")
            conut_re++;
    }

    cout << "AC x " << count_ac << endl;
    cout << "WA x " << count_wa << endl;
    cout << "TLE x " << count_tle << endl;
    cout << "RE x " << conut_re << endl;
}

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

    solve();
}


Measured memory_bytes: 6764
#include <iostream>
#include <algorithm>

using namespace std;

int n;
string best;

bool compare(string x, bool reversed) {
    for (int i = 0; i < n; i++) {
        if (!reversed && x[i] != best[i])return x[i] < best[i];
        if (reversed && x[n - 1 - i] != best[n - 1 - i])return x[n - 1 - i] < best[n - 1 - i];
    }
    return true;
}

int main() {
    int k;
    string s;
    cin >> n >> k >> s;

    for (int i = 0; i < k; i++) {
        string t = s;
        reverse(t.begin(), t.end());
        s += t;

        best = string(n, 'z');
        for (int j = 0; j <= n; j++) {
            string now = s.substr(j, n);
            if (compare(now, i != k - 1)) best = now;
        }

        if (best == s.substr(0, n)) {
            cout << best << endl;
            return 0;
        }
        s = best;
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    bool z=true;
    int i;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++){
        if(z){
            if(s[i]=='L')break;
            z=false;
        }
        else {
            if(s[i]=='R')break;
            z=true;
        }
    }
    if(i==s.length())printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int cnt[1000006];
int vis[1000006];
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int gc=0;
    bool chk=0;
    int cnt1=0;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        gc=__gcd(gc,x);
        cnt[x]++;
        if(cnt[x]>1 && x!=1)
        {
            chk=1;
        }
        if(x%2==0)
            cnt1++;
        if(cnt1>1)
            chk=1;
    }
    if(chk==0)
    {
        for(int i=2; i<=1e6; i+=2)
        {
            vis[i]=1;
        }
        for(int i=3; i<=1e6; i+=2)
        {
            int ase=0;
            for(int j=i; j<=1e6; j+=i)
            {
                ase += cnt[j];
                vis[j]=1;
            }
            if(ase>1)
            {
                chk=1;
                break;
            }
        }
    }
    if(gc!=1)
    {
        cout<<"not coprime\n";
    }
    else
    {
        if(chk==0)
        {
            cout<<"pairwise coprime\n";
        }
        else
        {
            cout<<"setwise coprime\n";
        }
    }
    return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    long long N;
    cin >> N;

    int ans = 0;

    for (long long i=2; i*i<=N; i++)
    {
        int f = 0;

        while (N % i == 0)
            N /= i, f++;
        
        int curr = 1;

        while (f >= curr)
            f -= curr, curr++, ans++;
    }

    if (N > 1)
        ans++;

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


Measured memory_bytes: 3664
#include<stdio.h>

int main() {
    int n;
    int a[110];
    int j, flag, cnt, tmp;


    scanf("%d", &n);
    for(j = 0; j < n; j++) scanf("%d", &a[j]);

    flag = 1;
    cnt = 0;
    while(flag) {
        flag = 0;
        for(j = n - 1; j > 0; j--) {
            if (a[j] < a[j - 1]) {
                tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                flag = 1;
                cnt++;
            }
        }
    }

    for(j = 0; j < n; j++) printf("%d%c", a[j], ((j == n - 1) ? '\n' : ' '));
    printf("%d\n", cnt);

    return 0;
}

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

int main(){
    int A,B,C,X,c=0;
    cin >> A >> B >> C >> X;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==X){
                    c++;
                }
            }
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    double x,y;
    double angle;
    x = 0;
    y = 0;
    angle = 90;

    while(true){
	auto d = split(chomp(readln()),",");
	if(d[0] == "0" && d[1] == "0" )break;
	auto dr = to!double(d[0]);
	auto rad = to!double(angle/360.0);
	x += dr * cos(2*PI*rad);
	y += dr * sin(2*PI*rad);
	angle -= to!double(d[1]);
    }
    x = to!int(x);
    y = to!int(y);
    writeln(x);
    writeln(y);
}

Measured memory_bytes: 2564
import sys,math,collections,itertools
input = sys.stdin.readline

S=input().rstrip()
Smod2019=[0]
num = 0
deg = 0
for i in range(len(S)-1,-1,-1):
    num = (num+int(S[i])*pow(10,deg,2019))%2019
    Smod2019.append(num)
    deg += 1
Sc = collections.Counter(Smod2019)

cnt = 0
for val in Sc.values():
    cnt += val*(val-1)//2
print(cnt)


Measured memory_bytes: 87484
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;

  cin >> N;

  if(N>999){
    cout << "ABD" << endl;
  }else{
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0 ; i < n; ++i) {
        cin >> a[i];
    }
    double res = 0;
    for (ll i = 0 ; i < n; ++i) {
        res += (double)1 / (double)a[i];
    }
    res = (double)1 / res;

    cout << fixed << setprecision(17) << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ1147().doIt();
	}
	
	class AOJ1147{
		void doIt(){
			while(true){
				int n = in.nextInt();
				if(n==0)break;
				int[] hyou = new int[n];
				for(int i=0;i<n;i++)hyou[i] = in.nextInt();
				Arrays.sort(hyou);
				int result = 0;
				for(int i=1;i<n-1;i++)result+=hyou[i];
				System.out.println(result/(n-2));
			}
		}
	}
	
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n, a, b;cin >> n >> a >> b;
	if(abs(a - b) % 2 == 0){
		cout << abs(a - b) / 2 << endl;
	}
	else {
		ll ans = LLINF;
		ans = min(ans, (b - (a+1)) / 2 + (a - 1) + 1);
		ans = min(ans, (b - (a+1)) / 2 + (n - b) + 1);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
  public static void main(String... args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int a = scan.nextInt();
    int b = scan.nextInt();

    int tmpa,tmpb;
    while(true){

      tmpa = moveA(a, b);
      if(a == tmpa){
        System.out.println("Borys");
        return;
      }
      a = tmpa;
      tmpb = moveB(a, b, n);
      if(b == tmpb){
        System.out.println("Alice");
        return;
      }
      b = tmpb;
    }

  }

  public static int moveA(int a, int b){
    int tmp = a;
    if(b-a == 1){
      if(a > 1)
        tmp -= 1;
    }else{
      tmp += 1;
    }

    return tmp;
  }

  public static int moveB(int a, int b, int n){
    int tmp = b;
    if(b-a == 1){
      if(b < n)
        tmp += 1;
    }else{
      tmp -= 1;
    }

    return tmp;
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_V = 100010;
int N;
int count1[MAX_V];
int count2[MAX_V];


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

  vector<int> v1, v2;
  cin >> N;
  rep(i, N) {
    int a; cin >> a;
    if (i%2 == 0) v1.push_back(a);
    else v2.push_back(a);
  }

  int ans = 0;
  vector<Pii> vpii[2];
  for (int i = 0; i < v1.size(); ++i) {
    count1[v1[i]]++;
  }
  for (int i = 1; i <= 100000; ++i) {
    if (count1[i] == 0) continue;
    vpii[0].push_back(Pii(N/2-count1[i], i));
  }

  for (int i = 0; i < v2.size(); ++i) {
    count2[v2[i]]++;
  }
  for (int i = 1; i <= 100000; ++i) {
    if (count2[i] == 0) continue;
    vpii[1].push_back(Pii(N/2-count2[i], i));
  }
  sort(all(vpii[0])); sort(all(vpii[1]));

  if(vpii[0][0].sc != vpii[1][0].sc) {
    ans = vpii[0][0].fi + vpii[1][0].fi;
  } else {
    if (vpii[0].size() >= 2) {
      ans = vpii[0][1].fi + vpii[1][0].fi;
    } else {
      ans = N/2 + vpii[1][0].fi;
    }
    if (vpii[1].size() >= 2) {
      ans = min(ans, vpii[0][0].fi + vpii[1][1].fi);
    } else {
      ans = min(ans, vpii[0][0].fi + N/2);
    }
  }

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


Measured memory_bytes: 2552
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    while (1) {
        bool leBase = std::all_of(all(A), [&](auto x) { return x < N; });
        if (leBase) {
            write(ans);
            return 0;
        }
        bool geBase = std::all_of(all(A), [&](auto x) { return x >= N - 1; });
        if (geBase) break;

        rep(i, N) {
            if (A[i] > N - 1) {
                A[i] -= N;
                rep(j, N) if (j != i) A[j]++;
                ans++;
                break;
            }
        }
    }

    rep(i, N) {
        ll exceed = A[i] - (N - 1);
        A[i] -= exceed / (N + 1) * (N + 1);
        ans += exceed / (N + 1) * (N + 1);
    }

    while (1) {
        bool leBase = std::all_of(all(A), [&](auto x) { return x < N; });
        if (leBase) {
            write(ans);
            return 0;
        }

        rep(i, N) {
            if (A[i] > N - 1) {
                A[i] -= N;
                rep(j, N) if (j != i) A[j]++;
                ans++;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
n = int(input())
buf = list(map(int,input().split()))
a = []
for i in range(n):
    a.append([buf[i],i])
a = sorted(a,reverse=True)

dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n):
    for j in range(n-i):
        cur = i+j
        temp1 = dp[i][j]+a[cur][0]*abs(n-1-a[cur][1]-j)
        temp2 = dp[i][j]+a[cur][0]*abs(a[cur][1]-i)
        dp[i+1][j] = max(dp[i+1][j],temp2)
        dp[i][j+1] = max(dp[i][j+1],temp1)

print(max([max(i) for i in dp]))

Measured memory_bytes: 100748
import Data.List
main=putStrLn.unwords.m show.(g<$>f.takeWhile(<8)<*>length.d(<8)).tail.sort.m((`div`400).read).words=<<getContents
g x y=[max 1 x,x+y]
f[]=0
f(x:l)=1+f(d(==x)l)
d=dropWhile
m=map

Measured memory_bytes: 1020
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("YES\n")
#define no printf("NO\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int a,b,x;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>a>>b>>x;
    if(a>x) {no;return 0;}
    if(a+b<x){no;return 0;}

    yes;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,string> P;
vector<string> t;
vector<P> u;
int n,c;
string str,tmp;

int main(){
  while(cin>>n&&n){
    t.clear();
    u.clear();
    cin.ignore();
    for(int i=0;i<n;i++){
      getline(cin,str);
      stringstream ss(str);
      while(ss>>tmp){
	t.push_back(tmp);
      }
    }
    sort(t.begin(),t.end());
    c=1;
    for(int i=1;i<(int)t.size();i++){
      if(t[i-1]==t[i])c++;
      else{
	u.push_back(P(-c,t[i-1]));
	c=1;
      }
    }
    u.push_back(P(-c,t[t.size()-1]));
    sort(u.begin(),u.end());

    char ch;
    cin>>ch;
    c=0;
    for(int i=0;i<(int)u.size();i++){
      if(ch==u[i].second[0]){
	if(c)cout<<' ';
	cout<<u[i].second;
	c++;
      }
      if(c==5)break;
    }
    if(c==0)cout<<"NA"<<endl;
    else cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;

signed main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3));
    for (int i=0;i<n;++i)
      cin>>v[i][0]>>v[i][1]>>v[i][2];
  int dp[n+1][3];
  dp[0][0]=v[0][0];
  dp[0][1]=v[0][1];
  dp[0][2]=v[0][2];
  
  for (int i=1;i<n;++i){
    dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=v[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;

}


Measured memory_bytes: 11084
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int cnt = 0;
    string s;
    cin >> n >> s;
    for(int i = 1; i < n; i++)
    {
        if(s[i] != s[i - 1]) cnt++;
    }
    cout << cnt + 1;

    return 0;
}


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

typedef long long ll;
#define int ll
#define db(x) cout<<#x<<" = "<<x<<"\n";
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ALL(a) a.begin(),a.end()
#define mset(a,b) memset(a,b,sizeof(a));


main() 
{
	FIN;
	string str;
	cin>>str;
	stack<char> s;
	int ans=0;
	for(auto i: str)
	{
	    if(i=='R')
	    {
	        s.push(i);
	    }
	    else
	    {
	        while(!s.empty())
	        {
	            s.pop();
	        }
	    }
	    if(ans<s.size())
	    ans=s.size();
	}
	cout<<ans<<endl;
	
  
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }



int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    LL ans = 0;
    for(LL i = 1; i < n; ++i){
        LL part = 0;
        for(LL j = 1; j*i < n-1; ++j){
            LL left = j*i;
            LL right = n-1-j*i;
            if((n-1)%i==0 && left >= right) break;
            if(right < i) break;
            part += a[left] + a[right];
            //cerr << "i=" << i << ", " << part << endl;
            ans = max<LL>(ans, part);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
while True:
    x = input()
    x = x.split(" ")
    x = [int(z) for z in x]
    if x[0] == 0 and x[1] == 0: break
    if x[0] < x[1]:
        print("%d %d" % (x[0], x[1]))
    else:
        print("%d %d" % (x[1], x[0]))

Measured memory_bytes: 7736
while True:
    m,f,r=map(int,input().split())
    if (m,f,r)==(-1,-1,-1):
        break
    if m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif 80>m+f>=65:
        print("B")
    elif 65>m+f>=50:
        print("C")
    elif m+f<30:
        print("F")
    elif 50>m+f>=30:
        if r>=50:
            print("C")
        else:
            print("D")


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

int main(void)
{
    int N, A, B, T;

    cin >> N >> A >> B;
    T = N * A;

    if (T < B)
    {
        cout << T << endl;
    }
    else if (T > B)
    {
        cout << B << endl;
    }
    else
    {
        cout << T << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    string s;
    cin >> s;
    n = s.size();
    int k = n / 2;
    int ans = 0;
    for(int i = 0; i < k; i++){
        if(s[i] != s[n-1-i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main() {
	
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;

	int xmax = -100, ymin = 100;
	vector<int> x(n), y(m);
	rep(i, 0, n) {
		cin >> x[i];
		xmax = max(xmax, x[i]);
	}
	rep(i, 0, m) {
		cin >> y[i];
		ymin = min(ymin, y[i]);
	}

	if (X >= ymin || Y <= xmax || ymin <= xmax) cout << "War" << endl;
	else cout << "No War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+1,mod=998244353;
int n,a[N],inv[N],w[N];
int main()
{
	inv[1]=1;
	for(int i=2;i<N;i++)
		inv[i]=(-1ll*inv[mod%i]*(mod/i)%mod+mod)%mod;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		scanf("%d",&tmp);
		a[tmp]+=tmp;
		a[tmp]%=mod;
		ans-=tmp;
		ans%=mod;
	}
	for(int i=1;i<N;i++)
	{
		int tot=0;
		(w[i]+=inv[i])%=mod;
		for(int j=i+i;j<N;j+=i)
		{
			w[j]-=w[i],w[j]%=mod;
			tot+=a[j],tot%=mod;
		}
		(tot+=a[i])%=mod;
		(ans+=1ll*tot*tot%mod*w[i]%mod)%=mod;
	}
	ans=(1ll*ans*inv[2]%mod+mod)%mod;
	cout<<ans;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){
    if(a>b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 *
 * */

int main() {

    int S,W;
    cin >> S >> W;

    string ans;
    if(S <= W){
        ans = "unsafe";
    }else{
        ans = "safe";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    H, W = map(int, input().split())
    if H % 3 == 0 or W % 3 == 0:
        print(0)
        return

    ans = min(H, W)
    for y in range(H):
        a = W * y
        x = W // 2
        b = (H - y) * x
        c = (H - y) * (W - x)
        ans = min(ans, max(a, b, c) - min(a, b, c))

    for x in range(W):
        a = H * x
        y = H // 2
        b = (W - x) * y
        c = (W - x) * (H - y)
        ans = min(ans, max(a, b, c) - min(a, b, c))

    print(ans)

if __name__ == '__main__':
    main()


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

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

    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    int ans = 100 * 100 * 100;
    for(int p=x[0]; p<=x[n-1]; p++){
        int energy = 0;
        for(int i=0; i<n; i++){
            energy += (x[i] - p) * (x[i] - p);
        }
        ans = min(ans, energy);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;;
    vec H(N); REP(i,N){
        cin>>H[i];
    }
    int ans = 0;
    int now = 0;
    REP(i,N){
        if(H[i]<=now) now = H[i];
        else{
            ans += H[i]-now;
            now = H[i];
        }
    }
    Out(ans);
}

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

using namespace std;

typedef long long ll;

int main() {

    ll n;
    cin >> n;
    int gy = 0, br = 0, gr = 0, cy = 0, bl = 0, yl = 0, org = 0, r = 0, h = 0;
    for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
    if(x >= 1 && x <= 399) {
        gy = 1;
    }
    else if(x >= 400 && x <= 799) {
        br = 1;
    }
    else if(x >= 800 && x <= 1199) {
        gr = 1;
    }
    else if(x >= 1200 && x <= 1599) {
        cy = 1;
    }
    else if(x >= 1600 && x <= 1999) {
        bl = 1;
    }
    else if(x >= 2000 && x <= 2399) {
        yl = 1;
    }
    else if(x >= 2400 && x <= 2799) {
        org = 1;
    }
   else if(x >= 2800 && x <= 3199) {
        r = 1;
    }
    else {
        h++;
    }

    }
    int y = min(8, h);

    cout << max((gy + br + gr + cy + bl + yl + org + r), 1) << " " << gy + br + gr + cy + bl + yl + org + r + h << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IO std::ios::sync_with_stdio(false);std::cin.tie(0)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
#define fi first
#define se second
#define pb push_back
int main(){
 int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0){
		a-=d;
		c-=b;
	}
	if(c<=0) cout<<"Yes"<<'\n';
	else cout<<"No"<<'\n';
}

Measured memory_bytes: 3676
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

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;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#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 all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

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

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

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;
#pragma endregion

signed solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a == b + c || a + c == b)
		print("Yes");
	else
		print("No");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m){
        cin >> b[i];
    }
    int cnt=0;
    rep(i,n){
        int sum=c;
        rep(i,m){
            int m;
            cin >> m;
            sum+=m*b[i];
        }
        if(sum>0){
            cnt+=1;
        }
    }
    cout << cnt;

    return 0;
}

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


int query (map<char, int> lcounter, map<char, int> rcounter) {
    int ans = 0;

    for (pair<char, int> lpair: lcounter) {
        char key = lpair.first;
        int count = lpair.second;

        if (count <= 0 or rcounter.find(key) == rcounter.end()) continue;
        if (rcounter[key] > 0) ans++;
    }

    return ans;
}


int main() {
    int n; string s; cin >> n >> s;
    map <char, int> lcount, rcount;
    int ans = 0;

    for (char c: s) {
        if (lcount.find(c) == lcount.end()) {
            lcount[c] = 1;
        }
        else {
            lcount[c]++;
        }
    }

    for (char c: s) {
        lcount[c]--;

        if (rcount.find(c) == rcount.end()) {
            rcount[c] = 1;
        }
        else {
            rcount[c]++;
        }
        ans = max(ans, query(lcount, rcount));
    }

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



Measured memory_bytes: 256
//
//  main.cpp
//  BC20161109
//
//  Created by TA on 2016/11/09.
//  Copyright © 2016年 TA. All rights reserved.
//

#include <iostream>
#include <list>
using namespace std;
int main(int argc, const char * argv[]) {
    int Origin[4]={0,0,0,0};
    cin >> Origin[2];
    cin >> Origin[3];
    int N;
    cin >> N;
    int a[100][3];
    int val;
    int index;
    int text[3*N];
    int ans = 0;
//    for (int i=0;i<3*N; i++) {
//        while (cin >> val) {
//            text[i]=val;
//        }
    
//    }
    for (int i = 0; i < N ; i++) {
        
        for (int j = 0; j < 3 ; j++) {
            cin >> index;
            a[i][j] = index;
        }
    }
    for (int i = 0; i< N; i++) {
        switch (a[i][2]) {
            case 1:
                if (Origin[0]<a[i][0]
                    ) {
                    Origin[0]=a[i][0];
                }
                break;
            case 2:
                if (Origin[2]>a[i][0]
                    ) {
                    Origin[2]=a[i][0];
                }
                break;
            case 3:
                if (Origin[1]<a[i][1]
                    ) {
                    Origin[1]=a[i][1];
                }
                break;
            case 4:
                if (Origin[3]>a[i][1]
                    ) {
                    Origin[3]=a[i][1];
                }
                break;
                
            default:
                break;
        }
    }
    if(Origin[0]<Origin[2]&&Origin[1]<Origin[3]){
        cout <<(Origin[2]-Origin[0])*(Origin[3]-Origin[1]) <<endl;
    }
    else{ cout << 0<<endl;}
    return 0;
}


Measured memory_bytes: 256