akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

    vector<LL> a(n+1);
    vector<LL> total(n+1,0);
    for(int i = 1; i < n+1; i++){
        cin >> a[i];
        total[i] = total[i-1] + a[i];
    }

    vector<LL> distl(n+1,0);
    vector<LL> distr(n+1,0);
    distl[2] = 1;
    for(int i = 3; i < n-1; i++){
        distl[i] = distl[i-1];
        bool frag = true;
        for(int j = distl[i-1] + 1; j < i && frag; j++){
            if(abs(total[j] - (total[i] - total[j])) < abs(total[distl[i]] - (total[i] - total[distl[i]]))){
                distl[i] = j;
            }else{
                frag = false;
            }
        }
    }
    distr[n-2] = n-1;
    for(int i = n-3; i >= 2; i--){
        distr[i] = distr[i+1];
        bool frag = true;
        for(int j = distr[i+1] - 1; j > i && frag; j--){
            if(abs((total[n] - total[j]) - (total[j] - total[i]) < abs((total[n] - total[distr[i]]) - (total[distr[i]] - total[i])))){
                distr[i] = j;
            }else{
                frag = false;
            }
        }
    }


    LL ans = 133333333333333;

    for(int i = 2; i < n-1; i++){
        LL ll = total[distl[i]];
        LL lr = total[i] - total[distl[i]];
        LL rl = total[distr[i]] - total[i];
        LL rr = total[n] - total[distr[i]];
        LL to = max(ll,max(lr,max(rl,rr)));
        LL from = min(ll,min(lr,min(rl,rr)));
        if(abs(to-from) < ans){
            ans = abs(to-from);
        }
    }

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

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> H(n,0);
    for (auto & h : H) {
        cin >> h;
    }
    sort(H.begin(), H.end());
    ll res = 1e9;
    for (ll i = 0; i + k <= n; ++i) {
        res = min(res, H[i+k-1] - H[i]);
    }
    cout << res << endl;
}


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

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    bool is_possible = true;
    while (S.length() > 0)
    {
        if(S.find("maerd") == 0)
        {
            S.erase(0, 5);
        }
        else if(S.find("remaerd") == 0)
        {
            S.erase(0, 7);
        }
        else if(S.find("esare") == 0)
        {
            S.erase(0, 5);
        }
        else if(S.find("resare") == 0)
        {
            S.erase(0, 6);
        }
        else
        {
            is_possible = false;
            break;
        }
    }
    if (is_possible) 
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;       
    }

}

Measured memory_bytes: 512
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			int k = cin.NextInt();
			int x = cin.NextInt();
			int y = cin.NextInt();
			if (n <= k) Console.WriteLine(x * n);
			else Console.WriteLine(x * k + y * (n - k));

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        // dp[j][k][s]は、x1,...,xj から k 枚選んで xi の合計を s にするような選び方の総数
        long[][][] dp = new long[n + 1][n + 1][n * a + 1];
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                for (int s = 0; s <= n * a; s++) {
                    if (j == 0 && k == 0 && s == 0) {
                        dp[j][k][s] = 1;
                        continue;
                    }
                    if (j >= 1 && s < x[j - 1]) {
                        dp[j][k][s] = dp[j - 1][k][s];
                        continue;
                    }
                    if (j >= 1 && k >= 1 && s >= x[j - 1]) {
                        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
                        continue;
                    }
                    dp[j][k][s] = 0;
                }
            }
        }

        long result = 0;
        for (int i = 1; i <= n; i++) {
            result += dp[n][i][i * a];
        }
        System.out.println(result);
    }

}

Measured memory_bytes: 83376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = INF;

int main(void){
  ll A, B, C;
  I(A);
  I(B);
  I(C);
  chmin(ret, A+B);
  chmin(ret, B+C);
  chmin(ret, C+A);
  P(ret);

}


