akhauriyash/Code-Regression huggingface dataset:
mod = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort(key=lambda x:-abs(x))

if N==K:
    ans = 1
    for i in range(N):
        ans *= A[i]
        ans %= mod
elif A[K-1]==0:
    ans = 0
else:
    p = []
    p_ = []
    n = []
    n_ = []
    for i in range(N):
        a = A[i]
        if i<K:
            if a>0:
                p.append(a)
            elif a<0:
                n.append(a)
        else:
            if a>0:
                p_.append(a)
            elif a<0:
                n_.append(a)
    if len(n)%2==0:
        ans = 1
        for a in n:
            ans *= a
            ans %= mod
        for a in p:
            ans *= a
            ans %= mod
    else:
        if len(p)+len(p_)==0:
            if len(n)+len(n_)==N:
                n += n_
                ans = 1
                for i in range(K):
                    ans *= n[-i-1]
                    ans %= mod
            else:
                ans = 0
        else:
            if len(p)==0:
                n.pop()
                ans = p_[0]
                for a in n:
                    ans *= a
                    ans %= mod
            else:
                cand = []
                ap = p.pop()
                if p_:
                    cand.append([ap,p_[0]])
                an = n.pop()
                if n_:
                    cand.append([an,n_[0]])
                if len(cand)==2:
                    ap1,ap2 = cand[0]
                    an1,an2 = cand[1]
                    ans = max(ap1*ap2,an1*an2)%mod
                    for a in n:
                        ans *= a
                        ans %= mod
                    for a in p:
                        ans *= a
                        ans %= mod
                else:
                    ans = cand[0][0]*cand[0][1]%mod
                    for a in n:
                        ans *= a
                        ans %= mod
                    for a in p:
                        ans *= a
                        ans %= mod
print(ans)

Measured memory_bytes: 114648
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    sc.close();

    String ans = "No";
    if (N % 2 == 0) {
      String s = S.substring(0, N / 2);
      if (S.equals(s + s)) ans = "Yes";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc102_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if(n % 2 == 0){
                WriteLine(n);
            }else{
                WriteLine(n*2);
            }
        }
    }
}

Measured memory_bytes: 11092
import numpy as np
import math

n = int(input())
max = math.ceil(np.sqrt(n))
sum_list = []
for x in range(1,max):
  if x**2 + x + 4 > n:
    break
  for y in range(1,max):
    if x**2 + y**2 + x*y + x + y + 1 > n:
      break
    for z in range(1,max):
      a = x**2 + y**2 + z**2 + x*y + y*z + z*x 
      if a > n:
        break
      sum_list.append(a)
line = [0 for i in range(n+1)]
for i in sum_list:
  line[i] += 1
  
for i in range(1,n+1):
  print(line[i])

Measured memory_bytes: 37076
using System;

