akhauriyash/Code-Regression huggingface dataset:
// Example program
#include <stdio.h>

long long n, m;

long long myAbs(long long x) {
    return x > 0 ? x : -x;
}

long long myMin(long long x, long long y) {
    return x < y ? x : y;
}

long long myMax(long long x, long long y) {
    return x > y ? x : y;
}

long long mn2(long long h, long long w, long long sq3) {
    long long toReturn = 1000000000;
    for(int i = myMax(h / 2 - 2, 0); i <= myMin(h / 2 + 4, h); i++) {
        long long sq1 = (w * i);
        long long sq2 = h * w - sq1;
        //printf("%d %d %d %d %d\n", h, w, sq1, sq2, sq3);
        if(sq1 < 0 || sq2 < 0 || sq3 < 0) continue;
        toReturn = myMin(toReturn, myMax(myAbs(sq2 - sq3), (myMax(myAbs(sq1 - sq2), myAbs(sq1 - sq3)))));
    }
    return toReturn;
}

long long mn3(long long h, long long w) {
    long long toReturn = 1000000000;
    for(int i = myMax(h / 3 - 3, 0); i < myMin(h, h / 3 + 5); i++) {
        long long H = h - i, W = w;
        long long sq = w * i;
        long long mn = myMin(mn2(H, W, sq), mn2(W, H, sq));
        toReturn = myMin(toReturn, mn);
    }
    return toReturn;
}

int main()
{
    scanf("%lld %lld", &n, &m);
    if(n % 3 == 0 || m % 3 == 0) {
        printf("0\n"); return 0;
    }
    
    printf("%lld\n", myMin(mn3(n, m), mn3(m, n)));
}


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