Measured memory_bytes: 256
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 11;
int dp[MAXN][10][10];
int sum[MAXN][10];
int num[MAXN];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    for (int i = 0; i < 10; i++) dp[1][i][i] = 1;
    num[1] = 10;
    for (int i = 0; i < 10; i++) sum[1][i] = 1;
    for (int i = 2; i < MAXN; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                for (int from = max(k - 1, 0LL); from <= min(k + 1, 9LL); from++) {
                    dp[i][j][k] += dp[i - 1][j][from];
                }
                sum[i][j] += dp[i][j][k];
            }
            num[i] += sum[i][j];
        }
    }
    int n;
    cin >> n;
    n--;
    int l = 1;
    while (n >= num[l] - sum[l][0]) {
        n -= num[l] - sum[l][0];
        l++;
    }
//    dbg(l)
//    dbg(n);
//    dbg(sum[2][1])
    vector<int> ans;
    int cur = 1;
    while (n >= sum[l][cur]) {
        n -= sum[l][cur];
        cur++;
    }
    ans.pb(cur);
    cur = max(cur - 1, 0LL);
//    cout << "DICK: " << cur << "\n";
    for (int i = 1; i < l; i++) {
        for (int j = 0; j < 2; j++) {
            if (n < sum[l - i][cur]) break;
            n -= sum[l - i][cur];
            cur++;
        }
//        dbg(cur)
        ans.pb(cur);
        cur = max(cur - 1, 0LL);
    }
