akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define mp make_pair
#define maxn 100010
using namespace std;
typedef pair<int,int> pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
map<int,int>ma[maxn];
queue<pii>q;
set<int>s[maxn];
int id[maxn];
int fa[maxn];
int find(int x)
{
    if(fa[x]==x)  return x;
    return fa[x]=find(fa[x]);
}
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int x=read(),y=read();
        if(x>y)  swap(x,y);
        ma[x][y]=1;
        s[x].insert(y);
        s[y].insert(x);
    }
    for(int i=1;i<n;i++)
    {
        int x=read(),y=read();
        if(x>y)  swap(x,y);
        ma[x][y]++;
        if(ma[x][y]==2)  q.push(mp(x,y));
        s[x].insert(y);
        s[y].insert(x);
    }
    for(int i=1;i<=n;i++)  id[i]=i;
    for(int i=1;i<=n;i++)  fa[i]=i;
    int cnt=0;
    while(q.size())
    {
        cnt++;
        pii now=q.front();
        q.pop();
        int u=find(now.first),v=find(now.second);
        if(u>v) swap(u,v);
        ma[u][v]=0;
        s[u].erase(s[u].find(v));
        s[v].erase(s[v].find(u));
        if(s[u].size()<s[v].size())  swap(u,v);
        fa[v]=u;
        set<int>::iterator it;
        for(it=s[v].begin();it!=s[v].end();++it)
        {
            int tmp=(*it);
            if(tmp>v)  ma[v][tmp]=0;
            else       ma[tmp][v]=0;
            
            if(tmp>u)
            {
                ma[u][tmp]++;
                if(ma[u][tmp]==2)  q.push(mp(u,tmp));
                else               s[u].insert(tmp),s[tmp].insert(u);
            }
            else{
                ma[tmp][u]++;
                if(ma[tmp][u]==2)  q.push(mp(tmp,u));
                else               s[u].insert(tmp),s[tmp].insert(u);
            }
            s[tmp].erase(s[tmp].find(v));
        }
    }
    if(cnt==n-1)  puts("YES");
    else          puts("NO");
    return 0;
}

