akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
bool Exists(vector<string>& A, string S) {
	int len = A.size();
	for (int i = 0; i < len; i++) {
		if (A.at(i) == S) return true;
	}
	return false;
}
int Point(vector<string>& A, vector<string>& B, string S) {
	int len1 = A.size(), len2 = B.size();
	int points = 0;
	for (int i = 0; i < len1; i++) {
		if (A.at(i) == S) points++;
	}
	for (int i = 0; i < len2; i++) {
		if (B.at(i) == S) points--;
	}
	return points;
}
int main() {
	int N, M;
	cin >> N;
	vector<string>Blue(N);
	for (int i = 0; i < N; i++) {
		cin >> Blue.at(i);
	}
	cin >> M;
	vector<string>Red(M);
	for (int i = 0; i < M; i++) {
		cin >> Red.at(i);
	}
	vector<string>Saying;
	for (int i = 0; i < N; i++)
	{
		if (Saying.empty()) Saying.push_back(Blue.at(i));
		else if (!Exists(Saying, Blue.at(i))) Saying.push_back(Blue.at(i));
	}
	for (int i = 0; i < M; i++)
	{
		if (Saying.empty()) Saying.push_back(Red.at(i));
		else if (!Exists(Saying, Red.at(i))) Saying.push_back(Red.at(i));
	}
	int ans = -10000;
	for (int i = 0; i < Saying.size(); i++) {
		int sum = Point(Blue, Red, Saying.at(i));
		if (ans < sum) ans = sum;
	}
	cout << max(ans, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int MOD = 1e9 + 7;

ll fac(ll n){
    ll ans = 1;
    for(ll i=1; i<=n; i++){
        ans = ans*i%MOD;
    }
    return ans%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    if(n>m) swap(n,m);
    if(m-n > 1) {
        cout<<0<<endl;
        return 0;
    } 
    else if(m == n+1){
        cout<<fac(n) * fac(m) % MOD << endl;
    }
    else{
        cout<<2 * fac(n) * fac(m) % MOD << endl;
    }
}

// arc076_a

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int a,b;
 cin >> a >> b;
 int s = (a-1)*(b-1);
 cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000

struct Node{
  int oya, le ,ri;
};

struct Node Tree[MAX];
int De[MAX],He[MAX];

void depth(int,int);
int height(int);
int sibling(int);
void print(int);

int main(){
int n,i,num,le,ri;
int root=0;
scanf("%d",&n);

for(i=0;i<n;i++)Tree[i].oya=-1;
for(i=0;i<n;i++){
  scanf("%d%d%d",&num,&le,&ri);
  Tree[num].le=le;
  Tree[num].ri=ri;
  if(le != -1) Tree[le].oya = num;
  if(ri != -1) Tree[ri].oya = num;
}
for(i=0;i<n;i++) if(Tree[i].oya == -1) root = i;
depth(root,0);
height(root);
for(i=0;i<n;i++) print(i);

  return 0;
}

void depth(int a,int b){
  if(a==-1)return;
  De[a]=b;
  depth(Tree[a].le, b+1);
  depth(Tree[a].ri, b+1);


}

int height(int a){
  int h1=0;
  int h2 =0;
  if(Tree[a].le != -1) h1= height(Tree[a].le)+1;
  if(Tree[a].ri != -1) h2= height(Tree[a].ri)+1;
  if(h1>h2) return He[a]=h1;
  else return He[a]=h2;
}

int sibling(int a){
  if(Tree[a].oya==-1) return -1;
  if(Tree[Tree[a].oya].le !=a && Tree[Tree[a].oya].le != -1 ){
    return Tree[Tree[a].oya].le;

  }
  if(Tree[Tree[a].oya].ri !=a && Tree[Tree[a].oya].ri != -1 ){
    return Tree[Tree[a].oya].ri;

  }

  return -1;
}

void print(int a){
  int de =0;
  printf("node %d: ",a);
  printf("parent = %d, ",Tree[a].oya);
  printf("sibling = %d, ",sibling(a));
  if(Tree[a].le != -1) de++;
  if(Tree[a].ri != -1) de++;
  printf("degree = %d, ",de);
  printf("depth = %d, ",De[a]);
  printf("height = %d, ",He[a]);

  if(Tree[a].oya == -1){
    printf("root\n");
  }
  else if(Tree[a].le == -1 && Tree[a].ri == -1){
    printf("leaf\n");

  }
  else printf("internal node\n");
}



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

data = []
p, q, r = (0, 0, 0)
for _ in range(n):
    (l, m, n) = map(int, input().split())
    data.append([l, m, n])
    if n:
        p = l
        q = m
        r = n


for x in range(101):
    for y in range(101):
        h = r + abs(p - x) + abs(q - y)
        if all(c == max(h - abs(a - x) - abs(b - y), 0) for a, b, c in data):
            print("{} {} {}".format(x, y, h))
            exit(0)


Measured memory_bytes: 3064
#include <iostream>

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

int main() {
    int a, b;
    std::cin >> a >> b;
    std::cout << gcd(a, b) << std::endl;
}

Measured memory_bytes: 3076
#include <stdio.h>
int T,F,R,c,a,t;char s[9];
main()
{
for(;c+21&&scanf("%s",s);a+=T)
{
c=*s-69;
c<0?a&&printf("%d\n",a),a=0,T=1,F=2,R=3:0;
c==9?t=T,T=F,F=7-t:0;
c==14?t=F,F=T,T=7-t:0;
!c?t=R,R=T,T=7-t:0;
c==18?t=T,T=R,R=7-t:0;
c==13?t=F,F=R,R=7-t:0;
c==7?t=R,R=F,F=7-t:0;
}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll p, ll M){
    ll ret = 1;
    while(p){
    if(p & 1) ret = ret * a % M;
    a = a * a % M;
    p >>= 1;
    }
    return ret;
}

int main() {
    ll N, M;
    M = 998244353;
    cin >> N;
    vector<ll> D(N);
    rep(i, N) cin >> D[i];

    vector<ll> num(N,0);
    rep(i,N) num[D[i]]++;
    ll ans = 1;
    for(int i = 1; i < N; i++){
        ans *= modpow(num[i-1], num[i],M);
        ans %= M;
    }
    if(num[0] != 1 || D[0] != 0) ans = 0;
    cout << ans << endl;

}

Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#undef gc
#undef pc
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
int n,k;
int main(){
	n = rd(),k = rd();
	//Rep(i,1,n) a[i] = rd(),if(a[i]==1) pos = i;
	int res = 1,ans = 0;
	while(res<n){
		ans++;
		res = res + k - 1;
	}writeln(ans);
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, h, w;

    cin >> n >> h >> w;

    int res = (n - h + 1) * (n - w + 1);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                int sum = 0;
                if (n == 0) { break; }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0, y = 0;
                for (int i = 0; i < scores.length; i++) {
                    sum = sum + scores[i];
                }
                average = (double)sum / n;
                for (int i = 0; i < scores.length; i++) {
                    double x = Math.pow((scores[i] - average), 2);
                    y = x + y;
                }
                variance = y / n;
                System.out.println(Math.sqrt(variance));
            }
        }
    }
}