const int MAX_N = 200030;
int A[MAX_N];

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

  long long ans[2] = {0};
  for(int ii=0;ii<2;ii++){
    long long sum = 0;
    for(int i=0;i<n;i++){
      sum += A[i];
      if(i % 2 && sum >= 0) ans[ii] += (sum+1), sum = -1;
      if(i % 2 == 0 && sum <= 0) ans[ii] += (1 - sum), sum = 1;
    }
    for(int i=0;i<n;i++)
      A[i] *= -1;
  }
  cout << min(ans[0],ans[1]) << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main(void)
{
    int n, c, k;
    cin >> n >> c >> k;
    vll t(n);
    rep(i, 0, n) cin >> t[i];
    sort(t.begin(), t.end());

    int ans = 0;
    int time = t[0] + k, pass = 0;
    rep(i, 0, n)
    {
        //cout << i << endl;
        if (pass == c || time < t[i])
        {
            //cout << time << " " << pass << endl;
            ans++;
            pass = 1;
            time = t[i] + k;
        }
        else
        {
            pass++;
        }
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから

            var vs = IO.ReadLineToIntArray();
            var N = vs[0];
            var K = vs[1];

            var h = IO.ReadLineToIntArray();

            var ans = h.Count(v => v >= K);

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToList(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}


Measured memory_bytes: 19040
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()

if (a+b) % 2 == 1:
    print("IMPOSSIBLE")
else:
    print(int((a+b)//2))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
main(){
  const int ans=[]{
    const string s=[]{string s;cin>>s;return s;}();
    const int a=[&s]{
      int a;
      for(int i=s.size()-1;i>=0;--i)if(s[i]=='A')a=i;
      return a;
    }();
    const int z=[&s]{
      int z;
      for(int i=0;i<s.size();++i)if(s[i]=='Z')z=i;
      return z;
    }();
    return z-a+1;
  }();
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
using namespace std;
const int maxn=20+10;
int n,q;
int a[maxn];
int dd;
bool solve(int pos,int d)
{
  if(d<0) return false;
  if(d==0)   return true;
  if(pos<n)
  {
     return solve(pos+1,d-a[pos])||solve(pos+1,d);
  }
  return false;
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    scanf("%d",&q);
    while(q--)
    {
       scanf("%d",&dd);
       if(solve(0,dd)) printf("yes\n");
       else printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define N 200001
#define T (1<<18)
using namespace std;
typedef long long ll;
ll n,p[N];
ll tree[T*2-1];
 
void update(ll i,ll x) {
  i+=(T-1);
  tree[i] = x;
  while(i!=0){
    i=(i-1)/2;
    tree[i] = min(tree[i*2+1],tree[i*2+2]);
  }
}
 
ll find(int a ,int b,int ima,int L,int R){
  if(R<=a || b<=L) return INF;
  if(a<=L && R<=b) return tree[ima];
  ll M = (R+L)/2;
  return min(find(a,b,ima*2+1,L,M),find(a,b,ima*2+2,M,R));
}

ll search(int L,int R,int E){
  while(L<R){
    int M=(L+R)/2;
    if(find(M,E+1,0,0,T)==p[E]) R=M;
    else L=M+1;
  }
  return L-1;
}


ll search2(int L,int R,int E){
  while(L<R){
    int M=(L+R)/2;
    if(find(E,M+1,0,0,T)==p[E]) L=M+1;
    else R=M;
  }
  return L;
}


int main(){
  cin>>n;
  for(int i=0;i<T;i++)update(i,INF);
  for(int i=0;i<n;i++)cin>>p[i],update(i,p[i]);
  ll sum=0;
  for(int i=0;i<n;i++){
    ll l=search(0,i,i);
    ll r=search2(i,n,i);
    sum+=p[i]*(i-l)*(r-i);
  }
  cout<<sum<<endl;
  return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int score = 0;
	rep(i, n - 1) {
		if (s[i] == s[i + 1]) score++;
	}
	int ans = min(score + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum([1 for i in  self._parents if i<0])-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size

uf=UnionFind(n,1)
for i in range(m):
    x,y,z=map(int,input().split())
    uf.unite(x,y)
print(uf.group_count())

Measured memory_bytes: 11148
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



int main() {

    //
    int num = (int)('z' - 'a') + 1;
    bool is_found[num];
    fill(is_found, is_found+num, false);

    //
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); ++i) {
        int j = (int)(S[i] - 'a');
        is_found[j] = true;
    }


    //
    bool is_all_found = true;
    for (int i = 0; i < num; ++i) {
        if(!is_found[i]){
            is_all_found = false;
            cout << (char) ('a' + i) << endl;
            break;
        }

    }
    if(is_all_found)
        cout << "None" << endl;



    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<iomanip>
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << setw(3) << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()


using namespace std;
using ll = long long;
const int MOD = 1000000007;
int n;
bool a[21][21];
vector<vector<int>> dp;

int recv(int k, int bit)
{
    if (k == 0) return 1;
    if (dp[k][bit] != -1) return dp[k][bit];
    int cnt = 0;
    REP(i, n) if ((bit >> i) & 1) cnt++;
    if (cnt < k) return 0;
    ll ans = 0;
    REP (i, n) {
        if (!((bit >> i) & 1)) continue;
        if (!a[i][k - 1]) continue;
        ans = (ans + recv(k - 1, bit ^ (1 << i))) % MOD;
    }
    // DDD(k, bit, ans);
    dp[k][bit] = ans;
    return ans;
}

int main()
{
    cin >> n;
    dp = vector<vector<int>>(n + 1, vector<int>(1 << n, -1));
    REP(i, n) REP(j, n) {
        int t;
        cin >> t;
        a[i][j] = t == 1;
    }
    cout << recv(n, (1 << n) - 1) << endl;

    // for(auto row : dp) {
    //     DV(row);
    // }
}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> q(n);
    for (int i = 0; i < n; i++) cin >> q[i];
    int ans = 0;
    for (int l = 0; l <= k; l++) {
        for (int r = 0; r <= k - l; r++) {
            if (l + r > n) break;
            int d = k - l - r;
            int cur = 0;
            vector<int> s;
            for (int i = 0; i < l; i++) {
                cur += q[i];
                s.push_back(q[i]);
            }
            for (int i = n-r; i < n; i++) {
                cur += q[i];
                s.push_back(q[i]);
            }
            sort(s.begin(), s.end());
            for (int i = 0; i < d; i++) {
                if (i >= s.size()) break;
                if (s[i] > 0) break;
                cur -= s[i];
            }
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define eb emplace_back
#define pb push_back
#define mk make_pair
#define mt make_tuple

#define Umap unordered_map
#define graph vector<vector<int>>

#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl

#define INF 1e9+5
#define N 40001
#define MAXN   100001


bool sortbysec(const tuple<int, int, int>& a,  
               const tuple<int, int, int>& b) 
{ 
    return (get<1>(a) < get<1>(b)); 
}
void dfs(int s, graph &g, bool vis[]){
	vis[s] = true;
	for(int i=0;i<g[s].size();i++){
		if(!vis[g[s][i]]) dfs(g[s][i],g,vis);
	}
}

string common_prefix(vector<string>& strings){
	string prefix;
	for(string s : strings){
		for(int i=0;i<s.size() && s[i]!='*';++i){
			if(i<prefix.size()){
				if(s[i]!=prefix[i]) return "*";
			}
			else prefix+=s[i];
		}
	}
	return prefix;
}

void reverse(vector<string>& strings){
	for(string& s : strings){
		reverse(s.begin(),s.end());
	}
}

int spf[0];
void sieve(){
	spf[1] = 1;
	for(int i=2;i<MAXN;i++) spf[i] = i;

	for(int i=4;i<MAXN;i+=2) spf[i] = 2;

	for(int i=3; i*i<MAXN;i++){
		if(spf[i]==i){
			for(int j=i*i;j<MAXN;j+=i){
				if(spf[j]==j) spf[j] = i;
			}
		}
	}
}
vector<int> getFactorization(int x){

	vector<int> primeFactors;
	while(x>1){
		primeFactors.pb(spf[x]);
		x /= spf[x];
	}
	return primeFactors;
}



void solve(){
	// sieve(); 
	int h1,s1,h2,s2; cin>>h1>>s1>>h2>>s2;

	bool ans = true;

	while(1){
		h2-=s1;

		if(h2<=0) {ans = true; break;}

		h1-=s2;

		if(h1<=0) {ans = false; break;}
	}

	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	





}

int main() {
IOS;
	int t=1; 
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
N = int(input())
W = list(map(int,input().split()))

s = sum(W)
count = 0
index = 0
for i in range(N):
    count += W[i]
    if count > s/2:
        index = i-1
        #print(index)
        break

W.append(0)
W.append(0)
ab1 = abs(sum(W[:index+1])-sum(W[index+1:]))
ab2 = abs(sum(W[:index+2])-sum(W[index+2:]))
print(min(ab1, ab2))


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= 9; i++ {
		for j := 0; j <= 9; j++ {
			if i*j == n {
				fmt.Print("Yes")
              return
			}
		}
	}

	fmt.Print("No")
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int maxn = 100010;

void ng() {
    puts("-1");
    exit(0);
}

int main() {
    int N;
    cin >> N;
    V<int> A(N + 1);
    V<ll> suf(N + 2);
    for (int i = 0; i <= N; ++i) cin >> A[i];

    if (N == 0) {
        if (A[0] == 1) {
            cout << 1 << endl;
            return 0;
        } else {
            ng();
        }
    }

    if (A[0] > 0) {
        ng();
    }

    for (int i = N; i >= 0; --i) {
        suf[i] = suf[i + 1] + A[i];
    }

    ll x = 1;
    ll ans = 1;

    for (int i = 1; i <= N; ++i) {
        if (x * 2 < A[i]) {
            puts("-1");
            return 0;
        }
        ll d = min(x * 2, suf[i]);
        ans += d;
        x = d - A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4264
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, y;
    scan(n, y);
    foreach (one; 0 .. n + 1)
    {
        foreach (five; 0 .. n + 1)
        {
            long ten = y - one * 1_000 - five * 5_000;
            if (ten % 10_000 == 0 && ten >= 0)
            {
                ten /= 10_000;
                if (one + five + ten == n)
                {
                    writefln("%s %s %s", ten, five, one);
                    return;
                }
            }
        }
    }
    writeln("-1 -1 -1");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

constexpr int MAX_N = 200000;

using P = std::pair<int, int>;

int N, K, L;
std::vector<int> G[2][MAX_N];
int id[2][MAX_N];
bool used[MAX_N];
int cnt = 0;
std::map<P, int> m;

void dfs( int v, int idx )
{
  if( used[v] )
    return;

  used[v] = true;

  id[idx][v] = cnt;
 
  rep( i, G[idx][v].size() ) if( !used[G[idx][v][i]] )
    dfs( G[idx][v][i], idx );

  return;
}

int main()
{
  scanf( "%d%d%d", &N, &K, &L );
  rep( i, K )
  {
    int p, q;
    scanf( "%d%d", &p, &q );
    --p; --q;
    G[0][p].push_back( q );
    G[0][q].push_back( p );
  }
  rep( i, L )
  {
    int r, s;
    scanf( "%d%d", &r, &s );
    --r; --s;
    G[1][r].push_back( s );
    G[1][s].push_back( r );
  }

  rep( i, N )
    dfs( i, 0 ), ++cnt;

  clr( used, false );
  cnt = 0;
  rep( i, N )
    dfs( i, 1 ), ++cnt;

  rep( i, N )
    ++m[P(id[0][i], id[1][i])];

  rep( i, N )
    printf( "%d%c", m[P(id[0][i], id[1][i])], i==N-1?'\n':' ' );

  return 0;
}

Measured memory_bytes: 28160
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
 
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;
 
int cut(int a, int b) {//切り捨て
    return (a - a % b) / b;
}
int up(int a, int b) {
    return (a + a % b) / b;
}
 
int x, y, a, b, c;
 
 
int main() {
    
    cin >> x >> y >> a >> b >> c;
    deque<int> p(a);
    deque<int> q(b);
    deque<int> r(c);
    deque<int> red(x);
    deque<int> green(y);
    for (int i = 0; i < a; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> q[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> r[i];
    }
    
    sort(p.begin(),p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    int j=a-1;
    for (int i = x-1; i >=0; i--) {
        red[i] = p[j];
        j--;
    }
    int l = b - 1;
    for (int i = y - 1; i >= 0; i--) {
        green[i] = q[l];
        l--;
    }
 
    for (int i = c-1; i>=0; i--) {
        if (r[i] < red[0] && r[i] < green[0]) break;
        if (red[0] < green[0]) {
            red.pop_front();
            red.push_back(r[i]);
        }
        else {
            green.pop_front();
            green.push_back(r[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i < x; i++) {
        ans += red[i];
        
    }
    for (int i = 0; i < y; i++) {
        ans += green[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

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

int lcm(int a, int b)
{
	return (a / gcd(a, b) * b);
}

int main(void)
{
	int n, i, array[1000], l;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &array[i]);
	}
	
	l = lcm(array[0], array[1]);
	
	for (i = 2; i < n; i++){
		l = lcm(l, array[i]);
	}
	
	printf("%d\n", l);
	
	return (0);
}

Measured memory_bytes: 600
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    from bisect import bisect_left,bisect_right
    from time import perf_counter
    from random import random
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    start_time  = perf_counter()

    D = II()
    C = LMIIS()
    S = []
    for i in range(D):
        S.append(LMIIS())
    



    T = [0]*D
    for i in range(D):
        max_sat = -1
        max_type = -1
        L = S[i]
        for j in range(26):
            if max_sat < L[j]:
                max_sat = L[j]
                max_type = j
        T[i] = max_type
    
    

    # M = 1000
    # Q = []
    # for i in range(M):
    #     Q.append((int(random()*(D-1)),int(random()*25)))
    satisfaction = 0
    last_helds = []
    for i in range(26):
        last_helds.append([-1])

    satisfactions = [0] * D
    for i,t in enumerate(T):
        last_helds[t-1].append(i)
        for j in range(26):
            satisfaction -= C[j] * (i-last_helds[j][-1])
        satisfaction += S[i][t-1]
    first_sat = satisfaction
    for i in range(26):
        last_helds[i].append(D)


    #for d,q in Q:
    while perf_counter() - start_time < 1.5:
        d,q = int(random()*(D-1)),int(random()*25)
        old = T[d-1]
        old_sat = satisfaction

        satisfaction -= S[d-1][old-1]
        satisfaction += S[d-1][q-1]

        old_idx = bisect_left(last_helds[old-1],d-1)
        #dbg(last_helds[old-1],d-1,old_idx)
        x = last_helds[old-1][old_idx - 1]
        y = last_helds[old-1][old_idx + 1]
        #dbg('old x,y',d-1,x,y,(1+(y-1-(d-1)))*(y-(d-1)-1)//2,(1+(d-1)-x-1)*((d-1)-x-1)//2,(1+ y-x-1)*(y-x-1)//2)
        satisfaction += C[old-1] * ((1+(y-1-(d-1)))*(y-(d-1)-1)//2  + (1+(d-1)-x-1)*((d-1)-x-1)//2)
        satisfaction -= C[old-1] * ((1+ y-x-1)*(y-x-1)//2)
        
        new_idx = bisect_left(last_helds[q-1],d-1)

        x = last_helds[q-1][new_idx-1]
        y = last_helds[q-1][new_idx]
        satisfaction += C[q-1]*((1+y-x-1)*(y-x-1)//2)
        satisfaction -= C[q-1]*((1+(d-1)-x-1)*((d-1)-x-1)//2+(1+y-(d-1)-1)*(y-(d-1)-1)//2)
        if old_sat < satisfaction:
            last_helds[old-1].pop(old_idx)
            # dbg('insert')
            # dbg(last_helds[q-1])
            last_helds[q-1].insert(new_idx,d-1)
            # dbg(last_helds[q-1])
            T[d-1] = q
        else:
            satisfaction = old_sat
    for t in T:
        print(t+1)
    dbg(satisfaction,first_sat)
    dbg(perf_counter()-start_time)




    
main()

Measured memory_bytes: 84776
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long h, w;
    cin >> h >> w;
    vector<vector<char> > a(h, vector<char>(w));
    vector<vector<char> > ans(h+2, vector<char>(w+2, '#'));

    for(long long i = 0; i < h; i++){
        for(long long j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    for(long long i = 1; i <= h; i++){
        for(long long j = 1; j <= w; j++){
            ans[i][j] = a[i-1][j-1];
        }
    }

    for(long long i = 0; i < h+2; i++){
        for(long long j = 0; j < w+2; j++){
            printf("%c", ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3624
open Printf
open Scanf

let id x = x

let n, x = scanf "%d %d" (fun n x -> n, x)
let xs = Array.init n (fun i -> scanf " %d" id)

let rec gcd m n =
  if m < n then gcd n m
  else if n = 0 then m
  else gcd n (m mod n)

let lcm m n = m * n / gcd m n

let calc n = abs (n - x)

let () =
  let r = ref (calc xs.(0)) in
  for i = 1 to n - 1 do
    r := gcd !r (calc xs.(i))
  done;
  printf "%d\n" !r


Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>

int main(){
	
	char str1[15], str2[15], trash[15];
	int balls1, balls2;
	
	scanf("%s %s", &str1, &str2);
	scanf("%d %d", &balls1, &balls2);
	scanf("%s", &trash);
	
	(strcmp(trash, str1) == 0) ? balls1-- : balls2--;
	printf("%d %d\n", balls1, balls2);
	
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[2])
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<algorithm>
using namespace std;
const int MAXN=100005;

int K;
int S(long long n)
{
	static char s[20];
	sprintf(s,"%lld",n);
	int ret=0;
	for(int i=0;s[i];i++)
		ret+=s[i]-'0';
	return ret;
}

int main()
{
	scanf("%d",&K);
	long long now=1,add=1;
	int s;
	while(K)
	{
		s=S(now);
		if(1.0*now/s<=(1.0*now+add)/(1.0*s+1))
		{
			while(K&&now%(add*10)<9LL*add)
			{
				printf("%lld\n",now);
				now+=add;
				K--;
			}
			if(!K)
				break;
			printf("%lld\n",now);
			now+=add;
			K--;
		}
		else
		{
			while(now%(add*10)<9LL*add)
				now+=add;
			add*=10LL;
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(void){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  set<int> G, H;
  for(int i = 0; i <= F; i++){
    for(int j = 0; j <= F; j++){
      int I = 100 * A * i + 100 * B * j;
      int J = C * i + D * j;
      if(I <= F) G.insert(I);
      if(J <= F) H.insert(J);
    }
  }
  int K = 1, L = 0;
  for(int g : G){
    for(int h : H){
      if(g + h > F || 100 * h > E * g) continue;
      if(L * g <= K * h){
        K = g;
        L = h;
      }
    }
  }
  cout << K + L << " " << L << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i=0;i<m;i++){
        cin >> b[i];
    }
    vector<vector<int>> a(n, vector<int>(m));
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }

    int cnt=0;
    for (int i=0;i<n;i++){
        int sum=c;
        for (int j=0;j<m;j++){
            sum += a[i][j]*b[j];
        }
        if(sum > 0)cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

void solve(){
	ll N,W;
	cin>>N>>W;

	ll w[N],v[N];
	ll i;
	rep(i,N)
	{
		cin>>w[i]>>v[i];
	}

	ll dp[W+1][N+1];
	memset(dp,0,sizeof(dp));
	ll j;

	fr(i,1,W)
	{
		fr(j,1,N){
			dp[i][j]=dp[i][j-1];
			if(i-w[j-1]>=0)
			{
				dp[i][j]=max(dp[i][j],v[j-1]+dp[i-w[j-1]][j-1]);
			}
		}
	}
	cout<<dp[W][N];
}

int main(){
	//fio();
	fast

	solve();
	return 0;
}

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

int64_t N, A, Q, ans, B, C;
map<int, int64_t>mp;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> A;
        mp[A]++;
        ans += A;
    }
    cin >> Q;
    rep(i, Q) {
        cin >> B >> C;
        mp[C] += mp[B];
        ans += (C - B) * mp[B];
        mp[B] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 9412
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
ll z[100005],ans,n,m;
vector<ll>t[35];
vector<ll>r[35];
int main(void){
    cin>>n>>m;
    for(ll i=0;i<n;i++){
        ll s,v,c;
        cin>>s>>v>>c;
        
            t[c].push_back(s);
            t[c].push_back(v);
        
    }
    for(ll i=1;i<=m;i++){
        sort(t[i].begin(),t[i].end());
        for(ll j=1;j<t[i].size();j+=2){
            if(r[i].size()>0&&r[i][r[i].size()-1]==t[i][j-1])r[i][r[i].size()-1]=t[i][j];
            else{
                r[i].push_back(t[i][j-1]);
                r[i].push_back(t[i][j]);
            }
            
        }
        
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<r[i].size();j+=2){
            z[r[i][j-1]]+=1;
            z[r[i][j]+1]-=1;
        }
    }
    for(int i=1;i<=100000;i++){
        z[i]+=z[i-1];
        ans=max(z[i],ans);
    }
    cout<<ans<<endl;
}

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

int main() {
    int ans = 0;
    string S, T;
    cin >> S >> T;
    for(int i = 0; i < 3; i++) {
        if(S[i] == T[i])
            ans++;
    }

    cout << ans << endl;
}

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

int main(){
  int a,b,W;
  cin >> W >> a >> b;
  if( ( a <= b && b <= (a + W) )|| (a <= (b + W) && (b + W) <= (a + W) )){
    cout << 0 << endl;
    return 0;
  }
  cout << min( min(abs(a - b),abs(a - (b + W))) , abs(a + W - b) ) << endl;
  return 0;
}


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

using namespace std;

int main(){
  vector<bool> v(26,false);
  char c;
  while(cin>>c){
    v[c-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!v[i]){
      cout<<(char)('a'+i)<<endl;
      return 0;
    }
  
  }
  cout<<"None"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long T = scanner.nextLong();
        long[] t = new long[N];
        long x = 0;
        t[0] = scanner.nextLong();
        for (int i = 1; i < N; i++) {
            t[i] = scanner.nextLong();
            if (t[i-1] + T < t[i]) {
                x += T;
            }else{
                x += t[i] - t[i-1];
            }
        }
        x += T;

        System.out.println(x);

    }

}

Measured memory_bytes: 87804
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	double ans = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		double x;
		string s;
		cin >> x >> s;
		if (s == "JPY") ans += x;
		else ans += x*380000;
	}
	cout << setprecision(10) << ans << endl;
	return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<queue>
using namespace std;
#define loop(i,n) for (int i = 0; i < n; i++)
#define loops(i,f,n) for (int i = (f); i < n; i++)

bool check(int x)
{
	return (0 <= x&&x <= 20);
}

int main()
{
	int n;
	cin >> n;
	vector<int> num(n);
	loop(i, n)cin >> num[i];
	long long int dp[100][21] = { 0 };
	dp[0][num[0]] = 1;
	loops(i, 1, n-1)
	{
		loop(j, 21)
		{
			if (dp[i - 1][j] != 0 && check(j + num[i]))dp[i][j + num[i]] += dp[i - 1][j];
			if (dp[i - 1][j] != 0 && check(j - num[i]))dp[i][j - num[i]] += dp[i - 1][j];
		}
	}

	cout << dp[n - 2][num[n - 1]] << endl;
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s; 
	cin>>s; 
	int A = 0;
	int B = 0;
	for(int i=0;i<3;i++){
		if(s[i]=='A')A++;
		if(s[i]=='B')B++;
	}
	if(A and B)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int k, n;
    cin >> k >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    int mn = a[n-1] - a[0];
    for (int i = 1; i < n; i++) {
        mn = min(mn, k - a[i] + a[i-1]);
    }
    cout << mn << endl;
    return 0;
}

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

void str_plus(string &str, int d, int i){
  int keta = str.size()-i-1;//?????¨?¶??????????????????±???
  if(keta < 0){
    str.insert(0, "0");
    keta++;
  }
  int r = str[keta] - '0' + d;
  str[keta] = '0' + r % 10;
  if(r/10)
    str_plus(str, r/10, i+1);
}
int main(){
  int n;
  string str1, str2;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> str1 >> str2;
    for(int i = 0; i < str2.size(); i++)
      str_plus(str1, str2[str2.size()-i-1]-'0', i);

    if(str1.size()>80)
      cout << "overflow" << endl;
    else
      cout << str1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;



	ll x, n;
	cin >> n;
	cin >> x;
	ll pb = 0;
	b = 1;
	pb = 1;
	for (int i = 0; i < n; i++)
	{
		b = b * 2 + 1;
		pb = pb * 2 + 3;
	}

	while (x >= 1)
	{
		
		if (pb <= 5)
		{
			if (x==1)
			{
				
			}
			else if(x==5)
			{
				ans += 3;
			}
			else
			{
				ans += x-1;
			}
			break;
		}
		else if (x == pb)
		{
			ans += b;
			break;
		}
		else if (x == 1 + (pb - 3) / 2)
		{
			ans += (b - 1) / 2;
			break;
		}
		else if (x == 2 + (pb - 3) / 2)
		{
			ans += (b - 1) / 2 + 1;
			break;
		}
		else if (x <= 1 + (pb - 3) / 2)
		{
			pb = (pb - 3) / 2;
			b = (b - 1) / 2;
			x -= 1;
		}
		else
		{
			x -= (pb - 3) / 2 + 2;
			ans += (b - 1) / 2 + 1;
			pb = (pb - 3) / 2;
			b = (b - 1) / 2;
		}
	}

	cout << ans << endl;

	//cout << ans << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 28 18:53:10 2019

@author: yuta
"""

S = input()
def main(s):
    yyyymmdd = s.rsplit("/")
    yyyy = int(yyyymmdd[0])
    mm   = int(yyyymmdd[1])
    dd   = int(yyyymmdd[2])
    if yyyy < 2019:
        print("Heisei")
    elif yyyy > 2019:
        print("TBD")
    else:
        if mm < 4:
            print("Heisei")
        elif mm > 4:
            print("TBD")
        else:
            if dd <= 30:
                print("Heisei")
            else:
                print("TBD")
main(S)

Measured memory_bytes: 3064
import itertools
n,m,q=map(int,input().split())
data=[]
for i in range(q):
    data.append(list(map(int,input().split())))
ans=0

for pair in itertools.combinations_with_replacement(list(range(1,m+1)),n):
    res=0
    for i in range(q):
        if(pair[data[i][1]-1]-pair[data[i][0]-1]==data[i][2]):
            res+=data[i][3]
    ans=max(ans,res)

print(ans)

Measured memory_bytes: 67784
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/


void proc() {
	LOAD(int, N);
	LOAD(std::string, S);
	int res = INF;
	int nb = 0, nw = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '#') {
			++nb;
		}
		else {
			++nw;
		}
	}
	int tmp = nw;
	res = tmp;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '#') {
			++tmp;
		}
		else {
			--tmp;
		}
		res = std::min({ res,tmp });
	}
	cout << res << endl;
}


#endif


Measured memory_bytes: 720
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a == 1) a = 100;
	if (b == 1) b = 100;
	if (a == b) printf("Draw\n");
	else if (a > b) printf("Alice\n");
	else printf("Bob\n");

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{ 
	public static void main(String args[]){
    	String x = new String("ABC");
      	String y = new String("ARC");
      	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	// System.out.println(s);
      	// System.out.println(x);
      	// System.out.println(y);
      	if(s.equals(x)) System.out.println(y);
      	else System.out.println(x);
      	scan.close();
    }
}

Measured memory_bytes: 35548
def choose(D, c, s, d, last, depth, point):
    maxpoint = -999999
    maxnum = 0
    if depth > 0:
        for i in range(26):
            point = s[d][i]
            point += changepoint(c, d, i, last)
            if point >= maxpoint:
                maxpoint = point
                maxnum = i
        return maxnum, maxpoint
    return 0, 0


def changepoint(c, d, num, last):
    point = 0
    for i in range(26):
        if i == num:
            continue
        point -= c[i]*(d-last[i])
    return point


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    last = [-1]*26
    for _ in range(D):
        s.append(list(map(int, input().split())))
    point = 0
    for i in range(D):
        num, point = choose(D, c, s, i, last, 1, point)
        print(num+1)


main()


Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  string s;
  cin>>n>>k;
  cin>>s;
  int l[n],r[n];
  if(s[0]=='0'){
    l[cnt]=0;
    r[cnt++]=0;
  }
  for(i=0;i<n;i++){
    if(s[i]=='1'){
      l[cnt]=i;
      while(n-1>i && s[i+1]=='1')i++;
      r[cnt++]=i;
    }
  }
  if(s[n-1]=='0'){
    l[cnt]=n-1;
    r[cnt++]=n-1;
  }
  int m=cnt,ma=0;
  if(m<=k){
    cout<<n<<endl;
    return 0;
  }
  for(i=0;i<m-k;i++){
    ma=max(ma,r[i+k]-l[i]+1);
  }
  cout<<ma<<endl;
}


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

int main(){
    ll n,k;
    cin >> n >> k;
    
    if(n == 1) cout << k;
    else{
        cout << setprecision(15) << k * pow(k-1,n-1);
    }
}


Measured memory_bytes: 256