akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin python3
# -*- coding: utf-8 -*-

n, w = map(int, input().split())
vi = [[] for _ in range(4)]
wi0, vi0 = map(int, input().split())
vi[0].append(vi0)

for _ in range(n-1):
    wii, vii = map(int, input().split())
    vi[wii-wi0].append(vii)

for i in range(4):
    vi[i].sort(reverse=True)
    vi[i] = [0] + vi[i]
    for j in range(1, len(vi[i])):
        vi[i][j] += vi[i][j-1]

ret = 0
for i in range(len(vi[3])):
    for j in range(len(vi[2])):
        for k in range(len(vi[1])):
            tw = i*(wi0+3)+j*(wi0+2)+k*(wi0+1)
            l = max(0,min(len(vi[0])-1,(w - tw)//wi0))
            tw += l*(wi0)
            if tw > w: continue
            tv = vi[3][i]+vi[2][j]+vi[1][k]+vi[0][l]
            ret = max(ret, tv)
print(ret)

Measured memory_bytes: 9140
// inputに入力データ全体が入る
function Main(str) {
  const num = str.split(' ');
  const num1 = parseInt(num[0]);
  const num2 = parseInt(num[1]);

  const max = Math.max(
    num1 + num2,
    num1 - num2,
    num1 * num2
  );

  if (max === -0 || max === +0) {
    console.log(0);
  } else {
    console.log(max);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

# input
S = input()

# solve
ans = True
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'L':
            ans = False
            break
    else:
        if S[i] == 'R':
            ans = False
            break

# output
print('Yes' if ans else 'No')


Measured memory_bytes: 2940
import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
    ans += a[i]*(aa[n-1] - aa[i]) % MOD
print(ans%MOD)


Measured memory_bytes: 29124
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int h, w;
vstr s;
vint dx = {-1, 0, 1, -1, 1, -1, 0, 1};
vint dy = {1, 1, 1, 0, 0, -1, -1, -1};

int calc(int x, int y) {
    int res = 0;
    rep(i, 8) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        if (nx < 0 || nx >= h) continue;
        if (ny < 0 || ny >= w) continue;
        if (s[nx][ny] == '#') res++;
    }
    return res;
}

int main() {
    cin >> h >> w;
    s.resize(h);
    rep(i, h) cin >> s[i];

    rep(i, h) rep(j, w) {
        if (s[i][j] == '#') continue;
        int res = calc(i, j);
        s[i][j] = (char)(res+'0');
    }

    rep(i, h) cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#define ll long long
#define pb push_back
using namespace std;
const int N=500005;
vector<int> g[N];

int n,f[N],id[N];
char s[N];
ll ans;

inline void add(int x,int y){ g[x].pb(y),id[y]++;}

inline void tpsort(){
	queue<int> q;
	for(int i=1;i<=n;i++) if(!id[i]) q.push(i);
	
	for(int x;!q.empty();q.pop()){
		x=q.front();
		for(int i:g[x]) if(!(--id[i])) f[i]=f[x]+1,q.push(i);
	}
	
	for(int i=1;i<=n;i++) ans+=(ll)f[i];
}

int main(){
	scanf("%s",s+1),n=strlen(s+1)+1;
	for(int i=1;i<n;i++) if(s[i]=='<') add(i,i+1); else add(i+1,i);
	tpsort();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 32000
#C
n,m = map(int,input().split())
denkyu = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    denkyu.append(tmp)   
p = list(map(int,input().split()))

#bit全探索？
import itertools
switch = list(itertools.product([0,1],repeat=n))
cnt = 0

for i in switch:
    gokei = 0
    flg = True
    for j in range(m):
        gokei = 0
        for k in range(1,len(denkyu[j])):
            gokei += i[denkyu[j][k]-1] 
            
        if gokei % 2 != p[j]:
            flg = False
            break
            
    if flg:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n, dp[100100], x, y, M, N;
vector<ll>adj[100010];
bool vis[100010];
ll dfs(ll x)
{
    if(adj[x].size()==0)
        return 0;
    ll ans = 0;
    if(vis[x])
        return dp[x];
    vis[x] = true;
    for(int i=0;i<adj[x].size();i++)
        ans = max(ans, dfs(adj[x][i])+1);
    return dp[x] = ans;
}
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> N >> M;
    ll ans= 0;
    for(i=1;i<=M;i++)
    {
        cin >> x >> y;
        adj[x].push_back(y);
    }
    for(i=1;i<=N;i++)
        if(!vis[i])
            ans = max(ans,dfs(i));
    cout << ans <<endl;
    return 0;
}



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

namespace ProblemF
{
    class Program
    {
        public static long div = 1000000007;

        static void Main(string[] args)
        {
            var K = long.Parse(Console.ReadLine());
            var S = (Console.ReadLine());
            long N = (long)S.Length;
            long[] pow25s = new long[K + 1];
            long[] pow26s = new long[K + 1];
            pow25s[0] = 1;
            pow26s[0] = 1;
            for (int i = 1; i < K + 1; i++)
            {
                pow25s[i] = (25 * pow25s[i - 1]) % div;
                pow26s[i] = (26 * pow26s[i - 1]) % div;
            }

            long combination = 1;
            long res = 0;
            for (long i = K; i >= 0; i--)
            {
                if(i != K)
                {
                    combination = combination * (N + K - i - 1);
                    combination %= div;
                    combination *= modinv(K - i, div);
                    combination %= div;
                }
                var resTemp = combination * pow25s[K - i];
                resTemp %= div;
                resTemp *= pow26s[i];
                resTemp %= div;
                res += resTemp;
                res %= div;
            }
            Console.WriteLine(res);



            #region 
            //var dp = new long[K + 1];
            //dp[0] = 1;
            //for (int i = 1; i < K + 1; i++)
            //{
            //    dp[i] = dp[i - 1];
            //    dp[i] *= ((len + 1) * 26 - len) % div;
            //    dp[i] %= div;
            //    len++;
            //}
            //Console.WriteLine(dp[K]);
            #endregion
        }

        static long nCm(long n, long m)
        {
            try
            {
                if (n == 0) return 0;
                if (m == 0) return 1;
                return checked(((n * nCm(n - 1, m - 1)) % div) / m);
            }
            catch(OverflowException)
            {
                throw new OverflowException();
            }
        }

        // return inverse num of a with mod m
        public static long modinv(long a, long m)
        {
            long b = m, u = 1, v = 0;
            while (b > 0)
            {
                long t = a / b;
                a -= t * b;
                var temp = a;
                a = b;
                b = temp;
                u -= t * v;
                temp = u;
                u = v;
                v = temp;
            }
            u %= m;
            if (u < 0) u += m;
            return u;
        }
    }
}


Measured memory_bytes: 47324
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	int a, b, c[20];
	int p[20];
	p[0] = 1;
	for (i = 1; i < 20; i++)
		p[i] = p[i - 1] * 2;
	int v;
	int dp[5003];
	for (i = 0; i < 5003; i++)
		dp[i] = -1;
	dp[0] = 0;
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a, &b);
		for (j = 0; j < b; j++)
			scanf("%d", &c[j]);
		v = 0;
		for (j = 0; j < b; j++)
			v += p[c[j] - 1];
		for (j = 0; j < 5003; j++)
		{
			if (dp[j] >= 0)
			{
				if (dp[j | v] < 0)
					dp[j | v] = dp[j] + a;
				else if (dp[j | v] > dp[j] + a)
					dp[j | v] = dp[j] + a;
			}
		}
	}
	printf("%d\n", dp[p[n] - 1]);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int[] nk = Console.ReadLine().ToIntArray();

        int N = nk[0];
        int k = nk[1];

        if (k == 1)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(N - k);
        }
        
    }
}

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