Measured memory_bytes: 40704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder_Core
{
    class Program
    {
        static void Main(string[] args)
        {
            var line1 = Console.ReadLine().Trim().Split(' ').Select(b => int.Parse(b)).ToArray();
            int N = line1[0];
            int M = line1[1];
            var A = Console.ReadLine().Trim().Split(' ').Select(c => int.Parse(c)).ToArray();
            Array.Sort(A);
            int selected = 0;
            for (int i = 0; i < A.Length; i++)
            {
                double lr = Math.Ceiling(((double)A.Sum() / (4.0 * (double)M)));
                if (A[i] >= lr)
                {
                    selected++;
                }
            }

            if (selected >= M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<N;i++)
using namespace std;
int main(){
  int N;
  cin >> N;
  int num[N];
  bool ans = true;
  
  rep(i,N){
    cin >> num[i];
  }
  
  rep(i,N){
    if(num[i]%2==0){
      if((num[i]%3!=0)&&(num[i]%5!=0)){
        ans = false;
      }
    }
  }
  if(ans){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

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

int main() {
  static const double pi = 3.141592653589793;
  double A,B;
  int H,M;
  cin >> A >> B >> H >> M;
  std::cout << std::setprecision(18);
  double radA,radB,radAOB;
  radA = 6.0*M;
  radB = 0.5*(60*H+M);
  if(radB > radA){
    radAOB = radB - radA;
  }else{
    radAOB = radA - radB;
  }
  //cout << radA << " " <<radB << " " << radAOB << endl;
  if(radAOB > 180){
	radAOB = 360 - radAOB;
  }
  
  //cout << radAOB << endl;
  
  if( abs(radAOB-180) < 1.0e-18){
    cout << A+B << endl;
  }else if( abs(radAOB) < 1.0e-18){
    //cout << "a" << endl;
    cout << abs(A-B) << endl;
  }else{
    //cout << sin(pi*radAOB/180) << endl;
    cout << sqrt(A*A + B*B - 2*A*B*cos(pi*radAOB/180) ) << endl;
  }

  //std::cout << "sin(pi)   = " << std::sin(pi) << std::endl;
  return(0);
}

Measured memory_bytes: 4116
def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	for j in range(len(b)):
		carry = 0
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans

# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)

def gcd(a, b):
	if bigint_compare(a, b) >= 0:
		M = a
		m = b
	else:
		M = b
		m = a
	if m == "0":
		return M
	else:
		q = bigint_divide(M, m)
		r = bigint_minus(M, bigint_multiply(m, q))
		return gcd(m, r)

def lcm(a, b):
	return bigint_divide(bigint_multiply(a, b), gcd(a, b))

def main():
	N = int(input())
	T = [input() for i in range(N)]
	ans = 1
	for i in range(len(T)):
		ans = lcm(T[i], ans)

	print(ans)

main()

Measured memory_bytes: 9364
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

void dfs(int v, vector<vector<int>>& to, vector<bool>& f) {
  if(f[v]) return;
  f[v] = true;
  for (auto u : to[v]) {
    dfs(u,to,f);
  }
}

int main() {
  int n,m,p;
  cin >> n >> m >> p;
  vector<vector<int>> to(n+1);
  vector<vector<int>> ot(n+1);
  vector< tuple<int,int,int> > edges;

  for (int i=0; i<m; i++) {
    int a,b,c;
    cin >> a >> b >> c;
    c = -(c-p);
    to[a].push_back(b);
    ot[b].push_back(a);
    edges.emplace_back(a,b,c);
  }

  // 1 からたどり着けないやつと Nにたどり着けないやつは考慮する必要が無い
  vector<bool> from1Flag(n+1,false);
  vector<bool> toNFlag(n+1,false);
  vector<bool> ok(n+1,false);
  dfs(1,to,from1Flag);
  dfs(n,ot,toNFlag);
  for (int i=1; i<=n; i++)
    ok[i] = from1Flag[i] && toNFlag[i];

  // Bellman-Ford アルゴリズム
  vector<long> d(n+1,INT_MAX);
  d[1] = 0;
  bool updated = true;
  int step = 0;

  while(updated) {
    updated = false;

    for(int i=0; i<m; i++) {
      int a,b,c;
      tie(a,b,c) = edges[i];
      if (!ok[a]) continue;
      if (!ok[b]) continue;

      if (d[a]+c < d[b]) {
        updated = true;
        d[b] = d[a]+c;
      }
    }
    step++;
    if(step > n) {
      puts("-1");
      return 0;
    }
  }

  int ans = -d[n];
  ans = max(ans,0);
  cout << ans << endl;
}

Measured memory_bytes: 768
// Aizu Vol-2 0285: Tennis
// 2017.8.25

#include <stdio.h>
#include <string.h>

char map[7][7][7][7];
int j, y;
char ans[20];

void combi(int i, int a, int b)
{
	if (a == j && b == y) {
		ans[i] = 0, puts(ans);
		return;
	}
	if (a < j && map[a][b][a+1][b]) {
		ans[i] = 'A';
		combi(i+1, a + 1, b);
	}
	if (b < y && map[a][b][a][b+1]) {
		ans[i] = 'B';
		combi(i+1, a, b + 1);
	}
}

int main()
{
	int a, b;

	memset(map, 1, sizeof(map));
	for (b = 0; b <= 3; b++)
		map[5][b][5][b+1] = 0, map[6][b][6][b+1] = 0, map[5][b][6][b] = 0;
	for (a = 0; a <= 3; a++)
		map[a][5][a+1][5] = 0, map[a][6][a+1][6] = 0, map[a][5][a][6] = 0;
	scanf("%d%d", &j, &y);
	combi(0, 0, 0);
	return 0;
}

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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i'|| c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    string ans;
    if(S=="Sunny")ans = "Cloudy";
    else if(S=="Cloudy")ans = "Rainy";
    else if(S=="Rainy")ans  ="Sunny";
    cout << ans << endl;
}


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

int n,suf[1000010],pre[1000010],cnt[3],p[3];
char s[1000010];

bool cmp(int a,int b) {return cnt[a]<cnt[b];}
void del(int x) {suf[pre[x]]=suf[x],pre[suf[x]]=pre[x];}

int main()
{
	scanf("%s",s+1),n=strlen(s+1),s[0]='D',s[n+1]='E',suf[n+1]=n+1;
	for (int i=0; i<=n+1; i++) suf[i]=i+1,pre[i]=i-1;
	for (int i=2; i<=n; i++) if (s[i]==s[i-1]) del(i); else cnt[s[i]-'A']++;
	cnt[s[1]-'A']++,p[0]=0,p[1]=1,p[2]=2,sort(p,p+3,cmp);
	if (cnt[p[1]]!=cnt[p[2]])
	{
		for (int i=suf[0]; i!=n+1; i=suf[i])
			if (s[i]==p[2]+'A'&&s[pre[i]]!=s[suf[i]])
			{
				cnt[p[2]]--,del(i);
				if (cnt[p[2]]==cnt[p[1]]) break;
			}
		if (cnt[p[1]]!=cnt[p[2]])
		{
			for (int i=suf[0]; i!=n+1; i=suf[i])
				if (s[pre[i]]==p[0]+'A'&&s[i]==p[2]+'A')
				{
					cnt[p[0]]--,cnt[p[2]]--,del(pre[i]),del(i);
					if (cnt[p[2]]==cnt[p[1]]) break;
				}
		}
	}
	if (cnt[p[0]]<cnt[p[1]])
	{
		for (int i=suf[suf[0]]; i!=n+1; i=suf[i])
			if (s[pre[pre[i]]]!=s[suf[i]])
				if (s[pre[i]]==p[1]+'A'&&s[i]==p[2]+'A'||s[pre[i]]==p[2]+'A'&&s[i]==p[1]+'A')
				{
					cnt[p[1]]--,del(pre[i]),del(i);
					if (cnt[p[0]]==cnt[p[1]]) break;
				}
	}
	for (int i=suf[0]; i!=n+1; i=suf[i]) putchar(s[i]);
	return puts(""),0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    int ans = 1000;
    rep(i,n-2){
        string ima = s.substr(i,3);
        int m = stoi(ima);
        ans = min(ans,abs(m-753));
    }
    cout << ans << endl;
}

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


#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(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 998244353;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,A,B;

ll K;

int fac[300010],inv[300010];

int C(int n,int k){
	return (ll)fac[n]*inv[k]%mod*inv[n-k]%mod;
}

void Work(){
	int ans=0;
	REP(i,0,n)if((ll)i*A<=K&&(K-(ll)i*A)%B==0&&(K-(ll)i*A)/B<=n){
		ans=((ll)C(n,i)*C(n,(K-(ll)i*A)/B)+ans)%mod;
	}
	cout<<ans<<endl;
}

void Init(){
	read(n,A,B,K);
	fac[0]=1;REP(i,1,n)fac[i]=(ll)fac[i-1]*i%mod;
	REP(i,0,n)inv[i]=fexp(fac[i],mod-2);
}

int main(){
	Init();
	Work();
	return 0;
}


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

int main(){

    int score[4];
    string s[4];
    int sum;
    string ABCD;

    cin >> ABCD;

    for(int i = 0; i < 4; ++i) score[i] = (int) ABCD[i] - '0';

    for(int bit = 0; bit < (1 << 4); ++bit){
        sum = 0;
        for(int i = 0; i < 4; ++i){
            if( (bit & (1 << i)) ){
                sum += score[i];
                s[i] = '+';
            }else{
                sum -= score[i];
                s[i] = '-';
            }
        }
        if(sum == 7){
            for(int j = 0; j < 3; ++j ){
                cout << score[j] << s[j+1];
            }
            cout << score[3] << "=7" << endl;
            return 0;
        }
       
    }
    return 0; 
}

Measured memory_bytes: 256
char*p[]={"Wednes","Thurs","Fri","Satur","Sun","Mon","Tues"};
a[]={3,1,3,2,3,2,3,3,2,3,2,3},m,d;
main(i){
    for(;~scanf("%d%d",&m,&d);){
        if(!m)return 0;
        for(i=0;i<m-1;d+=a[i++]);
        printf("%sday\n",p[d%7]);
    }
}

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

int main(void)
{
	char str[21];
	int i,size;
	
	gets(str);
	size = strlen(str);
	for (i=size-1; i>=0; i--){
		printf("%c", str[i]);
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 524
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Xinyi Tao
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CCitySaversABC135 solver = new CCitySaversABC135();
        solver.solve(1, in, out);
        out.close();
    }

    static class CCitySaversABC135 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n + 1];
            long[] b = new long[n];
            for (int i = 0; i < n + 1; i++)
                a[i] = in.nextLong();
            long c = 0;
            for (int i = 0; i < n; i++) {
                long v = in.nextLong();
                long c1 = Math.min(a[i], v);
                c += c1;
                long c2 = Math.min(v - c1, a[i + 1]);
                c += c2;
                a[i + 1] -= c2;
            }
            out.println(c);


        }

    }
}



Measured memory_bytes: 65120
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <iomanip>
#include <tuple>
using namespace std;

vector<vector<int>> mapping(9, vector<int>(2, 0));

double result = 0;
double length = 0;

double calculatePath(vector<int>& nums) {
	int curr = nums[0];
	int x = mapping[curr][0];
	int y = mapping[curr][1];

	double res = 0;

	for (int i = 1; i < nums.size(); i++) {
		int x1 = mapping[nums[i]][0];
		int y1 = mapping[nums[i]][1];
		res += sqrt(pow(x - x1, 2) + pow(y - y1, 2));
		x = x1;
		y = y1;
	}

	return res;
}

void generatePermutations(vector<bool>& visited, vector<int>& nums, vector<int>& temp, int n) {
	if (temp.size() == nums.size()) {
		result += calculatePath(temp);
		length++;
	}
	else {
		for (int i = 1; i <= n; i++) {
			if (!visited[i]) {
				temp.push_back(i);
				visited[i] = true;
				generatePermutations(visited, nums, temp, n);
				temp.pop_back();
				visited[i] = false;
			}
			
		}
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int first;
		int second;
		cin >> first >> second;
		mapping[i + 1][0] = first;
		mapping[i + 1][1] = second;
	}
  
  	result = 0;
  	length = 0;

	vector<bool> visited(9);
	vector<int> nums;
	for (int i = 1; i <= n; i++) nums.push_back(i);

	vector<int> temp;

	generatePermutations(visited, nums, temp, n);

	double answer = result / length;

	printf("%0.10f", answer);
}



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,ans,m;
      long a;
      ans=0;
      n=sc.nextInt();

      for(int i=0;i<n;i++) {
    	  a=sc.nextInt();
    	  for( m=0;a%2==0;m++) {
    		  a=a/2;


    	  }
    	  ans=ans+m;
      }
      System.out.println(ans);

  }
}