Measured memory_bytes: 31524
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int t[N+1];
    int x[N+1];
    int y[N+1];
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=1;i<N+1;i++)cin>>t[i]>>x[i]>>y[i];
    bool can=true;
    for(int i=0;i<N;i++){
           int d=t[i+1]+x[i+1]+y[i+1]-t[i]-x[i]-y[i];
           if(d%2==0&&d>=0){
               int a;
               bool can2=false;
               for(a=0;a<=d/2;++a){
                   if(a>=x[i+1]-x[i]&&a<=d/2-y[i+1]+y[i]){
                       can2=true;
                       break;
                   }   
               }
               if(!can2){
                   can=false;
                   break;
               }
        }
            else{
                can=false;
                break;
            }
    }
    if(can) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI acos(-1)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    while(cin>>a>>b)
    {
        ll ans=max(a+b,a-b);
        ans=max(a*b,ans);
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
import sys, array, re, functools
input = lambda: sys.stdin.readline()
@functools.lru_cache(maxsize = 10000)

def Main():
  N, M = map(int , input().split())
  A, B, C, D = [], [], [], []
  for _ in range(N):
    x, y = map(int , input().split())
    A.append(x)
    B.append(y)

  for _ in range(M):
    x, y = map(int, input().split())
    C.append(x)
    D.append(y)
    
  cnt  = 0
  res = []
  zemi = []
  mn = 123456789256913
  
  bal = 0
  sal = M
  rez = []
  zakia , zemi = [], []
  for i in range(N):
    for j in range( M):
      X = abs(A[i] - C[j]) + abs(B[i] - D[j])
      zemi.append(X)
    zakia = zemi
    # zemi.sort()
    chk = min(zemi)
    # print(zakia, len(zakia),  chk)
    
    for l in range(len(zakia)):
      if chk == zakia[l]:
        # print(zakia[l])
        rez.append(l+1)
        break
    
    zemi.clear()
 
  for i in range(len(rez)):
    print(rez[i])
  

if __name__ == '__main__':
  Main()

Measured memory_bytes: 4084
N, M = map(int, input().split())
n = [list(map(int, input().split())) for x in range(N)]
m = [list(map(int, input().split())) for x in range(M)]

for i in n:
    x = 0
    for j in range(M):
        c = m[j]
        k = m[x]
        a = max(i[0], k[0]) - min(i[0], k[0]) + max(i[1], k[1]) - min(i[1], k[1])
        b = max(i[0], c[0]) - min(i[0], c[0]) + max(i[1], c[1]) - min(i[1], c[1])
        if b < a : x = j
    print(x + 1)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	double N,M,D;
	cin >> N >> M >> D;
	if(D != 0) {
		cout << setprecision(9) << 2 * (N - D) * (M - 1) / (N * N) << endl;
	}
	else {
		cout << setprecision(9) << (N - D) * (M - 1) / (N * N) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  cout << a[0]+a[1] << endl;
}


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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_in_out;
    string s1,s2;
    cin >> s1 >> s2;
    if(s1.size() == s2.size())
    {
        if(s1 > s2)
        {
            cout << "GREATER";
        }
        else if(s1 < s2)
        {
            cout << "LESS";
        }
        else
        {
            cout << "EQUAL";
        }
    }
    else if(s1.size() > s2.size())
    {
        cout << "GREATER";
    }
    else
    {
        cout << "LESS";
    }
}