int main() {
  int L, R, d, count = 0;
  scanf("%d %d %d", &L, &R, &d);

  for(int i = L; i <= R; i++) {
    if(i % d == 0) {
      count++;
    }
  }

  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 1684
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.split('\n')
        // .map(str => str.trim());
    main();
});

function readLine() {
    return inputString[currentLine++];
}

function F(N, A, B) {
	let dp = Array(N+1).fill(0);
	for (let n=0;n<=N;n++){
		let x = n;
		for (let j=0;j<3;j++){
			if (n>=A[j]){
				let y = dp[n-A[j]] + B[j];
				if (x<y){
					x = y;
				}
			}
		}
		dp[n] = x;
	}
	return dp[N];
}

function main() {
    const n = parseInt(readLine(), 10);
    const a = readLine().split(' ').map(_ => parseInt(_, 10));
    const b = readLine().split(' ').map(_ => parseInt(_, 10));
    let n1 = F(n, a, b);
    let n2 = F(n1, b, a);
	console.log(n2);
}


Measured memory_bytes: 398284
#include <stdio.h>
#include <math.h>

using namespace std;


int main(){
	double a,b,c,d,e,f,x,y;

	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		x=(c*e-b*f)/(a*e-d*b);
		y=(a*f-c*d)/(a*e-b*d);
		if(x == 0)x=0;
		if(y == 0)y=0;
		printf("%.3lf %.3lf\n",x,y);
	}

    return 0;
}



