akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
		
	int n;
	cin >> n;

	const int maxn = 1e6 + 5;

	vector<int> f(maxn, -1);
	bool ok1 = true, ok2 = true;

	int g = 0;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		g = __gcd(g, x);
		a[i] = x;
	}

	if(g != 1)
		ok2 = false;

	for(int i = 2; i < maxn; i++){
		if(f[i] == -1){
			for(int j = i; j < maxn; j += i)
				f[j] = i;
		}
	}

	vector<int> cnt(maxn);
	for(int i = 0; i < n; i++){
		int x = a[i];
		// cerr << "here" << endl;
		while(x > 1){
			int p = f[x];
			// cerr << x << " " << p << endl;
			cnt[p]++;
			if(cnt[p] >= 2)
				ok1 = false;
			while(x % p == 0){
				x /= p;
			}
		}
	}

	if(ok1)
		cout << "pairwise coprime" << endl;
	else if(ok2)
		cout << "setwise coprime" << endl;
	else
		cout << "not coprime" << endl;
	
	return 0;
}

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

int main() {
	string n;
	cin >> n;
	string ans = "No";
	for (int i = 0; i < n.size(); i++) {
		if (n.at(i) == '9') {
			ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <char> mp[10];

void mk_mp(){
  mp[1].resize(5);
  mp[1][0]='\'', mp[1][1]=',',mp[1][2]='.',mp[1][3]='!',mp[1][4]='?';

  for(int i=0;i<5;i++){
    for(int j='a'+i*3;j<'a'+i*3+3;j++) mp[i+2].push_back(j);
    for(int j='A'+i*3;j<'A'+i*3+3;j++) mp[i+2].push_back(j);
  }
  for(int i='p';i<='s';i++) mp[7].push_back(i);
  for(int i='P';i<='S';i++) mp[7].push_back(i);
  for(int i='t';i<='v';i++) mp[8].push_back(i);
  for(int i='T';i<='V';i++) mp[8].push_back(i);
  for(int i='w';i<='z';i++) mp[9].push_back(i);
  for(int i='W';i<='Z';i++) mp[9].push_back(i);
 
}

string solve(string str){
  if(str[str.size()-1]!='0')str+='0';  
  string res;
  for(int i=0;i<str.size();i++){
    int cnt=0;
    if(str[i]=='0'){res+=' ';continue;}
    while(str[i]==str[i+1])i++,cnt++;
    res+=mp[str[i]-'0'][cnt%mp[str[i]-'0'].size()];    
    if(str[i+1]=='0')i++;
  }
  return res;
}

int main(){
  mk_mp();  
  string str;
  while(cin>>str)cout <<solve(str)<<endl;


}

Measured memory_bytes: 1212
#include<stdio.h>
int main()
{
          int x,i=1,j;
          do
          {
                    scanf("%d",&x);
                    if(x==0)
                    {
                              break;
                    }
                    printf("Case %d: %d\n",i,x);
                    i++;
          }
          while(x!=0);


                    return 0;

}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    string a, b;
    cin >> a >> b;
    for(int i = 0; i < a.size(); i++){
        if(i < b.size()) cout << a[i] << b[i];
        else cout << a[i];
    }
    
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right; sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, m = wi()
#XYZ
w = mi(m)

class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [-1 for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        """self.rank = [0] * (n + 1)"""


    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

        # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if x != y:
            if self.par[x] < self.par[y]:#par<0の小さい方に合わせる
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
            # 木の高さが同じなら片方を1増やす
                """if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1"""

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]
u = UnionFind(n)
for i in range(m):
    u.union(w[i][0], w[i][1])

se = set()
for i in range(1, n + 1):
    se.add(u.find(i))


print(len(se))

Measured memory_bytes: 60988
using System;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int d = int.Parse(str[3]);


            if(Math.Abs(a - c) <= d || Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<string,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int modpow(ll x, ll n){
    int res = 1;
    while(n){
        if(n % 2) res = (ll)res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }

    return res;
}

int main(void){

    int n;
    cin >> n;

    ll ans = modpow(10, n) - modpow(9, n) - modpow(9, n) + modpow(8, n);
    ans %= MOD;
    if(ans < 0) ans += MOD;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3624
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
 
E = [[] for _ in [0]*N]
for i,ab in enumerate(AB):
    a,b = ab
    a -= 1
    b -= 1
    E[a].append((b,i))
    E[b].append((a,i))
 
done = [False]*N
done[0] = True
ans = [0]*(N-1)
q = [(0,0)]
while q:
    i,c0 = q.pop()
    c = 1
    for j,ei in E[i]:
        if done[j]:continue
        done[j] = True
        if c==c0: c+=1
        q.append((j,c))
        ans[ei] = c
        c += 1
 
print(max(ans))
for out in ans:
    print(out)

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

VV G;
V c, dp;
Vll ans;
int s = 0;

ll chs(ll x) {
  return x*(x+1)/2;
}

void dfs(int u, int p=-1) {
  int tmp = s + dp[c[u]];
  ++s;
  for (auto v : G[u]) if (v != p) {
    dp[c[u]] = -s;
    dfs(v, u);
    ans[c[u]] -= chs(s + dp[c[u]]);
  }
  dp[c[u]] = tmp - s;
}


int main() {
  ll n; cin >> n;
  G.assign(n, V());
  c.assign(n, 0);
  dp.assign(n, 0);
  ans.assign(n, chs(n));

  rep(i, n) {
    cin >> c[i];
    --c[i];
  }
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);

  rep(i, n) {
    ans[i] -= chs(s + dp[i]);
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 29840
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  for(i=0;i<=VMAX;i++)C[i]=0;
  
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
  /*  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
    }*/
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9600
#include <stdio.h>

void print_frame(int height, int width);

int main(void){

    int h, w;

    while(1){
        //input
        scanf("%d %d", &h,&w);

        if(h==0 && w==0){
            return 0;
        }
        else{
            print_frame(h,w);
            printf("\n");
        }
    }

}

void print_frame(int height, int width){

    int i,j;

    for(i=0; i<height; i++){
        if( i==0 || i==(height-1) )
            for(j=0; j<width; j++){
                printf("#");
            }
        else{
            printf("#");
            for(j=1; j<(width-1); j++){
                printf(".");
            }
            printf("#");
        }
        printf("\n");
    }
}

Measured memory_bytes: 572
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

namespace FastFourierTransform
{
	using C = complex< double >;

	void DiscreteFourierTransform(vector< C > &F, bool rev)
	{
		const int N = (int)F.size();
		const double PI = (rev ? -1 : 1) * acos(-1);
		for (int i = 0, j = 1; j + 1 < N; j++) {
			int k=N>>1;
			for (; k > (i ^= k); k >>= 1);
			if (i > j) {
				swap(F[i], F[j]);
			}
		}
		C w, s, t;
		for (int i = 1; i < N; i <<= 1) {
			for (int k = 0; k < i; k++) {
				w = polar(1.0, PI / i * k);
				for (int j = 0; j < N; j += i * 2) {
					s = F[j + k];
					t = C(F[j + k + i].real() * w.real() - F[j + k + i].imag() * w.imag(),
						F[j + k + i].real() * w.imag() + F[j + k + i].imag() * w.real());
					F[j + k] = s + t, F[j + k + i] = s - t;
				}
			}
		}
		if (rev) for (int i = 0; i < N; i++) F[i] /= N;
	}

	vector< long long > Multiply(const vector<long long int > &A, const vector<long long int > &B)
	{
		int sz = 1;
		while (sz <= A.size() + B.size()) sz <<= 1;
		vector< C > F(sz), G(sz);
		for (int i = 0; i < A.size(); i++) F[i] = A[i];
		for (int i = 0; i < B.size(); i++) G[i] = B[i];
		DiscreteFourierTransform(F, false);
		DiscreteFourierTransform(G, false);
		for (int i = 0; i < sz; i++) F[i] *= G[i];
		DiscreteFourierTransform(F, true);
		vector< long long > X(A.size() + B.size() - 1);
		for (int i = 0; i < A.size() + B.size() - 1; i++) X[i] = F[i].real() + 0.5;
		return (X);
	}
};

long long int comb(long long int a, long long int k) {
	if(k==0)return 1;
	if(k==a)return 1;
	return comb(a-1,k-1)+comb(a-1,k);
}

long long int solve(int k,const vector<int>&v,vector< int>nums, const int now) {
	if (now == 10) {
		long long int ans=1;
		int sum=accumulate(nums.begin(),nums.end(),0);
		int rest=sum;
		for (int i = 0; i < 10; ++i) {
			if (nums[i]) {
				ans*=comb(rest,nums[i]);
				rest-=nums[i];
			}
		}
		if (nums[0]) {
			long long int nans=1;
			int rest=sum-1;
			for (int i = 0; i < 10; ++i) {
				if (nums[i]) {
					if(i==0)nans*=comb(rest,nums[i]-1);
					else nans*=comb(rest,nums[i]);

					if(i==0)rest-=nums[i]-1;
					else rest-=nums[i];
				}
			}
			ans-=nans;
		}
		return ans;
	}
	else {
		if (v[now]) {
			long long int ans=0;

			for (int x = 1; x <= v[now];++x) {
				nums[now]=x;
				ans += solve(k, v, nums, now + 1);
			}
			return ans;
		}
		else {
			nums[now]=0;
			return solve(k,v,nums,now+1);
		}
	}
}

int main()
{
	while (true) {
		int N,M;cin>>N>>M;
		if(!N)break;
		vector<int>v(M,-100000);
		for (int i = 0; i < N; ++i) {
			int a;cin>>a;
			int b;cin>>b;
			v[a-1]=max(v[a-1],b);
		}
		cout<<accumulate(v.begin(),v.end(),0)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3080
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;

int main(int argc, char *argv[])
{
	int N, sum[202] = {};
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		for (int j = -100; j <= 100; ++j) {
			sum[j + 100] += (a - j) * (a - j);
		}
	}
	int ans = 1 << 30;
	for (int j = -100; j <= 100; ++j) {
		ans = min(ans, sum[j + 100]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("mmx,avx,fma")
//#pragma GCC optimize ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, set<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define cont continue
#define ret return
#define For(i, a, b) for (int i = a; i < b;i++)
#define forn(i, a) for (int i = 0;i < a;i++)
#define ford(i, a, b) for (int i = b - 1;i >= a;i--)
#define fordn(i, a) for (int i = a - 1;i >= 0;i--)
#define forr(x, arr) for(auto &x: arr)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << (s_) << '\n';return 0;}
#define endl '\n'
#define makeunique(x) sort(all(x)), (x).resize(unique(all(a)) - (x).begin())
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef long double ldd;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_tree;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod = 1e9 + 7;
//const int mod = 998244353;
ll powq(ll a, ll n) {
    ll res = 1;
    while (n){
        if (n & 1) {
            res *= a;
            res %= mod;
            --n;
        }
        else {
            a *= a;
            n >>= 1;
            a %= mod;
        }
    }
    return res;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int ans = 0, gg = 0;
    forn(i, s.size()){
        if (s[i] == 'W') ans += gg;
        else gg++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
int main(void){
    
    int n,k;
    cin >> n >> k;

    vector<string> ng;

    for(int i=0; i<k; i++) {
        string temp;
        cin >> temp;
        ng.push_back(temp);
    }

    while(1) {
        bool found = false;
        for(auto itr = ng.begin(); itr != ng.end(); itr++) {
            string n_str = to_string(n);
            for(int i=0; i<n_str.size(); i++) {
                if(n_str.substr(i,1) == (*itr)) {
                    found = true;
                    break;
                }
            }
            if(found) break;
        }
        if(found) n++;
        else break;
    }
    
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [Int] -> [[Int]] -> [Int]
solve pl = iter where
    iter [] = []
    iter ([t, f]:qs) = search ! 2 : iter qs where
        dice = listArray (0, 5) pl
        search = rollUntil 0 t "W" $ case dice of
            _   | dice!3 == f  -> roll "ES" dice
                | dice!2 == f  -> roll "WS" dice
                | otherwise -> rollUntil 1 f "S" dice
        roll [] d = d
        roll (c:cs) d = roll cs $ case c of
            'N' -> d // [(0, d!1), (1, d!5), (4, d!0), (5, d!4)]
            'E' -> d // [(0, d!3), (2, d!0), (3, d!5), (5, d!2)]
            'W' -> d // [(0, d!2), (2, d!5), (3, d!0), (5, d!3)]
            'S' -> d // [(0, d!4), (1, d!0), (4, d!5), (5, d!1)]
        rollUntil p x c = iter where
            iter d  | d!p == x = d
                    | otherwise = iter (roll c d)
                                
readLine:: IO [Int]
readLine = fmap (map read . words) getLine

main :: IO() 
main = do
    pl <- readLine
    n  <- readLn
    ql <- replicateM n readLine
--    print pl
--    print ql
    mapM_ print (solve pl ql)



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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=200009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int far=1,mx=1;
vector<int>adj[M+6];
void  dfs(int u,int lvl,int par)
{
    if(lvl>=mx)
    {
        mx=lvl;
        far=u;
    }
    for(auto v:adj[u])
    {
        if(v==par)continue;
        dfs(v,lvl+1,u);
    }
}
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n-1)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1,1,1);
    dfs(far,1,far);
    if((mx)%3==2)
    {
        cout<<"Second"<<endl;
    }
    else
    {
        cout<<"First"<<endl;
    }
    return 0;

}





































Measured memory_bytes: 23832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,h,k,ans;
    cin>>a>>b>>h;
    k=(b-a)*h;
    k=k/2;
    ans=k+(a*h);
    cout<<ans<<en;
	return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,k,g,c,p;
    string t;
    cin>>n>>k>>g>>c>>p>>t;

    int ans=0;
    string te="";
    REP(i,0,n){
        if(i>=k){
            if(t[i]=='r' && te[i-k]!='p'){
                ans += p;
                te += "p";
            }else if(t[i]=='s' && te[i-k]!='g'){
                ans += g;
                te += "g";
            }else if(t[i]=='p' && te[i-k]!='c'){
                ans += c;
                te += "c";
            }else te += "x";
        }else{
            if(t[i]=='r'){
                ans += p;
                te += "p";
            }
            if(t[i]=='s'){
                ans += g;
                te += "g";
            }
            if(t[i]=='p'){
                ans += c;
                te += "c";
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

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

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}



int main(void)
{
    int n;
    int ans = 0;
    scanf("%d", &n);
    char s[n+1][10];
    int countAB = 0;
    int countA = 0;
    int countB = 0;
    int index = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", s[i]);
        int len = strlen(s[i]);
        if(s[i][len-1] == 'A' && s[i][0] == 'B')
            countAB++;
        else if(s[i][len-1] == 'A')
            countA++;
        else if(s[i][0] == 'B')
            countB++;

        for (int j = 0; j < len-1; j++)
        {
            if(s[i][j] == 'A' && s[i][j+1] == 'B')
                ans++;
        }
    }

    if(countAB > 0)
    {
        ans += countAB - 1;
     
        if(countA>=1)
        {
            countA--;
            ans++;
        }
        if(countB>=1)
        {
            countB--;
            ans++;
        }
        
        ans += countA < countB ? countA : countB;
        
    }
    else
    {
        ans += countA < countB ? countA : countB;
    }
    
    printf("%d\n", ans);
    
    
    return 0;
}



Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        a *= 2;
        int[] c = new int[a];
        int[] d = new int[a];
        int[] e = new int[a];
        for (int i = 1; i <= a; i++)
            c[i - 1] = i;
        for (int i = 0; i < b; i++)
        {
            int f = int.Parse(Console.ReadLine());
            if (f == 0)
            {
                Array.Copy(c, 0, d, 0, a / 2 );
                Array.Copy(c, a / 2, e,0 , a - a/2);
                for (int j = 0; j < a; j++)
                {
                    if (j % 2 == 0)
                        c[j] = d[j / 2];
                    else
                        c[j] = e[(j-1) / 2];
                }
            }
            else
            {
                Array.Copy(c, 0, d, 0, f );
                Array.Copy(c, f, e, 0, a - f);
                int j;
                for (j = 0; j < a - f+1; j++)
                    c[j] = e[j];
                for (int z = --j ; z < a; z++)
                    c[z] = d[z - (j)];
            }
        }
        for (int i = 0; i <a ; i++) {
            Console.WriteLine(c[i]);
        }
    }
}

Measured memory_bytes: 9172
#include <cstdio>
#include <functional>
#include <numeric>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    while (true) {
        int n; scanf("%d", &n);
        if (n == 0) break;
        vector<int> p(n-1); repeat (i, n-1) { scanf("%d", &p[i]); -- p[i]; }
        vector<int> d(n-1); repeat (i, n-1) scanf("%d", &d[i]);
        vector<vector<pair<int, int> > > g(n);
        repeat (i, n-1) {
            g[i+1].emplace_back(p[i], d[i]);
            g[p[i]].emplace_back(i+1, d[i]);
        }
        auto dist = vectors(n, n, -1);
        repeat (root, n) {
            function<void (int)> dfs = [&](int i) {
                for (auto e : g[i]) {
                    int j, d; tie(j, d) = e;
                    if (dist[root][j] == -1) {
                        dist[root][j] = dist[root][i] + d;
                        dfs(j);
                    }
                }
            };
            dist[root][root] = 0;
            dfs(root);
        }
        int longest = 0;
        repeat (i, n) if (g[i].size() >= 2) {
            repeat (j, n) if (g[j].size() >= 2) {
                setmax(longest, dist[i][j]);
            }
        }
        int d_sum = whole(accumulate, d, 0);
        int d_leaf = 0;
        repeat (i, n) if (g[i].size() == 1) {
            d_leaf += g[i][0].second;
        }
        int result = 3 * d_sum - 2 * d_leaf - longest;
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
set <int> s;
int main()
{
  	int a, b, c;
  	cin >> a >> b >> c;
  s.insert(a), s.insert(b), s.insert(c);
  if(s.size() == 2) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>

int makeFibonacci();
int F[45];

int main(){
    int n;

    scanf("%d", &n);
    printf("%d\n", makeFibonacci(n));

    return 0;

}
int makeFibonacci(int N){
    int i;

    F[0] = 1;
    F[1] = 1;
    
    for(i = 2; i <= N; i++){
        F[i] = F[i-2] + F[i-1];
    }
    return F[N];
}

Measured memory_bytes: 596
N, K = map(int, input().split())
s_sum = [0]
g_sum = [N]
mod = 10**9 + 7
for i in range(N):
    s_sum.append(s_sum[i] + (i+1))
    g_sum.append(g_sum[i] + (N-(i+1)))

# print(s_sum)
# print(g_sum)
ans = 0
for i in range(K, N+2):
    ans += g_sum[i-1] - s_sum[i-1] + 1
    ans %= mod

print(ans%mod)

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

using namespace std;

typedef long long ll;

signed main()
{
    int h, w, s, t;
    cin >> h >> w >> s >> t;
    if(h % 2 == 0 || w % 2 == 0){
        cout << "Yes" << endl;
    }
    else if((s + t) % 2 == 1){
        cout << "No" << endl;
    }else
        cout << "Yes" << endl;
}



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


void solve(long long N, long long M){
    cout << N * (N-1)/2 + M * (M-1)/2 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a

    if a > b:
        return gcd(b, a % b)
    else:
        return gcd(a, b % a)


def gcd_multi(nums):
    if len(nums) == 0:
        return 0
    if len(nums) == 1:
        return nums[0]

    ret = gcd(nums.pop(), nums.pop())
    while len(nums) > 0:
        ret = gcd(ret, nums.pop())
    return ret


def solve(inputs):
    monsters = string_to_int(inputs[0])
    return gcd_multi(monsters)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Measured memory_bytes: 15420
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long combi[1000][1000] = {};
long long combination(long long n, long long r) {
	if (combi[n][r]) return combi[n][r];
	if (n == 0) return 1;
	if (r == 0) return 1;
	if (n == r) return 1;
	return combi[n][r] = combination(n - 1, r) + combination(n - 1, r - 1);
}
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<long long> wow;
	REP(i, n) {
		long long c;
		cin >> c;
		wow.push_back(c);
	}
	sort(wow.begin(), wow.end(), greater<long long>());
	long long ans[2] = {};
	ans[0] += wow[0];
	bool ok = false;
	for (int i = 1;i < a;++i) {
		ans[0] += wow[i];
		if (wow[i] != wow[i - 1]) ok = true;
	}
	long long cnt = 0;
	for (int i = 0;i < n;++i) {
		if (wow[i] == wow[a-1]) cnt++;
	}
	if (ok == true) {
		for (int q = 0;q < n;++q) {
			if (wow[q] == wow[a-1]) {
				ans[1] = combination(cnt,a - q);
				break;
			}
		}
	}
	else {
		for (int q = n - 1;q >= 0;--q) {
			if (wow[q] == wow[0]) {
				for (int hoge = a;hoge <= b;++hoge) {
					if (hoge > q + 1) goto out;
					ans[1] += combination(q + 1, hoge);
				}
				goto out;
			}
		}
	}
out:;
	double woa = ans[0];
	woa /= a;
	cout <<fixed << setprecision(10) <<  woa << " " << ans[1] << endl;
	return 0;
}

Measured memory_bytes: 512
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


# --------------------------------------------

dp = None


def main():
    H, W = li_input()
    N = int(input())
    A = li_input()

    CS = [None]
    cs = 0
    for a in A:
        cs += a
        CS.append(cs)

    B = [[0] * W for _ in range(H)]

    B_idx = 0
    c_color = 1

    for i in range(H):
        if i % 2 == 0:
            rng = range(W)
        else:
            rng = range(W - 1, -1, -1)

        for j in rng:
            if B_idx == CS[c_color]:
                c_color += 1

            B[i][j] = c_color
            B_idx += 1

    for row in B:
        print(" ".join(list(map(str, row))))


main()


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

using namespace std;

const int N=1e6+5;

typedef long long ll;

int a[N],n,m,sum,ans,l,r;

char s[N];

int main()
{   
    int ans=2019;
    scanf("%d%d",&l,&r);
    for(int i=l;i<min(l+2019,r+1);i++){
        for(int j=i+1;j<min(i+2019,r+1);j++){
            int curr=((ll)i*j)%2019;
            ans=min(curr,ans);
        }
    }
    printf("%d\n",ans);

}


Measured memory_bytes: 256
import math
def PC(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
    return int(result)

#kaijou = [0, 1]
#for i in range(2, 1000):
 #   kaijou.append(kaijou[i - 1] * i)

#print(kaijou[0:10])

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = []
j = 0
for i in A:
    if j == 0:
        B.append(i)
    else:
        B.append(B[j - 1] + i)
    j += 1
for i in range(len(B)):
    B[i] = B[i] % M
C = sorted(B)
anscnt = 0
samecnt = 1
for i in range(len(C)):
    if C[i] == 0:
        anscnt += 1
    if i != 0:
        if C[i] == C[i - 1]:
            samecnt += 1
        elif samecnt != 1:
            anscnt += ncr(samecnt, 2)
            samecnt = 1
        if i == len(C) - 1 and samecnt != 1:
            anscnt += ncr(samecnt, 2)
            samecnt = 1
print(anscnt)
            

Measured memory_bytes: 15020
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int n, i;
    cin>>n;
    long int a[n-1], c[n+1]={0};
    for(i=0; i<(n-1); i++)
    {
        cin>>a[i];
        c[a[i]]++;
    }
    for(i=1; i<(n+1); i++)
    {
        cout<<c[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 6752
n = int(input())
m=list(map(int,input().split()))

l=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if m[i]!=m[j]:
            for k in range(j+1,n):
                if m[j]!=m[k] and m[k]!=m[i]:
                    p=0
                    if m[i]+m[j]>m[k]:
                        p+=1
                    if m[i]+m[k]>m[j]:
                        p+=1
                    if m[k]+m[j]>m[i]:
                        p+=1
                    
                    if p==3:
                        l+=1
print(l)
    

Measured memory_bytes: 68624
def solve():
    N, *h = map(int, open(0).read().split())
    
    ans = 0
    for _ in range(10000000):
        l, r = 0, 0
        tmp_min = 1000
        flag = False
        
        for i in range(N):
            if 0 < h[i]:
                l = i
                r = i
                flag = True
                tmp_min = h[i]
                break
        for i in range(l+1, N):
            if h[i] == 0:
                break
            r = i
            tmp_min = min(tmp_min, h[i])
        for i in range(l, r+1):
            h[i] -= tmp_min
        
        if not flag:
            break
        ans += tmp_min
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
class TravelingSalesmanAroundLake:
    def calculdat_diff(self, lake_dis, house_num, coordinate_list):
        count = 0
        max_dis = (lake_dis - coordinate_list[len(coordinate_list) - 1]) + coordinate_list[0]
        for c in coordinate_list:
            dis = coordinate_list[count + 1] - c
            if dis > max_dis:
                max_dis = dis
            count +=1
            if count + 1 == len(coordinate_list):
                break
        return max_dis
    
    def calculate_minimum(self, lake_distance, max_dis):
        return lake_distance - max_dis

if __name__ == "__main__":
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    tsl = TravelingSalesmanAroundLake()
    max_dis = tsl.calculdat_diff(K, N, A)
    result = tsl.calculate_minimum(K, max_dis)
    print(str(result))

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

int a[11], b, t;

int main() {
  cin>>a[0];
  t=1;
  
  while(cin>>b) {
    if(b>0) {
      a[t]=b;
      t++;
    }else {
      cout<<a[t-1]<<endl;
      t--;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1160
/**
 *  author: mahfuzz
 *  created: 28.04.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << #x << ':' << x << "\n"
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int x; cin >> x;
    for(int i = 1; i <= x; i++){
        if(floor(i * 1.08) == x){
            cout << i << "\n";
            return 0;
        }
    }
    
    cout << ":(\n";
    
        
    return 0;
}



Measured memory_bytes: 256
h,w,k=map(int,input().split())
f=[1,1,2,3,5,8,13,21]
m=10**9+7
dp=[[1]+[0]*(w-1)for i in range(h+1)]
h=0if w==1else h
for i in range(1,h+1):
 for j in range(w):
  if j==0:dp[i][0]=(dp[i-1][0]*f[w-1] + dp[i-1][1]*f[w-2])%m;
  elif j==w-1:dp[i][w-1]=(dp[i-1][w-1]*f[w-1] + dp[i-1][w-2]*f[w-2])%m
  else:dp[i][j]=(dp[i-1][j]*f[j]*f[w-j-1]+dp[i-1][j-1]*f[j-1]*f[w-j-1]+dp[i-1][j+1]*f[j]*f[w-j-2])%m
print(dp[h][k-1])

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int H, W, N;
	cin >> H >> W >> N;
	vector<vector<int> > s(H + 1, vector<int>(W + 1));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> s[i + 1][j + 1];
			s[i + 1][j + 1] += s[i + 1][j] + s[i][j + 1] - s[i][j];
		}
	}
	function<int(int, int, int, int)> sum = [&](int xa, int ya, int xb, int yb) {
		return s[xa][ya] + s[xb][yb] - s[xa][yb] - s[xb][ya];
	};
	function<int(int, int, int, int)> solve2 = [&](int xa, int ya, int xb, int yb) {
		int res = 0;
		for (int i = xa + 1; i <= xb - 1; ++i) {
			res = max(res, min(sum(xa, ya, i, yb), sum(i, ya, xb, yb)));
		}
		for (int i = ya + 1; i <= yb - 1; ++i) {
			res = max(res, min(sum(xa, ya, xb, i), sum(xa, i, xb, yb)));
		}
		return res;
	};
	function<int(int, int, int, int)> solve3 = [&](int xa, int ya, int xb, int yb) {
		int res = 0;
		for (int i = xa + 1; i <= xb - 1; ++i) {
			res = max(res, min(sum(xa, ya, i, yb), solve2(i, ya, xb, yb)));
			res = max(res, min(solve2(xa, ya, i, yb), sum(i, ya, xb, yb)));
		}
		for (int i = ya + 1; i <= yb - 1; ++i) {
			res = max(res, min(sum(xa, ya, xb, i), solve2(xa, i, xb, yb)));
			res = max(res, min(solve2(xa, ya, xb, i), sum(xa, i, xb, yb)));
		}
		return res;
	};
	if (N == 2) cout << solve2(0, 0, H, W) << '\n';
	if (N == 3) cout << solve3(0, 0, H, W) << '\n';
	if (N == 4) {
		int res = 0;
		for (int i = 1; i <= H - 1; ++i) {
			res = max(res, min(sum(0, 0, i, W), solve3(i, 0, H, W)));
			res = max(res, min(solve2(0, 0, i, W), solve2(i, 0, H, W)));
			res = max(res, min(solve3(0, 0, i, W), sum(i, 0, H, W)));
		}
		for (int i = 1; i <= W - 1; ++i) {
			res = max(res, min(sum(0, 0, H, i), solve3(0, i, H, W)));
			res = max(res, min(solve2(0, 0, H, i), solve2(0, i, H, W)));
			res = max(res, min(solve3(0, 0, H, i), sum(0, i, H, W)));
		}
		for (int i = 1; i <= W - 1; ++i) {
			for (int j = i + 1; j <= W - 1; ++j) {
				vector<int> ax(H - 1), ay(H - 1);
				for (int k = 1; k <= H - 1; ++k) {
					ax[k - 1] = min(sum(0, j, k, W), sum(k, i, H, W));
					ay[k - 1] = min(sum(0, i, k, W), sum(k, j, H, W));
				}
				int curx = 0;
				for (int k = 0; k <= H - 2; ++k) {
					curx = max(curx, min(sum(0, 0, k, j), sum(k, 0, H, i)));
					res = max(res, min(ax[k], curx));
				}
				int cury = 0;
				for (int k = H - 2; k >= 0; --k) {
					cury = max(cury, min(sum(0, 0, k + 1, i), sum(k + 1, 0, H, j)));
					res = max(res, min(ay[k], cury));
				}
			}
		}
		cout << res << '\n';
	}
	return 0;
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD{1000000007};
    unsigned long N;
    cin >> N;
    unsigned long S{0}, T{0};
    for(unsigned long i{0}, A; i < N; ++i){
        cin >> A;
        (S += A) %= MOD;
        (T += A * A) %= MOD;
    }
    cout << (S * S % MOD + MOD - T) * (MOD + 1) / 2 % MOD << endl;
    return 0;
}

Measured memory_bytes: 3628
import numpy as np

N=int(input())

S=[]
count_S={}
for i in range(N):
    s=input()
    S.append(s)
    count_S[s]=0

for key in S:
    count_S[key]+=1

keys=np.array(list(count_S.keys()))
values=np.array(list(count_S.values()),dtype=np.int32)
out=np.where(values==np.max(values))
result=np.sort(keys[out])

for r in result:
    print(r)

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

template<typename T, T mod>
class Modint {
private:
  T x;

public:
  Modint(): x((T)0) {}
  Modint(T y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}

  T get() {
    return x;
  }

  Modint &operator+=(const Modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  Modint &operator-=(const Modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  Modint &operator*=(const Modint &p) {
    x = x * p.x % mod;
    return *this;
  }

  Modint &operator/=(const Modint &p) {
    *this *= p.inverse();
    return *this;
  }

  Modint operator-() const { return Modint(-x); }
  Modint operator+(const Modint &p) const {return Modint(*this) += p; }
  Modint operator-(const Modint &p) const {return Modint(*this) -= p; }
  Modint operator*(const Modint &p) const {return Modint(*this) *= p; }
  Modint operator/(const Modint &p) const {return Modint(*this) /= p; }

  bool operator==(const Modint &p) const { return x == p.x; }
  bool operator!=(const Modint &p) const { return x != p.x; }

  Modint inverse() const {
    T a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return Modint(u);
  }

  Modint pow(int e) const {
    T a = 1, p = x;
    while(e > 0) {
      if (e % 2 == 0) {
	p = (p * p) % mod;
	e /= 2;
      } else {
	a = (a * p) % mod;
	e--;
      }
    }
    return Modint(a);
  }
};

constexpr long long MOD = 1000000007;

using mi = Modint<long long, MOD>;

int main() {
  ll n;
  cin >> n;
  if (n < 2) {
    cout << 0 << '\n';
    return 0;
  }

  mi ans = mi(10).pow(n) - mi(9).pow(n) - mi(9).pow(n) + mi(8).pow(n);
  cout << ans.get() << '\n';
  return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int ans = 0;
		if(X >= 400) {
			if(X < 600) {
				ans = 8;
			}else if(X < 800) {
				ans = 7;
			}else if(X < 1000) {
				ans = 6;
			}else if(X < 1200) {
				ans = 5;
			}else if(X < 1400) {
				ans = 4;
			}else if(X < 1600) {
				ans = 3;
			}else if(X < 1800) {
				ans = 2;
			}else if(X < 2000) {
				ans = 1;
			}
		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 35716