akhauriyash/Code-Regression huggingface dataset:
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

inline int calc(int x) {
	int s = 0;
	while (x) s += x % 10, x /= 10;
	return s;
}

int main() {
	int n, ans = 1e9;
	rd(n);
	for (int i = 1; i < n; i++)
		ans = min(ans, calc(i) + calc(n - i));
	print(ans);
	return 0;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
a=UnionFind(n)
for i in range(m):
    x,y=map(int,input().split())
    a.union(x-1,y-1)
print(-min(a.parents))

Measured memory_bytes: 14488
#include<bits/stdc++.h>
#define LL long long
#define ffor(i,s,n) for(int i=(s);i<(n);i++)
#define efor(i,s,n) for(int i=(s);i<=(n);i++)
using namespace std;

int main(){
	LL n;
	LL m;
	cin>>n;
	m=n;
	LL s=0;
	while(n>0){
		s+=n%10;
		n/=10;
	}
	if(!(m%s)){
		cout<<"Yes"<<endl;
	}else cout<<"No"<<endl;
	
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

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


    for(int i = 3; i <= N; ++i)
    {
        if(i % 3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            string s = to_string(i);
            REP(j,s.size())
            {
                if(s[j] == '3')
                {
                    cout << " " << i;
                    break;
                }
            }
        }
    }

    cout << endl;

    return 0;
}


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

int main() {
  int a, b, c, n;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> n;
  int ans = 0;
  for(int i = 0; i <= a; ++i) {
    for(int j = 0; j <= b; ++j) {
      for(int k = 0; k <= c; ++k) {
        if(500 * i + 100 * j + 50 * k == n) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input().split()

c1 = a.count('1')
c2 = a.count('2')
c3 = a.count('3')

dp =[ [[0] * (n+1) for _ in range(c3+c2+1)] for __ in range(c3+1)]
# dp[0][0][0] = 0

for i in range(c3+1):
    for j in range(c3+c2+1-i):
        for k in range(n+1-i-j):
            if(i+j+k == 0):
                dp[i][j][k]=0
            else:
                temp = 0
                if(i > 0):
                    temp += dp[i-1][j+1][k] * i/(k+j+i)
                if(j > 0):
                    temp += dp[i][j-1][k+1] * j/(k+j+i)
                if(k > 0):
                    temp += dp[i][j][k-1] * k/(k+j+i)
                dp[i][j][k] = temp + n/(k+j+i)

print(dp[c3][c2][c1])

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

int main() {
    int n;
    cin >> n;
    map<string, int> cnt;
    rep (i, n) {
        string s;
        cin >> s;
        cnt[s]++;
    }

    for (string s : {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << cnt[s] << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int x[100];
int main()
{
	int n,m,i,j,a,flag,b,k,num=0;
	scanf("%d %d %d",&a,&b,&k);
	if(k>(b-a))
	{
		for(i=a;i<=b;i++)
		{
			printf("%d\n",i);
		}
		return 0;
	}
	else if(k==1)
	{
		printf("%d\n",a);
		printf("%d\n",b);
		return 0;
	}
	for(i=a;i<a+k;i++)
	{
		printf("%d\n",i);
		x[num++]=i;
	}
	for(i=b-k+1;i<=b;i++)
	{
		flag=0;
		for(j=1;j<=num;j++)
		{
			if(i==x[j])
				flag=1;
		}
		if(flag==0)
			printf("%d\n",i);
	}
} 

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int honsen = 0;
    int kaigai = 0;
    int N, A, B; cin >> N >> A >> B;
    string S; cin >> S;
    rep(i, N){
        if(S[i] == 'c') cout << "No" << endl;
        else if(S[i] == 'a'){
            if(honsen < A+B) {cout << "Yes" << endl; honsen++;}
            else cout << "No" << endl;
        }
        else{
            if(honsen < A+B && kaigai < B){
                cout << "Yes" << endl;
                kaigai++;
                honsen++;
            }
            else cout << "No" << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define mp make_pair

const int INF = INT_MAX;

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	char a;
	scanf("%c", &a);

	if(a >= 97)
		printf("a\n");
	else
		printf("A\n");


	return 0;
}

Measured memory_bytes: 3712
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double d = sc.nextDouble();
    double t = sc.nextDouble();
    double s = sc.nextDouble();
    if(d/s<=t){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 37200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


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

int main() {
	// your code goes here
    long long int a,b,c,d;
    cin >> a>> b >> c >> d;
    long long int ans;
    if (a * b <= 0 || c * d <= 0) {
        cout << max ((long long int)0, max (b * d,max (b * c,max(a * c,a* d)) )) << endl;
    }
    else {
        cout << max (b * d,max (b * c,max(a * c,a* d)) ) << endl;
    }
    
}


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

typedef long long LL;

const int N=200000;

int n,x[N+9],y[N+9];
int idx[N+9],idy[N+9];

bool cmp0(const int &a,const int &b){return x[a]<x[b];}
bool cmp1(const int &a,const int &b){return y[a]<y[b];}

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	scanf("%d%d",&x[i],&y[i]);
	idx[i]=i;idy[i]=i;
  }
}

int p[N+9],q[N+9];
// p[i] -> 将点离散化后 x=i , y=p[i]

void Get_p(){
  sort(idx+1,idx+n+1,cmp0);
  sort(idy+1,idy+n+1,cmp1);
  for (int i=1;i<=n;++i) q[idy[i]]=i;
  for (int i=1;i<=n;++i) p[i]=q[idx[i]];
}

int bam[N+9],dan[N+9];

// bam[i] -> i 所属连续段的开头
// dan[i] -> i 所属连续短的结尾

void Get_bam(){
  bam[1]=1;dan[n]=n;
  for (int i=2;i<=n;++i) bam[i]=abs(p[i]-p[i-1])==1?bam[i-1]:i;
  for (int i=n-1;i>=1;--i) dan[i]=abs(p[i]-p[i+1])==1?dan[i+1]:i;
}

int Get_dis(int a,int b){
  a=idx[a];b=idx[b];
  return abs(x[a]-x[b])+abs(y[a]-y[b]);
}

map<int,LL>dp[2][N+9];

LL Dfs_ans(int l,int r,bool gg,int mn,int mx){
  map<int,LL>::iterator it=dp[gg][l].find(r);
  if (it!=dp[gg][l].end()) return it->second;
  vector<LL>opt;
  if (l>1&&(p[l-1]==mn-1||p[l-1]==mx+1)){
	LL tmp=Dfs_ans(bam[l-1],r,0,min(mn,p[bam[l-1]]),max(mx,p[bam[l-1]]));
	tmp+=Get_dis(bam[l-1],gg?r:l);
	opt.push_back(tmp);
  }
  if (r<n&&(p[r+1]==mn-1||p[r+1]==mx+1)){
	LL tmp=Dfs_ans(l,dan[r+1],1,min(mn,p[dan[r+1]]),max(mx,p[dan[r+1]]));
	tmp+=Get_dis(gg?r:l,dan[r+1]);
	opt.push_back(tmp);
  }
  LL res=l-r;
  if (opt.size()>=1){
	res=opt.front();
	if (opt.size()>=2) res=min(res,opt[1]);
  }
  return dp[gg][l][r]=res;
}

LL ans[N+9];

void Get_ans(){
  for (int i=1;i<=n;++i) ans[idx[i]]=Dfs_ans(i,i,0,p[i],p[i]);
}

void work(){
  Get_p();
  Get_bam();
  Get_ans();
}

void outo(){
  for (int i=1;i<=n;++i)
	printf("%lld\n",ans[i]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 82748
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


int main() {
    int n;
    scanf("%d", &n);

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

    int hanten = 0;
    bool ans = false;
    for(int i = 0; i<n-1; i++) {
        for(int j= i; j<n; j++) {
            int temp;
            temp = a[i];
            a[i] = a[j];
            a[j] = temp;

            for (int i = 0; i<n-1; i++) {
                for(int j = i+1; j<n;  j++ ) {
                    if (a[i] > a[j]) {
                        hanten++;
                    }
                }
            }

            if (hanten == 0) {
                ans = true;
            }

            temp = a[i];
            a[i] = a[j];
            a[j] = temp;
            hanten = 0;
        }
    }
    
    if (ans) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


import sys
input = sys.stdin.readline
s = input().rstrip("\n")
t = input().rstrip("\n")
flg = False
cnt = 0

for i in range(len(s)-len(t)+1)[::-1]:
    cnt = 0
    for j in range(len(t)):
        #print(s[i+j],t[j])
        if s[i+j] == t[j] or s[i+j] == '?':
            cnt += 1
        #print(cnt,len(t))
    if cnt == len(t):
        cnt = i
        flg = True
        #print(cnt)
        break

if not flg:
    print("UNRESTORABLE")
else:
    li = list(s.replace("?", "a"))
    #print(li)
    for j in range(len(t))[::-1]:
        #print(li[cnt+j], t[j])
        li[cnt+j] = t[j]
    print("".join(li))


Measured memory_bytes: 3064
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a,b,c,x,y,ans;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a>>b>>c>>x>>y;
	if(c>=(a+b+1)/2){
		cout<<x*a+y*b;
	}
	else{
		if(x>=y){
			ans+=y*c*2;
			ans+=(x-y)*a;
			int ans2=x*c*2;
			ans=min(ans,ans2);
		}
		else{
			ans+=x*c*2;
			ans+=(y-x)*b;
			int ans2=y*c*2;
			ans=min(ans,ans2);
		}
		cout<<ans;
	}
	//system("pause");
	return 0;
} 

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (X, N) = readLine()!!.split(" ").map { it.toInt() }

    if (N == 0) {
        println(X)
        return
    }

    val P = readLine()!!.split(" ").map { it.toInt() }

    if (!P.contains(X)) {
        println(X)
        return
    }

    var count = 0
    var sub = -1
    while (true) {
        if (!P.contains(X + sub)) {
            println(X + sub)
            return
        }

        count += 1
        if ((count % 2) == 0) {
            sub = (sub +1) * -1
            continue
        } else {
            sub *= -1
            continue
        }
    }
}

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b) - 1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  ll N;
  cin >> N;
  vvi p(N, vi(2));
  rep(i, 0, N) cin >> p[i][0] >> p[i][1];
  double sum = 0;
  auto square = [](double x) { return x * x; };
  vi v(N);
  iota(all(v), 0);
  do {
    rep(i, 0, N - 1) {
      ll s = v[i], t = v[i + 1];
      sum += sqrt(square(p[s][0] - p[t][0]) + square(p[s][1] - p[t][1]));
    }
  } while (next_permutation(all(v)));
  rep(i, 1, N + 1) sum /= i;
  cout << sum << endl;
}


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

int main() {
  int N;
  scanf("%d", &N);
  int X = N;
  int sum = 0;  
  while(X > 0) {
    sum += X % 10;
    X = X / 10;
  }
  if (N % sum == 0) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B_lst = list(map(int,input().split()))
count=0
for _ in range(N):
	A_lst = list(map(int,input().split()))
	ans = C
	for a,b in zip(A_lst,B_lst):
		ans += a*b
	if ans > 0:
		count += 1
print(count)

Measured memory_bytes: 3060
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    total = sum(a_list)
    d = (1 + N) * N // 2
    if total % d != 0:
        print("NO")
        return
    k = total // d
    for i in range(N - 1):
        diff = a_list[i + 1] - a_list[i]
        if diff > k or (k - diff) % N != 0:
            print("NO")
            return
    print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 14684
a, b, c, k = map(int, input().split()); s,t=0,0;
while(True):
    s=a
    if s>=k:
        t = k;    break
    else:
        t=a;    s += b
        if s>=k:
            break;
        else:
            s += c
            if s >= k:
                d = c-s+k;    t -= d
                break;
print(t)

Measured memory_bytes: 9040
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())
    A, B = [int(x) for x in input().split()]

    for i in range(A, B + 1):
        if i % K == 0:
            print("OK")
            return
    print("NG")

    

if __name__ == '__main__':
    main()



Measured memory_bytes: 61860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  int y;
  cin >> x;
if(x==0){y=0;
}else if(x==1 || x==10 || x==100){y=1;
}else if(x==11 || x==101 || x==110){y=2;
}else{y=3;
}
cout << y << endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
range_N = range(N)
m = []
for i in range_N:
  m.append(int(input()))

min_consump = sum(m)
rest = X - min_consump
if rest != 0:
	max_num = 0
	for consump in m:
		doughnut = rest // consump
		if doughnut > max_num :
			max_num = doughnut
	print(len(m) + max_num)
else:print(len(m))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int current = 0;
    for( int i = 0; i < 3; i++ ) 
    {
        if( s[i] == 'R') 
        {
            current++;
        }
        else
        {
            current = 0;
        }
        ans = max(ans, current);
    }
    cout << ans;
}

Measured memory_bytes: 3588
#include <stdio.h>
#define max(a, b) ((a)>(b) ? (a) : (b))

int main(){
  int n, w_max, w[101], v[101];
  scanf("%d %d", &n, &w_max);
  for(int i=0; i<n; i++) scanf("%d %d", &w[i], &v[i]);

  long int dp[100001] = {0};

  for(int i=0; i<n; i++){
    for(int j=w_max; j>=w[i]; j--){
      dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
    }
  }
     

  printf("%ld\n", dp[w_max]);
	
  
  return 0;
}
    


Measured memory_bytes: 896
#include<stdio.h>

int main(){
  char S[5];
  int judge=0,i;

  scanf("%s",&S);

  for(i=0;i<4;i++)
    if(S[i]=='A' && S[i+1]=='C')
      judge=1;

  if(judge)
    puts("Yes");
  else
    puts("No");


  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	while (true) {
		int h, w;
		cin >> h >> w;

		if (!h && !w) break;

		rep(i, h) {
			rep(j, w) {
				if (0 < i && i < h - 1 && 0 < j && j < w - 1) {
					cout << ".";
				}
				else
					cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
int main(){
  int n;cin>>n;
  vector<int> v(n),a(n,1e9+1);
  rep(i,n) cin>>v[i];
  reverse(ALL(v));
  rep(i,n) a[upper_bound(ALL(a),v[i])-a.begin()]=v[i];
  cout<<lower_bound(ALL(a),1e9+1)-a.begin()<<endl;
}

Measured memory_bytes: 4004
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int N, p[30], min_times;

map<int,int> rot[4] = {
    { {1, 28}, {2, 29}, {3, 30}, {15, 16}, {19, 21}, },
    { {3, 22}, {6, 25}, {9, 28}, {12, 19}, {13, 15} },
    { {7, 22}, {8, 23}, {9, 24}, {13, 18}, {10, 12} },
    { {1, 24}, {4, 27}, {7, 30}, {10, 21}, {16, 18} }
};

vector<int> group_id = {
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    9, 9, 9,
    12, 12, 12,
    15, 15, 15,
    18, 18, 18,
    21, 21, 21, 21, 21, 21, 21, 21, 21
};

void rotate(int i) {
    for (auto it=rot[i].begin(); it!=rot[i].end(); ++it) {
        swap(p[it->first - 1], p[it->second - 1]);
    }
}

bool isOK() {
    for (int i=0; i<(int)group_id.size(); ++i) {
        if (p[i] != p[group_id[i]]) return false;
    }
    return true;
}

int solve(int times, int &min_times) {
    if (8 <= times || min_times <= times || isOK()) {
        min_times = min(min_times, times);
        return times;
    }
    int ret = INT_MAX;
    for (int i=0; i<4; ++i) {
        rotate(i);
        ret = min(ret, solve(times + 1, min_times));
        rotate(i);
    }
    return ret;
}

int main() {
    cin >> N;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<30; ++j) {
            cin >> p[j];
        }
        min_times = INT_MAX;
        cout << solve(0, min_times) << endl;
    }
    return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  ll N,M,K;
  cin >> N >> M >> K;
  ll A[N], B[M];
  ll at[N+1], bt[M+1];
  rep(i,2){
    if(i==0){
      rep(j,N) cin >> A[j];
    }else{
      rep(j,M) cin >> B[j];
    }
  }
  at[0]=0;
  bt[0]=0;
  for(ll i=1; i<=N; i++) at[i]=at[i-1]+A[i-1];
  for(ll i=1; i<=M; i++) bt[i]=bt[i-1]+B[i-1];
  
  ll amax,bmax = 0;
  rep(i,N+1){
    amax=i;
    if(i==N) break;
    if(at[i+1]>K) break;
  }
  //cout << "amax:" << amax << "\n";
  ll max = 0;
  for(; amax>=0; amax--){
    ll ans= at[amax]+bt[bmax];
    while(ans<=K){
      ans = at[amax]+bt[bmax];
      if(bmax==M){
        ans = K+1;
      }else if(at[amax]+bt[bmax+1]<=K){
        bmax++;
      }else{
        break;
      }
    }
      
    if(max<amax+bmax) max = amax+bmax;
  }
    
  
  cout << max;
  
  return 0;
}

Measured memory_bytes: 9848
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
S = list(input())

l = len(S)
anss = []

for i in range(1<<l-1):
	i = list("{:b}".format(i).zfill(l-1))
	ans = []
	S_ = S.copy()
	ans.append(S_.pop(0))
	while S_ != []:
		if i.pop(0) == "1":
			ans.append("+")

		ans.append(S_.pop(0))

	anss.append(eval("".join(ans)))

print(sum(anss))

Measured memory_bytes: 13764
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
f = 1
ans = 0
while N>0:
    n = a.pop()
    cnt = 1
    while len(a) != 0 and n == a[-1]:
        a.pop()
        cnt += 1
    if N - (cnt*2 - f) <= 0:
        ans += (N-f) * n
    else:
        ans += (cnt * 2 - f) * n
    N -= cnt * 2 
    f *= 0

print(ans)

Measured memory_bytes: 31644
//#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 = 998244353;
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);
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
    dp[0][0] = 1;
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j <= s; j++)
        {
            dp[i + 1][j] += dp[i][j] * 2;
            dp[i + 1][j] %= MOD;
            if (j + a[i] <= s)
            {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= MOD;
            }
        }
    }
    cout<<dp[n][s]<<"\n";
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
bool match (int x, int y) {
  int z = x*y;
  int last = 10;
  while (z) {
    int cur = z%10;
    if (cur != last - 1  && last != 10)
      return 0;
    last = cur;
    z /= 10;
  }
  return 1;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> a[i];

  int ans = -1;
  for (int i = 1; i <= n; i++) 
    for (int j = i + 1; j <= n; j++)
      if (match (a[i], a[j]))
        ans = max (a[i] * a[j], ans);

  cout << ans << endl;


  return 0;
}






// Coded by Z..


Measured memory_bytes: 3208
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
if A + B >= 24:
    print(A + B - 24)
else:
    print(A + B)


Measured memory_bytes: 27192
import java.util.Scanner;
import java.util.Stack;

public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			Stack<Integer> stack = new Stack<Integer>();
			int n = scan.nextInt();
			for(int i = 0 ;i < n;i++){
				stack.push(scan.nextInt());
			}
			while(!stack.isEmpty()){
				System.out.print(stack.pop());
				if(!stack.isEmpty())
					System.out.print(" ");
				else
					System.out.println();
			}
		}finally{
			if(scan != null)scan.close();
		}
	}
}

Measured memory_bytes: 19896
#include<stdio.h>
int main()
{int a[100005];
 int n,x;
 while(~scanf("%d%d",&n,&x))
 {int i,j;
  for(i=0;i<n;i++)
  scanf("%d",&a[i]);
  long long sum=0;
  if(a[0]>x)
  {sum+=a[0]-x;
   a[0]=x;
  }
  for(i=1;i<n;i++)
  {int temp=a[i]+a[i-1]-x;
   if(temp>0)
   {a[i]=a[i]-temp;
    sum+=temp;
   }
  }
  printf("%lld\n",sum);
 }
 return 0;
}

Measured memory_bytes: 512
a, b, c, d = map(int, input().split())
ans = ""
ans += "U" * (d-b) + "R" * (c-a) + "D" * \
    (d-b) + "L" * (c-a+1) + "U"*(d-b+1) + \
    "R"*(c-a+1)+"DR"+"D"*(d-b+1)+"L"*(c-a+1)+"U"
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

int main(void){
	int n,d;
	cin>>n>>d;
	cout<<(n-1)/(2*d+1)+1<<endl;
	return 0;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,M;
  cin>>N>>M;
vector<ll> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  vector<bool> H(N,true);
  for(ll i=0;i<M;i++) {
ll A,B;
    cin>>A>>B;
    if(vec[A-1]>vec[B-1]) {
      H[B-1]=false;
    }
    else if(vec[A-1]<vec[B-1]) {
H[A-1]=false;
    }
    else {
H[A-1]=false;
      H[B-1]=false;
    }
  }
  ll ans=0;
  for(auto x:H) {
if(x) {
  ans++;
}
  }
  
  cout<<ans<<endl;
}

 

Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
typedef long long ll;

int main(){
    ll X;
    scanf("%lld",&X);
    ll year = 0,money = 100;
    while(money < X){
        money *= 1.01;
        year++;
    }
    printf("%lld",year);
}


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

using namespace std;

main(){
		int l;
		while(cin>>l){
			int o=0;
			for (int a=0; a < 10; a++){
				for (int b=0; b < 10; b++){
					for (int c=0; c < 10; c++){
						for (int d=0; d < 10; d++){
							if(a+b+c+d==l){
								o=o+1;
							}
						}
					}
				}
			}
			printf("%d\n",o);
		}
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, K, A[202020];
int B[202020];
map<int, int> M;

void solve() {
    M[0] = 1;
    itn ans = 0;
    FOR(N) {
        B[i + 1] = B[i] + A[i];
        B[i + 1] %= K;
        int b = B[i + 1];

        M[b]++;
        int bef = i - K + 1;
        if (bef >= 0) {
            M[B[bef]]--;
        }
        //cerr << M[b] << endl;
        ans += M[b] - 1;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    FOR(N) {
        cin >> A[i];
        A[i]--;
    }


    solve();
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
 
 ll int power(ll int a,int b)
 {
	 ll int ans=1,f=a;
	 while(b)
	 {
		 if(b&1)
		 ans=(ans*f)%mod;
		 b=b>>1;
		 f=(f*f)%mod;
	 }
	 return ans%mod;
 }
int main()
{
  int n,k;
  cin>>n>>k;
  ll int dp[k+1]={0};
  dp[k]=1;
  rfo(i,k-1,1)
  {
	  ll int u=k/i;
	  dp[i]+=power(u,n);
	  dp[i]%=mod;
	//  cout<<dp[i]<<endl;
	  for(int j=2*i;j<=k;j+=i)
	  dp[i]=(dp[i]-dp[j]+2*mod)%mod;
	  //cout<<dp[i]<<endl;
  }
  ll int ans=0;
  fo(i,1,k+1)
  {
	  //cout<<dp[i]<<endl;
	  ans=((dp[i]*i)%mod+ans)%mod;
	//  cout<<ans<<endl;
  }
  cout<<ans;
 
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using ll = long long;
using namespace std;

vector<ll> ans;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];
    sort(rall(A));
    sort(rall(B));
    sort(rall(C));

    rep(i,X)rep(j,Y)rep(k,Z){
        if(i*j*k>K)break;
        ans.push_back(A[i]+B[j]+C[k]);
    }
    sort(rall(ans));
 
    rep(i, K) cout << ans[i] << endl;
}


Measured memory_bytes: 35176
abcd=list(input())
lst=["+","-"]
lst_2=[]
lst_buf=[]
for x in lst:
    for y in lst:
        for z in lst:
            lst_buf=[x,y,z]
            lst_2.append(lst_buf)
buf=''
for l in lst_2:
    buf=abcd[0]+l[0]+abcd[1]+l[1]+abcd[2]+l[2]+abcd[3]
    if 7==eval(buf):
        print(buf+"=7")
        break

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var s string

	fmt.Scan(&n, &s)

	cumW := make([]int, n+1)
	cumE := make([]int, n+1)

	for i := 0; i < n ; i++ {
		if string(s[i]) == "W" {
			cumW[i+1] = cumW[i] + 1
		} else {
			cumW[i+1] = cumW[i]
		}
	}

	for i := 0; i < n ; i++ {
		if string(s[i]) == "E" {
			cumE[i+1] = cumE[i] + 1
		} else {
			cumE[i+1] = cumE[i]
		}
	}

	answer:= make([]int, n)
	for i := 0 ; i< n; i++ {
		answer[i] = cumW[i] + (cumE[n] - cumE[i+1])
	}

	fmt.Println(min(answer...))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 11004
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(void){
    ll N,M;cin>>N>>M;
    ll p[N];REP(i,N){cin>>p[i];p[i]--;}
    UnionFind uf(N);
    ll x,y;
    REP(i,M){
        cin>>x>>y;x--;y--;
        uf.merge(p[x],p[y]);
    }
    ll ans=0;
    REP(i,N){
        if(uf.issame(i,p[i]))ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 2560
#include<stdio.h>
int graph[100][100];

int main(){
  int n,u,k,i,j,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      graph[i][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j>0)printf(" ");
      printf("%d",graph[i][j]);

    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,x,sum=0,count=0;
	double req;
	set <int> st;
	set <int>:: reverse_iterator itr;
	cin >> n >> m;
	for(i=1;i<=n;i++)
	{
		cin >> x;
		st.insert(x);
		sum += x;
	}
	x = 4*m;
	req = sum/(float)x;
	//cout << req ;
	for(itr=st.rbegin();itr!=st.rend();itr++)
	{
		if( *itr >= req)
			count++;
		else
			break;
	}
	if(count>=m)
		cout << "Yes\n";
	else
		cout <<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

class Node
{
public:
	Node ()
	{
		this->parent = NULL;
		this->right = NULL;
		this->left = NULL;
	}

	Node* parent;
	Node* right;
	Node* left;
	int item;
};

class BinaryTree
{
private:
	Node* root;

	void PreOrder (Node* node)
	{
		if (node != NULL)
		{
			printf (" %d", node->item);
			PreOrder (node->left);
			PreOrder (node->right);
		}
	}

	void InOrder (Node* node)
	{
		if (node != NULL)
		{
			InOrder (node->left);
			printf (" %d", node->item);
			InOrder (node->right);
		}
	}

	void DeletePostOrder (Node* node)
	{
		if (node != NULL)
		{
			DeletePostOrder (node->left);
			DeletePostOrder (node->right);
			delete node;
		}
	}

public:
	BinaryTree ()
	{
		root = NULL;
	}
	~BinaryTree ()
	{
		DeletePostOrder (root);
	}

	void Insert (int value)
	{
		Node* searchNode = root;
		Node* parentNode = NULL;
		Node* newNode = new Node;
		newNode->item = value;

		//???????????°????????????????????\???????????¢?´¢??????
		while (searchNode != NULL)
		{
			parentNode = searchNode;

			if (newNode->item < searchNode->item)
			{
				searchNode = searchNode->left;
			}
			else
			{
				searchNode = searchNode->right;
			}
		}

		newNode->parent = parentNode;

		//?????????????????´???
		if (parentNode == NULL)
		{
			root = newNode;
		}
		else
		{
			//?????????????????´???????????????????????????
			if (newNode->item < parentNode->item)
			{
				parentNode->left = newNode;
			}
			else
			{
				parentNode->right = newNode;
			}
		}
	}

	void Print ()
	{
		InOrder (root);
		printf ("\n");
		PreOrder (root);
		printf ("\n");
	}
};

int main ()
{
	int dataCount;
	scanf ("%d", &dataCount);

	BinaryTree binaryTree;

	for (int lp = 0; lp < dataCount; lp++)
	{
		char inputStr[6 + 1];
		scanf ("%s", inputStr);

		//insert
		if (inputStr[0] == 'i')
		{
			int inputNum;
			scanf ("%d", &inputNum);
			binaryTree.Insert (inputNum);
		}
		//print
		else
		{
			binaryTree.Print ();
		}
	}

	return 0;
}

Measured memory_bytes: 26024
main(){int n,a,b,M[300001]={1};scanf("%d%d%d",&n,&a,&b);if(n>1LL*a*b||n<a+b-1)puts("-1");else{int N=b,C=n;while(1){for(int i=0;i<b;++i){if(a==C){for(int k=0;k<=n;++k)if(!M[k])printf("%d ",k);return 0;}C--;printf("%d ",N-i);M[N-i]=1;}a--;N=n<N+b?n:N+b;}}}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
        long long n;
        cin>>n;
        long long b[n]={0};
        for(long long i=0;i<n-1;i++){
                long long temp;
                cin>>temp;
                b[temp-1]++;
        }for(long long i=0;i<n;i++){
                cout<<b[i]<<endl;
        }
        return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
	cin>>n;
	double ans=0;
	for(int i=0;i<n;i++){
		int u;
		cin>>u;
		ans+=(double)(1/(double)u);
	}
	cout<<1/(double)ans;
	return 0;
}

Measured memory_bytes: 256