akhauriyash/Code-Regression huggingface dataset:
void E(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = temp;
}
void S(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = temp;
}
void N(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = temp;
}
void W(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = temp;
}
 
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
    int i, j, t, f, l, r, b, c, n=0, count=0, count1=0, count2=0;
    int t2, f2, l2, r2, b2, c2;
    int d[6], d2[6];
    int C=0;
     
    scanf("%d", &n);
     
    for(i=0; i<6; i++) {
        scanf("%d",&d[i]);
    }
    b = d[4];
    t = d[0];
    r = d[2];
    l = d[3];
    c = d[5];
    f = d[1];
     
    for(j=0; j<n-1; j++){
        for(i=0; i<6; i++) {
            scanf("%d",&d2[i]);
        }
        b2 = d2[4];
        t2 = d2[0];
        r2 = d2[2];
        l2 = d2[3];
        c2 = d2[5];
        f2 = d2[1];
         
        while (d2[1] != f) {
             
            if((d2[1] != b) &&
               (d2[1] != t) &&
               (d2[1] != r) &&
               (d2[1] != l) &&
               (d2[1] != c) &&
               (d2[1] != f) ){
                count++;
                break;
            }
             
            if (d2[2] == f || d2[3] == f) {
                E(d2);
            }
            N(d2);
        }
        while(d2[5] != c){
            if((d2[5] != b) &&
               (d2[5] != t) &&
               (d2[5] != r) &&
               (d2[5] != l) &&
               (d2[5] != c) &&
               (d2[5] != f) ){
                count1++;
                break;
            }
            if(0 < count) break;
            E(d2);
            C++;
            if(C >= 4)break;
        }
        C=0;
        while (d2[0] != t) {
            if((d2[0] != b) &&
               (d2[0] != t) &&
               (d2[0] != r) &&
               (d2[0] != l) &&
               (d2[0] != c) &&
               (d2[0] != f) ){
                break;
            }
            if(0 < count) break;
            if(0 < count1) break;
            E(d2);
            C++;
            if(C >= 4)break;
        }
         
        b2 = d2[4];
        t2 = d2[0];
        r2 = d2[2];
        l2 = d2[3];
        c2 = d2[5];
        f2 = d2[1];
         
        if(b == b2 &&
           t == t2 &&
           r == r2 &&
           l == l2 &&
           c == c2 &&
           f == f2){
            count2++;
        }
    }
    if(count2 == 0 ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
     
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll n, k;
    std::cin >> n >> k;
    std::cout << std::min(n % k, (k - n % k) % k) << '\n';
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  r <- readLn
  putStrLn $ solve r

solve :: Int -> String
solve r
  | r < 1200 = "ABC"
  | r < 2800 = "ARC"
  | otherwise = "AGC"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    ll n; cin >> n;
    ll t, ans = 1LL;
    for(int i = 0;i < n;i++){
        cin >> t;
        ans = LCM(t,ans);
    }
    cout << ans;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
const int MN = 1e5+5;
char str[MN];
int cnt[256];

inline int max(int a, int b) { return a > b ? a : b; }

int main() {
  scanf("%s", str);
  int len = strlen(str);
  
  if(str[0] == str[1]) {
    printf("1 2");
	return 0;
  }
  for(int i = 2; i < len; i++) {
    if(str[i-1] == str[i]) {
	  printf("%d %d", i, i+1);
	  return 0;
    }
	if(str[i-2] == str[i]) {
	  printf("%d %d", i-1, i+1);
	  return 0;
    }
  }
  printf("-1 -1");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include <iomanip>
#include <limits>
#include <thread>
#include <map>
#include <stack>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;


vector<array<int,3>> e;
ll dist[2505];

int main(){ 
  cin.tie(0); ios::sync_with_stdio(false);
  int n,m,p;
  cin >> n >> m >> p;
  rep(i,2505)dist[i] = _llinf;
  dist[1] = 0;

  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    e.push_back({a,b,c-p});
  }


  rep(_,n) for(const auto& i : e) dist[i[1]] = dist[i[0]] != _llinf && dist[i[1]] < dist[i[0]]+i[2] ? dist[i[0]]+i[2] : dist[i[1]];


  for(const auto& i : e) dist[i[1]] = dist[i[0]] != _llinf && dist[i[1]] < dist[i[0]]+i[2] ? llinf : dist[i[1]];


  rep(_,n) for(const auto& i : e) dist[i[1]] = dist[i[0]] == llinf ? llinf : dist[i[1]];

  ll ans;
  if(dist[n] < 0){
    ans = 0;
  }
  else{
    ans = dist[n] == llinf ? -1 : dist[n];
  }
  
  prints(ans);


  return 0;

}


Measured memory_bytes: 384
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
   input! {
      x: usize,
      y: usize,
   }
   for a in 0..=x {
      let b = x - a;
      if a * 2 + b * 4 == y {
         println!("Yes");
         return;
      }
   }
   println!("No");
}