Measured memory_bytes: 3508
#include<iostream>
#define INF 10000000

using namespace std;

int main()
{
    int Min=INF,Max=-1*INF,n,a;
    long long Sum=0;

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>a;
        Min=min(a,Min);
        Max=max(a,Max);
        Sum+=a;
    }
    cout<<Min<<" "<<Max<<" "<<Sum<<endl;


    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll POW[NUM];
ll nCm[NUM][NUM];
ll memo[NUM];

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	//コンビネーションを求める
	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++) {
		for (int k = 0; k <= N; k++) {
			if(k > 0){
				nCm[n][k] = nCm[n-1][k]+nCm[n-1][k-1];
			}else{ //k == 0
				nCm[n][k] = 1;
			}
			nCm[n][k] %= MOD;
		}
	}

	ll tmp;

	//num^Nを作っておく
	for(ll num = 1; num <= K; num++){
		tmp = 1;

		for(int i = 1; i <= N; i++){
			tmp *= num;
			tmp %= MOD;
		}
		POW[num] = tmp;
	}

	memo[1] = 1;

	for(ll num = 2; num <= K; num++){

		memo[num] = POW[num];

		for(int i = 1; i <= num-1; i++){
			memo[num] -= nCm[num][i]*memo[i];
			memo[num] %= MOD;
			if(memo[num] < 0)memo[num] += MOD;
		}
	}

	printf("%lld\n",memo[K]);

	return 0;
}




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

typedef long long ll;

int ord[25], val[25], seq[25];

