akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace C
{
    class Heap<T> : IEnumerable<T> where T : IComparable<T>
    {
        internal List<T> data = new List<T>() { default(T) };
        public int Count { get { return data.Count - 1; } }
        public Heap() { }
        public Heap(T[] array) { data.AddRange(array); }

        public IEnumerator<T> GetEnumerator()
        {
            return data.Skip(1).GetEnumerator();
        }

        public void MaxHeapify()
        {
            for (int i = data.Count / 2; i > 0; i--) MaxHeapify(i);
        }

        IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }

        internal void MaxHeapify(int index)
        {
            var left = index << 1;
            var right = left + 1;
            int largest = index;
            if (left < data.Count && data[left].CompareTo(data[largest]) > 0) largest = left;
            if (right < data.Count && data[right].CompareTo(data[largest]) > 0) largest = right;

            if (largest != index)
            {
                var tmp = data[largest];
                data[largest] = data[index];
                data[index] = tmp;
                MaxHeapify(largest);
            }
        }
    }

    public class PriorityQueue<T> where T : IComparable<T>
    {
        private Heap<T> heap = new Heap<T>();

        public void Push(T item)
        {
            heap.data.Add(item);
            var index = heap.data.Count - 1;
            var parent = index >> 1;
            while (parent > 0 && heap.data[parent].CompareTo(heap.data[index]) < 0)
            {
                var tmp = heap.data[parent];
                heap.data[parent] = heap.data[index];
                heap.data[index] = tmp;
                index = parent;
                parent = index >> 1;
            }
        }

        public T Pop()
        {
            var index = heap.data.Count - 1;
            var tmp = heap.data[1];
            heap.data[1] = heap.data[index];
            heap.data[index] = tmp;
            heap.data.RemoveAt(heap.data.Count - 1);
            heap.MaxHeapify(1);
            return tmp;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var queue = new PriorityQueue<int>();
            string[] strs;
            strs = Console.ReadLine().Split(' ');
            while (!strs[0].Equals("end"))
            {
                if (strs[0][0] == 'i') queue.Push(int.Parse(strs[1]));
                else Console.WriteLine(queue.Pop());
                strs = Console.ReadLine().Split(' ');
            }
        }
    }
}

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