Measured memory_bytes: 2144
X = int(input())
l = []
if X < 4:
  print(1)
else:
  for i in range(2, int(X ** 0.5) + 1):
    j = 2
    while i ** j <= X:
      l.append(i ** j)
      j += 1
  l.sort()
  print(l[-1])


Measured memory_bytes: 3060
#include<stdio.h>

#define H 251


int A[H];

int main(){
 
  int n;
  int i;

  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    scanf("%d",&A[i]);
  }

  for(i = 1;i <= n;i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(i/2 != 0){
      printf("parent key = %d, ",A[i/2]);
    }
    if(2*i <= n){
      printf("left key = %d, ",A[2*i]);
    }
    if(2*i+1 <= n){
      printf("right key = %d, ",A[2*i+1]);
    }
    printf("\n");
  }
return 0;
}
    

Measured memory_bytes: 600
require 'pp'

n = gets.to_i # 人数

a = Array.new(n){ Array.new(n, nil) }
n.times do |i|
  aa = gets.to_i
  aa.times do
    x, y = gets.split.map(&:to_i)
    if y == 1 # 正直
      a[i][x-1] = true
    else
      a[i][x-1] = false
    end
  end
end
# pp a

max = 0

[true, false].repeated_permutation(n).to_a.each do |arr|
  # puts "========"
  # p arr
  tmp = arr.count{|x|x}
  # p tmp
  flag = true
  arr.size.times do |i| # それぞれの人
    next if !arr[i] # 真偽不明の人はどうでもいい
    a[i].each.with_index do |aa, ii| # 曰く、i番目の人は.
      next if aa == nil
      if aa # 正直ですって行ってたのに
        if arr[ii] == false #違かったら
          flag = false
        end
      else # 非正直ですって行ってたのに
        if arr[ii] == true #違かったら
          flag = false
        end
      end
    end
  end
  if flag
    max = tmp if max < tmp
  end
end

p max
# 2 0 1