namespace Watch
{
    class Watch
    {
        public static void Main()
        {
            int sec = int.Parse(Console.ReadLine());
            int h = sec / 3600;
            int m = (sec - h * 3600) / 60;
            int s = sec - 3600 * h - 60 * m;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}



Measured memory_bytes: 17940
#include<iostream>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  int ans = 0;
  if (l >= 0){
    for (int i = 1; i < n; i++){
      ans += l+i;
    }
  }
  else if (l < 0 && n+l > 0){
    for (int j = 0; j < n; j++){
      if (l+j != 0)
        ans += l+j;
    }
  }
  else{
    for (int k = 0; k < n-1; k++){
      ans += l+k;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,P=0,W=0,G=0,Y=0;;
  cin >> N;
  for (int i=0 ; i < N ; i++) {
    string color;
    cin >> color ;
	
    if(color == "P"){
      P = 1 ;
    }
    else if(color == "W"){
      W = 1 ;
    }
    else if(color == "G"){
      G = 1 ;
    }
    else if(color == "Y"){
      Y = 1 ;
    }    
  }
  int C = P + W + G + Y;
  if(C == 4){
    cout << "Four" << endl;
  }
  else if(C == 3){
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=1005;
const int MOD= 1000000007;
int n,k,m;
string s;
vector<string>v;
int dp[N][N];
int solve(int x,int y){
	if(x<0||y<0||v[x][y]=='#')return 0;
	if(x==0&&y==0)return 1;
	int &res =dp[x][y];
	if(res!=-1){
		return res;
	}
	res=(solve(x-1,y)%MOD);
	res=(res%MOD+solve(x,y-1)%MOD)%MOD;
	return res;
}
int main(){

	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		cin >> s;
		v.push_back(s);
	}
	memset(dp,-1,sizeof dp);
	cout << solve(n-1,m-1);

	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

int main(){
  int N,M;
  cin >> N >> M;
  vector<mint> A(N),B(M);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A[i] = a;
  }
  for(int i=0;i<M;i++){
    int b;
    cin >> b;
    B[i] = b;
  }
  
  vector<mint> C = convolution(A,B);
  for(int i=0;i<N+M-1;i++) cout << C[i].val() << " ";
  return 0;
}


Measured memory_bytes: 19004
fun main(args: Array<String>) = println(run {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }

    val min = (a.sum()/(4.0*m))
    if (a.filter { it.toDouble() >= min }.count() >= m) "Yes" else "No"
})

Measured memory_bytes: 36084
import queue

def resolve():
    k = int(input())

    q = queue.Queue()
    for i in range(1,10):
        q.put(i)

    for i in range(k):
        x = int(q.get())
        mod = x % 10

        if mod != 0:
            q.put(10 * x + mod - 1)
        
        q.put(10 * x + mod)

        if mod != 9:
            q.put(10 * x + mod + 1)

    print(x)
    
resolve()

Measured memory_bytes: 12456
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int i,ans(0),n(1000);
    string s;
    cin >> i;
	for(;;){
      if(i <= n){
        cout << n - i;
        break;
      }
      n += 1000;
    }
}
   


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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

int main(){
	double db;
	ll a;
	cin >> a >> db;
	ll b = round(db*100);
	
	cout << a*b/100 << endl;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define N 100002
#define mod 1000000007
#define lld long long 
int main()
{
    string s; cin>>s;
    int flag=0;
    if(s[2]==s[3]&&s[4]==s[5])flag=1;
    flag==1?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long a,b,c;
    cin>>a>>b>>c;
    if(a<b && b<c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
    
}



Measured memory_bytes: 3080
#include <cstdio>

int N, M;

void solve()
{
	int i;
	double res = 0;
	double mi = 1;
	for(i=0; i<M; i++)
		mi *= 1.0/2;
	res += 1.0*(N-M)*100*1/mi;
	res += 1900.0*M*mi*1.0/mi/mi;
	printf("%d\n", (int)(res+0.00000001));
}

int main()
{
	scanf("%d%d", &N, &M);
	solve();
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
string grid[6];
string cur_grid[6];
int main(){
  int H;
  int W;
  int K;
  cin >> H >> W >> K;
  for(int i = 0; i < H; i++){
    cin >> grid[i];
  }
  int ans = 0;
  for(int bit_set_h = 0; bit_set_h < (1 << H); bit_set_h++){
    for(int bit_set_w = 0; bit_set_w < (1 << W); bit_set_w ++){
      for(int i = 0; i < H; i++){
        cur_grid[i] = grid[i];
      }
      for(int i = 0; i < H; i++){
        if(((bit_set_h >> i) & 1) == 1){
          for(int j = 0; j < W; j++){
            cur_grid[i][j] = '.';
          }
        }
      }
      for(int i = 0; i < W; i++){
        if(((bit_set_w >> i) & 1) == 1){
          for(int j = 0; j < H; j++){
            cur_grid[j][i] = '.';
          }
        }
      }

      int cur_black = 0;
      for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if(cur_grid[i][j] == '#'){
            cur_black ++;
          }
        }
      }
      if(cur_black == K){
        ans ++;
      }
    
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
  ll N, s[5];
  cin >> N;
  
  for(int i = 0; i < 5; i++) {
    cin >> s[i];
  }
  ll m = s[0];
  ll ans = 0;
  ll p = 0;
  for(int i = 1; i < 5; i++) {
    if(m > s[i]) { m = s[i]; p = i; }
  }
  if(m < N){
  ans += p;
  if(N % m == 0)
  ans += N / m;
  else 
  ans += N / m + 1;

  ans += 4 - p;

  }else {
    ans = 5;
  }
  cout << ans;



  return 0;
}

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


int dp[100][10001];



int main(){
    int N, W;
    cin >> N >> W;
    vector<pair<int, int>>  v_w(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v_w.at(i).first >> v_w.at(i).second;
    }

    for (int i = 0; i < N; i++)
    {
       for (int j = 1; j <= W; j++)
       {
           if (i == 0){
               if (j >= v_w.at(i).second){
                   int x = j / v_w.at(i).second;
                   dp[i][j] = v_w.at(i).first * x;
               }

           }

           else {
              if (j-v_w.at(i).second >= 0) dp[i][j] = max(dp[i-1][j], dp[i][j-v_w.at(i).second] + v_w.at(i).first);
              else dp[i][j] = dp[i-1][j];
           }

       }
       
    }
    
    cout << dp[N-1][W] << endl;
}


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

typedef long long ll;
const int inf = 1e9;

long long t;
string alphabet = "zabcdefghijklmnopqrstuvwxy";
string res;

int main(){
	cin>>t;
	res = "";
	while(t){
		int r = (t % 26);
		t /= 26;
		if(r == 0)t--;
		res += alphabet[r];
	}
	reverse(res.begin(), res.end());
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int d,n,b;
double pt;
const int maxn = 110;
double x[maxn],y[maxn];

int main()
{
	scanf("%d%d%d",&d,&n,&b);
	double ftd = d, ftb = b,ftn = n;
	for (int i=1; i<=n; ++i)
	{
		int tx, ty;
		scanf("%d%d",&tx,&ty);
		x[i] = tx;y[i] = ty;
	}
	double ansv = 100000000000000;
	for (int i=b; i>=0; --i)
	{
		//printf("%d\n",i);
		int tag = 0;
		double fnh = 0;
		double aniv = ansv;
		ftn = i+1;
		pt = ftd/((double)i+1);
		double dpt = 0;
		double nh = 0;
		for (int j=1; j<=n; ++j)
		{
			double ftx = x[j],fty = y[j];
			while (true)
			{
				if (ftx-pt<0) break;
				else
				ftx-=pt;
			}
		//	printf("%.6f\n",ftx);
			if (ftx == 0) 
			{
				tag = 1;break;
			} 
		//	printf("%.5f\n",ftx);
			fnh =-( fty * ftd * ftd/(ftx * (ftx-ftd/ftn) * 4 * ftn*ftn));
		//	printf("%.5f\n",fnh);
			if (fnh>nh) nh = fnh;
		}
	//	if (!tag)
		//	printf("%.5f\n",aniv);
		if (!tag)
		{
			double av;
			double stdh = ftd/(4*(i+1));
		//	printf("%.5f %.5f\n",nh,stdh);
			if (nh<stdh)
			{
				nh = stdh;
				av = sqrt(2*nh+ftd*ftd/(8*nh*ftn*ftn));
			//	av = sqrt(ftd/(i+1));
			}
			else
				av = sqrt(2*nh+ftd*ftd/(8*nh*ftn*ftn));
			if (av<ansv) ansv = av;
		}
	}
	printf("%.5f",ansv);
	return 0;
}

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

int main(){
  while(1){
    int M,T,P,R;
    cin>>M>>T>>P>>R;
    if(M==0 && T==0 && P==0 && R==0)
      break;

    int cp[50],tt[50],pt[50][10];
    for(int i=0; i<T; i++){
      cp[i] = tt[i] = 0;
      for(int j=0; j<P; j++){
        pt[i][j] =0;
      }
    }
    for(int i=0; i<R; i++){
      int m,t,p,j;
      cin>>m>>t>>p>>j;
      if(j==0){
        cp[t-1]++;
        tt[t-1] += (m+pt[t-1][p-1]);
      }
      else{
        pt[t-1][p-1] += 20;
      }
    }

    int tnow, tpre = -1;
    bool flg[50];
    for(int i=0; i<T; i++)
      flg[i] = false;

    for(int i=0; i<T; i++){
      tnow =-1;
      for(int j=0; j<T; j++){
        if(flg[j])
          continue;

        if(tnow==-1){
          tnow = j;
        }
        else{
          if(cp[j]>cp[tnow] || (cp[j]==cp[tnow] &&tt[j]<=tt[tnow])){
            tnow = j;
          }
        }
      }

      if(tpre!=-1){
        if(cp[tnow]==cp[tpre] && tt[tnow]==tt[tpre])
          cout<<'=';
        else
          cout<<',';
      }
      cout<<tnow+1;

      flg[tnow] = true;
      tpre = tnow;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
d,g = map(int,input().split())
P, C = [], []
probs = set([i for i in range(d)])
for _ in range(d):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
res = float('inf')
for i in range(2**d):
    tmp = []
    score = 0
    cnt = 0
    for j in range(d):
        if ((i>>j)&1):
            tmp.append(j)
    for k in tmp:
        score += (k+1)*100*P[k] + C[k]
        cnt += P[k]    
    if score >= g:
        res = min(res, cnt)
    else:
        x = list(probs - set(tmp))
        x.sort(reverse=True)
        for x_ in x:
            for _ in range(P[x_]):
                score += (x_+1)*100
                cnt += 1
                if score >= g:
                    res = min(res, cnt)
                    break
print(res)        
        

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

int main(){
  string n;
  cin >> n;
  bool check = false;
  for (int i=0; i<n.size(); i++){
    if (n[i] == '7') check = true;
  }
  if (check) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define Nmax 3005

using namespace std;

const long long INF=1e18l;
ifstream f("1.in");
ofstream g("1.out");

const int mod=1e9+7;

void add_self(int &a, int b)
{
    a+=b;
    if(a >= mod) a-=mod;
}

void sub_self(int &a, int b)
{
    a-=b;
    if(a < 0) a+=mod;
}

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    vector <int> dp(k+1);
    dp[0]=1;
    for (int child=0; child < n; child++)
    {
        int up_to;
        scanf("%d", &up_to);
        vector <int> fake(k+1);
        for (int used=k; used>=0; used--)
        {
            int tmp=dp[used];
            int L=used+1;
            int R=used+min(up_to, k-used);
            if(L<=R)
            {
                add_self(fake[L], tmp);
                if(R+1<=k) sub_self(fake[R+1], tmp);
            }
        }
        int ps=0;
        for (int i = 0; i <= k; i++)
        {
            add_self(ps, fake[i]);
            add_self(dp[i], ps);
        }
    }
    cout << dp[k];
    return 0;
}


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

using namespace std;

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

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{	
        int n; cin >> n;
        vector<int> cnt(9, 0);
        for (int i = 0; i < n; ++i)
        {
                int x; cin >> x;
                if (x >= 3200) cnt[8]++;
                else
                {
                        cnt[x / 400]++;
                }
        }
        if (cnt[8] == 0)
        {
                int res = 0;
                for (int i = 0; i < 8; ++i)
                {
                        if (cnt[i] != 0) res++;
                }
                cout << res << ' ' << res;
        }
        else
        {
                int res = 0, ct = 0, pl = cnt[8];
                for (int i = 0; i < 8; ++i)
                {
                        if (cnt[i] != 0) ct++;
                        if (cnt[i] == 0 && cnt[8] > 0)
                        {
                                cnt[i]++;
                                cnt[8]--;
                        }
                }
                cout << max(1, ct) << ' ' << ct + pl;
        }
        
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}

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

using namespace std;

int N;
vector<double> p;
vector< vector<int> > G, rG;
vector<int> cmp;

void dfs(int v, vector<bool>& used, vector<int>& order)
{
  if(used[v]) return;
  used[v] = true;
  for(int u : G[v]) dfs(u, used, order);
  order.push_back(v);
}

void rdfs(int v, const int& cnt)
{
  cmp[v] = cnt;
  for(int u : rG[v]) {
    if(cmp[u] == -1) rdfs(u, cnt);
  }
}

int scc()
{
  cmp.clear(); cmp.resize(N, -1);
  vector<bool> used(N, false);
  vector<int> order;
  for(int v = 0; v < N; v++) dfs(v, used, order);
  reverse(order.begin(), order.end());
  int cnt = 0;
  for(int i = 0; i < order.size(); i++) {
    if(cmp[order[i]] == -1) rdfs(order[i], cnt++);
  }
  return cnt;
}

int main()
{
  while(cin >> N, N) {
    p.clear(); p.resize(N);
    G.clear(); G.resize(N);
    rG.clear(); rG.resize(N);
    for(int i = 0; i < N; i++) {
      int m; cin >> p[i] >> m;
      for(int j = 0; j < m; j++) {
	int a; cin >> a; a--;
	G[i].push_back(a);
	rG[a].push_back(i);
      }
    }
    
    int n = scc();

    vector<double> P(n, 1.0);
    for(int i = 0; i < N; i++) P[cmp[i]] *= p[i];

    vector<bool> ine(n, false);
    for(int u = 0; u < N; u++) {
      for(int v : G[u]) ine[cmp[v]] = ine[cmp[v]] | (cmp[v] != cmp[u]);
    }
    
    double ans = 1.0;
    for(int i = 0; i < n; i++) {
      if(!ine[i]) ans *= (1.0 - P[i]);
    }    
    printf("%.10f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3356
// 16/06/2020 // 7:15 PM // 

#include <bits/stdc++.h>

using namespace std;

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define pb push_back
#define ll long long

const int MAXN  = 20;
const ll INF   = 0x3f3f3f3f3f3f3f3f;
const int MAXNN = 65536 + 5; // 2^16 + 5 

int n, max_mask; 
ll a[MAXN][MAXN], pts[MAXNN];
vector<ll> memo;

void pre_calc(){
	for(int mask=1; mask<=max_mask; mask++){   // O(2^n * n^2)
		for(int i=0; i<=n; i++){
			if(((1<<i)&mask) == 0) continue;
			
			for(int j=i+1; j<=n; j++)
				if(((1<<j)&mask)!=0)
					pts[mask] += a[i][j];
		}
	}
}

void solve(){
	
	memo[max_mask] = 0;
	for(int mask_total=max_mask-1; mask_total>=0; mask_total--){
		vector<int> disp;
		for(int k=0; k<n; k++){
			if(((1<<k)&mask_total)==0) disp.pb(k);
		}
		int max_temp = (1<<((int)disp.size()))-1; 
		for(int tmask=1; tmask<=max_temp; tmask++){
			int gp_mask = 0;
			for(int k=0; k<(int)disp.size(); k++){
				if(((1<<k)&tmask)!=0) gp_mask += (1<<disp[k]);
			}
			
			memo[mask_total] = max(memo[mask_total], pts[gp_mask] + memo[mask_total|gp_mask]);
		}
	}
	
}

int	main(){
	fast_io;
	
	cin >> n; 
	
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> a[i][j];
	
	max_mask = (1<<n)-1;
	
	memo.resize(max_mask+1, -INF);
		
	pre_calc();
	solve();
	
	cout << memo[0] << endl;
	
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<int> wa(0), su(0);
    rep(i, 1, 31) rep(j, 31) if(A * i * 100 + B * j * 100 <= F)
        wa.push_back(A * i + B * j);
    rep(i, F) rep(j, F) if(C * i + D * j <= F) su.push_back(C * i + D * j);
    double cma = -1;
    int wma = 0, sma = 0;
    for(auto w : wa) {
        for(auto s : su) {
            if(w * 100 + s > F) continue;
            if(w * E < s) continue;
            if(chmax(cma, 100.0 * s / double(w * 100 + s))) {
                wma = w;
                sma = s;
            }
        }
    }
    cout << wma * 100 + sma << " " << sma << endl;
}

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

int main() {
  ll a,b,c; cin>>a>>b>>c;
  if(c-a-b<=0){cout<<"No";}
  else if((c-a-b)*(c-a-b)>a*b*4){cout<<"Yes";}
  else{cout<<"No";}//cout<<a*b;  
}
   

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M,L,R;
  cin >> N;
  map<int,int> D[N];
  vector<int> LR[N], counter1(N), d(N);
  set<pair<int,int>> counter2;
  for (cin >> M; M; counter1[R]++, M--) {
    cin >> L >> R >> D[--L][--R];
    LR[L].push_back(R);
  }
  for (int i = 0; i < N; i++) {
    counter2.insert({counter1[i],i});
  }
  while (!counter2.empty()) {
    if (counter2.begin()->first) {
      cout << "No";
      return 0;
    }
    int p = counter2.begin()->second;
    counter2.erase(counter2.begin());
    for (int lr : LR[p]) {
      counter2.erase({counter1[lr]--,lr});
      counter2.insert({counter1[lr],lr});
      if (d[lr] && D[p][lr]+d[p] != d[lr]) {
        cout << "No";
        return 0;
      } else {
        d[lr] = D[p][lr]+d[p];
      }
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 27708
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

vector<vector<int> > to;
vector<P> id;
map<P,int> mp;
vector<bool> visit;

void dfs(int v, int pc = -1) {
    if (visit[v]) return;
    
    visit[v] = true;
    int c = 1;
    for (auto u: to[v]) {
        if (c == pc) ++c;
        //cout << "v: " << v << " u: " << u << " c: " << c << " pc: " << pc << endl;
        if (v < u && mp[P(v,u)]==-1) {
            mp[P(v,u)] = c;
            dfs(u,c);
            ++c;
        }
        if (u < v && mp[P(u,v)]==-1) {
            mp[P(u,v)] = c;
            dfs(u,c);
            ++c;
        }
    }
    return;
}

int main() {
    int n;
    cin >> n;
    to.resize(n);
    id.resize(n-1);
    visit.resize(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        --a, --b;
        to[a].pb(b);
        to[b].pb(a);
        if (a>b) swap(a,b);
        id[i] = P(a,b);
        mp[id[i]] = -1;
    }
    int maxc = 0;
    
    rep(i,n) {
        maxc = max(maxc, (int)to[i].size());
    }
    dfs(0);
    cout << maxc << endl;
    rep(i,n-1) {
        cout << mp[id[i]] << endl;
    }
    return 0;
}













Measured memory_bytes: 14976
n,k=map(int,input().split())
a=list(map(int,input().split()))
visit=[0 for i in range(n)]
goal,loop=[],[]
now=0

while visit[now]!=2 :
    if visit[now]==0 :
        goal.append(now)
    else :
        loop.append(now)
    visit[now]+=1
    now=a[now]-1

if len(goal)>k :
    print(goal[k]+1)
else :
    res=len(goal)-len(loop)
    print(loop[(k-res)%len(loop)]+1)

Measured memory_bytes: 34008
def solve(N):
    if N== 0:
        return ""
    if N == 1:
        return 'a'
    N -= 1
    A = 'abcdefghijklmnopqrstuvwxyz'
    N, r = divmod(N, 26)
    return solve(N) + A[r]
N = int(input())
print(solve(N))


Measured memory_bytes: 9164
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
if N%min(A,B,C,D,E) == 0:z = 4
else:z = 5
print(int(z+N/min(A,B,C,D,E)))

Measured memory_bytes: 3064
f=lambda:map(int,input().split())
n,k,l=f()
def root(x):
  while p[x]>=0: x=p[x]
  return x
def unite(x,y):
  x,y=root(x),root(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
def g(x):
  global p
  p=[-1]*n
  for _ in range(x):
    a,b=f()
    unite(a-1,b-1)
  return [root(i) for i in range(n)]
from collections import *
z=[*zip(g(k),g(l))]
C=Counter(z)
print(*[C[t] for t in z])

Measured memory_bytes: 53796
#何曜日かを入力
weekday = input()
#日曜日までの日数を出力
if weekday == "SUN":
    print(7)
elif weekday == "MON":
    print(6)
elif weekday == "TUE":
    print(5)
elif weekday == "WED":
    print(4)
elif weekday == "THU":
    print(3)
elif weekday == "FRI":
    print(2)
elif weekday == "SAT":
    print(1)

Measured memory_bytes: 8868
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
 
using namespace std;
 
typedef long long int ll;
typedef pair <int, int> ii;

const int MAXN = 1010;

int pset[MAXN];
int findset(int x){ if(x!=pset[x]) pset[x] = findset(pset[x]); return pset[x]; }
void unionset(int x, int y){ x = findset(x), y = findset(y); pset[x] = y; }
bool sameset(int x, int y){ return findset(x) == findset(y); }


int main(){
	
	int n; string s;
	cin >> n >> s;
	
	int ans = 0;
	rep(i, 0, n){
		rep(j, i+1, i+2){
			rep(k, j+1, j+2){
				if(s[i]=='A' && s[j]=='B' && s[k]=='C')
					ans++;
			}
		}
	}
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
ll dx[8]={-1,-1,-1,0,0,1,1,1};
ll dy[8]={-1,0,1,-1,1,-1,0,1};
int main()
{
     ll r,c;
     char arr[55][55];
     cin>>r>>c;
     for(int i=0;i<=r+1;i++)
     {
         for(int j=0;j<=c+1;j++)
         {
             arr[i][j]='.';
         }
     }
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             cin>>arr[i][j];
         }
     }
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             ll  cnt=0;
             if(arr[i][j]=='.')
             {
                 for(int k=0;k<8;k++)
                 {
                     ll x=dx[k]+i;
                     ll y=dy[k]+j;
                     if(arr[x][y]=='#')
                        cnt++;
                 }
                 arr[i][j]=cnt+48;
             }
         }
     }
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             cout<<arr[i][j];
         }
         cout<<endl;
     }
}


Measured memory_bytes: 3616
//============================================================================
// Name        : Hello5.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int A;
	int B;
	int C;
	cin >>A>>B>>C;
	if(A==B&&A!=C ||A==C&&A!=B ||B==C&&B!=A)
	{
		cout<<"Yes"
				<<endl;
	}
	else{cout<<"No"
	<<endl;}




	return 0;
}


Measured memory_bytes: 256
N = int(raw_input())
S = raw_input()

if N%2 == 1:
    print "No"
else:
    is_same=True
    for i in xrange(N/2):
        if S[i] != S[i+N/2]:
            print "No"
            is_same = False
            break
    if is_same:
        print "Yes"

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define inf (1LL<<61)
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define int long long
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >  
#define mod 1000000007
#define ll long long

vector<int> g[100005];
int dp[100005][2];
void dfs(int s,int p)
{
    bool ch = 1;
    dp[s][1] = 1;
    dp[s][0] = 1;
    for(auto it:g[s])
    {
        if(it!=p)
        {
            dfs(it,s);
            dp[s][0] = (dp[s][0] * ((dp[it][1] + dp[it][0])%mod))%mod;
            dp[s][1] = (dp[s][1] * dp[it][0])%mod;
        }
    }
}
int32_t main()
{
    IOS;
   
    int n;
    cin>>n;
    for(int i = 0;i < n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,1);
    cout<<(dp[1][0] + dp[1][1])%mod;
    return 0;
}

Measured memory_bytes: 14208
n, x, y = map(int, input().split())

ans = [0] * (n-1)
for i in range(n-1):
  for j in range(i+1, n):
    d = min(j-i, abs(i-x+1)+abs(j-y+1)+1)
    ans[d-1] += 1

for a in ans:
    print(a)
 


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

Measured memory_bytes: 384
n,k=map(int,input().split())
l=list(map(int,input().split()))
#配列をソートして大きい数字から並べる
l.sort()
l.reverse()

#出力用のans
ans=0

#for文で配列から大きい数値をk個取得してansに代入して足し算
for i in range(k):
  ans += l[i]
  
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n,t,a,b,c,d,e,cnt=0;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;
    cin>>a>>b;
    if(b>=a){
        cout<<"unsafe"<<endl;
    }
    else cout<<"safe"<<endl;


}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long


using namespace std;

int MOD = 1e9 + 7;
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> g;
  for(int i = 0 ; i < H ; i++ ){
    string line;
    cin >> line;
    g.push_back(line);
  }
  vector<vector<int> > dp(H+1, vector<int> (W+1,0 ));
  for( int i = 0 ; i < H && g[i][0] == '.' ; i++ )  dp[i][0] = 1;
  for( int i = 0 ; i < W && g[0][i] == '.' ; i++ )  dp[0][i] = 1;
  for( int i = 1 ; i < H ; i++ ){
    for( int j = 1 ; j < W ; j++ ){
      if( g[i][j] == '#') {
        dp[i][j] = 0;
        continue;
      }
      else{
        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
      }
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}


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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define v(t) vector<t>
#define vv(t) vector<vector<t>>
#define vn(t,n,val) vector<t>(n,val)
#define vvn(t,r,c,val) vector<vector<t>>(r, vector<t>(c,val))
#define vvv(t) vector<vector<vector<t>>>
#define vvvn(t,l,b,h,val) vector<vector<vector<t>>>(l,vector<vector<t>>(b,vector<t>(h)))

int main() {
	sp;

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

	int k;
	cin>>k;

	// vector<long long> a = {1,2,3,4,5,6,7,8,9};
	// int i = 0;
	// while(a.size() < k){
	// 	int n = log10(a[i]);
	// 	long long pow10 = powl(10,n);
	// 	int val = a[i]/pow10;
	// 	if(val != 1) a.emplace_back((val-1)*pow10*10ll + a[i]);
	// 	a.emplace_back(val*pow10*10ll + a[i]);


	// }

	vector<string> a = {"1","2","3","4","5","6","7","8","9"};
	int i = 0;
	int l;
	string t;

	while(a.size() < k){
		if(a[i].back() != '0'){
			t = a[i];
			t.push_back(a[i].back()-1);
			a.emplace_back(t);
		}
		

		t = a[i];
		t.push_back(a[i].back());
		a.emplace_back(t);

		if(a[i].back() != '9'){
			t = a[i];
			t.push_back(a[i].back() + 1);
			a.emplace_back(t);
		}


		// a.emplace_back(a[i].back())


		// l = a[i].size();
		// string t;
		// t = a[i];
		// if(a[i][l-1] != '1'){
		// 	t.push_back(a[i][l-1]-1);
		// 	a.emplace_back(t);
		// }
		// t = a[i];
		// t.push_back(a[i][l-1]);
		// a.emplace_back(t);
		// t = a[i];
		// if(a[i][l-1] != '9'){
		// 	t.push_back(a[i][l-1]+1);
		// 	a.emplace_back(t);
		// }
		i++;
	}

	// for(auto&x: a) cout<<x<<" ";
	// 	cout<<"\n";

	cout<<a[k-1];

  	return 0;
}

Measured memory_bytes: 6916
k,n = list(map(int,input().split()));
A = list(map(int,input().split()));

A.sort();

Am = [0]*n;
for i in range(n-1) :
    Am[i] = A[i+1] - A[i];
Am[n-1] = k-A[n-1] + A[0];

Am.sort();

print(sum(Am)-Am[n-1]);

Measured memory_bytes: 26444
W,H,N = map(int,input().split(" "))
x = [0]*N
y = [0]*N
a = [0]*N
for i in range(N):
    x[i],y[i],a[i]=map(int,input().split(" "))

i = 0
rx = W
ry = H
lx = 0
ly = 0
while i < N:
    if a[i] == 1:
        lx = max(x[i],lx)
    elif a[i] == 2:
        rx = min(x[i],rx)
    elif a[i] == 3:
        ly = max(y[i],ly)
    elif a[i] == 4:
        ry = min(y[i],ry)
    i += 1

print(max(rx-lx,0)*max(ry-ly,0))

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

#define ll long long int

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll num, a = 7, sum = 1;
  cin >> num;
  if (num % 5 == 0 || num % 2 == 0)
    cout << "-1" << '\n';
  else{
    while (a > 0){
      if (a < num){
	a = a * 10 + 7;
	sum++;
      }
      else
	a %= num;
    }
    cout << sum << "\n";
  }
  return 0;
}


Measured memory_bytes: 3660
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]

for s in S:
    minC = 10**10
    idx = 0
    for i, c in enumerate(C):
        d = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if d < minC:
            minC = d
            idx = i + 1
    print(idx)




Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <functional>
using namespace std;

typedef long long ll;

ll k;
ll res[51];

int main() {
	cin >> k;
	ll n = 50;
	for (ll i = 0; i < n; i++) res[i] = i + k/n;
	for (ll i = 0; i < k%n; i++) {
		for (ll j = 0; j < n; j++) {
			if (i == j) res[j] += n;
			else res[j] -= 1;
		}
	}
	cout << n << endl;
	for (ll i = 0; i < n; i++) {
		cout << res[i];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 8);
int main(){
  int n;cin>>n;
  double x1, y1, x2, y2, sx, sy;
  double ans=0;
  cin>>x1>>y1;
  sx=x1;sy=y1;
  while(--n){
    cin>>x2>>y2;
    ans += (x1*y2-x2*y1)*0.5;
    x1=x2;y1=y2;
  }
  ans += (x1*sy-sx*y1)*0.5;
  cout<<fixed<<setprecision(1)<<ans<<endl;
  return 0;
}



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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll q;
    cin >> q;
    ll l[q], r[q];
    rep(i, q) { cin >> l[i] >> r[i]; }
    int num = 200000;
    bool is_prime[num] = {};
    memset(is_prime, 1, sizeof is_prime);
    is_prime[0] = false;
    is_prime[1] = false;
    repd(i, 2, sqrt(num) + 1) {
        if (is_prime[i]) {
            ll index = i * 2;
            while (index < num) {
                is_prime[index] = false;
                index += i;
            }
        }
    }

    ll sum_prime[num];
    sum_prime[0] = 0;
    repd(i, 1, num) {
        sum_prime[i] = sum_prime[i - 1];
        if (is_prime[i] && i % 2 == 1 && is_prime[(i + 1) / 2]) {
            sum_prime[i]++;
        }
    }

    rep(i, q) {
        ll ans = sum_prime[r[i]] - sum_prime[l[i] - 1];
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
	fastio;
	
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];

	ll ans=0;
	for(int i=1; i<n; i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}

	cout<<ans<<nl;

	 

    
}

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

int main()
{
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int count = 0, i=0;
  while(a[i] % 2 == 0)
  {
    a[i] /= 2;
    count++;
    i++;
    if(i >= n) i = 0;
  }
  cout << count / n << endl;
  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> x(n),y(n),vec(n);
  rep(i,n){
    cin>>x[i]>>y[i];
    vec[i]=i;
  }
  double ans=0,cnt=0;
  do{
    rep(i,n-1){
      double dx=x[vec[i]]-x[vec[i+1]],dy=y[vec[i]]-y[vec[i+1]];
      ans+=sqrt(dx*dx+dy*dy);
    }
    cnt++;
  }while(next_permutation(all(vec)));
  ans/=cnt;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 5e6 + 3;
string a;
ll m,d;
stringstream ss;
ll go(string a)
{
    ll s;
    ss << a;
    ss >> s;
    ss.clear();
    return s;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    m = go(a.substr(5,2));
    d = go(a.substr(8,2));
    if(m <= 4) cout<<"Heisei";
    else
        cout<<"TBD";
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    ld A, B; cin >> A >> B;
    ld ans = A * B;
    cout << (ll)ans << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1;i <= n;i++)
	{
		//2,3,5,7,11,13,17,19,23,29,31
		//(2,3,*),(2,5,7..19),(2,7,11.13)
		//(3,5,7..13)
		//(2,2,2,3..23)
		//(3,3,3,2.5.7)
		int yk = 1;
		int ii = i;
		for(int j = 3;j < 14;j+=2)
		{
			int im = ii % j;
			if(im == 0)
			{
				int cc = 0;
				while(ii > 0 && ii % j == 0)
				{
					ii /= j;
					cc++;
				}
				yk *= cc + 1;
			}
		}
		if(yk == 8)
		{
			cnt++;
		}
	}
    cout << cnt << endl;
	return 0;
}


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

int main()
{
    int m, n, o, i, j;
    char ch;
    cin >> m;
    cin >> n;
    cin >> o;
    if (m>o && n<o){
        cout << "Yes";
    }
    else if (n>o && m<o){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
string s;
int main(){
	cin>>s;
	cout<<string(int(s.size()),'x');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n; cin >> n;
  map<string,int> mp;
  vector<string> t;
  string ans;
  int cnt = -1;;
  rep(i,n){
    string s; cin >> s;
    mp[s]++;
    cnt = max(cnt,mp[s]);
  }

  for(auto x : mp){
    if(x.second == cnt) t.pb(x.first);
  }

  sort(all(t));
  for(auto x : t){
    cout << x << endl;
  }



  return 0;
}


Measured memory_bytes: 26096
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
map<char, char> mp;
map<char, char> mp2;

int main(){
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    bool f=true;
    for(char c='a';c<='z';c++){
        mp[c]='A';
        mp2[c]='A';
    }
    for(int i=0;i<n;i++){
        if(mp[s[i]]=='A'){
            mp[s[i]]=t[i];
        }else{
            if(mp[s[i]]!=t[i]){
                f=false;
                break;
            }
        }
        if(mp2[t[i]]=='A'){
            mp2[t[i]]=s[i];
        }else{
            if(mp2[t[i]]!=s[i]){
                f=false;
                break;
            }
        }
    }
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 776
from collections import deque
H,W = map(int, input().split())
S = [input() for _ in range(H)]

used = [[0]*W for _ in range(H)]
q = deque()
ans = 0
for i in range(H):
    for j in range(W):
        if used[i][j] == 1:
            continue
        if S[i][j] == ".":
            continue
        dic = {"#":1, ".":0}
        q.append((i, j, "#"))
        used[i][j] = 1
        while q:
            temp = q.popleft()
            k = temp[0]
            l = temp[1]
            f = temp[2]
            if f == "#":
                f = "."
            else:
                f = "#"
            if k > 0 and S[k-1][l] == f and used[k-1][l] == 0:
                used[k-1][l] = 1
                dic[f] += 1
                q.append((k-1, l, f))
            if k < H-1 and S[k+1][l] == f and used[k+1][l] == 0:
                used[k+1][l] = 1
                dic[f] += 1
                q.append((k+1, l, f))
            if l > 0 and S[k][l-1] == f and used[k][l-1] == 0:
                used[k][l-1] = 1
                dic[f] += 1
                q.append((k, l-1, f))
            if l < W-1 and S[k][l+1] == f and used[k][l+1] == 0:
                used[k][l+1] = 1
                dic[f] += 1
                q.append((k, l+1, f))
        ans += dic["#"]*dic["."]

print(ans)

Measured memory_bytes: 4852