akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){

	int x,y;
  	int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  	
  	cin >> x >> y;
  	cout << ( a[x] == a[y] ? "Yes" : "No")<<endl;


}

Measured memory_bytes: 256
#エラトステネスの篩
MAX_NUM = 999999
primes = []
max = Math.sqrt(MAX_NUM).ceil
arr = [*2..MAX_NUM]
0.upto(max) {|i|
  next if arr[i] == nil
  primes << arr[i]
  i.step(arr.length, primes.last){|j| arr[j] = nil}
}
primes.concat(arr.compact!)
#Prime Number
while gets
  n = $_.to_i
  puts primes.count{|i| i <= n}
end

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

#define f first
#define s second
#define pb push_back

using namespace std;

typedef unsigned long long int lli;
typedef vector<int> vi;

vi arr;

int temp(int n){

    if(n%10 != 0) return n+(10-n%10); else return n;

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int ci;
    
    for(int i = 0;i<5;++i){
    
        cin>>ci;
        arr.pb(ci);
    
    }
    
    ci = 1000000;
    int som,a,b,c,d,e;
    for(int i = 0;i<5;++i){
        a = temp(arr[i]);
        
        for(int j = 0;j<5;++j){
            b = 0;
            if(j!=i){
                
                b = temp(arr[j]);
                
                for(int k = 0;k<5;++k){
                    c = 0;
                    if(k!=j && k!=i){
                        c = temp(arr[k]);
                        for(int l = 0;l<5;++l){
                            d = 0;
                            if((l!=k && l!=j) && l!=i){
                                d = temp(arr[l]);
                                for(int m = 0;m<5;++m){
                                    e = 0;
                                    if((m!=l && m!=k) && (m!=j && m!=i)){
                                        e = arr[m];
                                        ci = min(ci,a+b+c+d+e);
                                    }
                                }
                            }
                        }
                    }
                }
                
            }
        
        }
        
    }
    
    cout<<ci<<endl;
    
    return 0;

}

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

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

    vector<long long> cnt(N+1);
    for (long long i = 1; i < N+1; i++)
    {
        cnt[i] = 0;
    }
    for (long long i = 1; i <= pow(N,0.5); i++)
    {
        for (long long j = i; j <= N / i; j++)
        {
            if (i == j)
            {
                cnt[j * i] ++;
            }
            else
            {
                cnt[j * i] += 2;
            }
        }
    }

    long long ans = 0;
    for (long long i = 1; i <= N; i++)
    {
        ans += i * cnt[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 81404
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextString()
	var out int
	switch s {
	case "SUN":
		out = 7
	case "MON":
		out = 6
	case "TUE":
		out = 5
	case "WED":
		out = 4
	case "THU":
		out = 3
	case "FRI":
		out = 2
	case "SAT":
		out = 1
	}
	fmt.Println(out)
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
int i, n, x;
fscanf(stdin, "%d", &n);
for(i = 1; i<=n; i++){
x = i;
if (x % 3 == 0){
printf(" %d", i);
continue;
}
do {
if(x % 10 == 3){
printf(" %d", i);
break;
}
x /= 10;
}while( x );
}
printf("\n");
return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
  
typedef long double ldouble;
const ldouble eps = 0.000000001;
bool eq(ldouble a,ldouble b){return (-eps<a-b && a-b<eps);}
 
struct Point{
  ldouble x,y;
  Point operator + (const Point p)const{
    return (Point){x+p.x,y+p.y};
  }
  Point operator - (const Point p)const{
    return (Point){x-p.x,y-p.y};
  }
  Point operator * (const ldouble r)const{
    return (Point){x*r,y*r};
  }
};
bool eq(Point a,Point b){return ( eq(a.x,b.x) && eq(a.y,b.y) );}
  
typedef Point Vector;
 
ldouble dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
ldouble cross(Vector a,Vector b){return a.x*b.y-b.x*a.y;}
ldouble norm(Vector v){return dot(v,v);}
ldouble abs(Vector v){return sqrt(norm(v));}
  
  
Point project(Point a,Point b,Point p){
  Point base=b-a;
  ldouble r=dot(p-a,base)/norm(base);
  return a+base*r;
}
 
int n;
ldouble A,B;
vector<Point> t;
Point s,g;
ldouble ans;
  
ldouble func0(double H,double W){
  ldouble a=1.0;
  ldouble b=-2.0*W;
  ldouble c=W*W-(A*A*H*H)/(B*B-A*A);
  if(b*b-4.0*a*c<0)return min(H*B+W*A, sqrt(H*H+W*W)*B);
  ldouble t = (-b+sqrt(b*b-4.0*a*c))/(2.0*a);
  if(t>W){
    t=(-b-sqrt(b*b-4.0*a*c))/(2.0*a);
    if(t<0)return 0;
  }
  return t;
}
ldouble func02(Point a,Point b,Point g){
  Point D=project(a,b,g);
  return func0( abs(g-D) , abs(a-D) );
}
ldouble func(ldouble H,ldouble W){
  ldouble t=func0(H,W);
  ldouble ff = t*A+B*sqrt((W-t)*(W-t)+H*H );
  return ff;
} 
ldouble func2(Point a,Point b,Point g){
  Point D=project(a,b,g);
  return func( abs(g-D) , abs(a-D) );
}
  
void solve(){
  vector<Point> T;
  for(int i=0;i<n;i++){
    T.push_back(t[i]);
    if(i+1<n){
      ldouble tt = func02(t[i],t[i+1],g);
      Vector base=t[i+1]-t[i];      
      Point next =  t[i]+ base*( tt /abs(base) );
      if(!eq(next,t[i])&&!eq(next,t[i+1])
         && eq(abs(t[i]-next)+abs(t[i+1]-next),abs(t[i]-t[i+1]))
         )T.push_back(next);
    }
  }
    
  t=T;
  n=t.size();
  vector<ldouble> u(n);  
  u[0]=0;
  u[1]=abs(t[0]-t[1])*A;
  for(int i=2;i<n;i++){
    u[i]=u[i-1]+abs(t[i]-t[i-1])*A;
    for(int j=1;j<i;j++){
      u[i]=min(u[i],u[j-1]+func2(t[j-1],t[j],t[i]));
      u[i]=min(u[i],u[j-1]+func2(t[i],t[i-1],t[j-1]));
    }
  }
  for(int i=0;i+1<n;i++){
    ldouble na = u[i]+func2(t[i],t[i+1],g);
    ans=min(ans,na);
  }
}
  
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  while(1){
    vector<Point> nt;
    cin>>n;
    if(n==0)break;
    t.clear();t.resize(n);
    for(int i=0;i<n;i++)cin>>t[i].x>>t[i].y;
    cin>>A>>B>>s.x>>s.y>>g.x>>g.y;
    int flg=0,f=-1;
    for(int i=0;i<n;i++){
      int j=(i+1)%n;      
      if(eq(s,t[i]))flg=1;
      if(eq( abs(s-t[i])+abs(s-t[j]) , abs(t[i]-t[j]) )){
        f=j;
        break;
      }
    }
    if(flg==0)nt.push_back(s);
    else f=(f+n-1)%n;
    for(int j=0;j<n;j++)nt.push_back(t[(f+j)%n]);
    n=nt.size();
    t=nt;
    ans=abs(s-g)*B;
    solve();
    reverse(t.begin()+1,t.end());
    solve();
    double ans2=ans;
    printf("%.14f\n",ans2);
  }
  return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>

int main(){
  char s[15]; int k;int i=0;
  for(i;i<15;i++)
 {
    scanf("%c",&s[i]);//printf("%c",s[i]);
      switch(s[i]){
        case 'x':k++;/*printf("%d\n",k);*/break;
   	 default:break;
      }
  }
  //printf("%d",k);
  if (k>7){printf("NO\n");}
  else{printf("YES\n");}
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int H, A;
    scan(H, A);
    int ans = ceil((double)H / A);
    print(ans);

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

vector<pii> g[100005];
vector<int> cur[100005];
int dp[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        int a, b, c;
        cin >> a >> b >> c;
        g[a].eb(mp(b, c));
        g[b].eb(mp(a, c));
    }

    memset(dp, -1, sizeof(dp));
    priority_queue<pii> dq;
    // deque<pii> dq;
    dp[1] = 1;
    dq.push(mp(-dp[1], 1));
    for(int i=1;i<=1000000;i++) cur[1].eb(i);
    while(!dq.empty()){
        int u = dq.top().se;
        int val = -dq.top().fi;
        dq.pop();

        if(val != dp[u]) continue;

        sort(all(cur[u]));
        for(int i=0;i<sz(g[u]);i++){
            int v = g[u][i].fi, c = g[u][i].se;
            if(binary_search(all(cur[u]), c)){
                if(dp[v] == -1 || dp[v] > dp[u]){
                    cur[v].clear();
                    cur[v].eb(c);
                    dp[v] = dp[u];
                    dq.push(mp(-dp[v], v));
                }
                else if(dp[v] == dp[u]){
                    cur[v].eb(c);
                }
            }
            else{
                if(dp[v] == -1 || dp[v] > dp[u] + 1){
                    cur[v].clear();
                    cur[v].eb(c);
                    dp[v] = dp[u] + 1;
                    dq.push(mp(-dp[v], v));
                }   
                else if(dp[v] == dp[u] + 1){
                    cur[v].eb(c);
                }
            }
        }
    }
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 23928
#comb_mod(n, r, mod) = nCr % mod
def comb_mod(n, r, mod):
    ans = 1
    if r <= n/2:
        for i in range(n-r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    else:
        for i in range(r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, n-r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    return ans

#comb(n,r) = nCr
def comb(n, r):
    m = 1
    for i in range(n-r+1, n+1):
        m *= i
    for i in range(1, r+1):
        m //= i
    return m

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

ans = 0
pattern = comb_mod(n-1, k-1, 10**9+7)
for i in range(n-k+1):
    ans += (a[-(i+1)] - a[i]) * pattern
    pattern *= (n-k-i) * pow(n-1-i, 10**9+5, 10**9+7)
    pattern %= 10**9 + 7
print(ans % (10**9+7))

Measured memory_bytes: 63472
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan
import cmath as cma
import copy as cp
import sys
import re
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

def prime(n):
    ans = []
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            n //= i
            ans.append(i)
    if n > 1: ans.append(n)
    return ans

n = iinput()
primes = prime(n)
cnt = col.Counter(primes)

ans = 0
for key,val in cnt.items():
    i = 1
    while 1:
        val -= i
        if val < 0: break
        ans += 1
        i += 1

print(ans)


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100;
const ll MOD = 1e9+7;

int digs(int x) {
    int d = 0;
    while (x>0) {
        d++;
        x/=10;
    }
    return d;
}

int main()
{
    FAST_IO;

    int n; cin >> n;
    int ans = 0;
    FOR(i, 1, n) if (digs(i) & 1) ans++;
    cout << ans << endl;

    return 0;
}


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

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

  if((W-x) >= r && x >= r && (H-y) >= r && y >= r)
     cout << "Yes" << endl;
  else
     cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3092
n = gets.to_i
t, a = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

dif = 100000
result = 0

hs.each.with_index(1) do |h, i|
  tmp = ((t - h * 0.006) - a).abs
  if tmp < dif
    dif = tmp
    result = i
  end
end

puts result

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

int main() {
  int N, P, L, R, T,tot;
  P = 1;
  cin >> N;
  tot=0;
  while( N-P>=0){
    cin >> L >> R;
    T=R-L+1;
    tot=tot+T;
    P++;
  }
 cout << tot << endl;
}


Measured memory_bytes: 3584
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A

visit = {}
n = 1
cnt = 0
remain = K
# print("remain:", remain)
while(n not in visit.keys()):
    visit[n] = cnt
    cnt+=1
    n = A[n]
    remain -= 1
    if (remain==0):
        print(n)
        exit()
# remain -=1

# print(n, visit[n], cnt)
d = cnt - visit[n]
# print(d)
# print("d: ", d)
# print("remain:", remain)
remain = remain%d
# print("remain:", remain)
# print("current: ", n)
while(remain > 0):
    remain -= 1
    n = A[n]
    # print("new n:", n)
print(n)



Measured memory_bytes: 32300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <numeric>

int main()
{
	std::vector<std::vector<int>> input;
	std::vector<int> height_width(2);

	std::cin >> height_width[0] >> height_width[1];
	
	while (height_width[0] != 0 || height_width[1] != 0)
	{
		input.push_back(height_width);
		std::cin >> height_width[0] >> height_width[1];
	}

	size_t size = input.size();
	for (size_t i = 0; i < size; i++)
	{
		for (int j = 0; j < input[i][0]; j++)
		{
			for (int k = 0; k < input[i][1]; k++)
			{
				if (j == 0 || j == input[i][0] - 1 || k == 0 || k == input[i][1] - 1)
				{
					std::cout << "#";
				}
				else
				{
					std::cout << ".";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
int freq[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		int a;
		cin >> a;
		freq[a]++;
	}
	priority_queue<int, vector<int>, greater<int>> pq;
	for(int i = 1; i <= n; i++)
		pq.push(freq[i]);
	int ans = 0;
	while(pq.size() > k)
	{
		ans += pq.top();
		pq.pop();
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 2168
#include <iostream>

using namespace std;

int main()
{
    long long a,b;
    cin>>a>>b;
    if (a==b) cout<<-1;
    else if (a>b)
    {
        if (a%b==0) cout<<-1;
        else cout<<a;
    }
    else
    {
        cout<<a;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  char s;
  bool y = false;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(s == 'Y') y = true;
  }
  
  if(y)  cout << "Four" << endl;
  else cout << "Three" << endl;
}  

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n, m;
	cin >> n >> m;
	vector<string> vn(n), vm(m);
	REP(i, n) { cin >> vn[i]; }
	REP(i, m) { cin >> vm[i]; }
	REP(i, n - m + 1)
	{
		REP(j, n - m + 1)
		{
			bool ans = true;
			REP(k, m)
			{
				if (vm[k] != vn[i + k].substr(j, m))
				{
					ans = false;
					break;
				}
			}
			if (ans)
			{
				print("Yes");
				return 0;
			}
		}
	}
	print("No");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
  
using namespace std;
  
int LevenshteinDistance(string s, string t) {
    
  int len_s = s.size();
  int len_t = t.size();
    
  vector<vector<int> > dp(len_s+1, vector<int>(len_t+1, 0));
  
  for(int i=0; i<=len_s; i++)
    dp[i][0] = i;
    
  for(int i=0; i<=len_t; i++)
    dp[0][i] = i;
    
  int cost;
  for(int i=1; i<=len_s; i++) {
    for(int j=1; j<=len_t; j++) {
      if(s[i-1] == t[j-1]) cost = 0;
      else cost = 1;
        
      dp[i][j] = min(dp[i-1][j] + 1, min(dp[i][j-1] + 1, dp[i-1][j-1] + cost));
    }
  }
    
  return dp[len_s][len_t];
}
  
int main() {
    
  string s, t;
    
  cin >> s >> t;
    
  cout << LevenshteinDistance(s, t) << endl;
    
  return 0;
}

Measured memory_bytes: 4964
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		
		int maxcount=0;
		int max=0;
		
		
		for(int i = 1;i<=N;i++){
			int shou=i/2;
			int amari=i%2;
			int dasshu = 0;
			
			maxcount=0;
			
			do{
				
				
				
				if(amari==0&&shou==1){//割り切れたが最後の2だった
					maxcount+=1;
					dasshu=1;
				}else if(amari==0&&shou!=1){//2で割れた時だけ繰り返す
					
					shou = shou/2;
					amari = amari%2;
					maxcount+=1;
				}else if(amari !=0){//割り切れなくても脱出
					dasshu=1;
					
				}
			
				
			}while(dasshu==0);
			
			if(max<maxcount){
				max = maxcount;
			}
			
			
		}
		
		
		
		System.out.println((int)Math.pow(2, max));
		
		
		
		
		
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
	int a, b, c;
	
	scanf ("%d", &a);
	scanf ("%d", &b);
	scanf ("%d", &c);
	
	if (a < b && b < c) {
		printf ("Yes\n");
	} else {
		printf ("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2080
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nmxy = br.readLine().split(" ");
        int n = Integer.parseInt(nmxy[0]);
        int m = Integer.parseInt(nmxy[1]);
        int x = Integer.parseInt(nmxy[2]);
        int y = Integer.parseInt(nmxy[3]);
        
        String[] str_xs = br.readLine().split(" ");
        String[] str_ys = br.readLine().split(" ");
        
        int[] xs = new int[n];
        int[] ys = new int[m];
        
        int max_x = -200;
        int min_y = 200;
        
        for (int i = 0; i < n; i++) {
            xs[i] = Integer.parseInt(str_xs[i]);
            if (xs[i] > max_x) {
                max_x = xs[i];
            }
        }
        
        for (int i = 0; i < m; i++) {
            ys[i] = Integer.parseInt(str_ys[i]);
            if (ys[i] < min_y) {
                min_y = ys[i];
            }
        }
        
        boolean flag = false;
        if (min_y > max_x) {
            for (int i = max_x+1; i <= min_y ;i++) {
                if (x < i && i <= y) {
                    flag = true;
                }
            }
        }
        
        if (flag) {
            System.out.println("No War");
        }
        else {
            System.out.println("War");
        }
        
        
        
        
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll g=__gcd(n,m);
    ll l=n/g*m;
    for(int i=0,j=0; i<n; i+=n/g,j+=m/g){
        if(s[i]!=t[j]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<l<<endl;
}


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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,A[110]={},r[10]={};
    cin>>N;

    for(int i=1;i<=N;i++){
        cin>>A[i];

        if(A[i]>=3200){
            r[8]++;
        }else{
            r[(A[i]/400)]++;
        }
    }

    int ans=0;
    for(int i=0;i<8;i++){
        if(r[i]>0)ans++;
    }

    //min
    cout<<max(1,ans)<<" ";
    //max
    cout<<ans+r[8]<<endl;

    return 0;
}

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

int prime[1000000];

int init()
{
  memset(prime, -1, sizeof prime);
  prime[0] = prime[1] = 0;
  for(int i = 2; i < 1000000; i++)
  {
    if(prime[i] != -1)
      continue;
    prime[i] = 1;
    for(int j = i + i; j < 1000000; j += i)
      prime[j] = 0;
  }
}

int main()
{
  init();
loop:
  int n, p;
  vector<int> prm;
  vector<int> m;
  cin >> n >> p;
  if(n == -1)
    return 0;
  int i = n;
  for(int cnt = 0; cnt < 100; cnt++)
  {
    i++;
    while(!prime[i])
      i++;
    prm.push_back(i);
  }
  for(int i = 0; i < 100; i++)
    for(int j = i; j < 100; j++)
      m.push_back(prm[i] + prm[j]);
  sort(m.begin(), m.end());
  cout << m[p - 1] << endl;
  goto loop;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int N) {
	int H, W; cin >> H >> W;
	vector<vector<int>> v(H+1, vector<int>(W+1, 0));
	rep(i, N) {
		int a, b; cin >> a >> b; v[a][b] = 1;
	}
	int S, T; cin >> S >> T;
	reps(i, 1, H+1) reps(j, 1, W+1) {
		v[i][j] += v[i-1][j] + v[i][j-1] - v[i-1][j-1];
	}
	int res = 0;
	rep(i, H-S+1) rep(j, W-T+1) {
		chmax(res, v[i+S][j+T] - v[i][j+T] - v[i+S][j] + v[i][j]);
	}
	return res;
}

signed main() {
	int n;
	while (cin >> n, n) cout << solve(n) << endl;
}




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

using lint = long long int;

int main(){
    long N;
    lint A,B;
    lint tempb,tempn;
    lint exhaust=0;

    cin >> N >> A >> B;
    cin >> tempb;
    for(long i=1;i<N;i++){
        cin >> tempn;
        exhaust += min(A*(tempn-tempb),B);
        tempb = tempn;
    }

    cout << exhaust << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iostream>

int main(){

    size_t n;
    std::cin >> n;

    size_t cnt_2 = 0, cnt_n2 = 0, cnt_4 = 0;
    for(size_t i = 0; i < n; i++){
        size_t a;
        std::cin >> a;

        if(a % 4 == 0){
            cnt_4++;
        }else if(a % 2 == 0){
            cnt_2++;
        }else if(a % 2 != 0){
            cnt_n2++;
        }
    }

    if(cnt_2 > 0){
        if(cnt_4 >= cnt_n2){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }else{
        if(cnt_4 + 1 >= cnt_n2){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int X;
    cin >> X;
    for (int i = 1; i <= 1e9; i++) {
        X -= i;
        if (X <= 0) {
            cout << i << "\n";
            return 0;
        }
    }
}

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

int main(){
  int n,i;
  ll L=1;
  cin >> n;
  vector<ll> t(n);
  for(i=0;i<n;i++){
    cin >> t.at(i);
    L=L*(t.at(i)/__gcd(L,t.at(i)));
  }
  cout << L << endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		for (int i=0;i<N;i++) {
			int temp = sc.nextInt();
			if(temp%2==0) {
				if (temp%3!=0&&temp%5!=0) {
					System.out.println("DENIED");
					return ;
				}
			}
		}
		System.out.println("APPROVED");
	}
}

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

#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 2e5 + 5;
int p[MAXN],n;LL k;
bool vis[MAXN];
std::vector<int> S;
int st = 0;

inline void dfs(int v){
	S.pb(v);vis[v] = 1;
	if(vis[p[v]]) {st = p[v];return;}
	dfs(p[v]);
}

int main(){
	scanf("%d%lld",&n,&k);
	FOR(i,1,n) scanf("%d",p+i);
	dfs(1);int tp = 0;
	FOR(i,0,(int)S.size()-1) if(S[i] == st) {tp = i;break;}
	// DEBUG(tp);
	// for(auto x:S) DEBUG(x);
	if(k <= tp) {printf("%d\n",S[k]);return 0;}
	k -= tp;
	std::vector<int> T;
	FOR(i,tp,S.size()-1) T.pb(S[i]);
	printf("%d\n",T[k%T.size()]);
	return 0;
}

Measured memory_bytes: 11468
/*@authored by: Subham Pratap*/

/* ************************************************************************************************************************** */

#include <bits/stdc++.h>
using namespace std;
#define PKMKB ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define lli long long int
#define ull unsigned long long
#define INT_MAX 2147483647
#define all(a) begin(a),end(a)
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define MOD 1000000007

/* Look Bitch, Don’t mess with any of the code from here
   to the end of the function. None of us understand it,
   and any change seems to break the program in ways
   we don’t fuckin' understand. */

  int main()
  {
    PKMKB;
        lli n;
        cin >> n;
        cout << 3*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char mp[105][105];
int dp[105][105],n,m;

int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dp[i][j]=inf;
	for(int i=1;i<=n;i++) mp[i][0]='.';
	for(int i=1;i<=m;i++) mp[0][i]='.';
	dp[0][1]=0; dp[1][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(mp[i][j]=='.')
			{
				dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
			}
			else
			{
				if(mp[i-1][j]=='.') dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
				else dp[i][j]=min(dp[i][j],dp[i-1][j]);
				
				if(mp[i][j-1]=='.') dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
				else dp[i][j]=min(dp[i][j],dp[i][j-1]);
			}
		}
	}
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=m;j++)
//			cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n,k;
    cin >> n >> k;
    double tot = 0;
    for(int i=1; i<=n; i++){
        int score = i;
        double p = 1;
        while(score<k){
            score*=2;
            p/=2;
        }
        tot += p;
    }
    double ans = tot /n;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll inf=1e18;

ll A,B,C,K;
ll a,b,c;

int main(){
    cin>>A>>B>>C>>K;
    if(abs(A-B)>inf){
        cout<<"Unfair"<<endl;
    }
    else if(K%2==1){
        cout<<B-A<<endl;
    }
    else cout<<A-B<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include<iomanip>

using namespace std;

typedef long long ll;

int main() {
    double L;   cin >> L;
    cout << fixed << setprecision(15) << L*L*L/27.0 << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, C = [int(i) for i in input().split()]
BS = [int(i) for i in input().split()]
ASS = [[int (i) for i in input().split()] for _ in range(N)]

print(sum([1 if sum([a * b for a, b in zip(AS, BS)]) + C > 0 else 0 for AS in ASS]))


Measured memory_bytes: 3060
module M = Map.Make (struct type t = int let compare = compare end) ;;

Scanf.scanf "%d" (fun n ->
    let rec loop i cur map =
        if i = n then map else
            let cur = Scanf.scanf " %d" (fun a -> a + cur) in
            let map = M.add cur (1 + try M.find cur map with _ -> 0) map in
            loop (i + 1) cur map
    in
    let map = loop 0 0 (M.add 0 1 M.empty) in
    M.fold (fun _ v acc -> acc + v * (v - 1) / 2) map 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 14848
n,m=map(int,input().split())
a,d=list(map(int,input().split()))+[0],{}
for i in range(n):
	a[i]%=m
	a[i+1]+=a[i]
a[n]=0
for i in range(n+1):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
print(sum([x*(x-1)//2 for x in d.values()]))

Measured memory_bytes: 14696
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint N;
  cin >> N;
  vector<lint> L(N);
  for(auto& elem : L) cin >> elem;

  lint ans = 0;
  for(lint a=0; a<N; a++)
  for(lint b=a+1; b<N; b++)
  for(lint c=b+1; c<N; c++) {
    if(L[a] == L[b] or L[b] == L[c] or L[c] == L[a]) continue;
    auto c1 = (L[a] + L[b] > L[c]);
    auto c2 = (L[b] + L[c] > L[a]);
    auto c3 = (L[c] + L[a] > L[b]);
    ans += (c1 and c2 and c3);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e9 + 7;

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	if (b >= a + w)cout << b - a - w << endl;
	else
	{
		if (b + w >= a)cout << 0;
		else
		{
			cout << a - b - w << endl;
		}
	}
}

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

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define scc(t) scanf("%c", &t)
#define scw(t) cin >> t
#define scs(t) getline(cin, t)
#define fori(t) for (int i = 0; i < t; i++)
#define forij(t, p)             \
    for (int i = 0; i < t; i++) \
        for (int j = 0; j < p; j++)
#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

void solve()
{
    int k, n;
    cin >> k >> n;

    vi v(n);

    fori(n){
        scd(v[i]);
    }

    int mdis=0, prev=0;
    fori(n){
        mdis = max(mdis , abs(prev - v[i]));
        prev = v[i];
    }

    mdis = max(mdis , k-v.back() + v[0]);

    int ans = k - mdis;
    cout<<ans<<endl;
}

int main()
{
    solve();

    return 0;
}

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

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

const long long INF = 1LL << 60;
const long long mod = 1000000007;

int main(void){
    int x;cin >> x;
    vector<bool> a(1000000000,false);
    for(int i=1;i<=(x/100)+2;i++){
	for(int j=0;j<=5*i;j++){
	    a[100*i+j] = true;
	}
    }
    if(a[x]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 122368
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    cin >> n;

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

    int k = 0; // 入力された順番と入力された数字があっていない回数
    for (int i = 0; i < n; i++){
        if (p[i] != i + 1) k++;
    }

    if (k == 2 || k == 0){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

const int N = 1e2 + 5;
int mod;
inline int pls( int a , int b ) { a += b - mod; return a + ( a >> 31 & mod ); }
inline int mns( int a , int b ) { a -= b; return a + ( a >> 31 & mod ); }
inline void inc( int & a , int b ) { a += b - mod; a += a >> 31 & mod; }
inline void dec( int & a , int b ) { a -= b; a += a >> 31 & mod; }
inline int fpow( int b , int k ) {
  int res = 1;
  while( k ) {
    if( k & 1 ) res = 1LL * res * b % mod;
    b = 1LL * b * b % mod; k >>= 1;
  }
  return res;
}

int coe[N][N][N][2] , f[N][N][N][2] , n , m , k , binom[N][N];

int main( void ) {
  cin >> n >> m >> k >> mod;
  for( int i = 0 ; i < N ; ++i ) {
    binom[i][0] = 1;
    for( int j = 1 ; j <= i ; ++j )
      binom[i][j] = pls( binom[i - 1][j] , binom[i - 1][j - 1] );
  }
  f[0][0][0][0] = 1;
  for( int v = 0 , tmp ; v < k ; ++v )
    for( int j = 0 ; j <= m ; ++j ) {
      tmp = 1LL * mns( fpow( v + 1 , m - j ) , fpow( v , m - j ) ) * fpow( k - v , j ) % mod;
      coe[v][0][j][0] = 1;
      for( int i = 1 ; i <= n ; ++i )
        coe[v][i][j][0] = 1LL * coe[v][i - 1][j][0] * tmp % mod;
    }
  for( int v = 0 , tmp ; v < k ; ++v )
    for( int i = 0 ; i <= n ; ++i ) {
      tmp = 1LL * mns( fpow( k - v , i ) , fpow( k - v - 1 , i ) ) * fpow( v + 1 , n - i ) % mod;
      coe[v][i][0][1] = 1;
      for( int j = 1 ; j <= m ; ++j )
        coe[v][i][j][1] = 1LL * coe[v][i][j - 1][1] * tmp % mod;
    }
  for( int v = 0 , foo ; v < k ; ++v )
    for( int i = 0 ; i <= n ; ++i )
      for( int j = 0 ; j <= m ; ++j ) {
        if( f[v][i][j][0] ) {
          foo = f[v][i][j][0];
          for( int l = 0 ; l + i <= n ; ++l ) 
            inc( f[v][i + l][j][1] , 1LL * foo * coe[v][l][j][0] % mod * binom[n - i][l] % mod );
        }
        if( f[v][i][j][1] ) {
          foo = f[v][i][j][1];
          for( int l = 0 ; l + j <= m ; ++l ) 
            inc( f[v + 1][i][j + l][0] , 1LL * foo * coe[v][i][l][1] % mod * binom[m - j][l] % mod );
        }
      }
  cout << f[k][n][m][0];
  return 0;
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000000];
int main(int argc, char const *argv[]) {
   ll n,sum=0,dum=0,mn=1e18;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a[i];
     sum+=a[i];
   }
   for(int i=0;i<n-1;i++){
     dum+=a[i];
     sum-=a[i];
     ll k=abs(sum-dum);
     mn=min(mn,k);
   }
   cout<<mn<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;

int main(){
    char c[101010];
    cin >> c;
    bool app[26];
    for (int i = 0; i < 26; i++) {
        app[i] = false;
    }
    for (int i = 0; c[i] != '\0'; i++) {
        app[c[i] - 'a'] = true;
    }
    for (int i = 0; i < 26; i++) {
        if(!app[i]){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int a,b; cin >> a >> b;
    int ans1 = a+b;
    int ans2 = a-b;
    int ans3 = a*b;
    cout << max({ans1,ans2,ans3});
    }



Measured memory_bytes: 256
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int mod = 1e9 + 7;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];
ll dp[N][3];

vector<ll> v[N];

inline ll add(ll x, ll y){  return  (x % mod + y % mod) % mod;}
inline ll sub(ll x, ll y){  return  (x % mod - y % mod + mod) % mod;}
inline ll mul(ll x, ll y){  x %= mod;   y %= mod;   return 1LL * x * y % mod;}

ll dfs(ll node, ll par, ll prev){
    if(dp[node][prev] + 1)  return dp[node][prev];
    ll xx = 1, yy = 0;
    for(auto i: v[node]){
        if(i != par)    xx = mul(xx, dfs(i, node, 0));
    }
    if(prev < 1){
        yy = 1;
        for(auto i: v[node]){
            if(i != par)    yy = mul(yy, dfs(i, node, prev + 1));
        }
    }
    return dp[node][prev] = add(xx, yy);
}

void solve(){
    ll n, x, y;
    cin >> n;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[y].push_back(x);
        v[x].push_back(y);
    }
    memset(dp, -1, sizeof dp);
    cout << dfs(1, 1, 0);
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

char S[111], T[111];
ll i, j, k, ans;
int main(){
    scanf("%s%s", S, T);
    for (i = 0; T[i];++i){
        printf("%c", T[i]);
    }
    for (i = 0; S[i];++i){
        printf("%c", S[i]);
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  int sum = 0;
  for(int j=0;j<N;j++){
    for(int k=j+1;k<N;k++){
      sum +=  A.at(j)* A.at(k);
    }
  }
  
  cout << sum <<endl;

}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int N, K;
    cin >> N >> K;
    vl A(N);
    rep(i,N) {
        cin >> A[i];
        A[i]--;
    }

    map<ll, ll> cnts;
    cnts[0] = 1;
    ll ans = 0, sum_mod = 0;
    vl sum_mods(1,0);
    rep(i,N) {
        (sum_mod += A[i]) %= K;
        sum_mods.push_back(sum_mod);
        if (i >= K-1) cnts[sum_mods[i-(K-1)]]--;
        ans += cnts[sum_mod];
        cnts[sum_mod]++;
    } cerr << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18920
n, m = input().split()
n, m = int(n), int(m)

data = []

for i in range(m):
    temp_p, temp_y = input().split()
    temp_p, temp_y = int(temp_p), int(temp_y)
    data.append([temp_p, temp_y, i])

data.sort()

result = [[] for _ in range(m)]

i = data[0][0]

k = 1

for j in range(m):
    if i != data[j][0]:
        k = 1
        i = data[j][0]
    result[data[j][2]] = [data[j][0], k]
    k += 1

for temp_data in result:
    print("{:0>6}".format(temp_data[0]) + "{:0>6}".format(temp_data[1]))

Measured memory_bytes: 78808
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static char[][] map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力



		//int N = sc.nextInt();
		String str = sc.next();
		for(int i = 0;i < str.length()-1;i++){
			if(str.charAt(i) == str.charAt(i+1)){
				System.out.print("Bad");
				return;
			}
		}
		System.out.print("Good");


	}

	static int rsearch(int y,int x){

		int count = 0;
		while(x < map[0].length && map[y][x] != '#'){
			count++;
			x++;
		}
		return count;	

	}

	static int csearch(int y,int x){

		int count = 0;
		while(y < map.length && map[y][x] != '#'){
			count++;
			y++;
		}
		return count;	
	}


	static boolean checkswitch(int bit,int[] k,ArrayList<ArrayList<Integer>> list,int[] p,int m){

		//		System.out.println("bit " + bit);

		for(int i = 0;i < m;i++){

			ArrayList<Integer> sub = list.get(i);
			int onnum = 0;						//onの数
			for(int j = 0;j < sub.size();j++){
				//				System.out.println("sub "+ sub.get(j));
				if((bit & (1 << sub.get(j))) != 0){				//目的のスイッチがついているか
					onnum++;
					//					System.out.println("on  ");
				}

			}
			if(onnum % 2 != p[i]){				//一個でも電球がつかなかったらout
				return false;
			}

		}


		return true;

	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}





}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  otherpair.end - end;
	}
}




Measured memory_bytes: 21844