Measured memory_bytes: 2752
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, a: "List[int]"):
    
    a.sort(reverse=True)

    ans = 0
    for i in range(1, 2*N+1, 2):
        ans += a[i]
    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(3 * N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40436
#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;
  cin >> n;
  string s;
  cin >> s;
  if (n%2) {
    puts("No");
    return 0;
  }
  int k = n/2;
  if(s.substr(0,k) == s.substr(k,k)){
    puts("Yes");
  }
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());
    vector<int> a(n), b(n); //1つのvetor 要素n個
    for (int i = 0; i < n; i++) {
        a[i] = v[i].first;
        b[i] = v[i].second;
    }
    for (int i = 0; i < n; ++i) {
        if (b[i] >= k) {
            cout << a[i] << endl;
            return 0;
        } else {
            k -= b[i];
        }
    }
}


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

using ll=long long;

int main(){

int N;
cin >> N;

vector<int> A(N);

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

int j=0;

for(int i=0;i<N;++i){
if(A[i]%2==0){
if(A[i]%3!=0 && A[i]%5!=0){
cout<< "DENIED" << endl; goto xyz;
}
}
}

cout<< "APPROVED" << endl;

xyz:;

}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000;
const int MAXM=2000;
const int MOD=1000000007;
struct E { int a,b,c; };
bool operator<(const E &p,const E &q) { return p.c<q.c; }

int n,m; ll want;
E e[MAXM];

int extracost[MAXM];

int compid[MAXN];

int p[MAXM+1];