Measured memory_bytes: 13564
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main(){
  string S; cin >>S;
  int check[26]={};
  rep(i,0,S.size()) {
    int temp=S[i]-'a';
    check[temp]++;
  }
  bool flag=true;
  rep(i,0,26) {
    if (1<check[i]) {flag=false; break;}
  }
  cout <<(flag ? "yes":"no") <<endl;
  return 0;    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  long long cnt=0,ans=0;
  int n;
  cin >> n;
  map<long long,long long> mp;
  mp[0]=1;
  for(int i=0; i<n; i++) {
    long long a;
    cin >> a;
    cnt+=a;
    ans+=mp[cnt];
    mp[cnt]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
import numpy as np
hwk=input().split()
H=int(hwk[0])
W=int(hwk[1])
K=int(hwk[2])
bits=np.zeros(H+1,dtype='int64')
c = [input() for _ in range(H)]
ans=int(0)
while bits[H]==0:
    dp=np.zeros(H*W+1,dtype='int64')
    dp[0]+=1
    for j in range(W):
        kaz=0
        for i in range(H):
            if bits[i]==1 and c[i][j]=='#':
                kaz+=1
        for i in range(H*W,kaz-1,-1):
            dp[i]+=dp[i-kaz]
    ans+=dp[K]

    bits[0]+=1
    bas=0
    while bits[bas]==2:
        bits[bas]=0
        bas+=1
        bits[bas]+=1
print(ans)







Measured memory_bytes: 27160
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N, Y;
  cin >> N >> Y;

  bool judge = false;
  for(int i=0;i<=N;i++){
    for(int j=0;i+j<=N;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout << i << " " << j << " " << N-i-j <<endl;
        judge = true;
        break;
      }
    }
    if(judge) break;
  }
  if(!judge) cout << -1 << " " << -1 << " " << -1 <<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

bool pairCompare(const pair<ll, ll> &firstElof, const pair<ll, ll> &secondElof)
{
    return firstElof.second < secondElof.second;
}

int main()
{
    ll N = input<ll>();

    vector<pair<ll, ll>> a;
    for (ll i = 0; i < N; i++)
    {
        a.push_back(pair<ll, ll>(i + 1, input<ll>()));
    }

    sort(a.begin(), a.end(), pairCompare);

    for (ll i = 0; i < N; i++)
    {
        cout << a[i].first << (i != N - 1 ? " " : "\n");
    }

    return 0;
}

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

//a^b % modを求める
int64_t MODpow(int64_t a, int64_t b, int64_t mod) {
    int64_t result = 1;
    while (b) {
        if (b % 2 == 1) {
            result *= a;
            result %= mod;
        }

        b /= 2;
        a *= a;
        a %= mod;
    }

    return result;
}

class Combination {
public:
    Combination(int64_t max_num, int64_t mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (int64_t i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2, mod_);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    int64_t operator()(int64_t n, int64_t m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    vector<int64_t> fact_, inv_fact_;
    int64_t mod_;
};

int main() {
    int64_t N, M, K;
    cin >> N >> M >> K;

    constexpr int64_t MOD = 998244353;
    Combination comb(N + K, MOD);

    int64_t ans = 0;

    //i個の隣り合う組みが同じ色で塗られるとする
    for (int64_t i = 0; i <= K; i++) {
        //要素はN - i個
        //N - i個への色の与え方
        int64_t color_num = M * MODpow(M - 1, N - 1 - i, MOD) % MOD;

        //N - i個の組み合わせ方
        int64_t pattern = comb(N - 1, i);

        (ans += color_num * pattern % MOD) %= MOD;
    }
    cout << ans << endl;
}

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


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  string s;
  cin >> s;
  string tmp = "R";
  int ans = 0;
  for(int i=1; i<=3; i++){
    for(int j=0; j<3-i+1; j++){
      if(tmp==s.substr(j,i)) ans = i;
    }
    tmp += "R";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
from collections import deque
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
s=input()
n=len(s)
ten=[1]
mod=2019
for i in range(n-1):
  ten.append((ten[i]*10)%mod)
modls=[0]*n
modls[n-1]=int(s[n-1])
dic=defaultdict(int)
dic[modls[n-1]]+=1
dic[0]=1
for i in range(n-2,-1,-1):
  modls[i]=int(s[i])*ten[n-1-i]+modls[i+1]
  modls[i]%=mod
  dic[modls[i]]+=1
ans=0
#print(dic)
for num in dic.values():
	ans+=num*(num-1)//2
#ans+=dic[0]
print(ans)

Measured memory_bytes: 84440
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

char s[210000];
char t[210000];

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int r, c, n;
  while (scanf("%d%d%d", &r, &c, &n) == 3) {
    int x, y;
    scanf("%d%d", &x, &y);
    scanf("%s%s", s, t);
    --x, --y;

    int xl = 0, xr = r;
    int yl = 0, yr = c;

    bool fail = false;

    auto norm = [&]() {
      xl = max(xl, 0);
      xr = min(xr, r);
      yl = max(yl, 0);
      yr = min(yr, c);
      fail |= xl >= xr;
      fail |= yl >= yr;
    };

    for (int i = n - 1; i >= 0; i--) {
      switch (t[i]) {
        case 'L': yr++; break;
        case 'R': yl--; break;
        case 'U': xr++; break;
        case 'D': xl--; break;
      }
      norm();
      switch (s[i]) {
        case 'L': yl++; break;
        case 'R': yr--; break;
        case 'U': xl++; break;
        case 'D': xr--; break;
      }
      norm();
    }

    fail |= !(xl <= x && x < xr && yl <= y && y < yr);

    printf("%s\n", fail ? "NO" : "YES");
  }

  return 0;
}


Measured memory_bytes: 640
from collections import deque

R, C = map(int, input().split())
c = [["#" for _ in range(C + 2)]] + [["#"] + list(input()) + ["#"] for _ in range(R)] + [["#" for _ in range(C + 2)]]
tekazu = [[0 for _ in range(C + 2)] for _ in range(R + 2)]

def bfs(start, goal):
	queue = deque([start])
	visited = []
	while queue:
		#print(queue)
		label = queue.pop()
		
		if label == goal:
			visited.append(label)
			return True

		if label not in visited:
			visited.append(label)
			#print(visited)
			if c[label[0] + 1][label[1]] == "." and [label[0] + 1, label[1]] not in visited:
				queue.appendleft([label[0] + 1, label[1]])
				tekazu[label[0] + 1][label[1]] = tekazu[label[0]][label[1]] + 1

			if c[label[0] - 1][label[1]] == "." and [label[0] - 1, label[1]] not in visited:
				queue.appendleft([label[0] - 1, label[1]])
				tekazu[label[0] - 1][label[1]] = tekazu[label[0]][label[1]] + 1

			if c[label[0]][label[1] + 1] == "." and [label[0], label[1] + 1] not in visited:
				queue.appendleft([label[0], label[1] + 1])
				tekazu[label[0]][label[1] + 1] = tekazu[label[0]][label[1]] + 1

			if c[label[0]][label[1] - 1] == "." and [label[0], label[1] - 1] not in visited:
				queue.appendleft([label[0], label[1] - 1])
				tekazu[label[0]][label[1] - 1] = tekazu[label[0]][label[1]] + 1
		#print(visited)
	return False

if bfs([1, 1], [R, C]) == False:
	print(-1)
else:
	num = 0
	for r in c:
		num += r.count(".")
	print(num - tekazu[R][C] - 1)

Measured memory_bytes: 3564
class PrefixQueue
  def initialize
    @list = []
  end
 
  def empty?
    @list.empty?
  end
 
  def shift
    @list.shift
  end
 
  def push(key, value)
    index = @list.index{|target, _| target >= key}
    return @list[index][1] if index && @list[index][0] == key
    @list.insert(index || @list.size, [key, value])
    value
  end
end

class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def collect(n, arrows, goal)
  come_from = Array.new(n){[]}
  arrows.each do |arrow|
    come_from[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    come_from[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end
  reachable_from
end

def work(n, arrows, start, goal)
  reachable_from = collect(n, arrows, goal)
  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  go = Array.new(n){[]}
  arrows.each do |arrow|
    go[arrow.source] << arrow
  end

  max = n * arrows.map{|arrow| arrow.label.size}.max

  queue = PrefixQueue.new
  queue.push('', {start => true})
  until queue.empty?
    spell, map = queue.shift
    return spell if map[goal]

    return nil if spell.size > max

    map.each do |node, unused|
      go[node].each do |arrow|
        t = queue.push(spell + arrow.label, {})
        t[arrow.sink] = true if t
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts work(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 9956
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main()
{
	int N, D, cnt = 0;
	cin >> N >> D;
	for (int i = 0; i < N; i++)
	{
		ll x, y;
		cin >> x >> y;
		double dist = sqrt(x*x + y*y);
		if (dist <= D)cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3620
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=15;
const int MAXD=15;
int n,d,x[MAXN][MAXD],Ans;
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&x[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int ret=0;
			for(int k=1;k<=d;k++)
				ret+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			int t=int(sqrt(ret)+0.0001);
			if(t*t==ret)Ans++;
		}
	printf("%d\n",Ans);
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
#define endl '\n'

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
constexpr int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
constexpr int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
constexpr int32_t LCM(int32_t a, int32_t b){return a / GCD(a, b) * b;}
constexpr int64_t LCM(int64_t a, int64_t b){return a / GCD(a, b) * b;}

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

//#define int int64_t

/*global*/



//dfs
vector<vector<int>> to( 1005*1004/2 ) ;

vector<vector<int>>  id( 1005, vector<int>(1005) );
int toid(int i, int j)
{
	if( i > j ) swap( i, j ) ;

	return id[i][j] ;
}

bool visited[1005*1004/2];
bool calculated[1005*1004/2];
int dp[1005*1004/2]; //max length of path from v, vスタートの最長経路
int dfs( int v )
{
	if( visited[v] )
	{
		if(!calculated[v]) return -1;
		return dp[v] ;
	}
	visited[v] = true ;

	dp[v] = 1 ;
	for( auto &u: to[v] )
	{
		int res = dfs(u);
		if(res == -1) return -1;
		dp[v] = max( dp[v], res+1 ) ;
	}
	calculated[v] = true;

	return dp[v] ;
}


signed main()
{
	int n ; cin >> n ;
	vector<vector<int>> a( n, vector<int>(n-1) ) ;
 
	for(int i{}; i < n; ++i)
	{
		for(int j = 0; j < n-1; ++j)
		{
			cin >> a[i][j] ;
			a[i][j]--;
		}
	}

	int v{};
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if( i < j )
			{
				id[i][j] = v++;
			}
		}
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n-1; ++j)
		{
			a[i][j] = toid(i, a[i][j]);
		}
		for (int j = 0; j < n-2; ++j)
		{
			to[a[i][j+1]].emplace_back(a[i][j]);
		}
	}
	int ans{};
	for (int i = 0; i < v; ++i)
	{
		int res = dfs(i);
		if(res == -1)
		{
			cout << -1 << '\n';
			return 0;
		}
		ans = max(ans, res);
	}
	
	cout << ans << '\n';
}

Measured memory_bytes: 38528
#include <bits/stdc++.h>
#define base 950527
using namespace std;
typedef unsigned long long ll;
map <ll,ll> map;

int main(){
  string a,b;
  cin>>a>>b;
  
  ll hs=0,n=0,t=1;
  for(int i=0;i<b.size();i++){
    hs=hs*base+b[i];
    n=n*base+a[i];
    t*=base;
  }
  
  if(hs==n) cout <<0<<endl;
  for(int i=b.size();i<a.size();i++){
    n=n*base-t*a[i-b.size()];
    n+=a[i];
    if(hs==n) printf("%d\n",i-(int)b.size()+1);
  }
  return 0;
}

Measured memory_bytes: 2304
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
     ll N,a[100];
     std::cin >> N;
     for (int i = 0; i < N; i++) {
         std::cin >> a[i];
     }
     ll now=1;
     ll res=0;
     for (int i = 1; i < N; i++) {
         if(a[i-1]==a[i]){
             now++;
         }else{
             res+=now/2;
             now=1;
         }
     }
     res+=now/2;
     std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

ll dp[101][(int)(1e5+1)];
int main(){
	IOS
 	int n,W;
 	cin>>n>>W;
 	vector<pl> v(n);
 	cin>>v;

 	for(int i=1;i<=n;i++)
 	{
 		for(int w=1;w<=W;w++)
 		{
 			if(v[i-1].fi<=w)
 			dp[i][w] = max(dp[i-1][w-v[i-1].fi]+v[i-1].se,dp[i-1][w]);
 			else
 				dp[i][w] = dp[i-1][w];
 		}
 	}
 	cout<<dp[n][W];
 	


 
	return 0;	
}

Measured memory_bytes: 78336
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	s := eGetLine(scanner)
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


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

typedef long long LL;

int a;

LL b, n;

int main() {
	scanf("%d%lld%lld", &a, &b, &n);
	LL x = min(b - 1, n);
	printf("%lld\n", ((LL)a * x / b) - a * (x / b));
	
	return 0;
}

Measured memory_bytes: 3108
n = gets.split(" ").map(&:to_i)

v = []

v = gets.split(" ").map(&:to_i)

c = []

c = gets.split(" ").map(&:to_i)


v_c = [v,c].transpose.map{|a| a.inject(:-) }

v_c = v_c.sort

sum = 0

v_c.each do |v_c|
  if v_c <= 0
    next
  end
  sum += v_c

end

print sum



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
using ll =unsigned long long;

ll power(ll a,ll r)
{
    ll ans=1;
    for (int i=0;r>>i>0;i++)
    {
        if ((r>>i)&1) ans=ans*a%mod;
        a=a*a%mod;
    }
    return ans;
}

ll modinv(ll a)
{
    return power(a,mod-2);
}



 

int main()
{
    ll N,M,K; cin >> N >> M >> K;
    vector<ll> dp(N+1,0);
    vector<ll> fact(N+1,0);
    fact[0]=1;
    dp[1]=M;
    for (int i=1;i<N+1;i++)
    {
        fact[i]=fact[i-1]*i%mod;
    }
    for (int i=2;i<N+1;i++) dp[i]=dp[i-1]*(M-1)%mod;
    ll ans=0;
    for (int k=0;k<K+1;k++)
    {
        ans=(ans+dp[N-k]*fact[N-1]%mod*modinv(fact[k])%mod*modinv(fact[N-1-k])%mod)%mod;
        //cout << dp[N-k] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6428
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################



n , x , t = map(int , input().split())
print(math.ceil(n/x)*t)






Measured memory_bytes: 67172
#include<bits/stdc++.h>
using namespace std;
string S,T;
int ans=1000;
int main(){
    cin>>S>>T;
    for(int i=0;i+T.size()<=S.size();i++){
        int cnt=0;
        for(int j=0;j<T.size();j++)if(S[i+j]!=T[j])cnt++;
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int d4 = 0;
  int d2 = 0;
  int d1 = 0;
  
  rep(i,n){
    if(a[i]%4 == 0){
      d4++;
    }else if(a[i]%2 == 0){
      d2++;
    }else d1++;
  }
  
  if(d2 > 0){
    if(d1 <= d4) cout << "Yes";
    else cout << "No";
  }else{
    if(d1 <= d4 + 1) cout << "Yes";
    else cout << "No";
  }
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int i, ans = 700;
	char S[4];
	scanf("%s", S);
	for (i = 0; S[i] != 0; i++) if (S[i] == 'o') ans += 100;
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;


int main(){
    ll N; cin >> N;
    string S; cin >> S;
    vll black(N);
    vll white(N);
    ll b = 0; ll w = 0;
    for(int i=0; i<N; i++){
        if(S[i] == '#'){
            b++;
        }
        black[i] = b;
    }
    for(int i=0; i<N; i++){
        if(S[N-1-i] == '.'){
            w++;
        }
        white[N-1-i] = w;
    }
    ll mini = N;
    for(int i=0; i<N; i++){
        ll j;
        if(S[i] == '#'){
            j = black[i] + white[i];
        }
        else{
            j = black[i] + white[i] - 1;
        }
        if(mini > j){mini = j;}
    }
    ll h = min(N-b,N-w);
    cout << min(h,mini);
}

Measured memory_bytes: 3716
N = int(input())
N1 = N
candi22 = [20 + 6*i for i in range(4997)]
candi24 = [4 + 6*i for i in range(5000)]
candi3 =  [15 + 6*i for i in range(4998)]
candi6 =  [6 + 6*i for i in range(5000)]
if N == 3:
    print(2, 5, 63)
elif N == 4:
    print(2, 5, 20, 63)
elif N >= 15000:
    ans = [2, 8, 14, 3, 9]
    ans += candi22 + candi24 + candi3 + candi6[:N-15000]
    print(*ans)
else:
    ans = [2, 8, 14, 3, 9]
    N -= 5
    c22 = min(4995, N//3*3)
    N -= c22
    c24 = min(4998, N//3*3)
    N -= c24
    c3 = min(4998, N//2*2)
    N -= c3
    c6 = N
    ans += candi22[:c22] + candi24[:c24] + candi3[:c3] + candi6[:c6]
    print(*ans)

Measured memory_bytes: 4748
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int a, b, c;
  readf("%d %d %d\n", &a, &b, &c);
  
  if (a > b) {
    auto tmp = a;
    a = b;
    b = tmp;
  }

  if (a < c && c < b) writeln("Yes");
  else writeln("No");
}


Measured memory_bytes: 256
object Main extends App {
	val N = scala.io.StdIn.readInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	val c = new Array[Long](N)

	for(x<-a){
		c(x.toInt-1) += 1L
	}

	val sum = c.map(z => z*(z-1L)/2L).sum

	for(x <- a){
		println(sum - c(x.toInt-1) + 1L)
	}
}

Measured memory_bytes: 76988
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n-1];
    for (int i=0; i<n-1; i++) cin >> b[i];
    a[0] = b[0];
    for (int i=1; i<n-1; i++) {
        a[i] = min(b[i-1], b[i]);
    }
    a[n-1] = b[n-2];
    int ans = 0;
    for (int i=0; i<n; i++) ans += a[i];
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 3536
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
using namespace std;

int main() {
	int n, d, x[15][15], ans = 0;
	cin >> n >> d;
	for (int i = 1; i <= n;i++) {
		for (int j = 1; j <= d;j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 1; i <= n;i++) {
		for (int j = i+1; j <= n;j++) {
			int s = 0;
			for (int k = 1; k <= d;k++) {
				s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			for (int i = 1; i <= 200;i++) {
				if (s==i*i) {
					ans++;
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int odd = 0,even = 0;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        if(a % 2 == 1)
        {
            odd++;
        }
        else
        {
            even++;
        }
    }
    cout << int(pow(3,n)) - int(pow(2,even)) << "\n";
    
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k, x;
    cin >> k >> x;
    cout << (k * 500 >= x ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.math;

void main(){

    real[4] x;
    real[4] y;
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	auto s1 = split(chomp(s),',');
	for(int i=0;i<4;i++) x[i] = to!real(s1[2*i]);
	for(int i=0;i<4;i++) y[i] = to!real(s1[2*i+1]);
	bool flg = true;
	bool u,u1;
	if(x[1] - x[3] == 0){
	    u = (x[1] - x[0]) * (x[1] - x[2]) > 0;

	}else {
	    real m = (y[1] - y[3] ) / (x[1] - x[3]);
	    u = (y[2] - m * (x[2] - x[1]) - y[1] ) * (y[0] - m * (x[0] - x[1]) - y[1] )> 0 ;
	}
	if(x[2] - x[0] == 0){
	    u1 = (x[2] - x[1]) * (x[2] - x[3]) > 0;
	}else {
	    real m = (y[0] - y[2] ) / (x[0] - x[2]);
	    u1 = (y[3] - m * (x[3] - x[2]) - y[2] ) * (y[1] - m * (x[1] - x[2]) - y[2] )> 0 ;
	}
	flg = (u1 != u);
	if(!flg) writeln("YES");
	else writeln("NO");
    }
}

Measured memory_bytes: 2468
using System;
class Program{
	static void Main(){
		int s=int.Parse(Console.ReadLine());
		int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] t=new int[s];
		double a3=0;
		for (int i=0;i<s;i++){
			t[i]=q[i]-(i+1);
		}
		Array.Sort(t);
		for (int i=0;i<s;i++){
			a3+=Math.Abs(q[i]-(t[s/2]+i+1));
		}
		Console.WriteLine(a3);
	}
}

Measured memory_bytes: 30684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  
  int sum = 0;
  for (int i = 0; i < N - 1; i++){
    sum += L.at(i);
  }
  if(L.at(N-1) < sum){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() > k) {
        for (ll i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "..." << endl;

    } else {
        cout << s << endl;
    }
}


Measured memory_bytes: 3620
import java.util.Scanner;

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

    int sum = 0;
    for (int a = 1; a <= n; a++) {
      for (int b = 1; b <= n; b++) {
        for (int c = 1; c <= n; c++) {
          sum += _gcd(_gcd(a, b), c);
        }
      }
    }
    System.out.println(sum);
    }



  private static int _gcd (int a, int b) {
	int temp;
	while((temp = a % b) != 0) {
		a = b;
		b = temp;
  }
	return b;
  }
}


Measured memory_bytes: 27276
#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 a, b;
 cin >> a >> b;
 int n = min(a, b);
 int m = max(a,b);
 string ans;
 for(int i =0; i< m; i++) ans += to_string(n);
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
D = {}
for i in A :
    if i in D :
        D[i] += 1
    else :
        D[i] = 1
answer = 0
for key, value in D.items() :
    if key > value :
        answer += value
    else :
        answer += value-key
print(answer)


Measured memory_bytes: 18164
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
    int N;
    cin>>N;
    vll x(N),y(N);
    for (size_t i = 0; i < N; i++)
    {
        ll tx,ty;
        cin>>tx>>ty;
        x[i]=tx-ty;
        y[i]=tx+ty;
    }
    ll ans = max(abs(*max_element(all(x))-*min_element(all(x))),abs(*max_element(all(y))-*min_element(all(y))));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6388
import itertools
import math
import fractions
import functools
n = int(input())
x = []
y = []
l = []
for i in range(n):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)
    l.append(i)

distance = 0

p_list = list(itertools.permutations(l, n))

for i in range(len(p_list)):
    for j in range(len(p_list[i])-1):
        distance += math.sqrt((x[p_list[i][j]] - x[p_list[i][j+1]])**2+(y[p_list[i][j]] - y[p_list[i][j+1]])**2)

print(distance/len(p_list))

Measured memory_bytes: 79608
M,D =[int(i) for i in input().split()]

ct = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = int(str(d)[0])
        d10 = 0
        if len(str(d)) ==2:
            
            d10 = int(str(d)[1])
        if d1*d10 == m and d1>=2 and d10>=2:
            #print(m,d)
            ct += 1

print(ct)

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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int ans=0;
    for(i=0;i<n;i++){
    	if((i+1)%2==1&&a[i]%2==1) ans++;
    	else continue;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

template< typename T >
struct BinaryIndexedTree{

    //0-indexed
    vector< T > bit;

    BinaryIndexedTree(int sz){
        bit.assign(sz, 0);
    }

    //[0,k)までの総和を返す
    T sum(int k){
        T ret = 0;
        for (--k; k >= 0; k = (k&(k+1))-1) ret += bit[k];
        return ret;
    }
    
    //[l,r)の総和を返す
    T sum(int l, int r){
        return sum(r) - sum(l);
    }

    //kにx加算する
    void add(int k, T x){
        for (; k < bit.size(); k |= k+1) bit[k] += x;
    }
};

int main(){
    int n,q;cin >> n >> q;
    BinaryIndexedTree<int> bit(n);
    while(q--){
        int c,x,y;cin >> c >> x >> y;
        x--;
        if(c == 0){
            bit.add(x, y);
        }
        else{
            cout << bit.sum(x, y) << endl;
        }
    }
    return 0;
}



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using vll = vector<ll>;
using vld = vector<ld>;
using vpl = vector<pll>;
using vvll = vector<vll>;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(ll i=0;i<((ll)n);i++)
#define REP1(i,n) for(ll i=1;i<((ll)n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


//abc173
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    vll a(n), b(n);
    REP(i, n)cin >> a[i];
    REP(i, n)cin >> b[i];

    ll cor_num = 0;
    ll ans = 0;
    while (cor_num!=n) {
        bool flag = true;
        REP(i, n) {
            ll d = b[(n + i - 1) % n];
            ll e = b[i];
            ll f = b[(i + 1) % n];

            if (e < a[i]) {
                cout << -1 << endl;
                return 0;
            }

            if (d + f < e)
                flag = false;
            if ((e - a[i]) % (d + f) == 0) {
                ans += (e - a[i]) / (d + f);
                b[i] = a[i];
            }
            else {
                ans += e / (d + f);
                b[i] = e % (d + f);
            }
        }

        bool ok = true;
        REP(i, n)if (a[i] != b[i])ok = false;
        if (ok)break;

        if (flag) {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 6368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            for(int i=3;i<=num;i++)
            {
                if (i % 3 == 0) { Console.Write(" " + i); continue; }
                else if (i % 10 == 3) Console.Write(" "+i);
                else
                {
                    int j = i;
                    while (true)
                    {
                        j /= 10;
                        if (j == 0) break;
                        else if (j % 10 == 3) { Console.Write(" " + i); break; }
                    }
                }

            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9188
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

x, t = na()
print(max(x - t, 0))


Measured memory_bytes: 3444
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d1[200100];
ll d2[200100];

int main() {
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll c = 0;
  rep(i,0,s.sz){
  	if(s[i]=='#'){
  		c++;
  		d1[i+1]++;
  	}
  	else{
  		d2[i+1]++;
  	}
  }
  rep(i,1,200100){
  	d1[i] += d1[i-1];
  	d2[i] += d2[i-1];
  }
  ll mn = 1000000000;
  rep(i,0,s.sz){
  	mn = min(mn,d2[200050]-d2[i] + d1[i]);
  }
  cout << min(mn,c) << endl;
  return 0;
}

Measured memory_bytes: 3716