//    dbg(n)
    for (auto k : ans) cout << k;
}
/*
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>

struct rgb_struct {
        uint64_t r, g, b;
};

void rgb_count(struct rgb_struct *rgb, char c) {
        switch (c) {
        case 'R':
                ++rgb->r;
                break;
        case 'G':
                ++rgb->g;
                break;
        case 'B':
                ++rgb->b;
                break;
        }
}

int is_rgb(char x, char y, char z) {
        struct rgb_struct rgb = {0, 0, 0};

        rgb_count(&rgb, x);
        rgb_count(&rgb, y);
        rgb_count(&rgb, z);

        return (rgb.r == 1 && rgb.g == 1 && rgb.b == 1);
}

uint64_t solve(int k, char *s) {
        int i, j;
        struct rgb_struct rgb = {0, 0, 0};
        size_t size = strlen(s);
        uint64_t nr_sym = 0;

        for (i = 0; i < size; i++) {
                rgb_count(&rgb, s[i]);
        }

        for (i = 0; i < size; i++) {
                for (j = i + 2; j < size; j += 2) {
                        if (is_rgb(s[i], s[j], s[(j+i)/2]) == 1) {
                                ++nr_sym;
                        }
                }
        }

        return (rgb.r * rgb.g * rgb.b) - nr_sym;
}

int main() {
        int n;
        char s[4001];

        if (scanf("%4d %s", &n, s) == 0) {
                perror("scanf");
                return 1;
        }
        printf("%lld\n", solve(n, s));

        return 0;
}


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

int main() {
  	int K, A, B;
  	cin >> K >> A >> B;
  	for (int i = A; i <= B; ++i) {
     	if (i % K == 0) {
         	puts("OK");
          	return 0;
        }
    }
  	puts("NG");
 	return 0; 
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>    

using namespace std;

int main(){
    string s;
    int n, q;
    cin >> n >> q;
    cin >> s;
    vector<int> v(n+1);
    v[0]=v[1]=0;
    int cnt = 0;
    for (int i = 1; i < n; i++)
    {
        if(s[i-1]=='A'&&s[i]=='C')
        {
            cnt++;
        }
        v[i + 1] = cnt;

    }
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << v[r] - v[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
S=input()
FF=int(S[0]+S[1])
LL=int(S[2]+S[3])

if FF<13 and LL<13 and FF!=00 and LL!=00:
    print('AMBIGUOUS')
    exit(0)
elif  (FF>12 or FF==00) and (LL<13 and LL>0):
    print('YYMM')
    exit(0)
elif  (LL>12 or LL==00) and (FF<13 and FF>0):
    print('MMYY')
    exit(0)
else:
    print("NA")
    


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

int main (){
    ll n, d;
    cin >> n >> d;
    ll cont = 0;
    for(int i = 0; i < n; i++){
        ll a, b;
        double aux;
        cin >> a >> b;
        aux = sqrt((a*a) + (b*b));
        if(d >= aux) cont++;
    }

    cout << cont << endl;
    return 0;
}

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

int main() {
    std::vector<std::string> allhi = {
        "hi", "hihi", "hihihi", "hihihihi", "hihihihihi"
    };
    std::string s; std::cin >> s;
    for (const auto& ss: allhi) {
        if (ss == s) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n;
    pair<int,int> a[100005];//振られた番号　元の番号
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        printf("%d",a[i].second+1);
        if(i!=n-1)printf(" ");
    }
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(void){
long long int a,b,c,d,e,f,sum=0;
scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&d,&e,&f);
sum=(a*1)+(b*5)+(c*10)+(d*50)+(e*100)+(f*500);
if(sum>=1000) printf("1\n");
else printf("0\n");
return 0;
}



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

int N;
int A[210];

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

    int res = 0;

    while (true) {
        bool exist_odd = false; 
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true; 
        }

        if (exist_odd) break; 
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  
    }

    cout << res << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll, ll>> student;
    REP(i, N)
    {
        ll a;
        cin >> a;
        student.push_back(make_pair(a, i + 1));
    }
    sort(ALL(student));
    REP(i, N) cout << student[i].second << " ";
}


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

int main() {
    int N, min = 1e9;
    cin >> N;
    int A[N+1];
    long long ans, sum = 0;
    int count = 0;
    bool flag = false;
    

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

    for(int i=0; i<N; i++){
	if(A[i] < 0)
	    count++;
	else if(A[i] == 0){
	    flag = true;
	}

	if(abs(A[i]) < min)
	    min = abs(A[i]);	
	sum += abs(A[i]);	
    }

    if(count%2 == 0)
	flag = true;

    if(flag)
	ans = sum;
    else
	ans = sum -2*min;

    cout << ans << endl;            

}



Measured memory_bytes: 640
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(2)]
    ans = 0

    for i in range(n):
        ans = max(ans, sum(a[0][:i + 1]) + sum(a[1][i:]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
s = int(input())

def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return int(3*n + 1)
ln = [s]

while True:
    ln.append(f(ln[-1]))
    if f(ln[-1]) in ln:
        break
    else:
        pass
print(len(ln)+1)


Measured memory_bytes: 2940
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
　 let X = xs[0];
   let Y = xs[1];
   let Z = xs[2];
   let i = 0;   
   let ans = 0;
   while(true){
     ans=Y*i+Z*(i+1);
     //console.log(ans);
     if(ans<=X){
       i++;
     }else{
       console.log(i-1);
       break;
     }
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));





Measured memory_bytes: 9420
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0, startp = 0, endp = 0, checker = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> input;
	if(input>"2019/04/30"){
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())

ans = [0] * N

for i in range(1,N+1):
	q = [i]
	flg = [-1] * (N+1)
	flg[i] = 0
	while q:
		cp = q.pop(0)
		for d in [-1,1]:
			if 1 <= cp+d <= N:
				if flg[cp+d] == -1:
					flg[cp+d] = flg[cp]+1
					ans[flg[cp+d]] += 1
					q.append(cp+d)
		if cp == X:
			if flg[Y] == -1:
				flg[Y] = flg[cp]+1
				ans[flg[Y]] += 1
				q.append(Y)
		if cp == Y:
			if flg[X] == -1:
				flg[X] = flg[cp]+1
				ans[flg[X]] += 1
				q.append(X)

for i in range(1,N):
	print(ans[i]//2)

Measured memory_bytes: 47324
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define vv vector<lli>
#define vp vector<pair<lli,lli>>
#define vpp vector<pair<lli,pair<lli,lli>>>
#define lims(w) (w).begin(),(w).end()
#define rlims(w) (w).rbegin(),(w).rend()
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(lli i=a;i<b;i++)
#define ff first
#define ss second
#define sz(a) (lli)(a.size())
lli inf = (1e18 + 2);

int main()
{
	lli n,x,t;
	cin>>n>>x>>t;
	lli ans = (n % x == 0) ? ((n/x)*t) : (((n/x)*t) + t);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#define NIL -2000000001

int main(void){
  int i,H;

  scanf("%d", &H);

  //1 origin
  int heap[H+1];
  for(i = 0; i <= H; i++)
    heap[i] = NIL;

  for(i = 1; i <= H; i++)
    scanf("%d", &heap[i]);

  for(i = 1; i <= H; i++){
    printf("node %d: ", i);
    printf("key = %d, ", heap[i]);
    if(heap[i/2] != NIL && i/2 <= H && i/2 >= 0)
      printf("parent key = %d, ", heap[i/2]);
    if(heap[2*i] != NIL && 2*i <= H && 2*i >= 0)
      printf("left key = %d, ", heap[2*i]);
    if(heap[2*i+1] != NIL && 2*i+1 <= H && 2*i+1 >= 0)
      printf("right key = %d, ", heap[2*i+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k; cin >> a >> b >> c >> k;
    cout << a+b+c - max({a, b, c}) + (max({a, b, c}) << k);
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from itertools import permutations, combinations,combinations_with_replacement,product
from fractions import Fraction as frac
import bisect
import heapq

import logging
logging.basicConfig(level=logging.DEBUG)

import sys
#input = sys.stdin.readline().rstrip

setrecursionlimit(1000000)

MOD = 10**9+7
INF = float('inf')

def main():
    N=int(input())
    D=[int(x) for x in input().split()]
    
    C=combinations(D,2)
    ans=0
    for c in C:
        ans+=c[0]*c[1]
    print(ans)
main()

Measured memory_bytes: 69356
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "Yes":"No")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

char A[60][60];
string B,tmp;

int main() {

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

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

    for(int i=0; i<m; i++){
        cin>>tmp;
        B+=tmp;
    }

    int ok=0;

    for(int i=0; !ok && i<=(n-m); i++){

        for(int j=0; j<=(n-m); j++){
            if(A[i][j]==B[0]){
                tmp="";

                for(int k=i; k<i+m; k++){
                    for(int l=j; l<j+m; l++){
                        tmp+=A[k][l];
                    }
                }
               // cout<<i<<" "<<j<<" "<<tmp<<endl;
                if(tmp==B){
                    ok=1;
                    break;
                }
            }
        }
    }
    PRINT(ok);
    return 0;
}


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

int main(){
    int j = 0;
    string N;
    cin >>N;

        if(N.back() == '3'){
            j = 3;          
        }else if(N.back() == '0'){
            j =1;
            
        }else if(N.back() == '1'){
            j =1;
            
        }else if(N.back() == '6'){
            j =1;
            
        }else if(N.back() == '8'){
            j =1;
            
        }else if(N.back() == '2'){
            j =2;
            
        }else if(N.back() == '4'){
            j =2;
            
        }else if(N.back() == '5'){
            j =2;
            
        }else if(N.back() == '7'){
            j =2;
            
        }else if(N.back() == '9'){
            j =2;
            
        }


        if(j == 1){
            cout << "pon" << endl;
        }else if(j == 2){
            cout << "hon" << endl;
        }else if(j == 3){
            cout << "bon" << endl;
        }
    
    }


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#pragma GCC optimize(3)
#define CMAX(_a,_b) ((_a<_b)&&(_a=_b)) 
#define R register
using namespace std;
struct node{
	int id;long long x;
}A[200010];
bool CMP(node u,node v)
{
	return u.x > v.x;
}
long long a[200010][9];
int n,m,K;long long ans;
int main()
{
	scanf("%d%d",&n,&K); m = 3;
	for(R int i = 1; i <= n; i++)
		for(R int j = 1; j <= m; j++) scanf("%lld",&a[i][j]);
	for(R int sta = 0; sta < (1 << m); ++sta)
	{
		for(R int i = 1; i <= n; i++)
		{
			long long x = 0;
			for(R int j = 1; j <= m; j++)
			{
				if((1 << j - 1) & sta) x += a[i][j];
				else x -= a[i][j];
			}
			A[i].id = i; A[i].x = x;
		}
		sort(A+1,A+n+1,CMP);
		long long res[9] = {0,0,0,0,0,0,0,0,0};
		for(R int i = 1; i <= K; i++)
			for(R int j = 1; j <= m; j++)
			{
				res[j] += a[A[i].id][j];
			}
		long long Res = 0;
		for(R int i = 1; i <= m; i++) Res += abs(res[i]);
		CMAX(ans,Res);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2304
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	aa := make([]int, m)
	cc := make([]int, m)
	for i := 0; i < m; i++ {
		aa[i] = getNextInt(scanner)
		b := getNextInt(scanner)

		for ii := 0; ii < b; ii++ {
			c := getNextInt(scanner) - 1
			cc[i] |= 1 << uint(c)
		}
	}

	full := 1 << uint(n)
	dp := make([]int, full)

	for i := 1; i < full; i++ {
		dp[i] = math.MaxInt32
	}

	for i := 0; i < full; i++ {
		for j := 0; j < m; j++ {
			if dp[i|cc[j]] > dp[i]+aa[j] {
				dp[i|cc[j]] = dp[i] + aa[j]
			}
		}
	}

	if dp[full-1] == math.MaxInt32 {
		dp[full-1] = -1
	}

	fmt.Fprintln(writer, dp[full-1])
	writer.Flush()
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for(int i = 0; i < N; i++) a[i] = sc.nextInt();
        Arrays.sort(a, Comparator.reverseOrder());

        int Alice = 0;
        int Bob = 0;
        for(int i = 0; i < N; i+=2 ) {
            Alice += a[i];
        }
        for(int i = 1; i < N; i+=2) {
            Bob += a[i];
        }

        System.out.println(Alice - Bob);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n;
  cin >> n;
  ll a[n],b[n],c[n];
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
    sum += b[i];
  }
  rep(i,n-1){
    cin >> c[i];
  }
  rep(i,n-1){
    if(a[i]+1 == a[i+1]){
      sum += c[a[i]-1];
    }
  }
  cout << sum << endl;
}


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

// chmax, chmin
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 <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long T, long long A, std::vector<long long> H) {
  int cand = 0;
  double val = 10000000;
  for (int i = 0; i < N; i++) {
    double eval = abs(T - H[i] * 0.006 - A);
    if (eval <= val) {
      val = eval;
      cand = i;
    }
  }
  cout << cand + 1 << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long T;
  scanf("%lld", &T);
  long long A;
  scanf("%lld", &A);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, T, A, std::move(H));
  return 0;
}


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

int main(void)
{
        std::string s;
        std::map<std::string, int> m = {
                {"SUN", 7},
                {"MON", 6},
                {"TUE", 5},
                {"WED", 4},
                {"THU", 3},
                {"FRI", 2},
                {"SAT", 1},
        };
        std::cin >> s;
        std::cout << m[s] << std::endl;
        return 0;
}

Measured memory_bytes: 256
def main():
    h,w,k = [int(v) for v in input().split()]
    c = []
    for _ in range(h):
        c.append(int('0b'+input().replace('#','1').replace('.','0'),0))
    imax = 1 << w
    bc = [0] * imax
    for i in range(imax):
        bc[i] = len([v for v in list(bin(i)) if v=='1'])

    sum = 0
    for ih in range(1<<h):
        for iw in range(1<<w):
            cnt = 0
            for j in range(h):
                if ih & (1 << j):
                    cnt += bc[c[j] & iw]   
            if cnt==k:
                sum += 1
    
    print(sum)

main()

Measured memory_bytes: 9220
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long K = scan.nextLong();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
        }
        long sum = Arrays.stream(A).sum();
        long[][] diff = new long[40][2];
        for (int i = 39; 0 <= i; i--) {
            long mask = 1L << i;
            int count = 0;
            for (int j = 0; j < N; j++) {
                if (0 < (A[j] & mask)) {
                    count += 1;
                }
            }
            diff[i][0] = 0;
            diff[i][1] = (N - 2 * count) * pow(i);
        }
        boolean found = false;
        long max_diff = 0;
        long current_diff = 0;
        for (int i = 39; 0 <= i; i--) {
            long mask = 1L << i;
            if (0 < (K & mask)) {
                found = true;
            }
            if (!found) {
                continue;
            }
            if (0 == (K & mask)) {
                continue;
            }
            // i桁目を0にする場合
            long t = 0;
            for (int j = i - 1; 0 <= j; j--) {
                t += Math.max(0, diff[j][1]);
            }
            max_diff = Math.max(max_diff, current_diff + t);
            // i桁目を1にする場合
            if (0 < (K & mask)) {
                current_diff += diff[i][1];
            }
        }
        System.out.println(sum + Math.max(current_diff, max_diff));
    }
    private long pow(int N) {
        if (N == 0) {
            return 1;
        }
        if (N % 2 == 1) {
            return 2 * pow(N-1);
        }
        long x = pow(N / 2);
        return x * x;
    }
}


Measured memory_bytes: 58980
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#include<queue>

using namespace std;

typedef long long ll;
typedef pair<int,int> p;

int odd[105000];
int even[105000];

int n;

int main()
{
	cin>>n;
	int v;
	for(int i=0;i<n;i++){
		cin>>v;
		if(i%2==0){
			even[v]++;
		}
		else odd[v]++;
	}

	int me=0,sme=0;
	int mei=-1;
	int mo=0,smo=0;
	int moi=-1;
	int enu=0;int onu=0;
	for(int i=0;i<105000;i++){
		if(even[i]>me){
			sme=me;me=even[i];mei=i;enu=1;
		}
		else if(even[i]==me){
			enu++; sme=me;
		}
		else sme=max(sme,even[i]);
		if(odd[i]>mo){
			smo=mo;mo=odd[i];moi=i;onu=1;
		}
		else if(odd[i]==mo){
			onu++; smo=mo;
		}
		else smo=max(smo,odd[i]);
	}

	if(enu==1&&onu==1&&mei==moi)cout<<min(n-me-smo,n-mo-sme)<<endl;
	else cout<<n/2-me+n/2-mo<<endl;


	return 0;
}

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

struct times{
  int hour, mini, sec;
};

int  main(){

  times a, b, c;
  times a_ans, b_ans, c_ans;
  int a_sec[2], b_sec[2], c_sec[2];
  int s;

  for(int i = 0; i < 2; i++){
    cin >> a.hour >> a.mini >> a.sec;
    a_sec[i]=3600*a.hour;
    a_sec[i]+=60*a.mini;
    a_sec[i]+=a.sec;
  }
  s=a_sec[1]-a_sec[0];
  a_ans.hour=s/3600;
  s-=a_ans.hour*3600;
  a_ans.mini=s/60;
  s-=a_ans.mini*60;
  a_ans.sec=s;

  for(int i = 0; i < 2; i++){
    cin >> b.hour >> b.mini >> b.sec;
    b_sec[i]=3600*b.hour;
    b_sec[i]+=60*b.mini;
    b_sec[i]+=b.sec;
  }
  s=b_sec[1]-b_sec[0];
  b_ans.hour=s/3600;
  s-=b_ans.hour*3600;
  b_ans.mini=s/60;
  s-=b_ans.mini*60;
  b_ans.sec=s;

  for(int i = 0; i < 2; i++){
    cin >> c.hour >> c.mini >> c.sec;
    c_sec[i]=3600*c.hour;
    c_sec[i]+=60*c.mini;
    c_sec[i]+=c.sec;
  }
  s=c_sec[1]-c_sec[0];
  c_ans.hour=s/3600;
  s-=c_ans.hour*3600;
  c_ans.mini=s/60;
  s-=c_ans.mini*60;
  c_ans.sec=s;


  cout << a_ans.hour << " " << a_ans.mini << " " << a_ans.sec << endl;
  cout << b_ans.hour << " " << b_ans.mini << " " << b_ans.sec << endl;
  cout << c_ans.hour << " " << c_ans.mini << " " << c_ans.sec << endl;

}

Measured memory_bytes: 1164
n = int(input())
p = [int(i) for i in input().split()]
c = 0

for i in range(1,len(p)-1):
	if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
		c += 1

print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

vector<bool> seen(200001);
set<int> graph[200001];

int surch(const set<int> g){
    int succ = 0;
    for(auto x : g){
        if(seen[x]) continue;
        seen[x] = true;
        succ++;
        succ += surch(graph[x]);
    }
    return succ;
}

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

    rep(_, 0, m){
        int a, b; cin >> a >> b;
        a--;b--;
        graph[a].insert(b);
        graph[b].insert(a);
    }

    int ans = 1;
    rep(i, 0, n){
        if(seen[i]) continue;
        int tmp = surch(graph[i]);
        ans = max(ans, tmp);
    }

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


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

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    vector< long long int > k;

    for ( long long int i = 0; i < n; i++ ) {
      long long int in;
      cin >> in;
      k.push_back( in );
    }

    string s;
    cin >> s;

    for ( long long int j = 0; j < s.size(); j++ ) {

      long long int b = k[ j % k.size() ];
      if ( b >= 26 ) {
	b -= 26;
	if ( s[j] >= 'a' && s[j] <= 'z' ) {
	  s[j] += 'A' - 'a';
	}else {
	  s[j] += 'a' - 'A';
	}
      }
      if ( s[j] >= 'a' && s[j] <= 'z' ) {
	s[j] -= b;
	if ( s[j] < 'a' ) {
	  s[j] += 26;
	  s[j] += 'A' - 'a';
	}
      }else {
	s[j] -= b;
	if ( s[j] < 'A' ) {
	  s[j] += 26;
	  s[j] += 'a' - 'A';
	}
      }

    }

    cout << s << endl;

  }

  return 0;

}

Measured memory_bytes: 1224
#include<iostream>
using namespace std;
int main(void){
  string s;
  cin>>s;
  string a="AKIHABARA";
  int length=s.length();
  int length2=a.length();
  if(length > length2){
    cout<<"NO"<<endl;
    return 0;
  }
  if(length < 5){
    cout<<"NO"<<endl;
    return 0;
  }
  for(int i=0,j=0;j<length2;i++,j++){
    if(s[i]!=a[j]){
      if(a[j]!='A'){
        cout<<"NO"<<endl;
        return 0;
      }
      i--;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}

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

int main(void){
  int a, b;
  cin >> a >> b;
  if(a > b){
    for(int i=0; i < a; i++){
      cout << b;
    }
  }
  else if (a <= b){
    for(int i=0; i < b; i++){
      cout << a;
    }
  }
  else{
    
  }
    
 return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int m, int n)
{
    if (n == 0)
        return m;
    else
        return gcd(n, m % n);
}

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);

    printf("%d\n", gcd(a, b));

    return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;

/***/
//#include <iomanip>
//#include <cmath>
#include <bits/stdc++.h>