int main(){
    int n, m, l;
    std::cin >> n >> m >> l;
    
    std::vector< std::vector < long long > > a, b, c;
    a.resize(n);
    for(auto& x : a) x.resize(m);
    b.resize(m);
    for(auto& x : b) x.resize(l);
    c.resize(n);
    for(auto& x : c) x.resize(l);
    
  	for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
        std::cin >> a[i][j];
      }
    }
  	for(int i=0; i<m; i++){
      for(int j=0; j<l; j++){
        std::cin >> b[i][j];
      }
    }
  
    for(int k=0; k<m; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<l; j++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            if(j!=0) std::cout << " ";
            std::cout << c[i][j];
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string s,t;
    cin>>s>>t;
    int len=s.size();
    rep(i,len){
        s=s[len-1]+s.substr(0,len-1);
        if (s==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>

typedef long long ll;

const ll Div = 1000000007;

int main(){
   ll N;
   std::cin >> N;
   std::string S;
   std::cin >> S;


   ll sum = 1;
   for(char ch='a'; ch<='z'; ++ch){
      ll count = 0;
      for(int i=0; i<N; ++i){
	 if(S[i]==ch) ++count;
      }
      sum *= count+1;
      sum %= Div;
   }
   if(sum>0) sum--;
   else sum = Div-1;
   std::cout << sum%Div << std::endl;

   return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
private static String num;
private static int a,b;
    
  public static void main(String[] args){
    
    Scanner s= new Scanner(System.in);
while(true){
a=s.nextInt();
 num = s.next();
b=s.nextInt();

if(num.equals("?")){
    
    break;
}

switch(num){
    
    case "+":
        System.out.println(a+b);
        break;
    case "-":
        System.out.println(a-b);
        break;
    case "*":
        System.out.println(a*b);
        break;
    case "/":
        System.out.println(a/b);
        break;
    
    
    
}
    
}
}
}


Measured memory_bytes: 26388
m,n = map(int,input().split())
a = []*m
b = []*n
flag = False
for i in range(m):
    a.append(input())
for j in range(n):
    b.append(input())
flag = False
for i in range(m-n+1):#比較開始を縦方向に動かす
    for j in range(m-n+1):#比較開始を横方向へ動かす
        for k in range(n):#各行を1行ずつ比較
            if b[k] != a[i+k][j:j+n]:
                break
        else:
            flag = True
if flag:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 3060
#include<stdio.h>
int main(){

  int N;
  char S[10000];
  scanf("%d",&N);
  scanf("%s",S);

  for(int i=0;S[i]!='\0';i++){
      if(S[i]+N>'Z'){
      printf("%c",S[i]+N-('Z'-'A')-1);
    }else{
    printf("%c",S[i]+N);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    long long ans = A[0] - 1;
    int p = 2;
    for (int i = 1; i < N; i++) {
        if (A[i] <= p) {
            if (A[i] == p) p++;
            else continue;
        } else {
            if (A[i] % p == 0) ans += A[i] / p - 1;
            else ans += A[i] / p;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = IR(n)
counter = Counter(a)
ans = 0
for _, cnt in counter.items():
    if cnt % 2 != 0:
        ans += 1
print(ans)


Measured memory_bytes: 20760
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

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

Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// scott_wu氏
// https://atcoder.jp/contests/agc040/submissions/8277503
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

LL nt;
vector<pair<LL, LL>> res;

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){
    int N, a, b;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d %d", &a, &b);
        if(a < b) nt += b - a, res.push_back(make_pair(b, b));
        else      res.push_back (make_pair (a, b));
    }
    
    sort(res.begin(), res.end());
    
    LL shi = 0;
    LL nwhole = 0;
    LL nbest = 1, dbest = 1;
    for(int i = 0; i < N; i++){
        if(res[i].first <= nt){
            nt -= res[i].first;
            shi = max(shi, res[i].second);
            nwhole++;
            continue;
        }else{
            LL nnum = res[i].first - nt;
            LL dnum = max (shi, res[i].second);
            LL g = gcd(nnum, dnum);
            nnum /= g;
            dnum /= g;
            if(nnum * dbest < dnum * nbest){
                nbest = nnum;
                dbest = dnum;
            }
        }
    }
    
    LL tnum = (nwhole + 1) * dbest - nbest;
    LL tden = N * dbest;
    LL g = gcd(tnum, tden);
    tnum /= g;
    tden /= g;
    printf("%lld %lld\n", tnum, tden);
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    
        long long a,b,l,r,x,xx,y,yy,sum1,sum2,z,zz,sum3;
        cin>>l>>r>>a>>b;
        if(l>r)
            swap(l,r);
            x=l/a;
            if(a*x!=l)
                x++;
            xx=r/a;
            sum1=(xx-x+1);
        
            y=l/b;
            if(b*y!=l)
                y++;
            yy=r/b;
            sum2=(yy-y+1);
            
            long long lcm=a*b;
            lcm=lcm/(__gcd(a,b));
            z=l/lcm;
            if(lcm*z!=l)
                z++;
            zz=r/lcm;
            sum3=(zz-z+1);
            
            long long total=r-l+1;
            long long ans=total-sum1-sum2+sum3;
            cout<<ans;
    
        
    
        
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

template<class T> struct DisjointSparseTable {
    using F = function<T(T, T)>;
private : 
    const F f;
    vector<vector<T>> node;
    vector<int> idx;

public : 
    DisjointSparseTable (const vector<T> &v, const F &f) : f(f) {
        int b = 0, n = (int)v.size();
        while ((1<<b) <= n) b++;
        node.resize(b, vector<T>(n));
        for (int i = 0; i < v.size(); i++) node[0][i] = v[i];
        for (int i = 1; i < b; i++) {
            int s = (1<<i);
            for (int j = 0; j < n; j +=(s<<1)) {
                int t = min(j + s, n);
                node[i][t-1] = v[t-1];
                for (int k = t-2; k >= j; k--) {
                    node[i][k] = f(v[k], node[i][k+1]);
                }
                if (n <= t) break;
                node[i][t] = v[t];
                for (int k = t+1; k < min(t+s, n); k++) {
                    node[i][k] = f(node[i][k-1], v[k]);
                }
            }
        }
        idx.resize((1<<b), 0);
        for (int i = 2; i < (1<<b); i++) {
            idx[i] = idx[i>>1] + 1;
        }
    }

    const T query (int l, int r) const {
        assert(l <= --r);
        if (l == r) return node[0][l];
        return f(node[idx[l^r]][l], node[idx[l^r]][r]);
    }

};

template<typename T> inline T GCD(const T &a, const T &b) {
    if (b == 0) return a;
    if (a % b == 0) return b;
    return (GCD(b, a % b));
}

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    auto f = [](long long a, long long b) { return GCD(a, b); };
    DisjointSparseTable<long long> dst(a, f);
    
    long long ans = max(dst.query(1, n), dst.query(0, n-1));
    for (int i = 1; i < n-1; i++) {
        long long res = GCD(dst.query(0, i), dst.query(i+1, n));
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, m; std::cin >> n >> m;
    vvi to(n, vi(n, inf));
    vi a(m), b(m), c(m);
    rep(i, n) to[i][i] = 0;
    rep(i, m) {
        std::cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        to[a[i]][b[i]] = to[b[i]][a[i]] = c[i];
    }
    rep(k, n) rep(i, n) rep(j, n) chmin(to[i][j], to[i][k] + to[k][j]);
    int ans = 0;
    rep(k, m) {
        bool ok = false;
        rep(i, n) rep(j, n) {
            if (to[i][a[k]]+c[k]+to[b[k]][j] == to[i][j])
                ok = true;
        }
        if (!ok) ans++;
    }
    std::cout << ans << "\n";
}


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

int main()
{
	int a,b;
	cin >> a >>b;
	if(a%3==0 || b%3==0 || ((a+b)%3==0)) cout << "Possible";
	else cout << "Impossible";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	int u = (s[0] - '0') * 10 + s[1] - '0';
	int v = (s[2] - '0') * 10 + s[3] - '0';
	bool mmyy = false, yymm = false;
	if (1 <= u && u <= 12)mmyy = true;
	if (1 <= v && v <= 12)yymm = true;
	if (yymm && mmyy)cout << "AMBIGUOUS" << endl;
	else if (yymm)cout << "YYMM" << endl;
	else if (mmyy)cout << "MMYY" << endl;
	else cout << "NA" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        ll c;
        cin >> c;
        z.at(c-1) = i;
    }
    int ans = 1;
    int za = 1;
    for (int i = 0; i < n-1; i++) {
        if (z.at(i) < z.at(i + 1))za++;
        else { za = 1; }
        ans = max(ans, za);
    }
    cout << n-ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;
int main(){
	int n;
	cin>>n;
	int last_digit = n % 10;
	if(last_digit == 3)
		cout<<"bon"<<endl;
	else if(last_digit == 0 || last_digit == 1 || last_digit == 6 || last_digit == 8)
		cout<<"pon"<<endl;
	else
		cout<<"hon"<<endl;	
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct LazySegTree {
    int siz;
    vector<ll> node, lazy;

    LazySegTree(string &S) : siz(1) {
        int N = S.length();
        while (siz < N)
            siz *= 2;

        node.resize(2 * siz - 1);
        lazy.resize(2 * siz - 1);
        for (int i = 0; i < N; ++i)
            node[i + siz - 1] = (1LL << (S[i] - 'a'));
        for (int i = siz - 2; i >= 0; --i)
            node[i] = node[2 * i + 1] | node[2 * i + 2];
    }

    void eval(int k) {
        if (!lazy[k])
            return;
        if (k < siz - 1) {
            lazy[2 * k + 1] = lazy[k];
            lazy[2 * k + 2] = lazy[k];
        }
        node[k] = lazy[k];
        lazy[k] = 0;
    }

    void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (r <= a || b <= l)
            return;
        if (a <= l && r <= b) {
            lazy[k] = 1LL << x;
            eval(k);
            return;
        }
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
        node[k] = node[2 * k + 1] | node[2 * k + 2];
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (r <= a || b <= l)
            return 0;
        if (a <= l && r <= b)
            return node[k];
        ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (vl | vr);
    }
};

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

    int N, Q;
    string S;
    cin >> N >> S >> Q;
    LazySegTree segtree(S);
    for (int i = 0; i < Q; ++i) {
        int query;
        cin >> query;
        if (query == 1) {
            int a;
            char c;
            cin >> a >> c;
            segtree.update(a - 1, a, c - 'a');
        } else {
            int l, r;
            cin >> l >> r;
            ll res = segtree.query(l - 1, r);
            cout << __builtin_popcountll(res) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 20388
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int d[101] = {0};
int A[101] = {0};

int main()
{
	int N = 0, K = 0, ans = 0, i = 0;
	scanf("%d %d", &N, &K);
	for (i = 0; i < K; i++) {
		scanf("%d", &d[i]);
		int j = 0;
		for (j = 0; j < d[i]; j++) {
			int a = 0;
			scanf("%d", &a);
			A[a-1]++;
		}
	}

	for (i = 0; i < N; i++) {
		if (A[i] == 0) {
			ans++;
		}
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

struct edge{int to,cost;};

vector<edge> G[100000];
int d[100000];
bool f = true;

void dfs(int cur, int prev){
    for(auto e:G[cur]){
        if(e.to==prev)continue;
        if(d[e.to]==INF){
            d[e.to] = d[cur]+e.cost;
            dfs(e.to,cur);
        }
        if(d[e.to]!=INF && d[cur]+e.cost!=d[e.to])f = false;
    }
}

int main(){
    int v,e;
    cin>>v>>e;
    
    set<int> vs;
    
    rep(i,e){
        int s,t,d;
        cin>>s>>t>>d;
        s--,t--;
        vs.insert(s);
        vs.insert(t);
        G[s].pb(edge{t,d});
        G[t].pb(edge{s,-d});
    }
    
    rep(i,100000)d[i] = INF;
    for(auto elm:vs){
        if(d[elm]!=INF)continue;
        d[elm] = 0;
        dfs(elm,-1);
    }
    
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"

   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\

int a[3][100005];
int dp[3][100005];

void solve(){
    int n;
    cin >> n ;
    rep(i,0,n)cin >> a[0][i] >> a[1][i] >> a[2][i];
    dp[0][0]=a[0][0]; dp[1][0]=a[1][0]; dp[2][0]=a[2][0];
    rep(i,1,n){
        dp[0][i]=a[0][i]+ max(dp[1][i-1], dp[2][i-1]);
        dp[1][i]=a[1][i]+ max(dp[0][i-1], dp[2][i-1]);
        dp[2][i]=a[2][i]+ max(dp[1][i-1], dp[0][i-1]);
    } 
    cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);

}

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//   cout << fixed;  cout << setprecision(9);
//   freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout);
    
  //  int test; cin >> test;  while(test--)
    solve();
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n;
    cin >> n;

    vector<int> num(10);
    num[0]=1; num[1]=1; num[2]=1;
    bool c3,c5,c7;
    int x,t;
    int count=0;

    while(num[9]==0){
        x=0; t=1;
        c3=false; c5=false; c7=false;
        rep(i,9){
            if(num[i]==4){
                num[i]=1;
                num[i+1]++;
            }
            if(num[i]==1){
                c3=true;
                x+=3*t;
            }else if(num[i]==2){
                c5=true;
                x+=5*t;
            }else if(num[i]==3){
                c7=true;
                x+=7*t;
            }
            t*=10;
        }
        // cout << ' ' << x << endl;
        if(x>n) break;
        num[0]++;
        if(c3 && c5 && c7) count++;
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = 2 * a + 2 * b;
		System.out.println(area + " " + length);
	}

}

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


int main()
{
	int n;
	scanf("%d",&n);
	
	vector<int> v(n+1);
	
	for(int i=1;i<=n;i++)
	scanf("%d",&v[i]);
	
	vector<int> dp(n+1);
	
	dp[1] = 0;
	int x = fabs(v[1]-v[2]);
	dp[2] = x;
	
	for(int i=3;i<=n;i++)
	dp[i] = min(dp[i-1]+fabs(v[i]-v[i-1]),dp[i-2]+fabs(v[i]-v[i-2]));
	
	printf("%d\n",dp[n]);
	
	return 0;
}

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

int main() {

	int n; string s; cin >> n >> s;
	ll r_cnt = 0;
	ll g_cnt = 0;
	ll b_cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') r_cnt++;
		if (s[i] == 'G') g_cnt++;
		if (s[i] == 'B') b_cnt++;
	}
	ll tmp = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int k = 2 * j - i;
			if (n <= k) continue;
			if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
				tmp++;
			}
		}
	}
	ll ans = r_cnt * g_cnt * b_cnt - tmp;
	cout << ans << endl;
	return 0;
}

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

int gcd(int m, int n){
  if(n == 0) return m;
  else return gcd(n, m%n);
}
int Abs(int n){
  return n > 0 ? n : -n;
}
int main(){
  int n, x, ans;
  cin >> n>> x;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec[i];
    vec[i] = Abs(vec[i]-x);
  }
  if( n == 1 )
    ans = vec[0];
  else{
    ans = gcd(vec[0], vec[1]);
    for(int i = 2; i < n; i++)
      ans = gcd(ans, vec[i]);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())
S = input()
num = len(S)
if num % 2 == 1:
    print('No')
    sys.exit()

num = num //2
if S == S[:num]*2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38512
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
    int N,C;cin >> N >> C;
    int sum = 0;
    N++;
    for(int i = 0;i < C;i++){
        int b;cin >> b;
        sum += b;
    }
    cout<<sum / N + (sum % N == 0 ? 0 : 1)<<endl;
}



Measured memory_bytes: 3084
#include<iostream>
using namespace std;
#define nmax (int)(1e+5)+1
int main(){
  int a[nmax]={},cnt=0,n,b;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    if(b>n) cnt++;
    else a[b]++;
  }
  for(int i=1;i<=n;i++){
    cnt+=a[i]>=i?a[i]-i:a[i];
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 640
//QWsin
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

int main()
{
	int h,a;
	cin>>h>>a;
	cout<<(int)ceil((double)h/a)<<endl;
	return 0;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}


int main(){
  ll N,D;
  cin >> N >> D;
  vector<ll> X(N),Y(N);
  rep(i,N){
    cin >> X[i] >> Y[i];
  }
  ll ans = 0;
  rep(i,N){
    if(X[i]*X[i] + Y[i]*Y[i] <= D*D)ans++;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vi dp(100010,-1);

int dfs(vi &a, int i){
  if(dp[i] != -1) return dp[i];
  if(i < a[0]) return dp[i] = 0;
  int ret = 0;
  for(int v : a){
    if(i-v < 0) continue;
    ret |= (1 - dfs(a, i-v));
  }
  return dp[i] = ret;
}

int main(){
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  if(dfs(a,k) == 1) cout << "First" << endl;
  else cout << "Second" << endl;
}

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

int main(void)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int ans;

    ans = min(B, D) - max(A, C);

    if( ans > 0){
        cout << ans;
    }else {
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll a, b, c, x, y;
    cin>>a>>b>>c>>x>>y;
    ll res = 0;
    if(a+b > 2*c){
        ll z = min(x, y);
        res += z*c*2;
        y -= z;
        x -= z;
    }
    if(x>0 and a>2*c){
        res += 2*c*x;
        x = 0;
        if(x<y) y-=x;
        else y=0;
    }
    if(y>0 and b>2*c){
        res += 2*c*y;
        y = 0;
        if(y<x) x-=y;
        else x=0;
    }
    if(x) res += a*x;
    if(y) res += b*y;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N= int(input())
H = [int(i) for i in input().split()]

dp = [0 for i in range(N)]
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    tmp1 = abs(H[i]-H[i-1])+dp[i-1]
    tmp2 = abs(H[i]-H[i-2])+dp[i-2]
    if tmp1>tmp2:
        dp[i] = tmp2
    else:
        dp[i] = tmp1

print(dp[-1])


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

using ll = long long;
using pii = pair<ll, ll>;

constexpr ll inf = 1e18;

int main() {
  int n;
  while(cin >> n, n) {
    vector<char> com(n);
    vector<ll> id(n, -1), S(n, -1), p(n, -1);
    set<pii> pool = { make_pair(0, inf) };
    for(int i = 0; i < n; ++i) {
      cin >> com[i];
      if(com[i] == 'W') {
        cin >> id[i] >> S[i];
      } else if(com[i] == 'D') {
        cin >> id[i];
      } else {
        cin >> p[i];
      }
    }
    map<pii, int> seg_to_id;
    map<int, vector<pii>> segs; // id -> seg
    for(int i = 0; i < n; ++i) {
      if(com[i] == 'W') {
        vector<pii> erased;
        for(auto s : pool) {
          if(s.second - s.first > S[i]) {
            pool.emplace(s.first + S[i], s.second);
            segs[id[i]].emplace_back(s.first, s.first + S[i]);
            seg_to_id[segs[id[i]].back()] = id[i];
            S[i] = 0;
          } else {
            S[i] -= s.second - s.first;
            segs[id[i]].push_back(s);
            seg_to_id[s] = id[i];
          }
          erased.push_back(s);
          if(S[i] == 0) break;
        }
        for(auto e : erased) {
          pool.erase(e);
        }
      } else if(com[i] == 'D') {
        for(auto x : segs[id[i]]) {
          seg_to_id.erase(x);
        }
        pool.insert(begin(segs[id[i]]), end(segs[id[i]]));
        segs[id[i]].clear();
      } else {
        auto it = seg_to_id.lower_bound(make_pair(p[i], -1));
        if(it != end(seg_to_id) && it->first.first == p[i]) {
          cout << it->second << endl;
        } else if(it != begin(seg_to_id)) {
          it--;
          if(it->first.first <= p[i] && p[i] < it->first.second) {
            cout << it->second << endl;
          } else {
            cout << -1 << endl;
          }
        } else {
          cout << -1 << endl;
        }
      }
      //cout << "debug seg_to_id: " << endl;
      //for(auto& p : seg_to_id) {
      //  cout << p.first.first << ' ' << p.first.second << ' ' << p.second << endl;
      //}
      //cout << "debug pool: " << endl;
      //for(auto& s : pool) {
      //  cout << s.first << ' ' << s.second << endl;
      //}
      //cout << "segs: " << endl;
      //for(auto& p : segs) {
      //  cout << p.first << " -> " << endl;
      //}
    }
    cout << endl;
  }
}



Measured memory_bytes: 42568
n = int(input())
A = input().split(' ')

#for i in range(n):
#    A[i] = int(A[i])
print(" ".join(A))

for i in range(1, n):
    v = A[i]
    j = i - 1

    while j >= 0 and int(A[j]) > int(v):
        A[j+1] = A[j]
        j -= 1
        A[j+1] = v
    print(" ".join(A))

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

int main(){
  int n;
  cin >> n;
  bool flag = 0;
  for(int i = 1; i <= 9; ++i){
    if(n % i == 0){
      int s = n / i;
      if(s >= 1 && s <= 9) flag = 1;
    }
  } 
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc001 {

    export class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *
         * out
         *
         */
        main(): void {
            const [x, y, z]: number[] = this.args[0].split(' ').map(Number);

            //a b
            //a c
            console.log(`${z.toString()} ${x.toString()} ${y.toString()}`);

        }
    }

}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc001.Program(args);
prg.main();




Measured memory_bytes: 7372
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  set<int> U;
  int Q;

  cin >> Q;
  while(Q--) {
    int com, x, y;
    cin >> com;

    switch(com) {
    case 0:
      cin >> x;
      U.insert(x);
      cout << U.size() << LF;
      break;

    case 1:
      cin >> x;
      cout << U.count(x) << endl;
      break;

    case 2:
      cin >> x;
      U.erase(x);
      break;

    default:
      cin >> x >> y;
      for (auto it = U.lower_bound(x); it != U.upper_bound(y); ++it) {
        cout << *it << LF;
      }
    }
  }

  return 0;
}




Measured memory_bytes: 12496
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll = long long;
using namespace std;
int main(){
    ll n,m;
    cin >> n >> m;
    ll a=max(n,m);
    ll b=min(n,m);
    if(a==1&&b==1){
        cout<<1<<endl;
        return 0;
    }
    if(b==1){
        cout<<a-2<<endl;
        return 0;
    }
    cout<<(a-2)*(b-2)<<endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=2000;
int n,k;
int f[maxn+8][maxn+8],g[maxn+8][maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k)
{
    if (k<0) return 1;
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
    if (k&1)
        sum=1ll*sum*a%mod;
    return sum;
}

int main()
{
    n=read(),k=read();
    for (int i=1;i<=n;i++) g[0][i]=1;
    for (int i=1;i<k;i++)
        for (int j=1;j<=n-i;j++)
	    g[i][j]=(g[i-1][j+1]+g[i][j-1])%mod;
    printf("%lld\n",1ll*g[k-1][n-k+1]*power(2,n-k-1)%mod);
    return 0;
}


Measured memory_bytes: 16640
/*
AOJ - ITP1_6_c
Date: 20180925
Author: Mikoron
 */

#include<stdio.h>
#include<stdbool.h>

#define BUILDS 5
#define FLOORS 4
#define ROOMS 11

int main(void) {
        int line_num, i, j, k;
        int b, f, r, v;
        char tenants[BUILDS][FLOORS][ROOMS];

        //initialize
        for(i = 0; i < BUILDS; i++) {
                for(j = 0; j < FLOORS; j++) {
                        for(k = 0; k < ROOMS; k++) {
                                tenants[i][j][k] = 0;
                        }
                }
        }

        scanf("%d\n", &line_num);
        for(i = 0; i < line_num; i++) {
                scanf("%d %d %d %d\n", &b, &f, &r, &v);
                tenants[b][f][r] += v;
        }

        for(i = 1; i < BUILDS; i++) {
                for(j = 1; j < FLOORS; j++) {
                        for(k = 1; k < ROOMS; k++) {
                                printf(" %d", tenants[i][j][k]);
                        }
                        printf("\n");
                }
                if(i != BUILDS -1) {
                        printf("####################\n");
                }
        }

        return 0;
}



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

string a,b="CF";
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){
            bl++;
            if(bl==2)
                break;
        }
    if(bl==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 30
using namespace std;
int n,A[N];
double calc(double a,double b){return abs(a-b)/a;}

double DP(){
  unordered_map<int,double> dp[2];
  bool f=0;  
  dp[0][1] = 0;
  for(int i=0;i<n;i++,f=!f){
    dp[!f].clear();
    for(auto it = dp[f].begin();it!=dp[f].end();it++){
      int num = it->first;
      double cost = it->second;
      for(int j=num;;j+=num){
	if(dp[!f].count(j))dp[!f][j] = min(dp[!f][j],max(calc(A[i],j),cost));
	else dp[!f][j] = max(calc(A[i],j),cost);
	if(j>A[n-1]) break;
      }
    }
  }

  double res=1LL<<55;
  for(auto it = dp[f].begin();it!=dp[f].end();it++)res=min(res,it->second);
  return res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  printf("%.10f\n",DP());
  return 0;
}

Measured memory_bytes: 16964
package main

import (
	"fmt"
)

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func main() {
	var s string
	fmt.Scan(&s)
	var t string
	fmt.Scan(&t)

	sr := StringToRuneSlice(s)
	st := StringToRuneSlice(t)
	var count int
	for i := 0; i < len(sr); i++ {
		if sr[i] == st[i] {
			count++
		}
	}
	fmt.Println(count)
}


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

#define PII pair < int , int >
const int _ = 4e5 + 7;
char str[2][_]; int N , H , W , X , Y , dp[_][2];

int main(){
	scanf("%d %d %d %d %d %s %s" , &H , &W , &N , &X , &Y , str[0] , str[1]);
	vector < PII > q;
	for(int i = 0 ; i < N ; ++i){
		if(str[0][i] == 'L' || str[0][i] == 'R') q.push_back(PII(0 , str[0][i] == 'R'));
		if(str[1][i] == 'L' || str[1][i] == 'R') q.push_back(PII(1 , str[1][i] == 'R'));
	}
	for(int i = q.size() - 1 ; i >= 0 ; --i){
		dp[i][0] = dp[i + 1][0]; dp[i][1] = dp[i + 1][1];
		if(q[i].first == 0) ++dp[i][q[i].second];
		else dp[i][q[i].second ^ 1] = max(dp[i][q[i].second ^ 1] - 1 , 0);
	}
	for(int i = 0 ; i < q.size() ; ++i){
		if(q[i].first == 0){
			if(q[i].second == 0 && Y - dp[i][0] <= 0 || q[i].second == 1 && Y + dp[i][1] > W)
				Y += q[i].second == 0 ? -1 : 1;
		}
		else 
			if(q[i].second == 0 && Y + dp[i + 1][1] > W || q[i].second == 1 && Y - dp[i + 1][0] <= 0)
				Y += q[i].second == 0 ? -1 : 1;
		if(Y <= 0 || Y > W) return puts("NO") , 0;
	}
	memset(dp , 0 , sizeof(dp)); q.clear();
	for(int i = 0 ; i < N ; ++i){
		if(str[0][i] == 'U' || str[0][i] == 'D') q.push_back(PII(0 , str[0][i] == 'D'));
		if(str[1][i] == 'D' || str[1][i] == 'U') q.push_back(PII(1 , str[1][i] == 'D'));
	}
	for(int i = q.size() - 1 ; i >= 0 ; --i){
		dp[i][0] = dp[i + 1][0]; dp[i][1] = dp[i + 1][1];
		if(q[i].first == 0) ++dp[i][q[i].second];
		else dp[i][q[i].second ^ 1] = max(dp[i][q[i].second ^ 1] - 1 , 0);
	}
	for(int i = 0 ; i < q.size() ; ++i){
		if(q[i].first == 0){
			if(q[i].second == 0 && X - dp[i][0] <= 0 || q[i].second == 1 && X + dp[i][1] > H)
				X += q[i].second == 0 ? -1 : 1;
		}
		else 
			if(q[i].second == 0 && X + dp[i + 1][1] > H || q[i].second == 1 && X - dp[i + 1][0] <= 0)
				X += q[i].second == 0 ? -1 : 1;
		if(X <= 0 || X > H) return puts("NO") , 0;
	}
	puts("YES"); return 0;
}

Measured memory_bytes: 5744
N = int(input())
D, X = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))

List = []
for i in range(N):
    l = [j for j in range(1, D + 1) if (j - 1) % A[i] == 0]
    List.append(l)

tmp = 0
for i in range(N):
    tmp += len(List[i])

print(tmp + X)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main(){

	char table[3000];
	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		memset(table,0,sizeof(table));
		string str;
		cin>>str;
		int pos=1500;
		table[pos]=str[0];
		for(int j = 1; j < str.size(); j+=3){
			if(str.substr(j,2)=="->"){
				pos++;
				table[pos]=str[j+2];
			}
			else{
				pos--;
				table[pos]=str[j+2];
			}
		}
		for(int j = 0; j < 3000; j++){
			if(table[j]!=0){
				cout<<table[j];
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int field[30][30] = {0};
  int x,y,c;
  while(scanf("%d,%d,%d",&x,&y,&c)!=EOF){
    field[x+10][y+10]++;
    field[x+10][y+9]++;
    field[x+10][y+11]++;
    field[x+9][y+10]++;
    field[x+11][y+10]++;
    if(c>1){
      field[x+11][y+9]++;
      field[x+11][y+11]++;
      field[x+9][y+9]++;
      field[x+9][y+11]++;
    }
    if(c>2){
      field[x+8][y+10]++;
      field[x+12][y+10]++;
      field[x+10][y+8]++;
      field[x+10][y+12]++;
    }
  }
  int a = 0,b = 0;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      if(field[i+10][j+10] == 0) a++;
      if(field[i+10][j+10] > b) b = field[i+10][j+10];
    }
  }
  cout <<a<<endl<<b<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 12)cout << b << endl;
	else if (a > 5)cout << b / 2 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256