void run() {
	scanf("%d%d%lld",&n,&m,&want);
	REP(i,m) scanf("%d%d%d",&e[i].a,&e[i].b,&e[i].c),--e[i].a,--e[i].b;

	sort(e,e+m);
	REP(i,m) extracost[i]=-1;
	REP(i,n) compid[i]=i;
	ll have=0;
	REP(i,m) if(extracost[i]==-1) {
		int a=e[i].a,b=e[i].b,c=e[i].c,x=compid[a],y=compid[b]; assert(x!=y);
		REP(j,m) if(compid[e[j].a]==x&&compid[e[j].b]==y||compid[e[j].a]==y&&compid[e[j].b]==x) extracost[j]=e[j].c-c;
		REP(j,n) if(compid[j]==y) compid[j]=x;
		have+=c;
	}
	p[0]=1; FORE(i,1,m) p[i]=(ll)p[i-1]*2%MOD;

	//printf("have=%lld want=%lld\n",have,want);
	//printf("ec:"); REP(i,m) printf(" %d",extracost[i]); puts("");

	sort(extracost,extracost+m);
	int ret=0;
	for(int l=0,r=l;l<m;l=r) {
		while(r<m&&extracost[l]==extracost[r]) ++r;
		if(have+extracost[l]==want) {
			int cur;
			if(extracost[l]==0) {
				cur=(p[m]+(ll)2*(MOD-p[m-r]))%MOD;
			} else {
				cur=((ll)p[m-l]+MOD-p[m-r])%MOD;
				cur=(ll)2*cur%MOD;
			}
			//printf("%d..%d=%d\n",l,r,cur);
			ret=(ret+cur)%MOD;
		}
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<double,double>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////

void solve(){
  vl p(3);
  inl(N , K); in(p);
  ins(T);

  auto f = [&](char n){
    return n == 's' ? 0 : n == 'p' ? 1 : 2;
  };

  ll ans = 0;
  vi flg(N);
  rep(i , N){
    if(i < K) ans += p[f(T[i])] , flg[i]++;
    else if(T[i] != T[i - K] || flg[i - K] == 0){
      ans += p[f(T[i])] , flg[i]++;
    }
  }
  out(ans);

}

Measured memory_bytes: 848
#define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
#define endl '\n'
#define sq(x) (x) * (x)
#define print_case() cout << "Case #" << test_case_number++ << ": "

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int test_case_number = 1;

const long double PI = acos(-1);
int main(){
    cout << setprecision(12) << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int A, B, H, M;
    cin >> A >> B >> H >> M;

    ld ma = M * 6;
    ld ha = H * 30 + ((ld)30 * (ma/(ld)(360)));
    ld angle = min(360 - abs(ma - ha), abs(ma - ha));
    ld rad = angle * (PI/(ld)(180));
    debug() << imie(rad);
    debug() << imie(cos(rad));
    ld ans = (sq(A) + sq(B) - (2 * (A) * (B) * cosl(rad)));

    cout << sqrt(ans) << endl;
}


Measured memory_bytes: 4116
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen, memset
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
#include <fstream>
using namespace std;
int main()
{
    string h;
    cin >> h;
    int u = h.size();
    int t = 0;
    for( int i = 0; i < u - 1; i++)
        if( h[i] != h[i + 1]) t++;
    printf("%d\n", t);
    return 0;
}


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

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

    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[100000][3]={0};

int ans(int a[100000][3],int i,int j,int n)
{
	if(i==n)
		return 0;

	if(dp[i][j]!=0)
		return dp[i][j];

	int best=0;
	for(j;j<3;j++)
	{
		for(int k=0;k<3;k++) 
		{
			if(k==j)
				continue;
			best=max(best,a[i][j]+ans(a,i+1,k,n));
		}
		if(i!=0)
			break;
	}
	return dp[i][j]=best;
}

int main()
{
	ios_base::sync_with_stdio(0);           
	cin.tie(NULL);
	cout.tie(NULL);
	int n,a[100000][3];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	}
	cout<<ans(a,0,0,n);
    
    return 0;
}

Measured memory_bytes: 15300
use proconio::input;
use proconio::marker::Usize1;
use std::cmp;

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        pairs: [(Usize1, Usize1, usize, usize); q],
    }
    let mut s = vec![];
    let ans = dfs(&mut s, n, m, &pairs);

    println!("{}", ans);
}

fn dfs(s: &mut Vec<usize>, n: usize, m: usize, pairs: &Vec<(usize, usize, usize, usize)>) -> usize {
    if s.len() == n {
        let mut point = 0;
        for &pair in pairs {
            if s[pair.1] - s[pair.0] == pair.2 {
                point += pair.3;
            }
        }
        return point;
    }
    let mut max = 0;
    if s.len() == 0 {
        for i in 1..=m {
            s.push(i);
            max = cmp::max(max, dfs(s, n, m, pairs));
            s.pop();
        }
    } else {
        for i in s[s.len() - 1]..=m {
            s.push(i);
            max = cmp::max(max, dfs(s, n, m, pairs));
            s.pop();
        }
    }
    max
}


Measured memory_bytes: 2180
n, m, x = map(int, input().split())
a_list = list()

l = list()
ans = []

for i in range(0, n):
    a_list.append(list(map(int, input().split())))


for i in range(1, 2**n):
    num = format(i, '0' + str(n) + 'b')
    l.append(num)

# print(l)

list_len = len(l)

s = 0

tmp = [0]*(m+1)

for i in range(0, list_len):
    w_len = m
    num = l[i]
    for j in range(0, n):
        if int(num[j]) == 1:
            for z in range(0, m+1):
                tmp[z] += a_list[j][z]
    # print(tmp)
    if len(list(filter(lambda number: number >= x, tmp[1:]))) == m:
        ans.append(tmp[0])
    tmp = [0]*(m+1)

# print(ans)