#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define REP(i,n,x) for(long long i=n;i<x;i++)
#define REPN(i,n,x) for(long long i=n+1;i<x;i++)

#define pr printf
#define re return
#define mod 1000000007
#define mod 1000000007
#define fi first
#define se second
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

/***/

typedef long long int ll;
typedef pair<long long, long long> P;
long long n;
//vector<long long> g[200020];
vector<pair<long long,long long>> g[200020];
ll s[200020];
bool used[200020];
bool dp[100005];


vector<ll>a(51);
vector<ll>b(51);
vector<ll>c(51);
vector<ll>d(51);

ll A,B,C,N,K,M,Q,wk;
long long ans,sum;
	
ll v[10];
void solve(long long index,long long min){
    if(index==N){
        sum=0;
        rep(j,Q){
            if(v[b[j]]-v[a[j]]==c[j]){
                sum+=d[j];            
            }
        }
        ans=MAX(sum,ans);
        re;
    }
    REP(i,min,M+1){
        v[index]=i;
        solve(index+1,i);
    }
    re;
}
int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
    /*****/
	//s.insert(0, " ");
	//v.erase(unique(v.begin(), v.end()), v.end());
    //priority_queue<long long, vector<long long>, greater<long long> > que;
    //priority_queue<long long> que;
    //map<ll, ll, std::greater<ll>> mp;
    //set<ll> st;
    //stack<long long> sta;   
    //queue<long long> que;
    //deque<long long> dque;
    /*****/
    sum=ans=0;
    
    cin >> N >> M >> Q;
    
    rep(i,Q){
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
        cin >> d[i];
        a[i]--;
        b[i]--;
    }
    
    solve(0,1);
    pr("%lld",ans);
    re 0;
    
}


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