Measured memory_bytes: 33924
#include<bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9+7;
long long dp[1001][1001];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> G(H);
    for (auto & s : G) {
        cin >> s;
    }
    dp[0][1] = 1;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (G[i][j] == '.') {
                dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j];
                if (dp[i+1][j+1] >= mod) {
                    dp[i+1][j+1] -= mod;
                }
            }
        }
    }
    printf("%lld\n", dp[H][W]);
    return 0;
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Lucas Number
            int n = int.Parse(Console.ReadLine());

            var l = new long[87];
            l[0] = 2;
            l[1] = 1;

            for(int i = 2; i <= n; i++)
            {
                l[i] = l[i - 1] + l[i - 2];
            }

            Console.WriteLine(l[n]);
        }
    }
}

Measured memory_bytes: 13140
use std::io;
use std::str::FromStr;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn combination(n: u64, mut m: u64) -> u64 {
    if n < m {
        return 0;
    }
    if m > n - m {
        m = n - m
    }

    let mut ret = 1u64;
    for i in 0..m {
        ret *= n - i;        
    }

    let mut div = 1u64;
    for i in 1..(m+1) {
        div *= i;
    }
    ret / div
}

// 常にidxより前の桁の値は同じ状態で呼び出される
fn recur(idx: usize, n: &Vec<char>, left: u64) -> u64 {
    if idx == n.len() {
        return 1;
    }
    if left == 0 {
        return 1;
    }
    let d: u64 = n[idx] as u64 - 48;
    let mut tmp = 0;
    if d == 0 {
        // 桁が0の場合は0しかとれない
        if left as usize != n.len() - idx {
            tmp += recur(idx+1, n, left);
        }
    } else {
        // 桁の値より小さい&非0の値をとった場合
        tmp += combination((n.len() - idx - 1) as u64, left - 1) * 9u64.pow(left as u32 - 1) * (d - 1);

        // 0をとった場合
        tmp += combination((n.len() - idx - 1) as u64, left) * 9u64.pow(left as u32);
        
        // 桁の値と同じ値をとった場合
        tmp += recur(idx+1, n, left - 1);
    }
    tmp
}

