akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define mp make_pair
int INF=3e5;
vector<int> adjlist[100010];
int ans[100010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	priority_queue<ii,vector<ii>,greater<ii> > pq;
	int n,q;
	cin >> n;
	for(int i=1;i<=n-1;i++)
	{
		int u,v;
		cin >> u >> v;
		adjlist[u].push_back(v);
		adjlist[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
    {
        ans[i]=INF;
    }
	cin >> q;
	for(int i=1;i<=q;i++)
	{
		int u,num;
		cin >> u >> num;
		ans[u]=num;
		pq.push(ii(num,u));
	}
	while(!pq.empty())
	{
		int u=pq.top().second,num=pq.top().first;
		pq.pop();
		for(int i=0;i<adjlist[u].size();i++)
		{
			int v=adjlist[u][i];
			if(ans[v]==INF)
			{
				ans[v]=num+1;
				pq.push(ii(ans[v],v));
			}
			if(abs(ans[u]-ans[v])!=1)
			{
				cout << "No" << "\n";
				return 0;
			}
		}
	}
	cout << "Yes" << "\n";
	for(int i=1;i<=n;i++)
	{
		cout << ans[i] << "\n";
	}
}


Measured memory_bytes: 7924
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int H,W,h=0;
    vector<vector<char> > a;
    
    cin >> H >> W;
    for(int i=0;i<H;i++){
        vector<char> kari;
        bool flag=false;
        
        for(int j=0;j<W;j++){
            char x;cin >> x;
            if(x=='#')flag=true;
            
            kari.push_back(x);
        }
        if(flag){a.push_back(kari);h++;}
    }
    int flag[110]={0};
    for(int j=0;j<W;j++){
        for(int i=0;i<h;i++){
            if(a[i][j]=='#')flag[j]=1;
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<W;j++){
            if(flag[j]==0)continue;
            
            cout << a[i][j];
        }
        cout << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
    "os"
    "bufio"
    "strconv"
)
// 文字列を1行入力
func StrStdin() (stringInput string) {
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    stringInput = scanner.Text()

    stringInput = strings.TrimSpace(stringInput)//文字列の先頭と末尾の空白文字を削除する
    return
}
// 整数値1つ取得
func IntStdin() (int, error) {
    stringInput := StrStdin()
    return strconv.Atoi(strings.TrimSpace(stringInput))
}
// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}
// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
    // 文字列で1行取得
    stringInput := StrStdin()

    // 空白で分割
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}
// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // 文字列スライスを取得
    stringSplited := SplitStrStdin(" ")

    // 整数スライスに保存
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])//Atoi 文字列から整数
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}
// 配列の中の同じ要素削除
func removeDuplicate1(oldarr []int)[]int{
	results := make([]int, 0, len(oldarr))
	encountered := map[int]bool{}
	for i:=0;i<len(oldarr);i++{
		if !encountered[oldarr[i]]{
			encountered[oldarr[i]] = true
			results = append(results, oldarr[i])
		}
	}
	return results
}

func main(){
	var N,K int
	fmt.Scan(&N,&K)
	var d []int
	var A []int
	for i:=0;i<K;i++{
		var di int 
		fmt.Scan(&di)
		d = append(d,di)

		Ai :=make([]int,di)
		for x:=0;x<di;x++{
			fmt.Scan(&Ai[x])
		}
		for j:=0;j<len(Ai);j++{
			A = append(A,Ai[j])
		}
	}

	result := removeDuplicate1(A)

	fmt.Println(N-len(result))

}

Measured memory_bytes: 2912
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//#include<set>
#include<algorithm>
//#include<math.h>
//#include<iostream>
//#include<time.h>
using namespace std;

#define LL long long
int qread()
{
	char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-') && (t=-1);
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t;
}

//Pay attention to read!

int n;
#define maxn 211
struct Edge{int to,next;}edge[maxn]; int first[maxn],le=2;
void in(int x,int y) {Edge &e=edge[le]; e.to=y; e.next=first[x]; first[x]=le++;}
void insert(int x,int y) {in(x,y); in(y,x);}