int main(){
  int N;
  cin >> N;
  int a = (N - N/1000 * 1000) % 111 ;
  int b = (N - (N - N/10 *10)) % 1110;
           
  if ( a == 0 || b == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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


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

  int min,max;
  min = x-(k-1);
  max = x+(k-1);

  for(int i=min; i<=max; i++){
    cout << i << " ";
  }
  cout << endl;

}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

num =1
li = [1]
flag = [True]*n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d
print(li[ans])


Measured memory_bytes: 32376
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;

    int endCount[n+1] = {0};
    vector< vector<int> >aL;
    aL.resize(n+1);


    for (int i=0 ; i<m ; i++){
        int str,end;
        cin >> str >> end;
        aL[str].push_back(end);
        endCount[end]++;
    }

    int len[n+1] = {0};
    deque<int>que;


    for (int i=1 ; i<=n ; i++){
        if (endCount[i] == 0){
            que.push_back(i);
            len[i] = 0;
        }
    }

    while (que.size() != 0){

        int start = que.front();    
        int sz = aL[start].size();

        for (int i=0 ; i<sz ; i++){
            endCount[aL[start][i]]--;
            if (endCount[aL[start][i]] == 0){
                len[aL[start][i]] = len[start] + 1;
                que.push_back(aL[start][i]);
            }
        }
        que.pop_front();
    }
    int mx = 0;
    for (int i=1 ; i<=n ; i++){
        mx = max(mx,len[i]);
    }
    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 6528
n, k = map(int, input().split())

imos = [[0 for i in range(k)] for j in range(k)]

white = 0
for i in range(n):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c == "W":
        c = 1
    else:
        c = 0
    x %= 2*k
    y %= 2*k

    if x > k-1:
        x -= k
        c += 1
    if y > k-1:
        y -=k
        c += 1
    c %= 2

    if c == 1:
        white += 1
        imos[x][y] -= 1
    else:
        imos[x][y] += 1

for i in range(k):
    for j in range(k-1):
        imos[i][j+1] += imos[i][j]

for j in range(k):
    for i in range(k-1):
        imos[i+1][j] += imos[i][j]

ans = 0
for i in range(k):
    for j in range(k):
        exp = imos[k-1][k-1] - imos[k-1][j] - imos[i][k-1] + 2 * imos[i][j] + white
        ans = max(ans, max(exp, n - exp))

print(ans)

Measured memory_bytes: 59868
n, k = list(map(int, input().split()))
lim = 10**9 + 7
C = [[1], [1,1]]

for i in range(2, n+10):
    C.append([1] + [(C[i-1][j-1] + C[i-1][j])%lim for j in range(1, i)] + [1])

for i in range(1, k+1):
    if n-k+1 < i  or k < i:
        #赤ボールが操作回数よりも少ない時、青ボールが操作回数よりも少ない時
        print(0)
    else:
        #青ボールを入れる箇所の組み合わせ×各箇所に入れる青ボール個数の組み合わせ
        print((C[n-k+1][i]*C[k-1][i-1])%lim)

Measured memory_bytes: 83472
#include <stdio.h>
#include <string.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, cnt = 0;
  char s[200010], t[200010], flg[26];
  for(i = 0; i < 26; ++i) flg[i] = 0;
  scanf("%s%s", s, t);
  n = strlen(s);
  for(i = 0; i < n; ++i) {
    if(!flg[s[i] - 'a']) flg[s[i] - 'a'] = t[i];
    else if(flg[s[i] - 'a'] != t[i]) {
      printf("No");
      return 0;
    }
  }
  for(i = 0; i < 26; ++i) for(j = 0; j < 26; ++j) if(i != j && flg[i] && flg[i] == flg[j]) {
    printf("No");
    return 0;
  } 
  for(i = 0; i < 26; ++i) {
    if(flg[i] != i + 'a') ++cnt;
  }
  if(cnt == 1) printf("No");
  else printf("Yes");
  return 0;
}

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

ll INF = 1e18;
ll MOD = 1e9+7;


int main(){
    ll N, M; cin >> N >> M;
    ll ans;
    if(2*N >= M){
        ans = M / 2;
    }
    else {
        ans = N;
        M -= 2*N;
        ans += M/4;

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
H = rl()

ans = 0
for h in H:
	if h >= K:
		ans += 1
print(ans)

Measured memory_bytes: 49904