int main() {
	int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> ord[i];
    for(int i = 1; i <= n; i++) cin >> val[i];
    for(int i = 1; i <= n-1; i++) cin >> seq[i];
    int res = 0;
    for(int i = 1; i <= n; i++){
        res += val[ord[i]];
        if(i > 1){
            if(ord[i] == ord[i-1]+1){
                res += seq[ord[i-1]];
            }
        }
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
  int d, e;
  while (1) {
    scanf("%d%d", &d, &e);
    if (d == 0) break;
    double ans = abs(d - e);
    for (int x = 0; x <= d; x++) {
      int y = d - x;
      double l = sqrt(x * x + y * y);
      ans = min(ans, abs(l - e));
    }
    printf("%f\n", ans);
  }
}



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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    ll a,b,c,k; cin>>a>>b>>c>>k;
    if(a+b<k) cout<<a-(k-a-b)<<endl;
    else if(k<a) cout<<k<<endl;
    else cout<<a<<endl;


    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    string ss, tt; cin >> ss >> tt; int n = ss.size();
    deque<char> s(n), t(n);
    for(int i = 0; i < n; i++)s[i] = ss[i];
    for(int i = 0; i < n; i++)t[i] = tt[i];

    for(int i = 0; i < n*2; i++) {
        if(s == t) {
            cout << "Yes" << endl;
            return 0;
        } else {
            s.push_front(s.back());
            s.pop_back();
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    char c;cin>>c;
    if(c-'a'>=0 && c-'a'<=25){
        cout<<"a"<<endl;
    }else{
        cout<<"A"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3616
#include <stdio.h>
#define N 100

int main(){
    int in[N];
    int num;

    scanf("%d",&num);
    for(int i=0;i<N;i++){
    scanf("%d",&in[i]);
  }
  trace(in,num);
  insertsort(in,num);
  return 0;
}

int trace(int in[],int num){
  int i;
  for(i=0;i<num;i++){
    if(i>0)printf(" ");
    printf("%d",in[i]);
  }
  printf("\n");
}

int insertsort(int in[],int num){
  //swapをするのと一緒。
  int c;
  for(int i=1;i<num;i++){
    int j=i-1;
    int v = in[i];
    while(j>=0 && in[j] > v){
      in[j+1] = in[j];
      j--;
    }
    in[j+1] = v;
    trace(in,num);
  }
}



Measured memory_bytes: 2096
n = int(input())
if n>=64:
  print("64")
elif 64>n>=32:
  print("32")
elif 32>n>=16:
  print("16")
elif 16>n>=8:
  print("8")
elif 8>n>=4:
  print("4")
elif 4>n>=2:
  print("2")
else:
  print("1")

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

const ll BIG=998244353;
ll pow_ans(ll x, ll n){
  ll res = 1;
  while(n>0){
    if(n&1){res*=x; res%=BIG;}
    x*=x; x%=BIG;
    n>>=1;
  }
  return res%BIG;
}

int main(){
  //cout << fixed << setprecision(10);
  int n; cin>>n;
  vector<int> D(n);
  ll ans=-1;
  rep(i,n){
    cin>>D[i];
  }
  if(D[0]!=0) ans=0;
  sort(D.begin(),D.end());
  vector<ll> kazu(1);
  //ll ans=-1;
  rep(i,n){
    if(i==0&&D[i]!=0){
      ans=0; break;
    }
    if(i==1&&D[i]==0){
      ans=0; break;
    }
    if(D[i]==kazu.size()-1){
      kazu[D[i]]++;
    }else if(D[i]==kazu.size()){
      kazu.push_back(1);
    }else{
      ans=0; break;
    }
  }
  //N=1のときkazu[0]=1でおわり
  if(ans==0){
    cout<<0<<endl;
  }else{
    ans=1;
    for(ll i=1;i<kazu.size();i++){
      ans*= pow_ans(kazu[i-1],kazu[i]);
      ans%=BIG;
    }
    cout<< ans%BIG <<endl;
  }
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h,w,k;
	cin>>h>>w>>k;
	
	vector<string> vs(h);
	REP(i,h) cin>>vs[i];
	
	llong ans=0;
	REP(i,1<<h)REP(j,1<<w){
		int cnt=0;
		REP(p,h)REP(q,w){
			if(vs[p][q]=='#' and (i>>p)&1 and (j>>q)&1) cnt++;
		}
		if(cnt==k) ans++;
	}
	
	cout<<ans<<endl;
}

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

typedef long long ll;

int modpow(ll a, ll b, ll mod){
    ll res = 1;
    while (b > 0){
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

class combnk_mod{
private:
    int _maxn, _p;
    vector<ll> x;
    vector<ll> y;
public:
    combnk_mod(ll maxn, ll p){
        _maxn = maxn;
        _p = p;
        x.push_back(1);
        y.push_back(1);
        for (int i = 1; i <= _maxn; i++){
            x.push_back(x[i - 1] * modpow(i, _p - 2, _p) % _p);
            y.push_back(y[i - 1] * i % _p);
        }
    }

    int combnk(int n, int k){
        if (n < k) return 0;
        return (x[n - k] * x[k] % _p) * y[n] % _p;
    }
};

int main(){
    ll n, k;
    ll mod = 1e9 + 7;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    combnk_mod C(n, mod);
    if (k == 1){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> x(n, 0);
    vector<ll> y(n + 1);
    vector<ll> ya(n + 2, 0);
    for (int i = 0; i < n + 1; i++){
        y[i] = C.combnk(i, k - 2);
        ya[i + 1] = (ya[i] + y[i]) % mod;
    }

    int idx;
    for (int i = 0; i < n; i++){
        idx = max(0, (int)n - i - 1);
        x[i] = ya[i] - ya[idx];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += x[i] * a[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5228
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int n,x,a[N],b[N],ans,f[N];
int ef(int x){
	int l=1,r=n;
	while (l<r){
		int mid=(l+r)/2;
		if (a[mid]<x)l=mid+1;
		else r=mid;
	}
	if (a[l]!=x)return -1;
	return l;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld",&x);
		for (int j=2;j*j*j<=x;j++)
			while (x%(j*j*j)==0)x/=(j*j*j);
		a[i]=x;	
	} 
	sort(a+1,a+n+1);
	int tot=1;b[1]=1;
	for (int i=2;i<=n;i++){
		if (a[i]!=a[tot])a[++tot]=a[i];
		b[tot]++;
	}
	n=tot;
	for (int i=1;i<=n;i++){
		if (f[i])continue;
		if (a[i]==1){
			ans++;
			f[1]=1;
			continue;
		}
		x=a[i];
		int y=1,flag=1;
		for (int j=2;j*j*j<=x;j++){
			if (x%(j*j)==0){
				x/=(j*j);
				if (1e10/y<j){
					flag=0;
					break;
				}
				else y*=j;
			}
			if (x%j==0){
				x/=j;
				if (1e10/y/j<j){
					flag=0;
					break;
				}
				else y*=j*j;
			}
		}
		if ((int)sqrt(x)==sqrt(x)){
			int k=(int)sqrt(x);
			if (1e10/y<k)flag=0;
			else y*=k;
		}
		else {
			if (1e10/y/x<x)flag=0;
			else y*=x*x;
		}
		int p=ef(y);
		if (p==-1||!flag){
			ans+=b[i];
			f[i]=1;
			continue;
		}
		ans+=max(b[i],b[p]);
		f[p]=f[i]=1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2560
N = int(input())
a = [int(x) for x in input().split()]
b = [0]*N
b[0] = a[0]
for i in range(1, N):
    b[i] = a[i] + b[i-1]
ans = 10**15
for i in range(0, N-1):
    ans = min(ans, abs(b[i] - (b[N-1] - b[i])))
print(ans)

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

int main()
{
	int n,count=0;
	while(cin>>n){
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						if(i+j+k+l==n) count++;
					}
				}
			}
		}
		
		cout<<count<<endl;
		count=0;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#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 <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, l;
	cin >> n >> m >> l;
	vector<vector<ull> > A(n);
	REP(i, n) A.at(i).resize(m);
	REP(i, n) REP(j, m) cin >> A.at(i).at(j);
	vector<vector<ull> > B(m);
	REP(i, m) B.at(i).resize(l);
	REP(i, m) REP(j, l) cin >> B.at(i).at(j);
	REP(i, n) {
		REP(j, l) {
			ull sum = 0;
			REP(k, m) {
				sum += A.at(i).at(k) * B.at(k).at(j);
			}
			if(j == l-1) cout << sum << endl;
			else cout << sum << " ";
		}
	}
}



Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  long long N,A,B,ans=0;
  cin>>N>>A>>B;
  FOR(i,1,N+1){
    long long j=i;
    long long cnt=0;
    while(j>0){
      cnt+=j%10;
      j/=10;
    }
    if(A<=cnt&&cnt<=B){
      ans+=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int count = 0;
    for(int i=0;i<n/2;i++){
      	if (s[i] != s[n-1-i]){
            count++;
        }
    }
    cout << count <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string s,p,q;
cin>>s;
if(n&1){cout<<"No";return 0;}
p=s.substr(0,n/2);q=s.substr(n/2,n/2);
if(p==q)cout<<"Yes";
else cout<<"No";
return 0;
}


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

#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

int main(){
	c_p_c();
	int k,m; cin >> k >> m;
	int a[m];
	fo(i,m) cin >> a[i];
	int ans = a[m-1] - a[0];
	Fo(i,1,m){
		ans = min(a[i-1]+k-a[i],ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int res = 0;
		for(int i=0; i<S.length; i++) {
			if (S[i] == '+') res ++;
			else res--;
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 22996
#include <iostream>		 // cout, endl, cin
#include <string>		 // string, to_string, stoi
#include <vector>		 // vector
#include <algorithm>	 // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>		 // pair, make_pair
#include <tuple>		 // tuple, make_tuple
#include <cstdint>		 // int64_t, int*_t
#include <cstdio>		 // printf
#include <map>			 // map
#include <queue>		 // queue, priority_queue
#include <set>			 // set
#include <stack>		 // stack
#include <deque>		 // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>		 // bitset
#include <cctype>		 // isupper, islower, isdigit, toupper, tolower
#include <cmath>	
using namespace std;

int main()
{
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			int z = s - x - y;
			if(0 <= z && z <= k){
				ans += 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int res = 1;
  for (int i = 0; i < 3; ++i) {
    res *= n;
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    long long K;
    cin>>K;
    const int N=50;
    long long a[N];
    long long quo=K/N;
    long long amari=K%N;
    for(int i=0;i<N;i++){
        a[i]=quo+(long long)(N-1);
    }
    for(int i=0;i<amari;i++){
        a[i]+=(long long)N;
        for(int j=0;j<N;j++){
            if(j!=i) a[j]--;
        }
    }
    cout<<N<<endl;
    for(int i=0;i<N;i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int> pathN(0);
int N;
bool dfs(int p, int u, vector<vector<int>> &side) {
  if(u == N - 1) {
    pathN.push_back(u);
    return true;
  }
  for(int i = 0; i < side.at(u).size(); i++) {
    int v = side.at(u).at(i);
    if(v == p) continue;
    if(dfs(u, v, side)) {
      pathN.push_back(u);
      return true;
    }
  }
  return false;
}

void paint(vector<int> &tree, vector<vector<int>> &side, int u, int color) {
  for(int i = 0; i < side.at(u).size(); i++) {
    int v = side.at(u).at(i);
    if(tree.at(v) != -1) continue;
    tree.at(v) = color;
    paint(tree, side, v, color);
  }
}

int main() {
  cin >> N;
  vector<int> tree(N, -1);
  vector<vector<int>> side(N, vector<int> (0));
  for(int i = 0; i < N - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    side.at(a).push_back(b);
    side.at(b).push_back(a);
  }
  map<string, int> score;
  score["Fennec"] = 0; score["Snuke"] = 0;
  dfs(-1, 0, side);
  reverse(pathN.begin(), pathN.end());
  for(int i = 0; i < pathN.size(); i++) {
    if(tree.at(pathN.at(i)) == -1) tree.at(pathN.at(i)) = 1;
    else break;
    if(tree.at(pathN.at(pathN.size() - 1 - i)) == -1) tree.at(pathN.at(pathN.size() - 1 - i)) = 0;
    else break;
  }
  for(int i = 0; i < pathN.size(); i++) {
    paint(tree, side, pathN.at(i), tree.at(pathN.at(i)));
  }
  for(int i = 0; i < N; i++) {
    if(tree.at(i) == 1) score.at("Fennec")++;
    else score.at("Snuke")++;
  }
  cout << ((score.at("Fennec") > score.at("Snuke")) ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 13052
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		int N = readInt(), min = Integer.MAX_VALUE;for(int a = 1; a<N; a++) {
			int A = a, B = N-a; int sum = 0; 
			while(A > 0) {sum += A%10; A/=10;} while(B>0) {sum += B%10; B/=10;}
			min = Math.min(min, sum);
		}
		println(min);
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 23380
#include<stdio.h>
int main()
{
    int i,t=6,a[6],b,c;
    for(i=1;i<t;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<t;i++)
    {
        if(a[i]==0)
        {
            printf("%d\n",i);
        }
    }


}


Measured memory_bytes: 1688
import java.util.*;

class Main {
    
    static final long MOD = 1_000_000_007;
    static final int MAX = 2000000000;
    static final int INF = 100000000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        n -= m;
        long ans = n*100 + 1900*m;
        ans *= (int)Math.pow(2,m);
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,K;
    cin >> N >> K;
    graph G(N);
    bool seen[N];
    for(int i = 0; i < N; i++){
        G[i] = vector<ll>(0);
        seen[i] = false;
    }
    for(int i = 0; i < N -1; i++){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<ll> q = queue<ll>();
    q.push(0);
    seen[0] = true;
    ll count = K;
    ll MOD = 1000000007;
    while(!q.empty()){
        ll current = q.front();q.pop();
        if(current == 0){
            for(int i = 0; i < G[current].size();i++){
                count = (count * (K - i - 1)) % MOD;
            }
        }else{
            for(int i = 0; i < G[current].size() - 1;i++){
                count = (count * (K - i - 2)) % MOD;
            }
        }

        for(int i = 0; i < G[current].size();i++){
            ll next = G[current][i];
            if(seen[next]){
                continue;
            }
            seen[next] = true;
            q.push(next);
        }
    }
    cout << count << endl;



}


Measured memory_bytes: 7412
#include<cstdio>
#include<algorithm>
using namespace std;

const int INF = 1e9 + 7;

int main()
{
	int A, B, C, D, E, F;
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	int res_w = INF;
	int res_s = 0;
	for(int i=0;i<=F/(100*A);i++)
		for(int j=0;j<=F/(100*B);j++)
			for(int k=0;k<=F/C;k++)
				for(int p=0;p<=F/D;p++)
					if (100 * A*i + 100 * B*j + k*C + p*D <= F && (k*C + p*D)*(100 + E) <= E*(100 * A*i + 100 * B*j + k*C + p*D))
						if ((k*C + p*D)*(res_w + res_s) >= (100 * A*i + 100 * B*j + k*C + p*D)*res_s)
						{
							res_s = k*C + p*D;
							res_w = 100 * A*i + 100 * B*j;
						}
	printf("%d %d", res_w+res_s, res_s);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>

int main()  {
    int W,H,x,y,r,f;

    scanf ("%d %d %d %d %d",&W,&H,&x,&y,&r);

    f = 0;
    if (x - r < 0){
        f = 1;
    }
    
    if (x + r > W){
        f = 1;
    }
    if (y - r < 0){
        f = 1;
    }

    if (y + r > H){
        f = 1;
    }
    if (f == 0){
        printf("Yes\n");
    }

    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2676
import java.util.*;
import java.lang.*;

public class Main {
	static long MOD = 1000000007;
	static long[] count;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m + 2];
		a[0] = -1;
		for (int i = 1; i <= m; i++) {
			a[i] = sc.nextInt();
		}
		a[m + 1] = n + 1;
		long sum = 1;
		count = new long[n + 2];
		for (int i = 0; i < n; i++) {
			count[i] = -1;
		}
		count[0] = 0;
		count[1] = 1;
		for (int i = 2; i < n + 2; i++) {
			count[i] = (count[i - 1] % MOD + count[i - 2] % MOD) % MOD;
		}
		for (int i = 1; i < m + 2; i++) {
			int step = a[i] - a[i - 1] - 1;
			sum *= count[step];
			sum %= MOD;
		}
		System.out.println(sum);
	}
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  string s; cin >> s;

  vector<lint> l(n,0), r(n,0);
  for(lint i=1;i<n;i++) {
    l[i] = l[i-1];
    if(s[i-1] == 'W') { l[i]++; }
  }

  for(lint i=n-2;i>=0;i--) {
    r[i] = r[i+1];
    if(s[i+1] == 'E') { r[i]++; }
  }

  lint ans=n;
  for(lint i=0;i<n;i++) { ans = min(ans,r[i]+l[i]); }

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

Measured memory_bytes: 5380
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstring>

#define INF 1000000
using namespace std;

struct edge
{
  int to, nxt, w;
};

edge E[500005];
int head[10005], cnt = 0, dist[10005];
void add_edge(int u, int v, int w)
{
  E[cnt].to = v;
  E[cnt].w = w;
  E[cnt].nxt = head[u];
  head[u] = cnt++;
}

void dijkstra(int src)
{
  set <pair <int, int> > setds;
  for (int i = 0; i < 10005; i++)
  {
    dist[i] = INF;
  }
  setds.insert(make_pair(0, src));
  dist[src] = 0;
  while (!setds.empty())
  {
    pair<int, int> tmp = *(setds.begin());
    setds.erase(setds.begin());
    int u = tmp.second;
    for (int e = head[u]; ~e; e = E[e].nxt)
    {
      int v = E[e].to;
      int w = E[e].w;
      if (dist[v] > dist[u] + w)
      {
        if (dist[v] != INF)
        {
          setds.erase(setds.find(make_pair(dist[v], v)));
        }
        dist[v] = dist[u] + w;
        setds.insert(make_pair(dist[v], v));
      }
    }
  }
}

int main()
{
  memset(head, -1, sizeof(head));

  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    int v, deg;
    scanf("%d%d", &v, &deg);
    for (int j = 0; j < deg; j++)
    {
      int to, cost;
      scanf("%d%d", &to, &cost);
      add_edge(v, to, cost);
    }
  }
  dijkstra(0);
  for (int i = 0; i < n; i++)
  {
    printf("%d %d\n", i, dist[i]);
  }
}



Measured memory_bytes: 8768
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int left = 0, right = 0;

    for(int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0) {
            if (s[i] == '1') {
                right++;
            } else
            {
                left++;
            }
        } else {
            if (s[i] == '0') {
                right++;
            } else
            {
                left++;
            }
            
            
        }
        
        
    }
    if (left < right) {
        cout << left << endl;
    } else {
        cout << right << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 512
a,b,c,d=map(int,input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(x, y):
    return (x * y) // gcd(x, y)

e=lcm(c,d)


def k(a,b):
    return a//b


ans_h=k(b,c)+k(b,d)-k(b,e)-(k(a-1,c)+k(a-1,d)-k(a-1,e))

print(b-a+1-ans_h)

Measured memory_bytes: 38256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

const int MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll mod(ll i, ll j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

ll COM2(int n, int k) {
    ll ans = 1;
    REP(i, 1, k + 1) {
        ans *= ((ll(n) - ll(i) + 1) * modinv(i, MOD)) % MOD ;
        ans %= MOD;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;

    ll ans = mod(modpow(2, n, MOD) - 1, MOD);
    //COMinit();
    ans = mod(ans - COM2(n, a), MOD);
    ans = mod(ans - COM2(n, b), MOD);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (r, d, x) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    fun f(x: Int) = r * x - d

    for (i in 0 until 10) {
        var X = f(x)
        println(X)
        x = X
    }
}


Measured memory_bytes: 36044
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String a[] = new String[h];
        for(int i = 0; i < h; i++){
           a[i] = sc.next();
        }
        
        for(int i = 0; i < w+2; i++){
           System.out.print("#"); 
        }
        System.out.println("");
        
        for(int i = 0; i < h; i++){
           System.out.println("#"+a[i]+"#"); 
        }
        
        for(int i = 0; i < w+2; i++){
           System.out.print("#"); 
        }
        System.out.println("");
    }
}

Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <iostream>

typedef long long ll;

using namespace std;

#define N (200000)

int A[N];
int B[N];

int main() {
	int a, b, m;
	scanf("%d%d%d", &a, &b, &m);
	for (int i = 0; i < a; i++) {
		scanf("%d", A + i);
	}
	for (int i = 0; i < b; i++) {
		scanf("%d", B + i);
	}
	int ans = *min_element(A, A + a) + *min_element(B, B + b);
	for (int i = 0; i < m; i++) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		x--;
		y--;
		ans = min(ans, A[x] + B[y] - c);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1024
//Lin Gengxian Shunji
// Parallelism 08-144505
// Not sure if it is correct, the online judge has no test cases

#include <complex>
#include <cmath>
#include <iostream>
#include <cstdio>

using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

double e = 1e-11;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    xy_t A = xy_t(x2 - x1, y2 - y1);
    xy_t B = xy_t(x4 - x3, y4 - y3);

    double dot_prod =  abs(dot_product(A, B));
    double AB_magnitude = abs(A) * abs(B);
    
    if (dot_prod <= AB_magnitude + e && dot_prod >= AB_magnitude - e) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1248
/*  ex3_3
    person_A  */
#include<stdio.h>
int main(void){
    int decimalNumber,baseNumber,times=1;
    //N,Kの入力
    scanf("%d%d",&decimalNumber,&baseNumber);
    //十進数decimalNumberを余りを無視しながらdecimalNumberが基数baseNumber以上である限り、基数で割り続けその回数+1(times)を最終的な出力とする。
    while(decimalNumber>=baseNumber){
        decimalNumber/=baseNumber;
        times++;
    }
    printf("%d\n",times);
    return 0;
}

Measured memory_bytes: 128