fn main() {
    let n = input_char_vec();
    let k: usize = input();

    let d = n.len();
    if k > d {
        println!("0");
        return;
    }
    println!("{}", recur(0, &n, k as u64));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

// #define NMAX 1000000000
using VS = vector<string>;
int N;
VS S;

ll solve(){
	set<string> s;
	rp(i,0,N){
		s.insert(S[i]);
	}
	return s.size();
}

int main(){
	cin>>N;
	S.resize(N);
	rp(i, 0, N){
		cin>>S[i];
	}
	cout<< solve() <<endl;
	// cout<<cout<<setprecision(10)<< solve() <<endl;
	// printf("%f\n",solve());
	// solve();
}


Measured memory_bytes: 25092
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  string s, rgb = "RGB";
  int ans = 0;

  cin >> n >> s;
  FOR(i, 1, n - 1) {
    char x = s[i];
    int index = x == 'R' ? 0 : x == 'G' ? 1 : 2;
    char y = rgb[(index + 1) % 3];
    char z = rgb[(index + 2) % 3];
    int ly = 0,lz = 0,ry = 0,rz = 0;
    REP(j, i) {
      if(s[j] == y)ly++;
      if(s[j] == z)lz++;
    }
    FOR(j, i + 1, n) {
      if(s[j] == y)ry++;
      if(s[j] == z)rz++;
    }
    int tmp = ly * rz + lz * ry;
    for(int j = 1; i - j >= 0 && j + i < n; j++) {
      if(s[i - j] == y && s[j + i] == z)tmp--;
      if(s[i - j] == z && s[j + i] == y)tmp--;
    }
    ans += tmp;
  }

  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    //final List<Integer> list = new ArrayList<>();
    //final List<Integer> list2 = new ArrayList<>();
    int x = sc.nextInt();

    if(x >= 30){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
    






}
}