int du[maxn];
LL ans1,ans2; int dep;
void dfs(int x,int fa,int ddd)
{
	dep=max(dep,ddd);
	int now=0;
	for (int i=first[x];i;i=edge[i].next)
	{
		Edge &e=edge[i]; if (e.to==fa) continue;
		dfs(e.to,x,ddd+1); now++;
	}
	du[ddd]=max(du[ddd],now);
}
void calc(int x)
{
	dep=0; memset(du,0,sizeof(du)); dfs(x,0,1);
	LL pp=1; for (int i=dep-1;i;i--) {pp*=du[i];}
	if (dep<ans1)
	{
		ans1=dep;
		ans2=pp;
	}
	else if (dep==ans1) ans2=min(ans2,pp);
}
void calc(int x,int y)
{
	dep=1; memset(du,0,sizeof(du)); dfs(x,y,2); dfs(y,x,2); du[1]=2;
	LL pp=1; for (int i=dep-1;i;i--) {pp*=du[i];}
	if (dep-1<ans1)
	{
		ans1=dep-1;
		ans2=pp;
	}
	else if (dep-1==ans1) ans2=min(ans2,pp);
}
	
int main()
{
	n=qread();
	for (int i=1,x,y;i<n;i++) {x=qread(); y=qread(); insert(x,y);}
	
	ans1=1e18; ans2=1e18;
	for (int i=1;i<=n;i++) calc(i);
	for (int i=1;i<=n;i++)
		for (int j=first[i];j;j=edge[j].next)
			if (i<edge[j].to) calc(i,edge[j].to);
	printf("%lld %lld\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
using namespace std;

int main() {
	int n,s,sum=0,ans=10000;
	array <int, 110> w;
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> w[i];
		sum += w[i];
	}
	for (int i = 1; i < n; i++) {
		s = 0;
		for (int j = 1; j <= i; j++) {
			s += w[j];
		}
		if (ans>abs(s-(sum-s))) {
			ans = abs(s - (sum - s));
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
	DRII(a,b);
	int res=(a-1)*(b-1);
	printf("%d\n",res);
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

int x;

int main() {
    IO::read(x);
    printf("%d\n", x ^ 1);
    return 0;
}

Measured memory_bytes: 3744
import numpy as np

A = [list(map(int, input().split())) for l in range(3)]

col_0 = [A[0][1]-A[0][0], A[0][2]-A[0][0]]
col_1 = [A[1][1]-A[1][0], A[1][2]-A[1][0]]
col_2 = [A[2][1]-A[2][0], A[2][2]-A[2][0]]

bool = (col_0 == col_1) and (col_0 == col_2)

if bool == True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 12496
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
n, a, b, c, d = map(int,input().split())
s = input()
for i in range(a-1,c-2):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
for i in range(b-1,d-2):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
if c > d:
    for i in range(b-1,d):
        if s[i] == "." and s[i-1] == "." and s[i+1] == ".":
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstdlib>
#include <set>
#include <algorithm>
#include <ctime>
using namespace std;
 
 
int n, d1, d2, d[11][610][610], a[1000][1000];
vector <pair<int, int> > V;
 
void construct(int n, int d1, int dep) {
 
    if (d1 % 4 != 0) {
        if (d1 % 2 == 0) {
            for (int i = 0; i < 2 * n; i++)
                for (int j = 0; j < 2 * n; j++)
                    if (i % 2 == 0)
                        d[dep][i][j] = 1;
                    else
                        d[dep][i][j] = 0;
        }else {
            for (int i = 0; i < 2 * n; i++)
                for (int j = 0; j < 2 * n; j++)
                    if ((i + j) % 2 == 0)
                        d[dep][i][j] = 1;
                    else
                        d[dep][i][j] = 0;
        }
    }else {
        construct(n, d1 / 4, dep + 1);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k <= 1; k++)
                    for (int  p = 0; p <= 1; p++)
                        d[dep][i * 2 + k][j * 2 + p] = d[dep + 1][i][j];
    }
}
 
int dis(pair <int, int> x, pair <int, int> y) {
    return (x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second);
}
 
int main() {
    scanf("%d%d%d", &n, &d1, &d2);
    construct(n, d1, 0);
    for (int i = 0; i < 2 * n; i++)
        for (int j = 0; j < 2 * n ;j++)
            a[i][j] = d[0][i][j];
    construct(n, d2, 0);
    for (int i = 0; i < 2 * n; i++)
        for (int j = 0; j < 2 * n ;j++)
            a[i][j] &= d[0][j][i];
    
    for (int i = 0; i < 2 * n; i++)
        for (int j = 0; j < 2 * n; j++)
            if (a[i][j])
                V.push_back(make_pair(i, j));
    for (int i = 0; i < n * n; i++)
        printf("%d %d\n", V[i].first, V[i].second);
 
    // for (int i = 0; i < 2 * n; i++) {
    //  for (int j = 0; j < 2 * n; j++)
    //      printf("%d", d[0][i][j]);
    //  printf("\n");
    // }
 
    // printf("%lu %d\n", V.size(), n * n);
    // for (int i = 0; i < (int) V.size(); i++)
    //  for (int j = 0; j < (int) V.size(); j++)
    //      if (dis(V[i], V[j]) == d1 || dis(V[i], V[j]) == d2)
    //          printf("error\n");
}


Measured memory_bytes: 20212
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}

namespace SOLVE {
    void main(){
    }
}

int dp[200010][2];
int main() {
    int n;
    cin>>n;
    map<ll, ll>mp;
    mp[0] = 1;
    ll sum = 0;
    ll ans = 0;
    REP(i,0,n){
        ll c;cin>>c;
        sum+=c;
        ans += mp[sum];
        mp[sum]++;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    cout<<ans;
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 12800
// Beginner162.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

bool has7(int n)
{
	while (n > 0)
	{
		int c = n % 10;
		if (c == 7) return true;
		n /= 10;
	}
	return false;
}

int gcd(int a, int b)
{
	while (b != 0)
	{
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int main()
{
	//A
	/*int n;
	cin >> n;
	bool has = has7(n);
	cout << (has ? "Yes" : "No");*/

	//B
	/*int n;
	cin >> n;

	ll result = 0;
	for (int i = 1; i <=n; ++i)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			result += i;
		}
	}
	cout << result;*/
	
	//C
	int k;
	cin >> k;

	ll result = 0;
	vector<vector<int>> v(k + 1, vector<int>(k + 1, 0));
	for (int i = 1; i <= k; ++i)
	{
		for (int j = i; j <= k; ++j)
		{
			int g = gcd(i, j);
			v[i][j] = g;
			v[j][i] = g;
		}
	}
	
	for (int i = 1; i <=k; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			int ij = v[i][j];
			
			for (int l = 1; l <= k; ++l)
			{
				int ijl = v[ij][l];
				result += ijl;
			}
		}
	}
	
	cout << result;

	//D

	//E

	//F
}



Measured memory_bytes: 3720
local n,k=io.read("*n","*n")
local ans=0
if (k==0) then
  ans=n*n
else
  for i=k,n do
    ans=ans+(i-k)*(math.floor(n/i))
    if (n%i>=k) then
      ans=ans+(n%i)-k+1
    end
  end
end
print(ans)

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string S[3]; cin >> S[0] >> S[1] >> S[2];
    cout << S[0][0] << S[1][0] << S[2][0] << endl;
    return 0;
}

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

def main():
    N = input()
    Ns = []
    for n in N:
        Ns.append(int(n))
    Ns.sort()
    a = Ns[0]

    while True:
        num = a*100+a*10+a
        if num >= int(N):
            print(num)
            exit()
        a += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# python3
# utf-8

import itertools

rows_nr, cols_nr = (int(x) for x in input().split())
d1___d2___cost = []
for i in range(10):
    d1___d2___cost_i___j = [int(x) for x in input().split()]
    d1___d2___cost.append(d1___d2___cost_i___j)
r_c___value = []
for row in range(rows_nr):
    c___value = [int(x) for x in input().split()]
    r_c___value.append(c___value)

f = d1___d2___cost
for i, v, u in itertools.product(range(10), repeat=3):
    f[u][v] = min(f[u][v], f[u][i] + f[i][v])
ans = 0
for row in r_c___value:
    for value in row:
        if value == -1:
            continue
        ans += f[value][1]
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    int x[5]; 
    rep(i,5){
        cin >> x[i];
        if(x[i] == 0) cout << i + 1<< endl;
    }

    return 0;
}


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

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

int main() {
    string o, e;
    cin >> o >> e;

    REP(i, e.size()) {
        cout << o[i];
        cout << e[i];
    }
    if (o.size() > e.size())
        cout << o.back() << endl;
    else
        cout << endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int F[50];
  F[0] = F[1] = 1;
  for (int i = 2; i <= n; i++)
    F[i] = F[i - 1] + F[i - 2];

  cout << F[n] << endl;

  return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(B % A == 0) {
			System.out.println(A + B);
		}else{
			System.out.println(B - A);
		}
	}
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
				using namespace std;
				#define ll long long
				#define mod 1000000007
				#define pll pair<long,long>
				#define se second
				#define fi first
				#define pb push_back
				#include <ext/pb_ds/assoc_container.hpp>
				#include <ext/pb_ds/tree_policy.hpp>
				using namespace __gnu_pbds;

				typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
				typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
				
				const ll m=998244353;
				ll cache[3002][3002];
				ll n,s;
				vector<ll> v;
				ll dp(ll idx,ll s)
				{
					//cout<<idx<<" "<<s<<" "<<cache[idx][s]<<endl;
					if(s==0)
						return n-idx+1;
					
					if(s<0 || idx>=n)
						return 0;
					
					if(cache[idx][s]!=-1)
						return cache[idx][s];
					ll ans=0;
					ans=dp(idx+1,s)+dp(idx+1,s-v[idx]);
					ans%=m;
					return cache[idx][s]=ans;
						
				}
				
				int main()
				{
					ios_base::sync_with_stdio(false);
					cin.tie(NULL);
					cin>>n>>s;	
					v.resize(n);
				
					for(ll i=0;i<n;i++)
						cin>>v[i];
					ll res=0;
					for(ll i=0;i<=3000;i++)
					{
						for(ll j=0;j<=3000;j++)
							cache[i][j]=-1;
					}
					for(ll i=0;i<n;i++)
						{res+=dp(i,s);res%=m;
						//	cout<<dp(i,s)<<endl;
						}
					res%=mod;
					cout<<res;
				}
				


Measured memory_bytes: 70912
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

sortPermutations :: [[Int]] -> Int -> Int -> [[Int]]
sortPermutations xs n a | n == a = sortBy (\x y -> compare (x !! n) (y !! n)) xs
                        | otherwise = sortBy (\x y -> compare (x !! a) (y !! a)) (sortPermutations xs n (a+1))

main = do
  n <- getInt
  ps <- getIntList
  qs <- getIntList
  let ns = permutations [1..n]
  let ns' = sortPermutations ns (n-1) 0
  let a = fromJust(elemIndex ps ns')
  let b = fromJust(elemIndex qs ns')
  print $ abs (a - b)


Measured memory_bytes: 22908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[5];
int main()
{
  int c = 1;
  for(int i=0;i<3;i++){cin>>a[i];}
  for(int i=1;i<3;i++){
        if(a[i] != a[i-1]) c++;
  }
  if(c==3 && a[0]==a[2]) cout<<2;
  else
  cout<<c;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,i,j;
	cin>>a;
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=9;j++)
		{
			if(i*j==a)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<vector<vector<pair<int,int>>>> g(n,vector<vector<pair<int,int>>>(n));
	vector<vector<int>> c(n,vector<int>(n,0));
//	vector<vector<vector<int>>> a(n,vector<int>(n));
//	game1:優先される試合
	int tmp1=0;
	int tmp2=0;
	pair<int,int> game1,game2;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n-1; j++) {
			tmp2=tmp1;
			cin>>tmp1;
			if (j>0) {
				game1=make_pair(min(i,tmp2-1),max(i,tmp2-1));
				game2=make_pair(min(i,tmp1-1),max(i,tmp1-1));
				g[game1.first][game1.second].push_back(game2);
				c[game2.first][game2.second]++;
			}
		}
	}
	//湧き出しを探す
	int count=0;
	queue<pair<int,int>> q;
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			if (c[i][j]==0) {
				q.push(make_pair(i,j));
				count++;
			}
		}
	}
	//bfs
	int task;
	int day=0;
	pair<int,int> dest,source;
	while (q.size()>0) {
		task=q.size();
		for (int i = 0; i < task; i++) {
			source=q.front();
			for (int j = 0; j < g[source.first][source.second].size(); j++) {
				dest=g[source.first][source.second][j];
				c[dest.first][dest.second]--;
				if (c[dest.first][dest.second]==0) {
					q.push(dest);
					count++;
				}
			}
			q.pop();
		}
		day++;
	}
	if (count==n*(n-1)/2) {
		cout<<day<<endl;
	}else {
		cout<<-1<<endl;
	}
}

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

int f (int x) {
	std::vector<int> d;
	for (int i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			d.push_back(i);
			if (x / i != i) d.push_back(x / i);
		}
	}
	return (int)(d.size());
}