if ans == []:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 9312
/*input
4
3 1 4 2
10 20 30 40
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =2e5+2;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int bit[N];
int v=0,n;
int get(int idx)
{
	int ans=0;
	while(idx>0)
	{
		ans=max(ans,bit[idx]);
		idx-=idx&-idx;
	}
	return ans;
}
void update(int idx,int val)
{
	while(idx<=v)
	{
		bit[idx]=max(val,bit[idx]);
		idx+=(idx&(-idx));
	}
}
signed main()
{
	cin>>n;
	int h[n+1],a[n+1];
	Rep(i,n)
	{
		cin>>h[i];
		v=max(v,h[i]);
	}
	//cout<<v<<endl;
	int sum=0;
	Rep(i,n)
	{
		cin>>a[i];
		//sum+=a[i];
	}
	update(h[1],a[1]);
	//cout<<a[1]<<" ";
	for(int i=2;i<=n;i++)
	{
		int temp=get(h[i]);
		temp+=a[i];
		//cout<<temp<<" ";
		update(h[i],temp);
	}
	int ans=get(v);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const int mod = int(1e9) + 7;

int n;
char s[100005];
int cnt[26];

int main() {
	scanf("%d%s", &n, s);
	for (int i = 0; i < n; ++i) ++cnt[s[i] - 'a'];
	int ans = 1;
	for (int i = 0; i < 26; ++i) ans = 1LL * ans * (cnt[i] + 1) % mod;
	printf("%d\n", (ans - 1 + mod) % mod);
}

Measured memory_bytes: 3888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] list = S.split("");

		if (list[0].equals(list[1]) && list[1].equals(list[2])) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

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

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v)
{
  visited[v] = true;
  for (int v2 = 0; v2 < n; v2++) {
    if (graph[v][v2] == false) continue;
    if (visited[v2] == true) continue;
    dfs(v2);
  }
}

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

  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;

  for (int i = 0; i < m; i++) {
      graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
      for (int j = 0; j < n; j++) visited[j] = false;
      dfs(0);

      bool bridge = false;
      for (int j = 0; j < n; j++) if (visited[j] == false) bridge = true;
      if (bridge) ans += 1;

      graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def solve():
    A, B, C = map(int, input().split())

    cnt = 0
    while True:
        if A % 2 or B % 2 or C % 2:
            return cnt
        ta = B // 2 + C // 2
        tb = A // 2 + C // 2
        tc = A // 2 + B // 2
        if ta == A and tb == B and tc == C:
            return -1
        A, B, C = ta, tb, tc
        cnt += 1


print(solve())

Measured memory_bytes: 3064
import math
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N + 1)]
for i in range(N, N // 2, -1):
    b[i] = a[i - 1]
for i in range(N // 2, 0, -1):
    bi = a[i - 1]
    for j in range(2, N // i + 1):
        bi = bi ^ b[i * j]
    b[i] = bi
print(sum(b))
for i, j in enumerate(b):
    if j == 1:
        print(i, end = ' ')


Measured memory_bytes: 7276
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  if ((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0) {
    cout << "Possible" << endl;
  } else
    cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

typedef long long ll;

const int N = 1e5 + 5;

int A[N];

double dis(pair<int, int> a, pair<int, int> b)
{
    int k = a.F - b.F;
    k *= k;
    int q = a.S - b.S;
    q *= q;
    k += q;
    return sqrt(k);
}

int n;
double ans;
vector<pair<int, int>> v;
map<pair<int, int>, double> d;

void solve(int p, int k, int b, double r)
{

    if (k == n) {
        ans += r;
        return;
    }

    for (int i = 0; i < v.sz; i++) {
        if (b & (1 << i))
            continue;
        solve(i, k + 1, b | (1 << i), r + (k > 0) * d[{ p, i }]);
    }
}

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v.pb({ x, y });
    }

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            double D = dis(v[i], v[j]);
            d[{ i, j }] = d[{ j, i }] = D;
        }
    }

    solve(0, 0, 0, 0);

    int f = 1;

    for (int i = 2; i <= n; i++)
        f *= i;

    cout << setprecision(10) << ans / (double)f;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N, M;
	cin >> N >> M;

	vector<int> num(N, 1);
	set<int> st;
	st.insert(0);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;

		num[x]--;
		num[y]++;
		
		if (st.find(x) != st.end()) {
			st.insert(y);
		}
		if (num[x] == 0) {
			st.erase(x);
		}
	}

	cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int h, w, kk; cin>>h>>w>>kk;
    int m1 = pow(2, h);
    int m2 = pow(2, w);
    char g[h][w];
    For(i, 0, h){
        For(j, 0, w){
            cin>>g[i][j];
        }
    }
    int ans = 0;
    For(k, 0, m1){
        For(l, 0, m2){
            vector<int> r(h, 0), c(w, 0);
            int mask1 = k;
            int mask2 = l;
            For(i, 0, h){
                if(mask1 % 2){
                    r[i]=1;
                }
                else{
                    r[i]=0;
                }
                mask1/=2;
            }
            For(i, 0, w){
                if(mask2 % 2){
                    c[i]=1;
                }
                else{
                    c[i]=0;
                }
                mask2 /= 2;
            }
            int b = 0;
            For(i, 0, h){
                For(j, 0, w){
                    if(!r[i] && !c[j] && g[i][j]=='#')
                        b++;
                }
            }
            if(b == kk){
                ans++;
            }
        }
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 4004
'use strict';
let execute = input => {
  let sum = input.split('').reduce((sum, el) => (sum += +el), 0);
  return input % sum === 0 ? 'Yes' : 'No';
};

function Main(input) {
  console.log(execute(input));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<ll>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n;
  cin >> n;
  ll p = 1;
  vec a(n);
  rep (i,n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep (i,n) {
    ll b = p, c = a[i], d = 0;
    while (b / 10 > 0) {
      b /= 10;
      d++;
    }
    while (c / 10 > 0) {
      c /= 10;
      d++;
    }
    if (d > 18) {
      cout << -1 << endl;
      return 0;
    } else if (d == 18 && b * c > 1) {
      cout << -1 << endl;
      return 0;
    }
    p *= a[i];
    if (p > 1000000000000000000ll) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << p << endl;
}


Measured memory_bytes: 4048
fn c() {
    input! {
        n: usize,
        m: usize,
        x: i32,
        c: [[i32; m + 1]; n]
    }
    let all = 1 << n;
    let mut ans = std::i32::MAX;
    for mask in 0..=all {
        
        let mut table = vec![0; m + 1];

        for i in 0..n {
            if mask >> i & 1 == 1 {
                for j in 0..(m + 1) {
                    table[j] += c[i][j];
                }
            }
        }
        if table.iter().skip(1).all(|&s| s >= x) {
            if ans > table[0] {
                ans = table[0];
            }
        }
    }
    if ans == std::i32::MAX {
        println!("-1");
    }
    else {
        println!("{}", ans);
    }
}

use proconio::input;
use proconio::marker::Chars;

fn main() {
    c();
}

Measured memory_bytes: 2196
#include<stdio.h>

int main(void){
    char S[5],T[5];

    scanf("%s",S);
    scanf("%s",T);

    int count=0;

    int i;
    for(i=0;i<3;i++){
        if(S[i]==T[i]){
            count++;
        }
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 128
import sys
import math
import cmath
sys.setrecursionlimit(1000000)

def dft_divide(f, l):
    if l == 1:
        return
    ll = l // 2
    f0, f1 = [0] * ll, [0] * ll
    for i in range(ll):
        f0[i] = f[2 * i]
        f1[i] = f[2 * i + 1]
    dft_divide(f0, ll)
    dft_divide(f1, ll)
    dft_solve(f, f0, f1, l)
    return

def dft_solve(f, f0, f1, l):
    ll = l // 2
    zz = cmath.exp(2j * cmath.pi / l)
    z = 1
    for i in range(l):
        f[i] = f0[i % ll] + z * f1[i % ll]
        z *= zz
    return

def idft_divide(f, l):
    if l == 1:
        return
    ll = l // 2
    f0, f1 = [0] * ll, [0] * ll
    for i in range(ll):
        f0[i] = f[2 * i]
        f1[i] = f[2 * i + 1]
    idft_divide(f0, ll)
    idft_divide(f1, ll)
    idft_solve(f, f0, f1, l)
    return

def idft_solve(f, f0, f1, l):
    ll = l // 2
    zz = cmath.exp(-2j * cmath.pi / l)
    z = 1
    for i in range(l):
        f[i] = f0[i % ll] + z * f1[i % ll]
        z *= zz
    return

def multiply(f, g, ma):
    lf, lg = len(f), len(g)
    m = 2 ** (int(math.log2(lf + lg)) + 1)
    for i in range(m - lf):
        f.append(0)
    for i in range(m - lg):
        g.append(0)
    dft_divide(f, m)
    dft_divide(g, m)
    fg = [0] * m
    for i in range(m):
        fg[i] = f[i] * g[i]
    idft_divide(fg, m)
    c = [0] * (2 * ma + 1)
    for i in range(2 * ma + 1):
        c[i] = round(fg[i].real / m)
    return c

n, m = map(int, input().split())
a = list(map(int, input().split()))
ma = max(a)
happiness1 = [0] * (ma + 1)
happiness2 = [0] * (ma + 1)
for i in a:
    happiness1[i] += 1
    happiness2[i] += 1
c = multiply(happiness1, happiness2, ma)
cnt = 0
ans = 0
for i in range(2 * ma, -1, -1):
    if c[i] + cnt >= m:
        ans += (m - cnt) * i
        cnt += (m - cnt)
    else:
        ans += c[i] * i
        cnt += c[i]
    if cnt == m:
        break
print(ans)

Measured memory_bytes: 195412
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string ma;
	while (cin >> ma)
	{
		if (ma=="0")break;
		int sum = 0;
		for (int i = 0; i < ma.length(); i++)
			sum += (static_cast<int>(ma[i])-48);
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)
    cin >> d.at(i);
  int R;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++)
      R+=d[i]*d[j];
  }
  
  cout << R;
}

Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
S = input()

d1 = defaultdict(int)
d2 = defaultdict(int)
d3 = defaultdict(int)

for s in S:
    for x in d2:
        d3[x+s]+=1
    for y in d1:
        d2[y+s]+=1
    d1[s]+=1

print(len(d3))

Measured memory_bytes: 3572
#include<cstdio>
int main()
{
  int q,h,s,d,n;
  scanf("%d%d%d%d%d",&q,&h,&s,&d,&n);
  if(q*4<s)s=q*4;
  if(h*2<s)s=h*2;
  if(s*2<d)printf("%lld\n",n*1ll*s);
  else printf("%lld\n",n/2*1ll*d+(n%2)*s);
}

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

int dp[3010][7000];

int main(){
    int N,T; cin >> N >> T;
    vector<pair<int,int>> dish(N);
    int m_t=0;
    for(int i=0;i<N;i++){
        int a,b; cin >> a >> b;
        dish[i]={a,b};
        m_t=max(m_t,a);
    }
    sort(dish.begin(),dish.end());
    memset(dp,0,sizeof(dp));
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        int a=dish[i].first;
        int b=dish[i].second;
        for(int j=0;j<T;j++){
            if(j-a>=0){
                dp[i+1][j]=max(dp[i][j-a]+b,dp[i][j]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans=max(dp[i][T-1]+dish[i].second,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 82560
#include <bits/stdc++.h>
using namespace std;
int main(){
int K; cin >> K;
vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << A[K-1] << "\n";
}

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

int main(){
  string a,b,c;
  cin >> a >> b >>c;
  a.at(0) -=32;
  b.at(0) -=32;
  c.at(0) -=32;
  cout << a.at(0) << b.at(0) << c.at(0) << endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 998244353
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<LL>> dp(n,vector<LL>(2,INF));
  vector<int> count(n,0);
  vector<LL> ruijo(n+1);
  vector<vector<int>> coo(n,vector<int>(2,0)),cooo(n,vector<int>(2,0));
  vector<map<int,int>> h(n);
  map<int,int>::iterator itr;
  ruijo[0]=1;
  for(int i=1;i<=n;i++){
    ruijo[i]=ruijo[i-1]*2%MOD;
  }
  int a,b,c;
  int co[2]={0,0};
  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    a--,b--;
    if(a<=1&&b<=1){
      if(a==1&&b==1){
        dp[1][1-c]=0;
      }else{
        co[c]++;
      }
    }else if(a==b){
      dp[a][1-c]=0;
    }else if(abs(a-b)==1){
      coo[max(a,b)][c]++;
    }else if(abs(a-b)==2){
      cooo[max(a,b)][c]++;
    }else{
      itr=h[max(a,b)].find(min(a,b));
      if(itr==h[max(a,b)].end()){
        h[max(a,b)][min(a,b)]=c;
        count[max(a,b)]++;
      }else{
        if(itr->second!=c){
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  int ini[5][5]={
    {8,4,2,1,1},
    {4,2,1,0,0},
    {2,1,1,0,0},
    {1,0,0,0,0},
    {1,0,0,0,0},
  };
  int inii[2][3][3]={
    {
      {2,1,1},
      {1,0,0},
      {1,0,0}
    },
    {
      {2,1,0},
      {1,1,0},
      {0,0,0}
    },
  };
  if(dp[1][0]!=0){
    dp[1][0]=ini[co[0]+1][co[1]];
  }
  if(dp[1][1]!=0){
    dp[1][1]=ini[co[0]][co[1]+1];
  }
  // cout << dp[1][0] SP dp[1][1] << endl;
  // cout << coo[2][0] SP coo[2][1] << endl;
  // cout << cooo[2][0] SP cooo[2][1] << endl;
  // cout << coo[3][0] SP coo[3][1] << endl;
  // cout << cooo[3][0] SP cooo[3][1] << endl;
  for(int i=2;i<n;i++){
    // cout << "------" SP i << endl;
    if(dp[i][0]!=0){
      dp[i][0]=(dp[i-1][0]*ini[coo[i][0]+2][coo[i][1]]%MOD*inii[0][cooo[i][0]][cooo[i][1]]%MOD*ruijo[i-2-count[i]]%MOD
        +dp[i-1][1]*ini[coo[i][0]+1][coo[i][1]+1]%MOD*inii[1][cooo[i][0]][cooo[i][1]]%MOD*ruijo[i-2-count[i]]%MOD)%MOD;
    }
    // cout << ini[coo[i][0]+2][coo[i][1]] SP inii[0][cooo[i][0]][cooo[i][1]] SP ruijo[i-2-count[i]] << endl;
    // cout << ini[coo[i][0]+1][coo[i][1]+1] SP inii[1][cooo[i][0]][cooo[i][1]] SP ruijo[i-2-count[i]] << endl;
    if(dp[i][1]!=0){
      dp[i][1]=(dp[i-1][0]*ini[coo[i][0]+1][coo[i][1]+1]%MOD*inii[0][cooo[i][0]][cooo[i][1]]%MOD*ruijo[i-2-count[i]]%MOD
        +dp[i-1][1]*ini[coo[i][0]][coo[i][1]+2]%MOD*inii[1][cooo[i][0]][cooo[i][1]]%MOD*ruijo[i-2-count[i]]%MOD)%MOD;
    }
    // cout << ini[coo[i][0]+1][coo[i][1]+1] SP inii[0][cooo[i][0]][cooo[i][1]] SP ruijo[i-2-count[i]] << endl;
    // cout << ini[coo[i][0]][coo[i][1]+2] SP inii[1][cooo[i][0]][cooo[i][1]] SP ruijo[i-2-count[i]] << endl;
  }
  // cout << dp[n-1][0] SP dp[n-1][1] << endl;
  cout << (dp[n-1][0]+dp[n-1][1])%MOD << endl;
  return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  cout<<vec_sum(v)-n<<endl;
  
}
///////////////////////////



Measured memory_bytes: 256
fun main(args: Array<String>){
    val n = readLine()!!.split(" ").map { it.toInt() }
    if (n[0] > 1){
        if (n[1] > 1){
            val a = n[0] -1
            val b = n[1] - 1
            val c = n[0] * a
            val d = c / 2
            val e = n[1] * b
            val f = e / 2
            val g = d + f
            println(g)
        } else {
            val a = n[0] -1
            val c = n[0] * a
            val d = c / 2
            println(d)
        }
    } else {
        if (n[1] > 1){
            val b = n[1] - 1
            val e = n[1] * b
            val f = e / 2
            println(f)
        } else {
            println(0)
        }
    }
}


Measured memory_bytes: 37996
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    int a[51];
    REP(i,n)cin>>a[i];
    REP(i,n){
      if(i==n-1){cout<<a[i];break;}
      if(a[i+1]-a[i]!=1) cout<<a[i]<<" ";
      else{
        cout<<a[i];
        FOR(j,i,n){
          if(j==n-1||a[j+1]-a[j]!=1){
            cout<<"-"<<a[j];
            if(j!=n-1)cout<<" ";
            i=j;
            break;
          }
        }
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1e9 + 7;
double EPS = 1e-10;

int main() {
	vector<ll> F(100001);
	F[0] = 1;
	for (int x = 1; x <= 100000; x++)
		F[x] = F[x - 1] * x % MOD;
	int x, y; cin >> x >> y;
	int d = abs(x - y);
	if (d == 0) cout << 2 * F[x] * F[y] % MOD << endl;
	else if (d == 1) cout << F[x] * F[y] % MOD << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 1024