Measured memory_bytes: 35664
#include <complex>
#include <cmath>
#include <cstdio>
 
using namespace std;
 
typedef double D;
typedef complex<D> P;
#define EPS (1e-10)


D dot(P a,P b){
  return real(conj(a) * b);
}

D cross(P a,P b){
  return imag(conj(a) * b);
} 

int ccw(P p0,P p1,P p2){
  P a = p1 - p0;
  P b = p2 - p0;
 
  if(cross(a,b) > EPS) return 1;
  if(cross(a,b) < -EPS) return -1;
  if(dot(a,b) < -EPS) return 2;
  if(norm(a) < norm(b)) return -2;
  return 0;
}

bool check(P p1,P p2,P p3,P p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0 &&
      ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0);
}
 
int main(){
  int n;
  P P[3],T[2];
 
  scanf("%d" ,&n);
  while(n--){
    for(int i = 0 ; i < 3 ; i++){
      scanf("%lf %lf" ,&P[i].real() ,&P[i].imag());
    }

    for(int i = 0 ; i < 2 ; i++){
      scanf("%lf %lf" ,&T[i].real() ,&T[i].imag());
    }

    int cnt = 0; 
    if(check(P[0],P[1],T[0],T[1])){
      cnt++;
    }   
    if(check(P[0],P[2],T[0],T[1])){
      cnt++;
    } 
    if(check(P[1],P[2],T[0],T[1])){
      cnt++;
    } 
 
    if(cnt % 2){
      puts("OK");
    }else{
      puts("NG");
    }
  }
 
  return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

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

    vec<int> B(N, -1);
    vec<int> W(N, -1);
    B[0]     = 0;
    W[N - 1] = 0;

    function<void(int,int,int)> dfs = [&](int now, int nowd, int color) {
        if(color == 1) B[now] = nowd;
        else if(color == 2) W[now] = nowd;

        for (auto e : G[now]) {
            bool isBlack = color == 1 && B[e] != -1;
            bool isWhite = color == 2 && W[e] != -1;
            if (isBlack || isWhite) continue;
            dfs(e,nowd+1,color);
        }
    };
    dfs(0,0,1);
    dfs(N-1,0,2);

    int ans = 0;
    rep(i,N){
        if(B[i]<=W[i]) ++ans;
        else --ans;
    }
    if(ans>0) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}


Measured memory_bytes: 17152
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define EACHPRINT(A) for_each(begin(A), end(A), [&](int i){ cout << i << "\n"; })

typedef long lint;
typedef pair<lint, lint> P;


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

    map<lint, lint> counter;

    lint N; cin >> N;

    lint S = 0;

    REP(i, N) {
        int a; cin >> a;
        S += a;
        counter[S] += 1;
    }

    lint res = 0;

    for(P p:counter) {
        if (p.first == 0) {
            res += p.second*(p.second+1)/2;
        } else {
            res += p.second*(p.second-1)/2;
        }

    }

    cout << res << "\n";

    return 0;
}

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