int main() {
	int n;
	std::cin >> n;
	
	int ans = 0;
	for (int c = 1; c < n; c++) ans += f(c);
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int a,b,c; cin>>a>>b>>c;

  int ans=b/a;
  if(ans>c){
    cout<<c<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f(i, n) for (int i = 0; i < n; i++)
#define f2(i, n) for (int i = 1; i <= n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define fr2(i, n) for (int i = n; i >= 1; i--)
#define F(i, a, b) for (int i = a; i <= b; i++)
#define MOD 1000000007
#define INF INT_MAX
#define MIL 1000000
#define NMAX 200005

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int, int> ii;

int main() {
   ios_base::sync_with_stdio(false);
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);

   string a, b, ans;
   cin >> a >> b;

   int dp[b.size() + 2][a.size() + 2];
   memset(dp, 0, sizeof dp);

   for (int i = 1; i <= b.size(); i++)
   for (int j = 1; j <= a.size(); j++)
      if (a[j - 1] == b[i - 1])
         dp[i][j] = dp[i - 1][j - 1] + 1;
      else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

   //cout << dp[b.size()][a.size()] << endl;

   int x = b.size(), y = a.size();
   while (x > 0 && y > 0) {
      if (a[y - 1] == b[x - 1]) {
         ans = a[y - 1] + ans;
         x--; y--;
      }
      else if (dp[x - 1][y] == dp[x][y])
         x--;
      else y--;
   }

   cout << ans << endl;

   return 0;
}


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

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> P(N);
  vector<int> C(N);

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

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

  vector<long long> sum(N);
  long long ans = -1000000000;
  int tmp = 0;

  for(int j = 0; j < N; j++){
    tmp = j;
    for(int i = 0; i < min(K, N); i++){
      tmp = P[tmp] - 1;
      if(i == 0){
        sum[i] = C[tmp];
      }else{
        sum[i] = sum[i - 1] + C[tmp];
      }
      if(i == K - 1){
        if(*max_element(sum.begin(), sum.begin() + i + 1) > ans){
          ans = *max_element(sum.begin(), sum.begin() + i + 1);
        }
        break;
      }
      if(tmp == j){
        if(sum[i] <= 0){
          if(*max_element(sum.begin(), sum.begin() + i + 1) > ans){
            ans = *max_element(sum.begin(), sum.begin() + i + 1);
          }
        }else{
          if(K % (i + 1) == 0){
            if((K / (i + 1) - 1) * sum[i] +  *max_element(sum.begin(), sum.begin() + i + 1) > ans){
              ans = (K / (i + 1) - 1) * sum[i] +  *max_element(sum.begin(), sum.begin() + i + 1);
            }
          }else{
            long long tmp1 = K / (i + 1) * sum[i] + *max_element(sum.begin(), sum.begin() + K % (i + 1));
            long long tmp2 = (K / (i + 1) - 1) * sum[i] +  *max_element(sum.begin(), sum.begin() + i + 1);
            if(max(tmp1, tmp2) > ans){
              ans = max(tmp1, tmp2);
            }
          }
        }
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>(b);i--)
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define mp make_pair
#define pb push_back
#define gap " "
//memset(dp,-1,sizeof(dp)) sets value to -1 of everything in dp
//vector < vector<int > > vec(n,vector<int>(m,0)) here n are rows(top to down ) and m columns all with m vectors initialised with values 0
//ARRAY OF VECTORS --> vector<int> ar[size] and to pass it in a function we use foo(vector<int>(&ar)[size])

typedef long long ll;
using namespace std;


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

vector<pair<int,int> > v(n+1);
for(int i=1;i<=n;i++)
{
    int a,b;
    cin>>a>>b;
    v[i].first=a;
    v[i].second=b;

}
int flag=0;
rep(i,1,n-1)
{
    if(v[i].first==v[i].second&&v[i+1].first==v[i+1].second&&v[i+2].first==v[i+2].second)
    {
        flag=1; break;
    }

}
if(flag==1) {cout<<"Yes"; return 0;}
if(flag==0) {cout<<"No"; return 0;}
}
int main(){
int t=1;
while(t--){
      solve();
}
return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;

  if(n > m/2)
    cout << m/2 << endl;
  else
    cout << n + (m - 2 * n) / 4 << endl;
  
  
}


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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
	if(l >= 0) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	
}

void solve(){
	pos = 0;
	rec(0, pre.size());
	for (int  i = 0; i < n; i++)
	{
		if(i) cout << " ";
		cout << post[i];
	}
	cout << endl;
}

int main(){
	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	int x, y, z;
	x = ab + bc;
	y = bc + ca;
	z = ca + ab;
	if(x <= y && x <= z) cout << x << endl;
	else if(y <= x && y <= z) cout << y << endl;
	else cout << z << endl;

	return 0;	 
}

Measured memory_bytes: 256
n, m = map(int, input().split())
py = [[0] * 3 for i in range(m)]
for i in range(m):
    py[i][0], py[i][1] = map(int, input().split())
    py[i][2] = i

py.sort()

ans = [""] * m
current = 1
prev = 0
for i in range(m):
    current = py[i][0]
    if current != prev:
        right = 1
        prev = current
    else:
        right += 1

    ans[py[i][2]] = str(current).zfill(6) + str(right).zfill(6)

for i in range(m):
    print(ans[i])

Measured memory_bytes: 31320
import Control.Applicative
import Data.Bool (bool)


main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve [x, y] = bool "No" "Yes" $ even a && even b && a >= 0 && b >= 0
  where
    a = 4 * x - y
    b = y - 2 * x


Measured memory_bytes: 3880
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [int(input()) for _ in range(d)]
ans = 0
k = [-1] * 26
for i in range(d):
    p = t[i]
    ans += s[i][p - 1]
    k[p - 1] = i
    for j in range(26):
        ans -= c[j] * (i - k[j])
    print(ans)


Measured memory_bytes: 74332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=10;
//i_am_noob
int n;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	cout << fixed << setprecision(12);
	print1((n/3.0)*(n/3.0)*(n/3.0));
	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify

N = int(input())
edges = [[] for i in range(N)]
for v in range(N):
    for w, c in enumerate(map(int, input().split())):
        if c != -1:
            edges[v].append((w, c))

visited = [0]*N
que = [(c, w) for w, c in edges[0]]
visited[0] = 1
heapify(que)

d=[0]+[10**9]*(N-1)

#左がコスト
ans = 0
while que:
    c, u = heappop(que)
    if visited[u]:
        continue
    visited[u] = 1
    d[u]=c
    for v, c in edges[u]:
        if visited[v]:
          continue
        heappush(que, (c, v))
print(sum(d))


Measured memory_bytes: 6652
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B, C; cin >> A >> B >> C;

  int result = 0;
  if (A%2==B%2 && B%2!=C%2) { A++; B++; result++; }
  else if (B%2==C%2 && C%2!=A%2) { B++; C++; result++; }
  else if (C%2==A%2 && A%2!=B%2) { C++; A++; result++; }
  int m = max(A, max(B,C));
  result += (m-A)/2 + (m-B)/2 + (m-C)/2;
  cout << result << endl;
  return 0;
}

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

