akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    int N = s.size();
    vector<string> ans;

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= 5; j++) {
            string ss = s.substr(i, j);
            bool flag = true;
            for (int k = 0; k < ans.size(); k++) {
                if (ans[k] == ss) flag = false;
            }
            if (flag) {
                ans.push_back(ss);
                sort(ans.begin(), ans.end());
                if (ans.size() == K + 1) {
                    ans.pop_back();
                }
            }
        }
    }
    cout << ans.back() << endl;
    return 0;
}

Measured memory_bytes: 256
def insertionSort(N,A):
    print(" ".join(map(str,A)))
    for i in range(1,N):
        v = A[i]
        j = i-1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str,A)))

insertionSort(int(input()),list(map(int,input().split())))
            


Measured memory_bytes: 5608
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

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

int main()
{
  char s[6];
  int len;

  scanf("%s", s);
  len = strlen(s);

  for (int i=0; i<len-1; i++) {
    if (s[i]=='A' && s[i+1]=='C') {
      printf("Yes");
      return 0;
    }
  }
  printf("No");

  return 0;
}

Measured memory_bytes: 128
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

A, B = rl()

if A >= 13:
	print(B)
elif A >= 6:
	print(B//2)
else:
	print(0)


Measured memory_bytes: 68492
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

#ifndef DIVISOR
#define DIVISOR
//約数の列挙, o(sqrt(n))
template<typename T>
vector<T> divisor(T n){
	vector<T> res;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}
#endif

int main(void){
    ll S;
    cin >> S;

    ll x, y;

    if(S == (ll)1e18){
        printf("0 0 0 %d %d 0\n", INF, INF);
        return 0;
    }

    if(S <= INF){
        printf("0 0 %lld 0 0 1\n", S);
    }else{
        ll k, l;
        k = S % INF;
        l = S / INF;

        int a1, a2, b1, b2;
        a2 = 1;
        b1 = INF - k;
        a1 = INF;
        b2 = l + 1;

        printf("0 0 %d %d %d %d\n", a1, b1, a2, b2);
    }

    return 0;
}

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

typedef long long ll;

 
int main(){
  string s, ans;
  cin >> s;
  char a = s[s.size()-1];
  if(a=='2'||a=='4'||a=='5'||a=='7'||a=='9') ans = "hon";
  else if(a=='3') ans = "bon";
  else ans = "pon";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
fn a() {
    input!{
        n: u32,
        x: u32,
        t: u32
    }

    let surplus = if n % x == 0 { 0 } else { t };
    println!("{}", n / x * t + surplus);
}

use proconio::{input, marker::Chars};

fn main() {
    a();
}

Measured memory_bytes: 2120
#include <stdio.h>

int main(void)
{
	int r, g, b, A;
        scanf("%d %d %d", &r, &g, &b);

	A = (r * 100 + g * 10 + b) % 4;

	if (A == 0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define chmax(x, y) x = max(x,y);

int main(){
int n,r;
cin>>n>>r;
if (n>=10){
  cout<<r;
}else{
  int ans;
  ans=r+(100*(10-n));
  cout<<ans;

}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓


            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = input[0];
            var b = input[1];
            var c = input[2];

            Console.WriteLine(Math.Max(c - (a - b),0));

			//↑
        }
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N;
    cin >> N;
    int ans=0;
    if(N<10)ans=N;else ans+=9;
    if(N>=100){
      if(N<1000)ans+=N-99;else ans+=900;
    }
    if(N>=10000){
      if(N<100000)ans+=N-9999;else ans+=90000;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    // int k=200;
    ll ans = 0;
    rep1(i, k) rep1(j, k) rep1(n, k) ans += gcd(gcd(i, j), n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(s:#));
    let s = s.chars().map(|x| x == 'W').collect::<Vec<_>>();
    let mut count = 0;
    let mut now = s[0];
    for x in s {
        if now != x {
            count += 1;
            now = x;
        }
    }
    count.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "BBBWW" => "1",
    test2: "WWWWWW" => "0",
    test3: "WBWBWBWBWB" => "9",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e6+9;
int a[N];
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x;
    for (int i=1;i<x;i++){
        cin>>y;
        a[y]++;
    }
    for (int i=1;i<=x;i++)
        cout<<a[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4352
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int res = 0;
    if(m2 >= m1){
        res = m2 - m1;
        res += (h2 - h1) * 60;
    }
    else{
        res += (m2 + 60 - m1);
        res += (h2 - h1 - 1) * 60;
    }
    cout << res - k << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int a,b,c;
    cin>>a>>b>>c;
    bool flag=b-a==c-b;
    cout<<(flag?"YES":"NO")<<endl;

    return 0;
}


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

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    int b[30];
    for (int i = 0; i < M; i++)
        cin >> b[i];
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = C;
        for (int j = 0; j < M; j++)
        {
            int a;
            cin >> a;
            sum += a * b[j];
        }
        if (sum > 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,y,total;
    scanf("%d%d",&x,&y);

    if(x>=1 && x<=100 && y>=1 && y<=100 && y%2==0)
    {
           total=x+(y/2);
    }
    printf("%d\n",total);

    return 0;

}


Measured memory_bytes: 128
//解説を参照した
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int ans = 0;
    for (int i=0;i<=K;i++){
      for (int j=0;j<=K;j++){
      int z = S - i - j;
        if (z>=0 && z<=K){
          ans ++;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
n = gets.to_i
v = 0; w = 1
n.times do
    a, b = gets.split.map &:to_i
    case a
    when 1
        v += b * w
    when 2
        v -= b * w
    when 3
        v *= b
    when 4
        w *= b
    end
end
p v / w

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define x first
#define y second
#define pb push_back

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

const int N = 2e6 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;



int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    ll n;
    cin >> n;
    ll ans = 1e18;
    forn(i, 1, n - 1) {
        ll x = 0;
        for (ll a = i, b = n - i; a || b; a /= 10, b /= 10)
            x += a % 10 + b % 10;
        ans = min(ans, x);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
<?php
while (fscanf(STDIN, "%d %d", $a, $L) && ($a || $L)) {
  $table = array();
  
  for ($i = 0; ; $i++) {
    if (isset($table[$a])) {
      print $table[$a] . " " . $a. " " . ($i - $table[$a]) . "\n";
      break;
    } else {
      $table[$a] = $i;
    }
    
    $a = strval($a);

    while (strlen($a) != $L) $a .= "0";

    $a = str_split($a);
    rsort($a);
    $b = implode($a);
    sort($a);
    $c = implode($a);
    
    $a = intval($b) - intval($c);
  }
}

Measured memory_bytes: 6644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>b;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pw 1000000000
#define pi 3.141592653589793238

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       //string s;
       int a[n+1];
       f(i,2,n+1)
       cin>>a[i];
       map<int,int> m;
       f(i,2,n+1)
       m[a[i]]++;
       f(i,1,n+1)
       {
           cout<<m[i]<<endl;
       }
       //sort(a,a+n);
       cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 13756
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll dp1[3300][3300];
ll dp2[3300][3300];

signed main(){
	ll n,t; cin>>n>>t;
	VL a(n),b(n); rep(i,n) cin>>a[i]>>b[i];
	// memset(dp1,-1,sizeof(dp1));
	// memset(dp2,-1,sizeof(dp2));
	dp1[0][0]=0LL; dp2[n+1][0]=0LL;
	reps(i,n){
		rep(j,t){
			dp1[i][j]=dp1[i-1][j];
			if(j-a[i-1]>=0) chmax(dp1[i][j],dp1[i-1][j-a[i-1]]+b[i-1]);
		}
	}
	REPS(i,n){
		rep(j,t){
			dp2[i][j]=dp2[i+1][j];
			if(j-a[i-1]>=0) chmax(dp2[i][j],dp2[i+1][j-a[i-1]]+b[i-1]);
		}
	}
	ll ans=max(dp1[n][t-1],dp2[1][t-1]);
	rep(i,n){
		rep(j,t){
			chmax(ans,dp1[i][j]+b[i]+dp2[i+2][t-1-j]);
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 157952
h, w = map(int, input().split())

dir = [(-1, 0), (0, -1), (1, 0), (0, 1)]

grid = [input() for _ in range(h)]

def ok(y, x):
    for d, r in dir:
        if d + y < 0 or d + y >= h or r + x < 0 or r + x >= w:
            continue
        yield grid[d+y][r+x] == "#"

for y in range(h):
    for x in range(w):
        if grid[y][x] == ".":
            continue

        if not any(ok(y, x)):
            print("No")
            exit()

print("Yes")






Measured memory_bytes: 3064
#include<stdio.h>
#define ll long long 
int main(){
    int a, b, c, d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int p = (a + d - 1) / d;
    int q = (c + b - 1) / b;
    if(p >= q)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 1660
alphabet = "abcdefghijklmnopqrstuvwxyz"
alphabet_i = {v:i for i,v in enumerate("abcdefghijklmnopqrstuvwxyz")}
N = int(input())
ans = []

memo = {}

def dfs(tmp,i):
    if i == N:
        ans.append(tmp)
        return

    maxi = max([alphabet_i[c] for c in tmp])
    for c in alphabet[:maxi+2]:
        dfs(tmp+c, i+1)

dfs("a", 1)
for s in ans:
    print(s)

Measured memory_bytes: 12656
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846

void Koch(int,double,double,double,double);
int main(){
  int n;
  double x1=0,y1=0,x2=100,y2=0;
  scanf("%d",&n);
  printf("%.8lf %.8lf\n",x1,y1);
  if(n>0)Koch(n,x1,y1,x2,y2);
  printf("%.8lf %.8lf\n",x2,y2);
  return 0;
}
void Koch(int n,double x1,double y1,double x2,double y2){
  n--;
  double x,y;
  x=((x2-x1)/3)*cos(PI/3)-((y2-y1)/3)*sin(PI/3)+(x2-x1)/3+x1;
  y=((x2-x1)/3)*sin(PI/3)+((y2-y1)/3)*cos(PI/3)+(y2-y1)/3+y1;
  
  if(n>0)Koch(n,x1,y1,(x2-x1)/3+x1,(y2-y1)/3+y1);

  printf("%.8lf %.8lf\n",(x2-x1)/3+x1,(y2-y1)/3+y1);

  if(n>0)Koch(n,(x2-x1)/3+x1,(y2-y1)/3+y1,x,y);

  printf("%.8lf %.8lf\n",x,y);

  if(n>0)Koch(n,x,y,(x2-x1)/3*2+x1,(y2-y1)/3*2+y1);

  printf("%.8lf %.8lf\n",(x2-x1)/3*2+x1,(y2-y1)/3*2+y1);

  if(n>0)Koch(n,(x2-x1)/3*2+x1,(y2-y1)/3*2+y1,x2,y2);
}


Measured memory_bytes: 2044
#include <cstdio>
#include <map>

#define cmax(a,b) ((a)>(b)?(a):(b))

using std::map;

template<class T>inline void fr(T &a) {
    T s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=w*s;
}
template<class T>inline T fr() {T a;fr(a);return a;}
#define R() fr<int>()

const int N=1e5;
map<int,int>ans[N+10];
struct Node {int u,v;}E[N+10];
namespace Edges {
    struct Edge {int to,nxt;}e[(N<<1)+10];
    int hd[N+10],deg[N+10],etot=0;
    void adde(int x,int y) {
        e[++etot]=(Edge){y,hd[x]},hd[x]=etot,deg[y]++;
    }
}
using namespace Edges;

void dfs(int u,int f,int x) {
    int cnt=1;
    for(int i=hd[u];i;i=e[i].nxt) {
        int v=e[i].to;
        if(v==f)continue;
        if(cnt==x)cnt++;
        ans[u][v]=ans[v][u]=cnt;
        dfs(v,u,cnt);
        cnt++;
    }
}

signed main() {
    int n=R(),Ans=0;
    for(int i=1;i<n;i++) {
        int x=R(),y=R();
        adde(x,y),adde(y,x);
        E[i]=(Node){x,y};
    }
    for(int i=1;i<=n;i++) Ans=cmax(Ans,deg[i]);
    printf("%d\n",Ans);
    dfs(1,0,0);
    for(int i=1;i<n;i++) printf("%d\n",ans[E[i].u][E[i].v]);
    return 0;
}

Measured memory_bytes: 15232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N;
    cin >> N;
    vector<string> s(2);
    cin >> s[0];
    cin >> s[1];

    ll ans = 0;
    int prev, i;
    const ll MOD = 1e9 + 7;

    if (s[0][0] == s[1][0]) {
        ans = 3;
        prev = 0;
        i = 1;
    }
    else{
        ans = 6;
        prev = 1;
        i = 2;
    }
    for(;i < N; i++){
        if(s[0][i] == s[1][i] && prev == 0){
            ans = (ans * 2) % MOD;
            prev = 0;
        }else if (s[0][i] != s[1][i] && prev == 0){
            ans = (ans * 2) % MOD;
            prev = 1;
            i++;
        }else if (s[0][i] == s[1][i] && prev == 1){
            prev = 0;
        }else if (s[0][i] != s[1][i] && prev == 1){
            ans = (ans * 3) % MOD;
            prev = 1;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 504
// inputに入力データ全体が入る
    function Main(inputString: string) {
        // 1行目がinput[0], 2行目がinput[1], …に入る
		let arrInputString = inputString.trim().split("\n");
		let a = arrInputString[0]
		let b = arrInputString[1]
		// StartWithする
		let isStartWith = b.startsWith(a)

		// lengthが+1か比較する
		let isPlusOne = (b.length - a.length == 1)
		// 最後の文字が英数字か確認する
		const regex = RegExp('^[A-Za-z0-9]*$');
		let isAlphanumeric = regex.test(b)

		//出力
		
    	if(isStartWith && isPlusOne && isAlphanumeric){
			console.log('Yes')
		}else {
			console.log('No')
		};
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
	Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29588
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

int main() {
  std::string s;
  int w;
  std::cin >> s >> w;
  for (int i = 0; w * i < (int)s.length(); ++i) std::cout << s[w * i];
  std::cout << std::endl;
  return 0;
}


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

int main() {
  int h, m, s;
  while(cin >> h >> m >> s) {
    int time = (h*3600 + m*60 + s) * -1;
    cin >> h >> m >> s;
    time += h*3600 + m*60 + s;

    h = time/3600;
    time %= 3600;
    m = time/60;
    s = time%60;
    cout << h << ' ' << m << ' ' << s << endl;
  }
}

Measured memory_bytes: 1160
/// referenced: https://beta.atcoder.jp/contests/abc066/submissions/2252964
#include <bits/stdc++.h>
using namespace std;

constexpr int64_t MOD = 1000000007;

int64_t Power(int64_t base, int64_t exp) {
  int64_t x = 1;
  while (exp) {
    if (exp % 2) {
      x = x * base % MOD;
    }
    base = base * base % MOD;
    exp /= 2;
  }
  return x;
}

int64_t Inv(int64_t x) {
  return Power(x, MOD - 2);
}

int64_t Factorial(int64_t x) {
  static vector<int64_t> xs;
  if (xs.size() == 0) {
    xs.resize(100002);
    xs[0] = 1;
    for (int i = 1; i < xs.size(); ++i) {
      xs[i] = xs[i - 1] * i % MOD;
    }
  }
  return xs[x];
}

int64_t InvFact[100002];

int64_t Combination(int64_t n, int64_t r) {
  if (n < r) return 0;
  int64_t x = Factorial(n);
  x = x * InvFact[r] % MOD;
  x = x * InvFact[n - r] % MOD;
  return x;
}


int main(){
  int64_t n,a;
  bool c[100002];
  cin >> n;
  for(int64_t i=1;i<=n;i++) c[i]=false;
  int64_t p[100002];
  int64_t x,y;

  for(int64_t i=0;i<=n;i++){
    cin >> a;
    if(c[a]){
      x=p[a];
      y=i;
    }
    c[a]=true;
    p[a]=i;
  }


//  Factorial[0]=1;
//  for(int64_t i=1;i<=n+1;i++) Factorial[i]=i*Factorial[i-1]%MOD;
  for(int64_t i=0;i<=n+1;i++) InvFact[i]=Inv(Factorial(i));

  for(int64_t i=1;i<=n+1;i++){
    int64_t ans;
    ans=Combination(n+1,i);
    if(i-1<=n-(y-x)) ans+=MOD-Combination(n-(y-x),i-1);
    cout << (ans%MOD) << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int n,d;
int a[15][15];
int x,ans=0;

int main(){
	scanf("%d %d",&n,&d);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=d;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			x=0;
			for(int k=1;k<=d;k++){
				x+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int g=sqrt(x);
			if(g*g==x) ans++;
		}
	}
	printf("%d\n",ans);
	
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 998244353;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;




int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int n,x;
	cin>>n>>x;
	int l[n];
	int cnt = 0;
	int cur  = 0;
	if(x>=cur)
		cnt++;
	for(int i = 0; i<n ; i++)
	{
		cin>>l[i];
		cur+=l[i];
		if(x>=cur)
			cnt++;
	}

	cout<<cnt<<endl;
	return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string N;
  cin >> N;
  if ((N[0] == '7') || (N[1] == '7') || (N[2] == '7')) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3028
#include <iostream>
#include <string>
using namespace std;
using ll=long long;

int main(){
    string S;
    cin >> S;
    ll K;
    cin >> K;
    string ans = "1";
    int place;
    for(int i = 0; i < S.length(); i++){
        if(S.substr(i,1) != "1"){
            ans = S.substr(i,1);
            place = i;
            break;
        }
    }
    if(K <= place) cout << "1" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 

  // input
  int a,b;
  cin>>a>>b;


  if(a==1 && b!=1)
    cout<<"Alice"<<endl;
  else if(a!=1 && b==1)
    cout<<"Bob"<<endl;
  else if(a==b)
    cout<<"Draw"<<endl;
  else if(a>b)
    cout<<"Alice"<<endl;
  else
    cout<<"Bob"<<endl;
  

	return 0;
}


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

int main(){
  int R,W,c,r;
  while(1){
    cin>>R>>W>>c>>r;
    if(R==0&&W==0&&c==0&&r==0)break;
    int ans=0;
    while( (R+ans*r) < c*W )ans++;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i, N) {
        cin >> D.at(i);
    }
    int M;
    cin >> M;
    vector<int> T(M);
    REP(i, M) {
        cin >> T.at(i);
    }
    int cnt = 0;
    sort(D.begin(), D.end());
    sort(T.begin(), T.end());
    int j = 0;
    REP(i, N) {
        if(D.at(i) == T.at(j)) {
            if(j != M-1) {
                j++;
            } else {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

#include <iostream>
using namespace std;

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(W>=x+r && H>=y+r && x+r>0 && y+r>0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}



Measured memory_bytes: 3096
def distance(a, b, n):
    count = 0
    for i in range(n):
        if a[i] != b[i]:
            count += 1
    return count

def main():
    array = [int(x) for x in input()]
    n = len(array)
    a0 = [1 if i % 2 == 1 else 0 for i in range(n)]
    a1 = [1 if i % 2 == 0 else 0 for i in range(n)]
    print(min(distance(array, a0, n), distance(array, a1, n)))

if __name__ == '__main__':
    main()


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

int main(){

    uint64_t A;
    string B;
    cin >> A >> B;
    int B_int = stoi(B.erase(1, 1));

    uint64_t C = A*B_int/100;
    cout << C << endl;

    return 0;
}

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct Dice {
    top: u32,
    south: u32,
    east: u32,
    west: u32,
    north: u32,
    bottom: u32
}

impl Dice {
    fn new(a: &[u32]) -> Self {
        Dice {
            top: a[0],
            south: a[1],
            east: a[2],
            west: a[3],
            north: a[4],
            bottom: a[5]
        }
    }

    fn stdout_top(&mut self) -> u32 {
        return self.top;
    }

    fn go_north(&mut self) {
        let tmp = self.top;
        self.top = self.south;
        self.south = self.bottom;
        self.bottom = self.north;
        self.north = tmp;
    }
    fn go_south(&mut self) {
        let tmp = self.top;
        self.top = self.north;
        self.north = self.bottom;
        self.bottom = self.south;
        self.south = tmp;
    }
    fn go_east(&mut self) {
        let tmp = self.top;
        self.top = self.west;
        self.west = self.bottom;
        self.bottom = self.east;
        self.east = tmp;
    }
    fn go_west(&mut self) {
        let tmp = self.top;
        self.top = self.east;
        self.east = self.bottom;
        self.bottom = self.west;
        self.west = tmp;
    }
}

fn main() {
    let arr:Vec<u32> = (0..6).map(|_| read()).collect();
    let mut dice = Dice::new(&arr);
    let cm:String = read();
    for c in cm.chars() {
        match c {
            'N' => dice.go_north(),
            'E' => dice.go_east(),
            'W' => dice.go_west(),
            _ => dice.go_south()
        }
    }
    println!("{:?}", dice.stdout_top());
}


Measured memory_bytes: 5028
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, m, maxn = 0;
	vector<int>list;
	int k;
	string s;

	cin >> n >> k >> s;

	s[k - 1] += 32;

	cout << s << endl;



	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  var arr = input[1].split(" ").map(Number);
  var sum = 0;
  for(var i=0;i<arr.length;i++){
  if(arr[arr[i]-1] == i+1) sum++;
  }
  console.log(sum/2);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int main() {
  string s;
  cin >> s;
  rep(i, s.length()) {
    if ((i % 2 == 1 && s[i] == 'R') || (i % 2 == 0 && s[i] == 'L')) {
      cout << "No" << endl; 
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
G = [list(map(int, input().split())) for _ in range(N)]

sections = [[0 for _ in range(C)] for _ in range(3)]
for y in range(N):
    for x in range(N):
        sections[(x+y+2)%3][G[y][x]-1] += 1

discomfort = [[0 for _ in range(C)] for _ in range(3)]
for section in range(3):
    for target in range(C):
        for source in range(C):
            if source != target:
                discomfort[section][target] += D[source][target] * sections[section][source]
ans = float('inf')
for i in range(C):
    for j in range(C):
        if i != j:
            for k in range(C):
                if k not in [i, j]:
                    ans = min(ans, discomfort[0][i]+discomfort[1][j]+discomfort[2][k])
print(ans)


Measured memory_bytes: 5620
n=int(input())
a=list(map(int,input().split()))
cost=abs(a[n-1])
a.append(0)
a.insert(0,0)
for i in range(n):
    tmp=abs(a[i]-a[i+1])
    cost+=tmp
for i in range(n):
    ans=cost+abs(a[i]-a[i+2])-abs(a[i+1]-a[i])-abs(a[i+1]-a[i+2])
    print(ans)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int A, B, H, M;
	cin >> A >> B >> H >> M;
	double theta = abs(H * 30 + 30 * M / 60.0 - M * 6);
	if (theta == 180) {
		cout << A + B << endl;
		return 0;
	}
	if (theta == 0) {
		cout << abs(A - B) << endl;
		return 0;
	}
	if (theta > 180) {
		theta = 360 - theta;
	}
	double pi = atan(1) * 4;
	theta *= pi / 180;
	double res = sqrt(A * A + B * B - 2 * A * B * cos(theta));
	cout << fixed << setprecision(15) << res << endl;

	return 0;
}


Measured memory_bytes: 4100
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n = int(input())

    for i in range(26):
        if (n-i*4) % 7 == 0 and n - i * 4 >= 0:
            print("Yes")
            break

    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
input_str = input().strip()

def main():
  N = len(input_str)
  input_str_part1 = input_str[:int((N-1)/2)]
  input_str_part2 = input_str[int((N+3)/2)-1:]
  flag0 = input_str == input_str[::-1]
  flag1 = input_str_part1 == input_str_part1[::-1]
  flag2 = input_str_part2 == input_str_part2[::-1]
  if flag0 * flag1 * flag2:
    print("Yes")
  else:
      print("No")
  return

if __name__ == "__main__":
  main()

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
  int height, width;  scanf("%d%d", &height, &width);
  char field[52][52];
  for(int i=0; i<height; i++)
    scanf("%s", field[i]);

  for(int i=0; i<height; i++){
    for(int j=0; j<width; j++){
      if(field[i][j] == '#'){
	printf("#");
      }else{
	int sum = 0;
	for(int row=-1; row<=1; row++){
	  for(int column=-1; column<=1; column++){
	    if(row == 0 && column == 0)  continue;
	    if(i+row < 0 || j+column<0 || i+row >=height || j+column >= width)
	      continue;
	    if(field[i+row][j+column] == '#')  sum++;
	  }
	}
	printf("%d", sum);
      }
    }puts("");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

vector<i64> z(string S) {
  vector<i64> A(S.size());
  A[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
  return A;
}

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

  i64 ans = 0;
  for (i64 i = 0; i < n; ++i) {
    auto a = z(s.substr(i));
    for (i64 j = i; j < n; ++j) {
      // cerr << a[j - i];
      ans = max(ans, min(j - i, a[j - i]));
    }
    // cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int& x:a) cin>>x;
	int res=1e9;
	for(int i=-100;i<=100;++i){
		int total=0;
		for(int x:a) total+=(x-i)*(x-i);
		res=min(res,total);
	}
	cout<<res;
}

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

int main() {
  int n; cin >>n;
  vector<ll> a(n);
  ll sum = 0;
  for (int i=0; i<n; i++){
    cin >>a.at(i); sum += a.at(i);
  }
  ll mindis = sum;
  ll buf = 0;
  for (int i=0; i<n-1; i++){
    buf += a.at(i);
    ll dist = max(sum-buf,buf-sum);
    ll sub = max(dist-(sum-dist),(sum-dist)-dist);
    if (sub<mindis){
      mindis = sub;
    }
  }
  ll ans = mindis;
  cout <<ans <<endl;
}


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

#define NAME "rewind"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 1e5;
bool first[maxn+1];
int a[100];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<=k;i++){
        for(int j = 0;j<n && i - a[j] >=0 ;j++)
            if(!first[ i - a[j] ]) {
                    first[i] = true;
                    break;
            }
    }
    if (first[k])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
}


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

int main(){
  int N;
  int sum = 0;
  cin >> N;
  int A = N;
  for (int i = 1; i < 9; i++){
    int B = A % 10;
    sum += B;
    A -= B;
    A /= 10;
  }
  
  if (N % sum == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll pr[2000010];
const ll mod=1e9+7;
int n, k;
char s[1000010];
long long fact[2000010];
void pre(){
    fact[0]=1;
    for(long long i=1; i<2000010; ++i){
        fact[i]=(fact[i-1]*i)%mod;
    }
}
long long pwr(long long x, long long e){
    if(e==0)
        return 1;
    long long tmp=pwr(x,e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2)
        tmp=(tmp*x)%mod;
    return tmp;
}
long long cmb(long long x, long long y){
    long long res, tmp;
    tmp=pwr(fact[x-y], mod-2);
    res=(fact[x]*tmp)%mod;
    tmp=pwr(fact[y],mod-2);
    res=(res*tmp)%mod;
    return res;
}
int main(){
    pr[0]=1;
    for(int i=1; i<2000010; ++i){
    	pr[i]=pr[i-1]*25;
    	pr[i]%=mod;
    }
    pre();
    while(cin>>k){
        ll ans=0;
        scanf("%s",s);
        n=strlen(s);
        ll tmp26=1, tmp1;
        for(int i=0; i<=k; ++i){
        	tmp1=tmp26*cmb(n+k-i-1, n-1);
        	tmp1%=mod;
        	tmp1*=pr[k-i];
        	ans+=tmp1;
        	ans%=mod;
        	tmp26*=26;tmp26%=mod;
        }
        printf("%lld\n",ans);
    }
  return 0;
}




Measured memory_bytes: 35952
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int N,mas[16][17],dp[1<<16];
inline int rec(int bit){
  if(dp[bit]) return dp[bit];
  if(!bit) return 0;
  int ret = INF;
  for(int i = 0 ; i < N ; i++ ){
    if(!(bit & (1 << i))) continue;
    int min_cost = mas[i][0];
    for(int j = 0 ; j < N ; j++ ){
      if(!(bit & (1 << j))) min_cost = min( min_cost, mas[i][j+1]);
    }
    ret = min( ret, min_cost + rec(bit&~(1 << i)));
  }
  return dp[bit] = ret;
}
int main(){
  while(cin >> N , N ){
    for(int i = 0 ; i < 1 << N ; i++ ) dp[i] = 0;
    for(int i = 0 ; i < N ; i++ ){
      for(int j = 0 ; j <= N ; j++ ){
        cin >> mas[i][j];
      }
    }
    cout << rec((1 << N)-1) << endl;
  }
}

Measured memory_bytes: 1420
n,m=[int(i) for i in input().split()]
count=m
a=[]

for i in range(m):
  a.append([int(j) for j in input().split()])
 
a.sort(key=lambda x:x[1])

k=0
for i in range(1,m):
    if a[k][1] > a[i][0]:
      count -= 1
    else:
      k = i

print(count)


Measured memory_bytes: 22816
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i + 1) * (j + 1) * (l + 1) <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])


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

int main(void){
   int N,L;
   cin>>N>>L;
   vector<string> S(N);
   for(int i=0;i<N;i++){
      cin>>S[i];
   }
   sort(S.begin(),S.end());
   string result="";
   for(int i=0;i<N;i++){
      result+=S[i];
   }
   cout<<result<<endl;
   return 0;
}



Measured memory_bytes: 256
import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
import itertools

t=[i for i in range(1,n+1)]
a = list(itertools.permutations(t))




def num(b,t,n):
  c = 0
  for i in range(len(t)):
    if list(t[i]) != b:
      c += 1
    else:
      break
  return(c)


 
x = num(p,a,n)
y = num(q,a,n)
print(abs(x-y))

Measured memory_bytes: 13860
source = input().split('/')
year, month, day = int(source[0]), int(source[1]), int(source[2])
if year < 2019:
    print('Heisei')
elif year == 2019:
    if month < 4:
        print('Heisei')
    elif month == 4:
        if day <= 30:
            print('Heisei')
    else:
        print('TBD')
else:
    print('TBD')

Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

vector<vector<pair<long, long> > > tt;
vector<ll> dist;
vector<long> vis;

void dfs( long curr )
{
    if(vis[curr]) return;
    vis[curr]=1;
    long i;
    for(i=0; i<(long)tt[curr].size(); i++) {
        long next = tt[curr][i].first;
        if(!vis[next]) {
            dist[next] = dist[curr] + tt[curr][i].second;
            dfs(next);
        }
    }
    return;
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    tt.resize(n);
    long i;
    for(i=0; i<n-1; i++) {
        long a,b,c;
        scanf("%ld%ld%ld", &a, &b, &c);
        tt[a-1].push_back(make_pair(b-1, c));
        tt[b-1].push_back(make_pair(a-1, c));
    }

    long q, k;
    scanf("%ld%ld", &q, &k);

    vis.resize(n);
    dist.resize(n);
    dist[k-1]=0.0;
    dfs( k-1 );

    for(i=0; i<q; i++) {
        long x, y;
        scanf("%ld%ld", &x, &y);
        printf("%lld\n", dist[x-1] + dist[y-1]);
    }

    return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>

int main(){
	
  int a,b,c,d,e,aa,bb,cc,dd,ee,max,sum;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  sum = a + b + c + d + e;
  if(a%10==0){
    aa = 0;
  } else {
    aa = 10 - a%10;
  }
  if(b%10==0){
    bb = 0;
  } else {
    bb = 10 - b%10;
  }
  if(c%10==0){
    cc = 0;
  } else {
    cc = 10 - c%10;
  }
  if(d%10==0){
    dd = 0;
  } else {
    dd = 10 - d%10;
  }
  if(e%10==0){
    ee = 0;
  } else {
    ee = 10 - e%10;
  }
  
  max = sum + bb + cc + dd + ee;
  if(max > sum + aa + cc + dd + ee){
    max = sum + aa + cc + dd + ee;
  }
  if(max > sum + aa + bb + dd + ee){
    max = sum + aa + bb + dd + ee;
  }
  if(max > sum + aa + bb + cc + ee){
    max = sum + aa + bb + cc + ee;
  }
  if(max > sum + aa + bb + cc + dd){
    max = sum + aa + bb + cc + dd;
  }
   
  	printf("%d\n",max);
  
	return 0;
  	
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;
 
fn main(){
    let n = read::<i32>();
    let a = read::<i32>();
    println!("{}", if n%500<=a {"Yes"} else {"No"} )    
}
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
int a[50], b[50];
bool dp[51][51];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) cin >> b[i];
	for (int i = 0; i < N; i++) {
		if (a[i] != b[i] && b[i] >= (a[i] + 1) / 2) {
			cout << -1 << endl;
			return 0;
		}
	}
	vector<int> S;
	ll ans = 0;
	for (int i = 50; i >= 1; i--) {
		memset(dp, 0, sizeof(dp));
		for (int j = 0; j <= 50; j++) dp[j][j] = 1;
		for (int j = 0; j <= 50; j++) {
			for (int k = 1; k < i; k++) {
				dp[j][j%k] = 1;
			}
			for (int k : S) {
				dp[j][j%k] = 1;
			}
		}
		for (int m = 0; m <= 50; m++) {
			for (int j = 0; j <= 50; j++) {
				for (int k = 0; k <= 50; k++) {
					dp[j][k] |= (dp[j][m] & dp[m][k]);
				}
			}
		}
		bool ok = 1;
		for (int j = 0; j < N; j++) {
			if (!dp[a[j]][b[j]]) {
				ok = 0;
				break;
			}
		}
		if (!ok) {
			ans += 1LL << i;
			S.push_back(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256