int main() {
  for (int i = 1; i <= 5; i++) {
    int x;
    cin >> x;
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
	int data, ans;
	while (1) {
		cin >> data; if (data == 0) break;
		ans = 0; data = 1000 - data;
		while (data >= 500) { data = data - 500; ans++; }
		while (data >= 100) { data = data - 100; ans++; }
		while (data >=  50) { data = data -  50; ans++; }
		while (data >=  10) { data = data -  10; ans++; }
		while (data >=   5) { data = data -   5; ans++; }
		while (data >=   1) { data = data -   1; ans++; }
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2992
import collections
import math


def comb(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


input()
a = list(map(int, input().split()))
c = collections.Counter(a)

summ = sum([comb(v, 2) for v in c.values()])
for ai in a:
    print(summ - c[ai] + 1)

Measured memory_bytes: 25896
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      ls <- replicateM n getLine
      pqrc <- getLine
      let ls' = map (map read . words) ls
          pqrc' = map read .  words $ pqrc
      mapM_ putStrLn $ solve ls' pqrc'
      main
      
solve :: [[Int]] -> [Int] -> [String]
solve ls pqrc
  | checkedL == [] = ["NA"]
  | otherwise = checkedL
  where
    checkedL = foldl check [] ls
    check :: [String] -> [Int] -> [String]
    check acc item = check' acc item pqrc
      where
        check' :: [String] -> [Int] -> [Int] -> [String]
        check' acc [i,pi,qi,ri] [p,q,r,c]
          | pi <= p && qi <= q && ri <= r && (pi * 4 + qi * 9 + ri * 4) <= c = acc ++ [(show i)]
          | otherwise = acc

Measured memory_bytes: 5636
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll K,N;cin>>K>>N;
    vector<ll>a(N);
    rep(i,N)cin>>a[i];
    vector<ll>b(N);
    rep(i,N-1){
        b[i]=a[i+1]-a[i];
    }
    b[N-1]=K-(a[N-1]-a[0]);
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    cout<<K-b[0]<<endl;
}
 



Measured memory_bytes: 3456
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())
    
A = [0]+A+[0]

fromleft = [0]*N
fromright = [0]*N
fromleft[0] = A[0]
fromright[-1] = A[-1]

for i in range(1,N):
    fromleft[i] = max(A[i],fromleft[i-1])
    fromright[-(i+1)] = max(A[-(i+1)],fromright[-i])

#print(fromleft)
#print(fromright)

for i in range(N):
    print(max(fromleft[i],fromright[i]))

Measured memory_bytes: 20140
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int main(){
  char c;
  cin >> c;
  cout << (char) (c + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
n, *alst = map(int, open(0).read().split())
alst += [0]
s = abs(alst[0]) + sum(abs(alst[i] - alst[i + 1]) for i in range(n))
print(s + abs(alst[1]) - (abs(alst[0]) + abs(alst[0] - alst[1])))
for i in range(1, n):
  print(s + abs(alst[i - 1] - alst[i + 1]) - (abs(alst[i - 1] - alst[i]) + abs(alst[i] - alst[i + 1])))

Measured memory_bytes: 13804
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M - 1));}

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++){
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++){
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0){
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i,n,h;
	char str[L], com[9];
	for (i=0; i<M; i++)  H[i][0] = '\0';
	scanf("%d", &n);
	for (i=0; i<n; i++){
		scanf("%s %s", com, str);

		if (com[0] == 'i'){
			insert(str);
		} else {
			if (find(str)){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 15496
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  
  if (c.at(0) == 'a' || c.at(0) == 'i' || c.at(0) == 'u' || c.at(0) == 'e' || c.at(0) == 'o')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3624
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

lst = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

print(int(m1 != m2 and lst[m1] == d1))

Measured memory_bytes: 3060
def calc(a,D,K):
  if K==1:
    return a+(D-1)*9
  elif K==2:
    return (a-1)*(D-1)*9 + (D-1)*(D-2)//2*81
  else:
    return (a-1)*(D-1)*(D-2)//2*81 + (D-1)*(D-2)*(D-3)//6*729

N=input()
K=int(input())
D = len(N)
score=0
for i,a in enumerate(N):
  if a!="0":
    score+=calc(int(a),D-i,K)
    K-=1
  if K==0:
    break
print(score)

Measured memory_bytes: 9104
def check(mat):
    frag = True
    for i in range(N):
        for j in range(i + 1, N):
            if mat[i][j] != mat[j][i]:
                frag = False
        if not frag:
            break
    return frag

N = int(input())
S = [input() for i in range(N)]
ans = 0
for i in range(N):
    mat = S[i:] + S[:i]
    if check(mat):
        ans += N
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

bool used[100][100];
bool fin[100][100];

pll d[100][100];

void dfs(ll s,ll t){
    if(fin[s][t] || fin[t][s]) return ;
    if(d[s][t].fi==-1){
        used[s][t]=true;
        used[t][s]=true;
        fin[s][t]=true;
        fin[t][s]=true;
        return ;
    }
    fin[s][t]=true;
    fin[t][s]=true;
    dfs(s,d[s][t].fi);
    dfs(d[s][t].fi,t);
    
    return ;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<pll> edge(m);
    rep(i,n){
        rep(j,n){
            d[i][j]=make_pair(-1,INF);
        }
    }
    rep(i,m){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b]=make_pair(-1,c);
        d[b][a]=make_pair(-1,c);
        edge[i]=make_pair(a,b);
    }
    
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(d[i][j].se>d[i][k].se+d[k][j].se){
                    d[i][j]=make_pair(k,d[i][k].se+d[k][j].se);
                }
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(i==j) continue;
            dfs(i,j);
        }
    }
    ll ans=m;
    rep(i,m){
        if(used[edge[i].fi][edge[i].se]) ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3808
def main():
	n = int(input())
	exp_num = [0]*(n+1)

	for i in range(2, n+1):
		cur = i
		for j in range(2, i+1):
			while cur % j == 0:
				exp_num[j] += 1
				cur //= j

	def num(m:int) -> int:
		return len(list(filter(lambda x: x > m-2, exp_num)))

	total = (
		num(75) + num(25)*(num(3)-1)
		 + num(15)*(num(5)-1)
		 + (num(5)*(num(5) - 1)//2)*(num(3)-2)
		 )

	print(total)


if __name__ == '__main__':
    main()

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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


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

    ll n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    ll i,j;
    bool arr[n];
    for(i=0;i<n;i++){
        if(str[i]=='L')
            arr[i]=0;
        else
            arr[i]=1;
        // cout<<arr[i]<<" ";
    }
    // cout<<"\n";
    ll flag=0;
    i=0;
    j=n-1;
    ll ans=0;
    while(i<=j){
        if(k==0)
            break;        
        
        while(arr[i]==arr[i+1]&&i+1<n && i+1<=j){ ans++; i++;}
        
        while(arr[j]==arr[j-1]&&j-1>=0 && i<=j-1){ ans++; j--; }
        // cout<<i<<" "<<j<<"\n";
        if(abs(i-j)==1 && arr[i]!=arr[j] && k){
            cout<<n-1<<endl;
            return 0;
            break;
        }
        
        if(k){
            arr[i]=!arr[i];
            arr[j]=!arr[j];
            k--;
        }
    }
    // cout<<i<<" "<<j<<"\n";
    while(i<=j){
        if(arr[i]==arr[i+1] && i+1<n){
            ans++;
        }
        i++;
    }
    cout<<ans;
    return 0;  
}

Measured memory_bytes: 592
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int count = 1;
		while(true){
			int w = sc.nextInt();
			if(w == 0)
				break;
			int n = sc.nextInt();
			int [][] dp = new int[n+1][w+1];
			int [][] data = new int[n+1][2];
			for(int i=1; i < n+1; i++){
				String [] input = sc.next().split(",");
				data[i][0] = Integer.parseInt(input[0]);
				data[i][1] = Integer.parseInt(input[1]);
			}

			for(int i=1; i < n+1; i++){
				for(int j=1;j <= w; j++){
					int index = j - data[i][1];
					if(index < 0){
						dp[i][j] = dp[i-1][j];
					}
					else{
						dp[i][j] = Math.max(dp[i-1][j], dp[i-1][index] + data[i][0]);
					}
				}
			}

			//debug
//			for(int i=0; i < w; i++){
//				System.out.printf("%3d ",i);
//			}
//			System.out.println("");
//			for(int j=0; j < n+1; j++){
//				for(int i=0; i < w; i++){
//					System.out.printf("%3d ", dp[j][i]);
//				}
//				System.out.println("");
//
//			}

			int max = 0;
			int maxIdx = 0;
			for(int i=0; i <= w; i++){
				if(dp[n][i] > max){
					max = dp[n][i];
					maxIdx = i;
				}
			}
			System.out.println("Case " + count++ + ":");
			System.out.println(max);
			System.out.println(maxIdx);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 16000
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.IntMap as M

readIntLL :: IO [[Int]]
readIntLL = map (unfoldr (B.readInt.B.dropWhile(==' '))) . B.lines <$> B.getContents

rsort :: Ord a => [a] -> [a]
rsort = sortBy $ flip compare

f :: [Int] -> [Int]
f xyz = map (sum.zipWith (*) xyz) [[s,g,h]|s<-[1,(-1)],g<-[1,(-1)],h<-[1,(-1)]]

main=do
    ([n,m]:xyzs) <- readIntLL
    print
        $ head  $ rsort $ map (sum. take m . rsort)
        $ transpose $ map f $ take n xyzs


Measured memory_bytes: 2300
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    
    scanf("%d", &n);
    
    if (n==7||n==5||n==3) {
        printf("YES");
    } else {
        printf("NO");
    }
    
    return 0;
}



Measured memory_bytes: 1664
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

int n, m, mod = 1000000000 + 7;
int mat[1000][1000];
int dp[1000][1000];
bool issafe(int i, int j)
{
    if (i >= n || i < 0 || j < 0 || j >= m)
        return 0;
    return 1;
}
int total_paths(int i, int j)
{
    if (!issafe(i, j))
        return 0;
    if (dp[i][j] != -1)
        return dp[i][j];
    int tot = 0;
    if (issafe(i - 1, j) && mat[i - 1][j])
    {
        (tot += total_paths(i - 1, j) % mod) % mod;
    }
    if (issafe(i, j - 1) && mat[i][j - 1])
    {
        (tot += total_paths(i, j - 1) % mod) % mod;
    }
    dp[i][j] = tot % mod;
    return tot % mod;
}
int32_t main()
{
    cin >> n >> m;
    for (int i = 0; i < 1000; i++)
        for (int j = 0; j < 1000; j++)
            dp[i][j] = -1;
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            char ch;
            cin >> ch;
            if (ch == '.')
                mat[i][j] = 1;
        }
    cout << total_paths(n - 1, m - 1) << endl;
}


Measured memory_bytes: 15872
N = int(input())
B = [[-1]*N for i in range(N)]

for i in range(N):
    tmpA = int(input())
    for j in range(tmpA):
        x,y = map(int,input().split())
        B[i][x-1] = y

ans = 0

for i in range(1<<N):
    tmp = i
    tmpans = 0
    while tmp!=0:
        tmpans += tmp%2
        tmp //= 2
    tmpshi = [-1]*N
    flag = 0
    for j in range(N):
        if flag == 1:
            break
        if ((i>>j)&1)==1:
            for k in range(N):
                if B[j][k] != -1:
                    if B[j][k] == tmpshi[k] or tmpshi[k]==-1:
                        tmpshi[k]=B[j][k]
                    else:
                        flag = 1
                        break
    flag1 = 0
    if flag == 0:
        for j in range(N):
            if ((i>>j)&1)!=tmpshi[j] and tmpshi[j]!=-1:
                flag1 = 1
                break
        if flag1 == 0:
            ans = max(ans,tmpans)
print(ans)

Measured memory_bytes: 47324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for(int i=0; i<N; i++) {
        cin >> P[i];
    }
    for(int i=0; i<N; i++) {
        cin >> Q[i];
    }
    
    int a = 0, b = 0;
    while(next_permutation(P.begin(), P.end())) {
        ++a;
    }
    while(next_permutation(Q.begin(), Q.end())) {
        ++b;
    }
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
	int n;
	cin>>n;
	n%=10;
	switch(n){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:cout<<"hon";break;
		case 0:
		case 1:
		case 6:
		case 8:cout<<"pon";break;
		case 3:cout<<"bon";break;
	}
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        long int n,m;
    	cin>>n>>m;
    	long long int t=pow(2,m);
    	long long int x =(1900*m+100*(n-m));
    	cout<<x*t;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  while (b <= a) {
    b *= 2;
    --k;
  }
  while (c <= b) {
    c *= 2;
    --k;
  }
  if (k >= 0) {
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
  return 0;
}


Measured memory_bytes: 3656