int main()
{
    int a, b, ans;

    char op;


    for (;;) {

        std::cin >> a >> op >> b;


        if (op == '?') break;

        switch (op) {
        case '+':
            ans = a + b;
            break;

        case '-':
            ans = a - b;
            break;

        case  '*':
            ans = a * b;
            break;

        case '/':
            ans = a / b;
            break;
        }

        std::cout << ans << std::endl;


    }


    return 0;
}


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

using namespace std;

const long long inf = (long long) 1e18;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  vector<long long> pref(3 * n);
  vector<long long> suff(3 * n);
  priority_queue<int, vector<int>, greater<int>> pref_q;
  priority_queue<int> suff_q;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    pref_q.push(a[i]);
  }
  pref[n - 1] = sum;
  for (int i = n; i < 2 * n; i++) {
    sum += a[i];
    pref_q.push(a[i]);
    int smallest = pref_q.top(); pref_q.pop();
    sum -= smallest;
    pref[i] = sum;
  }
  sum = 0;
  for (int i = 3 * n - 1; i >= 2 * n; i--) {
    sum += a[i];
    suff_q.push(a[i]);
  }
  suff[2 * n] = sum;
  for (int i = 2 * n - 1; i >= n; i--) {
    sum += a[i];
    suff_q.push(a[i]);
    int smallest = suff_q.top(); suff_q.pop();
    sum -= smallest;
    suff[i] = sum;
  }
  long long ans = -inf;
  for (int i = n - 1; i < 2 * n; i++) {
    ans = max(ans, pref[i] - suff[i + 1]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 10096
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define lld long long

int main(){
    int A,B;
    cin >> A >> B;
    int ans = -1;
    for(int i=0;i<1500;i++){
        if((int)(i*0.08) == A && (int)(i*0.1) == B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
a=0
b=0
c=0
for i in range(1,N):
  if i==1:
    ans+=A[c]
    c+=1
    continue
  if b==0:
    ans+=A[c]
    b+=1
  else:
    ans+=A[c]
    c+=1
    b=0
print(ans)

Measured memory_bytes: 31752
// C - Ordinary Beauty

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	double beauty;
	if (d == 0) beauty = n;
	else beauty = max(0LL, n-d) * 2;

	//cout << "beauty = " << beauty << endl; // **** debug ****

	double ans = beauty / (n * n);

	for (int i=3; i<=m; i++) {
		ans = ans + beauty / (n * n);
	}

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

//ans(i) = ( ans(i-1) * n^(i-1) * n + beauty * n^(i-2) ) / n^i
//       = ans(i-1) + beauty / n

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a <= c && c <= b ? "Yes":"No") << endl;
}


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

using namespace std;

int main(void){
  const long long MOD = 1000000007LL;
  long long N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  long long ans = 0;
  long long cumsum = 0;
  for(int i = N - 2; i >= 0; i--){
    cumsum += A[i + 1];
    cumsum %= MOD;
    ans += cumsum * A[i];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4836
// http://code-festival-2017-quala.contest.atcoder.jp/submissions/1618390 改
 
#include <stdio.h>
 
int main(){
    int n,m,k;
    int i,j,ans;
 
    scanf("%d %d %d",&n,&m,&k);
 
    ans=0;
    for(i=0;i<n+1;++i){
        for(j=0;j<m+1;++j){
            if(k==(m*i+n*j-2*i*j)){
                ans=1;
                break;
            }
        }
    }
 
    puts(ans?"Yes":"No");
 
    return 0;
}

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

int n, p;
int dp[101][76];

bool isp(int n){
    for (int i = 2; i * i <= n; ++i)if (n % i == 0)return 0;
    return 1;
}

int main(){
    cin >> n;
    dp[0][1] = 1;
    for (int i = 2; i <= n; ++i){
        if (isp(i) == 0)continue;
        int cnt = 0;
        for (int j = 1; j <= n; ++j){
            int a = j;
            while (a % i == 0)cnt++, a /= i;
        }
        for (int j = 0; j <= cnt; ++j){
            for (int k = 0; k * (j + 1) <= 75; k++){
                dp[i][k * (j + 1)] += dp[p][k];
            }
        }
        p = i;
    }
    cout << dp[p][75] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int x = 0;
		int max = 0;

		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == 'I') {
				x++;
				if (x > max) {
					max = x;
				}
			} else {
				x--;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21972
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double deg = min(abs(H * 30 - M * 5.5), (360.0 - abs(H * 30.0 - M * 5.5)));
    double ans = sqrt(A * A + B * B - 2.0 * A * B * cos(deg / 180.0 * M_PI));
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 4136
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
using namespace std;
int main() {
	long long int a, b;
	cin >> a >> b;
	if (a - b < 0) {
		b = a;
	}
	cout << a - b << endl;
}

Measured memory_bytes: 768
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
vector<pair<int, int>> E;

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

	cin >> N >> K;

	if ((N - 2)*(N - 1) / 2 < K)
	{
		cout << -1 << endl;
		return 0;
	}

	rep(i, 1, N) 
	{
		E.push_back(mp(0, i));
	}

	int c = 0;
	rep(i, 1, N)rrep(j, i + 1, N)
	{
		if ((N - 2)*(N - 1) / 2 - K <= c)
		{
			break;
		}
		E.push_back(mp(i, j));
		c++;
	}

	cout << SZ(E) << endl;
	for (auto& p : E)
	{
		cout << p.first + 1 << " " << p.second + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 512
n = int(input())

a = 0
b = 0
c = 0
d = 0

for i in range(n):
  s = input()
  if s == "AC":
    a += 1
  elif s == "WA":
    b += 1
  elif s == "TLE":
    c += 1
  elif s == "RE":
    d += 1
    
print("AC x " + str(a))
print("WA x " + str(b))
print("TLE x " + str(c))
print("RE x " + str(d))

Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

//解説で説明された方法でACしてみよう!
//N=10^5 O(n^2)は使えない。
int main() {
	
	int n, t; cin >> n >> t;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<int> mx(n-1);

	int tempmax = -1;
	for (int i = n - 1; i >= 1; --i) {
		
		if (tempmax < a[i]) {
			tempmax = a[i];
		}

		mx[i - 1] = tempmax;
	}
	
	int mincost = 1 << 30;
	int maxdiff = -1;
	int cnt = 0;


	for (int i = 0; i < n-1; i++) {
		int diff = mx[i] - a[i];
		
		if (diff > maxdiff) {
			maxdiff = diff;
			cnt = 1;
		}
		else if (diff==maxdiff) {
			++cnt;
		}
	}

	cout << cnt << endl;

}


Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))
xors = lambda x, y: sum([(a & x) ^ y for a in A])
memo = {}
def dp(flag, k):
  if k < 0:
    return 0
  if (flag, k) in memo:
    return memo[(flag, k)]
  x = 2 ** k
  ret = 0
  if flag:
    if K & x:
      # 1
      ret = xors(x, x) + dp(True, k-1)
      # 0
      tmp = xors(x, 0) + dp(False, k-1)
      ret = ret if ret > tmp else tmp
    else:
      # 0
      ret = xors(x, 0) + dp(True, k-1)
  else:
    ret = xors(x, x) + dp(False, k-1)
    tmp = xors(x, 0) + dp(False, k-1)
    ret = ret if ret > tmp else tmp
  memo[(flag, k)] = ret
  return ret

print(dp(True, 40))

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

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

   string ans;

   switch(d) {
       case 25:
       ans = "Christmas";
       break;

       case 24:
       ans = "Christmas Eve";
       break;

       case 23:
       ans = "Christmas Eve Eve";
       break;

       case 22:
       ans = "Christmas Eve Eve Eve";
       break;
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner f = new Scanner(System.in);
        // fill in the dictionary with the initial value
        int len = f.nextInt();
        int[] one = new int[len];
        int[] two = new int[len];
        double euc = 0;
        double man = 0;
        double cheb = 0;
        double min = 0;
        // Read in values
        for(int i = 0; i < len; i++){
            one[i] = f.nextInt();
        }
        for(int i = 0; i < len; i++){
            two[i] = f.nextInt();
        }
        for(int i = 0; i < len; i++){
            man +=(double) Math.abs(one[i] - two[i]);

        }
        Minkoswki minkoswki = new Minkoswki(one,two);
        System.out.println(minkoswki.calcDist(1));
        System.out.println(minkoswki.calcDist(2));
        System.out.println(minkoswki.calcDist(3));
        System.out.println(minkoswki.chebyshev());
    }
}
class Minkoswki{
    public int[] one;
    public int[] two;
    Minkoswki(int[] one, int[] two){
        this.one = one;
        this.two = two;
    }

    public double calcDist(int p){
        double sum = 0;
        for(int i = 0; i < this.one.length; i++){
            sum += (double) Math.pow(Math.abs(this.one[i] - this.two[i]),p);
        }
        return Math.pow(sum, (1.0/p));
    }
    public double chebyshev(){
        double max = 0;
        for(int i = 0; i < this.one.length; i++){
            max = Math.max(max, Math.abs(this.one[i] - this.two[i]));
        }
        return max;
    }
}


Measured memory_bytes: 26500
from collections import deque

S = input()


stack = []
stack.append(S[0])
count = 0
for c in S:
    if stack[-1] != c:
        count += 1
        stack.append(c)
ans = 10 ** 18
ans = min(ans, count)

count = 0
stack = []
stack.append(S[-1])
for c in S[::-1]:
    if stack[-1] != c:
        count += 1
        stack.append(c)

ans = min(ans, count)

print(ans)

Measured memory_bytes: 4340
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll ans=1;
    bool check=false;
    rep(i,n){
        ll temp;
        cin>>temp;
        if(temp==0)return cout<<0<<"\n",0;
        if (temp <= 1000000000000000000/ans)
            ans*=temp;
        else check=true;
    }
    if(check)cout<<-1<<"\n";
    else
    cout<<ans<<"\n";
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(c: str):
    if c in ["a", "e", "i", "o", "u"]:
        print("vowel")
    else:
        print("consonant")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = next(tokens)  # type: str
    solve(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060