akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n,q;
    string s;
    cin>>n>>s>>q;
    while(q--) {
        int k;
        cin>>k;
        vector<ll> c(n+1),m1(n+1),m2(n+1);
        for(int i = 0; i < n; i++) {
            c[i+1]=c[i];
            m1[i+1]=m1[i];
            m2[i+1]=m2[i];

            if(s[i]=='C') {
                c[i+1]++;
                m2[i+1]+=m1[i+1];
            }
            if(s[i]=='M') m1[i+1]++;
        }
        //for(int x:c) cout<<x<<" ";cout<<endl;
        //for(int x:m1) cout<<x<<" ";cout<<endl;
        //for(int x:m2) cout<<x<<" ";cout<<endl;

        ll ans=0;
        for(int i = 0; i < n; i++) {
            if(s[i]=='D') {
                ans+=m2[min(n,i+k)]-m2[i];
                //cout<<m2[min(n,i+k)]-m2[i]<<endl;
                ans-=m1[i+1]*(c[min(n,i+k)]-c[i]);
                //cout<<m1[i+1]<<" "<<c[min(n,i+k)]<<" "<<c[i]<<endl;
                //cout<<ans<<endl;
            }
        }
        cout<<ans<<endl;
        //break;
    }
}

Measured memory_bytes: 24836
#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 = 0;
  cin >> n;
  vector <int> x(n);
  rep(i, n) cin >> x[i];
  sort(x.begin(), x.end());
  rep(i, n - 1) 
  {
    if(x[i] == x[i + 1])
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

using namespace std;

void kei(int d, int f[],int r)
{
	for (int l = r; l < 10; l++) {
		f[l] += d % 10;
		if (f[l] >= 10 && l != 9) {
			f[l+1] += f[l] / 10;
			f[l] %= 10;
		}
		d /= 10;
	}
	return;
}

void keisan(int a, int b) 
{
	if (b == 0) {
		return;
	} else {
		int t;
		int y;
		int r[10] = {0};
		int x;
		y = a;
		for (int j = 0; j < 10; j++) {
			x = a * (y % 10);
			kei(x,r,j);
			y /= 10;
		}
		t = r[2] + r[3] * 10 + r[4] * 100 + r[5] * 1000;
		cout << t << endl;
		keisan(t,b-1);
	}
}

int main() {
	int n;
	int k;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k;
		cout << "Case " << i+1 << ":" << endl;
		keisan(k,10);
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != 'x') {
                    sb.append(s.charAt(i));
                }
            }

            if (!sb.toString().equals(sb.reverse().toString())) {
                out.println(-1);
                return;
            }

            int ans = 0;
            int index1 = 0;
            int index2 = s.length() - 1;
            while (index1 < index2) {
                if (s.charAt(index1) == s.charAt(index2)) {
                    index1++;
                    index2--;
                } else if (s.charAt(index1) == 'x' && s.charAt(index2) != 'x') {
                    ans++;
                    index1++;
                } else {
                    ans++;
                    index2--;
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

using namespace std;

typedef long long ll;

const ll MD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, ans = 1;
    cin >> n;
    vector<int> a(n);
    for (int &i : a)
        cin >> i;
    sort(a.begin(), a.end(), greater<int>());
    bool state = true;
    for (int i = 0, j = 0; i < n - 1 - (n % 2); i += 2, j++)
        state &= (a[i] == a[i + 1] && a[i] == n - (2 * j + 1));
    if (n % 2)
        state &= (a[n - 1] == 0);
    if (state)
    {
        for (int i = 0; i < n / 2; i++)
            ans = (ans << 1) % MD;
        cout << ans << "\n";
    }
    else
        cout << 0 << "\n";
    return 0;
}

Measured memory_bytes: 640
from fractions import gcd
n,m = map(int,input().split())
s = input()
t = input()

len_x = n*m//gcd(n,m)

li = set([i*(len_x//n)+1 for i in range(n)])&set([j*(len_x//m)+1 for j in range(m)])

for l in li:
    if s[(l-1)//(len_x//n)]!=t[(l-1)//(len_x//m)]:
        print(-1);exit()
print(len_x)

Measured memory_bytes: 21128
#D問題
#D問題
import math
N=int(input())
n=int(math.sqrt(N))
plist=[]
for i in range(1,n+1):
    if N%i == 0:
        plist.append(i)
        if i != int(N/i):
            plist.append(int(N/i))
ans=0
for i in range(len(plist)):
    x=plist[i]
    kari=int(N/x)-1
    if kari == 0:
        pass
    else:
        q=int(N/kari)
        r=N%kari
        if q == r:
            ans+=kari
print(ans)
            


Measured memory_bytes: 3272
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <numeric>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N), R(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i];
  }
  iota(R.begin(), R.end(), 0);
  double dist = 0;
  int64_t path_num = 0;
  do {
    for (int i = 1; i < N; ++i) {
      int dx = x[R[i - 1]] - x[R[i]];
      int dy = y[R[i - 1]] - y[R[i]];
      dist += sqrt(dx * dx + dy * dy);
    }
    ++path_num;
  } while (next_permutation(R.begin(), R.end()));
  cout << setprecision(11) << (static_cast<double>(dist) / path_num) << endl;
  return 0;
}


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

int main(){
  double a,b,c,dire,S,L,h;

  cin >> a >> b >> dire;

  dire = 3.14159265358979 / 180 * dire;

  c = sqrt(a*a + b*b - 2*a*b*cos(dire));
  h = b*sin(dire);
  L = a + b + c;
  S = a * h * 0.5;

  cout << fixed << setprecision(12) << S << endl << L << endl << h << endl;

  return 0;
}



Measured memory_bytes: 3484
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();

        if(s.length() > k){
            s = s.substring(0, k) + "...";
        }

        System.out.println(s);
        sc.close();

    }
}

Measured memory_bytes: 38608
#include<iostream>
#include<stdio.h>

using namespace std;

int main() {
	int n;
	int x;

	cin >> n;

	for (int i = 1; i <= n; i++) {

		x = i;

		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}
		while (1) {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}

			x /= 10;
			if (x == 0) break;

		}
	}
	cout << endl;

	return 0;
}

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

int main() {
    long long X;
    cin >> X;
    
    long long year = 0;
    long long yokin = 100;

    while(1) {
        year++;
        yokin = (long long)(double)yokin * 1.01;
        if(yokin >= X) {
            break;
        }
    }

    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3636
import math
g,k=map(int,input().split())
def cou(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if g<2:
  a=0
else:
  a=cou(g)
if k<2:
  b=0
else:
  b=cou(k)
print(a+b)

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int n; rd(n);
	vector<int> a(n);
	for (int& i : a) rd(i);
	vector<int> memo(n);

	for (int i = n-2; i >= 0; i--) {
		memo[i] = min(memo[i+1] + abs(a[i+1] - a[i]), i == n-2 ? INF : memo[i+2] + abs(a[i+2] - a[i]));
	}

	printf("%d\n", memo[0]);
}

Measured memory_bytes: 3924
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=100005,mod=1e9+7;
int n,c[N],ans; char s[N];
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
int main()
{
	RI i,j; for (scanf("%d%s",&n,s+1),ans=i=1;i<=n;++i)
	++c[s[i]-'a'],(ans+=1LL*ans*quick_pow(c[s[i]-'a'])%mod)%=mod;
	return printf("%d",ans-1),0;
}

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

int main()
{
   int64_t n,a,b,ans=0;
   cin>>a>>b;
   for(int i=a;i<=b;i++)
   {
       int64_t p=i,mod=0,rev=0;
       while(p)
       {
         mod=p%10;
         rev=(rev*10)+ mod;
         p/=10;
       }
       if(i==rev)  ans++;
   }
   cout<<ans;



    return 0;
}


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

int main() {
  int n;
  cin>>n;
  long long ans = 1;
  long long mod = 1e9 + 7;
  long long cnt[n];
  int cnt0 = 0;
  for (int i=0; i<n; i++) cnt[i] = 0;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    if (a == 0) {
      ans *= 3 - cnt0;
      ans %= mod;
      ++cnt[0];
      ++cnt0;
      continue;
    }
    ans *= cnt[a-1];
    ans %= mod;
    ++cnt[a];
    --cnt[a-1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
def main():
    x = int(input())
    if x <= 6:
        print(1)
    elif x % 11 == 0:
        print(2 * (x // 11))
    elif x % 11 <= 6:
        print(2 * (x // 11) + 1)
    else:
        print(2 * (x // 11) + 2)
    return


main()


Measured memory_bytes: 2940
from collections import deque
def bfs(start, g, visited):
    q = deque([])
    k_neibs = g[start]
    visited[start] = (0,start)
    for neib, dist in k_neibs:
        q.append((neib, neib)) # node, root parent (k neib)
        visited[neib] = (dist, neib) # dist, root parent (k neib)

    while q:
        curr_node, root_pare = q.popleft()
        for next_node, dist in g[curr_node]:
            if visited[next_node] != (-1,-1): continue
            curr_dist = visited[curr_node][0]
            visited[next_node] = (curr_dist+dist, root_pare)
            q.append((next_node, root_pare))


def main():
    n = int(input())
    g = [ [] for _ in range(n+1)]
    for _ in range(n-1):
        a, b, c = map(int, input().split()) 
        g[a].append((b,c))
        g[b].append((a,c))

    q,k = map(int, input().split())
    visited = [(-1,-1)] * (n+1) # dist, root parent (k neib)
    bfs(k, g, visited)

    ansl = []
    for _ in range(q):
        x,y = map(int, input().split())
        xd, xp = visited[x]
        yd, yp = visited[y]
        # めっちゃ無駄なことしてたーーーーーーーー！
        if xp == yp:
            ans = xd+yd
            ansl.append(ans)
        else:
            ans = xd+yd
            ansl.append(ans)

    for a in ansl: print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 109952
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int x;
    cin >> x;
    cout << ((x == 3 || x == 5 || x == 7) ? "YES" : "NO") << endl;
}

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

int N, A[100005];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	int dir = 0, ans = 1;
	for (int i = 1; i < N; i++) {
		int nowdir;
		if (A[i] > A[i - 1]) nowdir = 1;
		else if (A[i] == A[i - 1]) nowdir = 0;
		else nowdir = -1;
		if (dir == -nowdir && dir != 0) {
			ans++;
			dir = 0;
		} else if (dir == 0) {
			dir = nowdir;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 640
void main() {
	auto N = ri;
	auto A = readAs!(ulong[]);
	ulong res, total, xor_sum, r;

	foreach(l; 0..N) {
		// 尺取り法(l: left, r: right)
		// 題意(和とxorが等しい)を満たすなら
		while(r < N && (total + A[r] == (xor_sum ^ A[r]))) {
			total += A[r];
			xor_sum ^= A[r];
			r += 1; // ひとつ右に進める

			//writefln("[%d, %d)", l, r);
			//debug iota(l, r).map!(a => A[a]).writeln;
		}
		res += r - l; // 区間長をたす(一回前までうまくいっていたので)
		//debug write("*", r - l, " ");

		// 区間の左端をひとつ右に進めるので、そのぶん(A[i])をなかったことにする
		total -= A[l];
		xor_sum ^= A[l];
		/*
		＿人人人人人人人人人人＿
		＞　xorの逆演算はxor　＜ … a = (a xor b) xor b
		￣Y^Y^Y^Y^Y^Y^Y^YY^Y^Y￣
		*/
	}
	res.writeln;

}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 11312
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
ll dp[10005][105][2];
vector<int>num;
int n,d;
ll solve(int idx,int rem,int less)
{
    if(idx>=num.size())return (rem==0);
    ll &ans = dp[idx][rem][less];
    if(ans!=-1)
        return ans;
    ans = 0;
    if(less==0)
    {
        for(int i=0;i<=num[idx];i++)
        {
            ans+=solve(idx+1,(rem-i+d)%d,less+(i<num[idx]));
            ans%=mod;
        }
    }
    else
    {
        for(int i=0;i<10;i++)
        {
            ans+=solve(idx+1,(rem-i+d)%d,1);
            ans%=mod;
        }
    }
    ans%=mod;
    return ans;
}
int main()
{
    fastio;
    string s;
    cin>>s>>d;
    num.clear();
    set_ar(dp,-1);
    for(char c : s)
    {
        num.pb(c-'0');
    }
    n = s.size();
    cout<<(solve(0,0,0)-1+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 17536
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#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__) << "] "
using ll = long long ;

int main(){
    int n , m ;
    cin >> n >> m ;
    char grid[n][m] ;
    vector<int> rows[n] , cols[m] ;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> grid[i][j] ;
            if ( grid[i][j] == '#' ){
                rows[i].push_back(j) ;
                cols[j].push_back(i) ;
            }
        }
    }
    int ans = 0 ;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if ( grid[i][j] == '.' ){
                int index = upper_bound(rows[i].begin(),rows[i].end(),j) - rows[i].begin() ;
                // do not forget to minus one after you find row and col
                int row = 0 ;

                if ( (int) rows[i].size() == 0 )
                    row = m ;
                else if ( index == 0 ) {
                    row = rows[i][index] ;
                }
                else if ( index == (int) rows[i].size() ){
                    row = m - rows[i][index-1] - 1;
                }
                else {
                    row = rows[i][index] - rows[i][index-1] - 1;
                }
                index = upper_bound(cols[j].begin(),cols[j].end(),i) - cols[j].begin() ;

                int col = 0 ;
                if ( (int) cols[j].size() == 0 )
                    col = n ;
                else if ( index == 0 ) {
                    col = cols[j][index] ;
                }
                else if ( index == (int) cols[j].size() ){
                    col = n - cols[j][index-1] - 1;
                }
                else {
                    col = cols[j][index] - cols[j][index-1] - 1 ;
                }
                ans = max(ans,row+col-1) ;
                debug() << imie(i) imie(j) imie(row) imie(col) imie(ans) ;
            }
        }
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 38272
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;
    var height = fieldInfo[1] - 0;
          
    if(!width && !height){
      break;
    }
          
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    var c;
    for(var y = height; y--;){
      i++;
      var ni = input[i];
      for(var x = 0; x < width; x++){
        c = ni[x];
        
        if(c === '.'){
        }else if(c === '1' || c === '2' || c === '3' || c === '4' || c === '5'){
          var e = elem[c - 1];
          e[e.length] = pos(x, y);
        }else if(c === 'S'){
          start = pos(x, y);
        }else{
          goal = pos(x, y);
        }
          
      }
    }
          
    var INF = 1 << 30;
    var bestElement = -1;
    var distance = INF;
    
    for (var startElem = 0; startElem < 5; startElem++) {
      
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        var initdph = dp[h];
        initdph.length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          initdph[hidx] = INF;
        }
      }
      
      var first = (startElem + 1) % 5;
      var firstLength = elem[first].length;
      var dpf = dp[first];
      var elemf = elem[first];
      for (var j = 0; j < firstLength; j++) {
        dpf[j] = dist(start, elemf[j]);
      }
      
      for (var e = 0; e < 3; e++) {
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var dpnw = dp[now];
        var dpnx = dp[next];
        var elnw = elem[now];
        var elnx = elem[next];
        var nowLength = elnw.length;
        var nextLength = elnx.length;
        for (var j = 0; j < nowLength; j++) {
          var dpnwj = dpnw[j];
          var elnwj = elnw[j];
          for (var k = 0; k < nextLength; k++) {
            dpnx[k] = min(
              dpnx[k],
              dpnwj + 
                  dist(elnwj, elnx[k]));
          }
        }
      }

      var last = (first + 3) % 5;
      var dpl = dp[last];
      var ell = elem[last];
      var lastLength = ell.length;
      for (var j = 0; j < lastLength; j++) {
        var d = dpl[j] + dist(ell[j], goal);
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
                  
      }
                
    }
              
    if (distance == INF) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
          
    i++;
  }
            
          
}
          
function dist(from, to){
  return abs((from >> 11) - (to >> 11)) + abs((from & 2047) - (to & 2047));
}
          
function min(a, b){
  var t = a - b;
 return b + (t & (t >> 31));
}
          
function pos(a, b){
  return (a << 11) + b;
}
         
function abs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
          
var
input = '';
          
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 51440
H,W,K = map(int,input().split())
S = [list(map(lambda c: c=="#",input())) for _ in [0]*H]

ans = [[0]*W for _ in [0]*H]
new = 1

cumS = [[0]*(W+1) for _ in [0]*(H+1)]
for i in range(H):
    cumSi = cumS[i+1]
    for j in range(W):
        cumSi[j+1] = cumSi[j] + S[i][j]
for i in range(H):
    for j in range(W):
        cumS[i+1][j+1] += cumS[i][j+1]

def split(si,sj,gi,gj,new):
    cnt = cumS[gi][gj] - cumS[si][gj] - cumS[gi][sj] + cumS[si][sj]
    if cnt == 1:
        for i in range(si,gi):
            for j in range(sj,gj):
                ans[i][j] = new
        return new+1
    
    l = si
    r = gi
    while l+1<r:
        k = (l+r)//2
        s = cumS[k][gj] - cumS[si][gj] - cumS[k][sj] + cumS[si][sj]
        if s != 0 and s != cnt:
            new = split(si,sj,k,gj,new)
            new = split(k,sj,gi,gj,new)
            return new
        if s==0:
            l = k
        else:
            r = k
    
    l = sj
    r = gj
    while l+1<r:
        k = (l+r)//2
        s = cumS[gi][k] - cumS[si][k] - cumS[gi][sj] + cumS[si][sj]
        if s != 0 and s != cnt:
            new = split(si,sj,gi,k,new)
            new = split(si,k,gi,gj,new)
            return new
        if s==0:
            l = k
        else:
            r = k
    return -1

split(0,0,H,W,new)
for out in ans:
    print(" ".join(map(str,out)))

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

int main() {
  int N;
  int64_t ans=0;
  cin >> N;
  vector<int>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  
  //cout << data.at(0) <<" " << data.at(1) << endl;
  if(N%2==0){
    ans+=data.at(0);
    for(int i=1;i<N/2;i++){
      ans+=2*data.at(i);
    }
  }
  else{
    ans+=data.at(0);
    for(int i=1;i<N/2;i++){
      ans+=2*data.at(i);
    }
    ans+=data.at(N/2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll N; cin >> N ;
    vector<ll> X, Y;
    rep(i, N){
        ll inp; cin >> inp;
        X.pb(inp);
        Y.pb(inp);
    }
    
    sort(all(Y));
    
    rep(i,N){
        if(X[i] <= Y[(N/2) -1 ]) cout << Y[N/2] << endl;
        else cout << Y[(N/2)-1] << endl;
    }
    
    

    //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long

int main() {
    
    ll n;
    cin >> n;
    ll a[n+1],b[n];
    for (ll i=0;i<n+1;++i){
        cin >> a[i];
    }
    for(ll i=0;i<n;++i){
        cin >> b[i];
    }
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
        if(a[i+1]>=b[i]){
            ans+=b[i];
        }
        else{
            ans+=a[i+1];
            b[i]-=a[i+1];
            if(b[i]>=a[i]){
                ans+=a[i];
                a[i]=0;
            }
            else {
                ans+=b[i];
                a[i]-=b[i];
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
"use strict";

var main = function main(input) {
  var N = input.split(' ')[0];
  var Y = input.split(' ')[1];
  var flag = false;

  for (var i = 0; i <= N; i++) {
    for (var j = 0; j <= N - i; j++) {
      var k = N - i - j;
      var sum = 1000 * k + 5000 * j + 10000 * i;

      if (sum == Y) {
        console.log("".concat(i, " ").concat(j, " ").concat(k));
        flag = true;
        break;
      }
    }

    if (flag) {
      break;
    }
  }

  if (!flag) {
    console.log("-1 -1 -1");
  }
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 7500
import numpy as np
n, m = map(int, input().split())
a = list(map(int, input().split()))
box = {0:0}
A = 0
for i in range(n):
    A = (A+a[i]%m)%m
    if A in box:
        box[A] += 1
    else:    
        box[A] = 1

result = box[0]
for i, j in box.items():
    result += (j*(j-1))//2
print(result)

Measured memory_bytes: 23400
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	string s;
	int ans = 0;
	cin >> s;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == '1') ans++;
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int a[maxn];
int n,k;

bool f(int x){
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += (a[i] - 1) / x;
	}
	return (ans <= k);
}

int32_t main(){
    fast_io;
    cin>>n>>k;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    int l = 1, r = MOD;
    int ans = MOD;
    while(l <= r){
    	int m = (l + r) / 2;
    	if(f(m)){
    		r = m - 1;
    		ans = min(ans, m);
    	}
    	else l = m + 1;
    }
    show(ans);
    return 0;
}

Measured memory_bytes: 5140
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int a = 0;
  int b = 0;
  int c = 0;
  rep(i, N){
    int p;
    cin >> p;
    if(p <= A){
      a++;
    }else if(p <= B){
      b++;
    }else{
      c++;
    }
  }
  int ans = a;
  ans = min(ans, b);
  ans = min(ans, c);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
l,r=map(int,input().split())
a=(l-1)//2019
b=l%2019
c=r//2019
d=r%2019
if a<c:
  print("0")
else:
  if b>=d:
    d=d+2019
  e=(b*d)%2019
  for i in range(b,d):
    for j in range(i+1,d+1):
      f=(i*j)%2019
      if f<e:
        e=f
      j=j+1
    i=i+1
  print(e)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  string s, t;
  cin >> s >> t;
  int e = s.size();
  int b = t.size();
  int c = 0; int m = 0;
  for (int i = 0; i<= e- b; i++) {
    for (int j = 0 ; j < b ; j++ ) {
      if ( t[j] == s[j+i] ) {
        c++;} }
      m = max(m,c);
      c = 0; }
    cout << b - m; } 

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int res=1;
    for(int i=1;i<n;i++) if(s[i]!=s[i-1]) res++;
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vector<int>>a(n),b(n);
  int k[2];
  int count=0;
  for(int i=0;i<n;i++){
    cin >> k[0] >> k[1];
    a[i].push_back(k[0]);
    a[i].push_back(k[1]);
  }
  for(int i=0;i<n;i++){
    cin >> k[0] >> k[1];
    b[i].push_back(k[0]);
    b[i].push_back(k[1]);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  for(int i=0;i<n;i++){
    int l =-1;
    while(++l<a.size()){
      if(b[i][0]<a[l][0]) break;
    }
    int tmp=-1;
    int max=-1;
    for(int j=0;j<l;j++){
      if(max<a[j][1] && a[j][1]<b[i][1]){
        max=a[j][1];
        tmp=j;
      }
    }
    if(tmp!=-1){
      count++;
      a.erase(a.begin()+tmp);
    }
  }
  cout << count << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner pct = new Scanner(System.in);
        int n = pct.nextInt();
        int y = pct.nextInt();
        pct.close();
        int demo = y;
        boolean ebishu = true;
        for(int i = 0 ; i <= demo / 10000 && ebishu ; i++){
            for(int j = 0 ; j <= demo / 5000 && ebishu ; j++){
                demo = y - i * 10000 - j * 5000;
                if(i + j + demo / 1000 == n && demo >= 0){
                    System.out.println(i + " " + j + " " + demo / 1000);
                    ebishu = false;
                }
                demo = y;
            }
            demo = y;
        }
        if(ebishu){
            System.out.println("-1 -1 -1");
        }
    }
}

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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;
const int def = 1000000;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================関数================*/
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() {
    st = chrono::high_resolution_clock::now();
  }

  chrono::milliseconds::rep get() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
  }
};

Timer timer;
RandomNumberGenerator rnd;
/*====================================*/



void init(){
	input();
	return;
}


void output(short ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int sum(int i){
	return (i*(i+1))/2;
}

int getScore(short a[]){
	int last[30] = {};
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += s[i][a[i]]; 
		ans -= c[a[i]] * sum(i-last[a[i]]);
		last[a[i]] = i+1;
	}
	for(int j = 0;j < m;j++){
		ans -= c[j] * sum(n-last[j]);
	}
	return ans;
}

int main(){
	init();

	short now[365];
	short ans[365]; 

	for(int i = 0;i < n;i++){
		ans[i] = now[i] = rnd(26); 
	}

	int ans_score = getScore(ans);

	const int fin = 1990;
	const double C = fin*2000.0;

	int now_time = 0;
	int AS = ans_score;
	short ANS[365];
	while((now_time = timer.get()) < fin){
		int idx = rnd(365);
		int old = now[idx];
		int nxt = rnd(26);
		now[idx] = nxt;
		int now_score = getScore(now);

		double r = rnd(100000)/100000.0;

		double line = (fin-now_time)/C; 

		if(ans_score <= now_score || line > r){
			ans[idx] = nxt;
			ans_score = now_score;
			if(AS < ans_score){
				memcpy(ANS, ans, sizeof(ans));
				AS = ans_score;
				//cerr << AS << endl;
			}
		}else{
			now[idx] = old; 
		}
	}

	output(ANS);

	return 0;
}

Measured memory_bytes: 3872
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
 
 
 
 
 
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}

Measured memory_bytes: 3576
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


b = sorted(b, reverse=True)

inds = []
val = -1
for i in range(n):
    if a[i] == b[i]:
        val = a[i]
        inds.append(i)
if val == -1:
    print("Yes")
    print(*b)
    exit()

is_val = [False] * n
for i in range(n):
    if a[i] == val or b[i] == val:
        is_val[i] = True

for i in range(n):
    if not is_val[i] and inds:
        j = inds.pop()
        b[i], b[j] = b[j], b[i]
if not inds:
    print("Yes")
    print(*b)
    exit()
print("No")

Measured memory_bytes: 116428
#include<stdio.h>
#include<string.h>
int main()
{
    char s[5],t[5];
    int len,i,count=0;
    gets(s);
    gets(t);
    len=strlen(s);
    for(i=0;i<len;i++)
    {
      if(s[i]==t[i])
            count++;
    }
    printf("%d\n",count);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0;i < n; i++) {
        cin >> v[i];
    }
    
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            ans += v[i] * v[j];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c,d;cin>>a>>b>>c>>d;
  int p,q,r,s;
  p=a-'a'+49;
  q=b-'a'+49;
  r=c-'a'+49;
  s=d-'a'+49;
  if(p+q+r+s==7){
    cout<<p<<"+"<<q<<"+"<<r<<"+"<<s<<"=7"<<endl;
    return 0;
  }
  if(p+q+r-s==7){
    cout<<p<<"+"<<q<<"+"<<r<<"-"<<s<<"=7"<<endl;
    return 0;
  }
  if(p+q-r+s==7){
    cout<<p<<"+"<<q<<"-"<<r<<"+"<<s<<"=7"<<endl;
    return 0;
  }
  if(p+q-r-s==7){
    cout<<p<<"+"<<q<<"-"<<r<<"-"<<s<<"=7"<<endl;
    return 0;
  }
  if(p-q+r+s==7){
    cout<<p<<"-"<<q<<"+"<<r<<"+"<<s<<"=7"<<endl;
    return 0;
  }
  if(p-q+r-s==7){
    cout<<p<<"-"<<q<<"+"<<r<<"-"<<s<<"=7"<<endl;
    return 0;
  }
  if(p-q-r+s==7){
    cout<<p<<"-"<<q<<"-"<<r<<"+"<<s<<"=7"<<endl;
    return 0;
  }
  if(p-q-r-s==7){
    cout<<p<<"-"<<q<<"-"<<r<<"-"<<s<<"=7"<<endl;
    return 0;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	StringBuilder sb = new StringBuilder();
	int[][][] inf = new int[4][3][10];
	int n = in.nextInt();
	for (int i = 0; i < n; i++) {
	    int b = in.nextInt();
	    int f = in.nextInt();
	    int r = in.nextInt();
	    int v = in.nextInt();
	    inf[b - 1][f - 1][r - 1] += v;
	}
	for (int build = 0; build < 4; build++) {
	    for (int floor = 0; floor < 3; floor++) {
		sb.setLength(0);
		for (int room = 0; room < 10; room++) {
		    sb.append(" ");
		    sb.append(inf[build][floor][room]);
		}
		System.out.println(sb);
	    }
	    if (build != 3) {
		System.out.println("####################");
	    }
	}
    }
}


Measured memory_bytes: 29212
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int F[100][15];
int main(void) {
	int N,sum=0,ave,ans=INF;
	std::cin >> N;
	std::vector<int> a(N);
	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	for (int j = -100; j <= 100; j++) {
		sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (j - a[i])*(j - a[i]);
		}
		ans=std::min(ans, sum);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 00:14:43 2020

@author: H_Hoshigi
"""

N = int(input())
a_list = list(map(int, input().split()))

sunuke = a_list[0]
araiguma = sum(a_list[1:])
min_difference = abs(sunuke - araiguma)

for i in range(1,N-1):
    sunuke += a_list[i]
    araiguma -= a_list[i]
    min_difference = min(min_difference,
                         abs(sunuke - araiguma))

print(min_difference)


Measured memory_bytes: 23800
import math
n,*t = map(int,open(0).read().split())
def lcm(a,b):
  return a*b//math.gcd(a,b)
if n == 1:
  print(t[0])
else:
  ans = lcm(t[0],t[1])
  for i in range(2,n):
    ans = lcm(ans,t[i])
  print(ans)

Measured memory_bytes: 9196
#include<stdio.h>
int main()
{
    char s[15];
    char t[15];
    gets(s);
    gets(t);
    int i=0;
    while(s[i])
    {
        if(s[i]!=t[i])
        {
            printf("No\n");
            return 0;
        }
        i++;
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <vector>
#define int long long
using namespace std;
int dp[55][55][2600]={};
vector<int> x;


signed main(){
    int n,a;
    cin>>n>>a;
    x.resize(n+1);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<55;j++){
            for(int k=0;k<2600;k++){
                dp[i+1][j][k]+=dp[i][j][k];
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
            }   
        }
    }
    
    int ret=0;
    for(int j=0;j<51;j++){
        ret+=dp[n][j][a*j];
    }
    cout<<ret-1;
    return 0;
}



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c>a+b)
    {
        c = a+b+1;
    }
    
    cout<<b+c<<endl;
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  
  int acgt = 0;
  int ans = 0;
  for(int i = 0; i < s.length(); ++i)
  {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] =='T')
    {
      acgt++;
    }
    else
    {
      ans = max(ans, acgt);
      acgt = 0;
    }
  }
  
  ans = max(ans, acgt);
  cout << ans << endl;
}

Measured memory_bytes: 3528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String strArr[]= br.readLine().split(" ");
            int init = 0;
            int last = n - 1;
            long arr[] = new long[n];
            boolean flag = true;
            for (int i = n - 1; i >= 0; i--) {
                long num = Long.parseLong(strArr[i]);
                if (flag) {
                    arr[init] = num;
                    init++;
                } else {
                    arr[last] = num;
                    last--;
                }
                flag = !flag;
            }
            for (int i = 0; i < n; i++) {
                if (i > 0) {
                    System.out.print(" ");
                }
                System.out.print(arr[i]);
            }
            System.out.println();
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}

Measured memory_bytes: 68600
// BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

using namespace std;

/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
	lli res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%p;
		//y must be even now
		y=y>>1; //y=y/2
		x=(x*x)%p;
	}
	return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b) 
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b) 
{
  if (a < b)
    return a;
  return b;
}
lli bins(lli arr[], lli l, lli r, lli x)
{
  if (r >= l) {
    lli mid = l + (r - l) / 2;
    if (arr[mid] == x)
      return mid;
    if (arr[mid] > x)
      return bins(arr, l, mid - 1, x);
    return bins(arr, mid + 1, r, x);
  }
  return -1;
}
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 lli n;
 cin>>n;
 lli h[n];
 forz(i,n)cin>>h[i];
 lli dp[n];
 dp[0]=0;
 dp[1]=abs(h[1]-h[0]);
 for(int i=2;i<n;i++)
 {
   dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
 }
 p0(dp[n-1]);
 return 0;
}

Measured memory_bytes: 1792
N = int(input())
B = list(map(int,input().split()))
A = []
B.reverse()
for i in range(N):
    #print(i)
    if i == 0:
        A.append(B[i])
    elif i == N - 1:
        A.append(B[i - 1])
    else:
        A.append(min(B[i] , B[i - 1]))
print(sum(A))


Measured memory_bytes: 3060
#create date: 2020-06-30 09:01

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    d = ni()
    print("Christmas" + " Eve" * (25-d))

if __name__ == "__main__":
    main()

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1;

const ll INF = 1LL << 60;

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

// a^n mod を計算 再帰
ll modpow(ll a,ll n,ll &mod){
  if(!n) return 1;
  ll x = modpow(a,n/2,mod)%mod;
  x *=x;
  if(n%2==1)x*=a;
  return x%mod;
}


int main(){
  ll x;cin>>x;
  ll s=100;
  int c=0;
  while(s<x){
    s=s*1.01;
    c++;
  }
  cout<<c;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	int A, B, r;
	scanf("%d %d", &A, &B);
	
	if(20*B > 25*(A+1) || 25*A > 20*(B+1) || A%4==0 && B%5==4 || A%4==3 && B%5==0) printf("-1");
	else if (20*B <= 25*A) printf("%d", (25*A + 1) / 2);
	else printf("%d", 10*B);

		return 0;
	
}

Measured memory_bytes: 128