akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_H = 22;
const int MAX_W = 22;

string s[MAX_H];

const int INF = 1001001001;
int dist[MAX_H][MAX_W];

int H, W;
bool isin(int i, int j) {
  return 0 <= i && i < H && 0 <= j && j < W;
}

int di[4] = {0, 1, 0, -1};
int dj[4] = {1, 0, -1, 0};

int bfs(int si, int sj) {
  REP(i, H) REP(j, W) dist[i][j] = INF;

  queue<int> q;
  q.push(si);
  q.push(sj);
  dist[si][sj] = 0;
  while (!q.empty()) {
    int ci = q.front(); q.pop();
    int cj = q.front(); q.pop();
    for (int k = 0; k < 4; k++) {
      int ni = ci + di[k];
      int nj = cj + dj[k];
      if (isin(ni, nj) && s[ni][nj] == '.' && dist[ni][nj] > dist[ci][cj] + 1) {
        q.push(ni);
        q.push(nj);
        dist[ni][nj] = dist[ci][cj] + 1;
      }
    }
  }

  int md = 0;
  REP(i, H) REP(j, W) if (s[i][j] == '.') {
    chmax(md, dist[i][j]);
  }
  return md;
}

int main2() {
  H = nextInt();
  W = nextInt();
  REP(i, H) cin >> s[i];

  int ans = 0;
  REP(i, H) REP(j, W) {
    if (s[i][j] == '.') {
      int val = bfs(i, j);
      chmax(ans, val);
    }
  }

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
N = int(input())

t = 0
a = 0
for _ in range(N):
    rt,ra = map(int,input().split())
    c = max((t-1)//rt+1, (a-1)//ra+1)
    t = rt*c
    a = ra*c
    if a+t == 0:
        t += rt
        a += ra
    
answer = t+a
print(answer)


Measured memory_bytes: 3060
// AOJ 0099: Surf Smelt Fishing Contest II
// 2017.10.28 bal4u@uu

#include <stdio.h>
//#include <stdlib.h>

#define QSIZE 110000
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int id, key, c; } QUE;
QUE que[QSIZE+3]; int qsize;

void max_heapify(int i)
{
	int l, r, max;
	QUE t;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize &&
		(que[l].key > que[i].key || (que[l].key == que[i].key && que[l].id < que[i].id)))
		max = l;
	else max = i;
	if (r < qsize && (que[r].key > que[max].key ||
			(que[r].key == que[max].key && que[r].id < que[max].id)))
		max = r;
	if (max != i) {
		t = que[i]; que[i] = que[max], que[max] = t;
		max_heapify(max);
	}
}

void deq(void)
{
//	if (qsize == 0) return;
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(void)
{
	int i, max;
	QUE t;
	i = qsize++;
	while (i > 0 && (que[max = PARENT(i)].key < que[i].key
		|| (que[max].key == que[i].key && que[max].id > que[i].id))) {
		t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define MAX 1000000
int ff[MAX+3], cc[MAX+3];

int main()
{
	int n, q, a;

	n = in(), q = in();
	qsize = 0;
	while (q--) {
		a = in(), ff[a] += in(), cc[a]++;
		que[qsize].id = a, que[qsize].key = ff[a], que[qsize].c = cc[a];
		enq();

		while (1) {
			a = que[0].id;
			if (cc[a] == que[0].c) {
				printf("%d %d\n", que[0].id, que[0].key);
				break;
			}
			deq();
		}
	}
	return 0;
}



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

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int cnt = 0;
  rep(i, a + 1) rep(j, b + 1) rep(k, c + 1) {
    int cost = 500 * i + 100 * j + 50 * k;
    if (cost == x) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    long long N;
    cin >> N;
    for (int n = 1; n <= 3500; n++) {
        for (int h = 1; h < 3500; h++) {
            long long first = 4 * h*n - n*N - h*N;
            long long second = N * h * n;
            if (first <= 0 || second <= 0)
                continue;
            if (second % first)
                continue;
            long long ans = second / first;
            cout << h << " "<< n << " " <<  ans << endl;
            return 0;
           

        }

    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i,x;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(x%2==0){
            if(!(x%3==0 || x%5==0)){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
    
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::{random, Rng, SeedableRng};
use rand::rngs::SmallRng;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

use std::time::{Duration, Instant};

// code...
// #[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d]
    }

    let start = Instant::now();

    let mut rng = SmallRng::from_entropy();

    let mut ans = Vec::new();
    for day in 0..d {
        let w = s[day].iter().enumerate().max_by_key(|x| x.1).unwrap().0 + 1;
        ans.push(w);
    }
    let mut scr = score(d, &c, &s, &ans);

    // dbg!(scr);

    // let mut count = 0usize;

    while start.elapsed().as_millis() < 1900 {
        let prev = ans.clone();
        ch(&mut ans, &c, &s, &mut rng);
        let new = score(d, &c, &s, &ans);
        if new <= scr {
            ans = prev;
        } else {
            scr = new;
        }
        // count += 1;
    }

    // dbg!(score(d, &c, &s, &ans));
    // dbg!(count);

    for i in ans {
        println!("{}", i);
    }
}

fn score(d: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, ans: &Vec<usize>) -> i64 {
    let mut last = vec![0usize; 26];
    let mut a = 0i64;

    for day in 0..d {
        a += s[day][ans[day] - 1];
        last.iter_mut().for_each(|x| *x += 1);
        last[ans[day] - 1] = 0;
        a -= last
            .iter()
            .enumerate()
            .map(|(i, l)| c[i] * *l as i64)
            .sum::<i64>();
    }
    a
}

fn ch(ans: &mut Vec<usize>, c: &Vec<i64>, s: &Vec<Vec<i64>>, rng: &mut SmallRng) {
    for i in ans.iter_mut() {
        if rng.gen_bool(0.10) {
            *i = rng.gen_range(1, 27);
        }
    }
}


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

using namespace std;

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}

  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

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

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> fr(n, 0), bl(n, 0);
  int a, b, c, d;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--, b--;
    uf.merge(a, b);
    fr[a]++, fr[b]++;
  }
  for (int i = 0; i < k; i++) {
    cin >> c >> d;
    c--, d--;
    if (uf.issame(c, d)) {
      bl[c]++, bl[d]++;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << uf.size(i) - fr[i] - bl[i] - 1 << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll ans = 180 * (N - 2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
from bisect import bisect_left

N, K = map(int, input().split())
a = [int(input()) - K for _ in range(N)]

s = [0]
for i in range(N) :
    s.append(s[-1] + a[i])

t = list(set(s))
t.sort()
for i in range(N + 1) :
    s[i] = bisect_left(t, s[i])

class BinaryIndexedTree() :
    def __init__(self, N) :
        self.size = N
        self.tree = [0] * (N + 1)
        
    def sum(self, i) :
        s = 0
        while i > 0 :
            s += self.tree[i]
            i -= i & -i
        return s
        
    def add(self, i, x) :
        while i <= self.size :
            self.tree[i] += x
            i += i & -i
            
ret = 0
BIT = BinaryIndexedTree(N + 5)
for i in range(N + 1) :
    ret += BIT.sum(s[i] + 1)
    BIT.add(s[i] + 1, 1)
    
print(ret)

Measured memory_bytes: 91736
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S, T; cin >> S >> T;
  string ans = "";
  REP(i, N){
    ans += S.substr(i, 1);
    ans += T.substr(i, 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	l := make([]int, n)
	for i, _ := range l {
		fmt.Scan(&l[i])
	}
	sort.Ints(l)
	ans := 0
	for i := 0; i < k; i++ {
		ans += l[n - i - 1]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5
2 4
1 9
1 8
4 9
3 12
'''

def solve(l):
	n = len(l)
	l = sorted(l)
	# print('l:',l)
	last = 0
	for i in range(n):
		last += l[i][1]
		if(last > l[i][0]):
			return 'No'
	return 'Yes'
	

N = int(stdin.readline())
L = []
for _ in range(N):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	L.append([b,a])
ans = solve(L)
print(ans)


Measured memory_bytes: 39132
#include<vector>
#include<iostream>
#include<algorithm>
#include<chrono>
#include<set>
#include<cstdio>
#include<string>
#include<unordered_map>

using namespace std;


int main()
{
    int n, q;
    long long ans = 0;
    scanf("%d",&n);
    unordered_map<int, int> mp;
    for(int i = 0; i < n; i++){
        int a;
        scanf("%d", &a);
        mp[a]++;
        ans += a;
    }
    scanf("%d",&q);
    for(int i = 0; i < q; i++){
        int b, c;
        scanf("%d%d", &b, &c);
        mp[c] += mp[b];
        ans += (mp[b]*c - mp[b]*b);
        mp[b] = 0;
        cout << ans << endl;
    }
}

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


public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArr = br.readLine().split(" ");
        int[] numArr = new int[strArr.length];

        for (int i = 0; i < numArr.length; i++) {
            numArr[i] = Integer.parseInt(strArr[i]);
        }
        if (numArr[0] < numArr[1] && numArr[1] < numArr[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 24228
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const arr = input.split('\n');
let cards = [];
let str = '';
for(let i=0; i<arr.length; i++){
  if(arr[i] === '-') break;
  if(/\d+/.test(arr[i])) continue;
  if(/[a-z]/.test(arr[i])) {
    cards = arr[i].split('');
    rep = Number(arr[i+1]);
    for(let j=i+2; j<i+2+rep; j++){
      const num = Number(arr[j]);
      const move = cards.splice(num);
      cards = move.concat(cards);
    }
    str += cards.join('') + '\n';
  }
}
console.log(str.trim());


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

using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  int ans = t.length();
  for(int i = 0; i <= s.length() - t.length(); i++){
    int diff = 0;
   	for(int j = 0; j < t.length(); j++){
      if(s[i+j] != t[j])
        diff++;
    }
    ans = min(ans, diff);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3596
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    string S;
    cin >> S;

    int ans = 0;
    int b = 0;
    REP(i, S.size()) {
        if (S[i] == 'B') {
            b++;
        }
        else {
            ans += b;
        }
    }
    cout << ans <<  endl;


    return 0;
}


Measured memory_bytes: 1336
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N, X; cin >> N >> X;
	vec m(N); int sum_m = 0; int min_m = INF;
	for(int i=0; i<N; i++) {
		cin >> m.at(i);
		if(min_m>m.at(i)) min_m = m.at(i);

		sum_m += m.at(i);
	}

	int ans = N + (X-sum_m)/min_m;
	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
#coding: UTF-8

import sys

while True:
	hight,width = map (int,raw_input().split())
	if hight+width == 0:
		break
	else:
		for h in range(hight):
			if h%2 == 0:
				for w in range(width):
					if w%2 == 0:
						sys.stdout.write("#")
					else:
						sys.stdout.write(".")
				print ""
			else:
				for w in range(width):
					if w%2 == 0:
						sys.stdout.write(".")
					else:
						sys.stdout.write("#")
				print ""
		print ""

Measured memory_bytes: 6448
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
///*二進数割り算*/div2(ll x,ll y){}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 char s[300000];
 sc(s);
 ll n=strlen(s);
 ll cnt=0;ans=0;
 rep(i,0,n){
  if(s[i]=='W'){
   ans+=i-cnt;
   cnt++;
  }
 }
 pr(ans);
return 0;}

Measured memory_bytes: 3808
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int hh = sc.nextInt();
        int ww = sc.nextInt();
        int sum = h*w;

        System.out.println(sum-(h*ww)-(w*hh)+(hh*ww));
        

        
    }

}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}
 
signed main(){
    /*
    int n,m;
    cin>>n>>m;
 
    h.assign(n,0);
    rep(i,0,n) cin>>h[i];
 
    Graph G(n);
    rep(i,0,m){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
 
    seen.assign(n,-1);
 
    rep(i,0,n){
        if(seen[i]==-1){
            dfs(G,i);
        }
    }
 
    int sum=accumulate(all(seen),0);
 
    cout<<sum<<endl;*/
 
    ll k; cin>>k;
    ll n=50;
    ll s[n],ans[n];
    vector<ll> d(n,0);
 
    ll div=k/n; ll ama=k%n;
 
    rep(i,0,n){
        s[i]=div+(i<ama);
    }
 
    rep(i,0,n){
        int sum=0;
        for(int j=0;j<n;j++){
            if(i!=j) sum+=s[j]; 
        }
        ans[i]=n*(s[i]+1)-sum-1;//max(0LL,n*s[i]-d[i]);
    }
 
    cout<<n<<endl;
    rep(i,0,n){
        cout<<(i ? " ":"") <<ans[i];
    }
 
    cout<<endl;
}   

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

int main(int argc, char const *argv[])
{
    int n, a[100010]; cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        b--;
        a[i] = b;
    }
    int p = 0, count = 0;
    for (int i = 0; i < n+1; i++)
    {
        p = a[p];
        count ++;
        if (p == 1) {
            cout << count << endl;
            return 0;
        }
    }
    cout << -1 << endl;


    return 0;
}


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

int vacation(int a[],int b[],int c[],int n){
    int dp[n+1][3];
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];

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

        dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0] , dp[i-1][1]);
    }

    return max(dp[n][0] ,max(dp[n][1],dp[n][2]));
}
int main() {
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    cout<<vacation(a,b,c,n);

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN1(A) int A; cin >> A
#define CIN2(A, B) int A, B; cin >> A >> B
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C
#define CINV(A, N) REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl

int
main()
{
  CIN1(N);
  
  double sum = 0;
  REP(i, N) {
    double a;
    string s;
    cin >> a >> s;
    if (s == "JPY") sum += a;
    else sum += a * 380000;
  }

  printf("%f\n", sum);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
  ll from,to,dis;
};
bool cmp(const edge a,const edge b){
  return a.dis<b.dis;
}
ll par[200010];
ll len[200010];
void init(ll n){
  for(ll i=0;i<n;i++){
    par[i]=i;
    len[i]=0;
  }
}
ll root(ll n){
  if(par[n]==n)return n;
  return par[n]=root(par[n]);
}
void unit(ll a,ll b){
  a=root(a);
  b=root(b);
  if(a==b)return;
  if(len[a]<len[b]){
    par[a]=b;
  }
  else{
    par[b]=a;
    if(len[a]==len[b])len[a]++;
  }
}
int main(){
  ll n,m,k;cin>>n>>m>>k;
  ll c[n];
  ll now=1;
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]==0){
      c[i]=now+100000;
      now++;
    }
  }
  vector<edge> v;
  for(int i=0;i<m;i++){
    ll a,b,w;cin>>a>>b>>w;
    a--;b--;
    edge e={a,b,w};
    v.push_back(e);
  }
  sort(v.begin(),v.end(),cmp);
  init(200001);
  ll ans=0;
  ll cnt=0;
  for(int i=0;i<m;i++){
    edge e=v[i];
    ll f=e.from,t=e.to,d=e.dis;
    f=c[f],t=c[t];
    if(root(f)!=root(t)){
      unit(f,t);
      ans+=d;
      cnt++;
    }
    if(cnt==k-1){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 7152
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int A, B;
	scanf("%d", &A);
	scanf("%d", &B);

	if (A <= 9 && B <= 9)
	{
		printf("%d\n", A*B);
	}

	else
	{
		printf("%d", -1);
	}


	return 0;
}

Measured memory_bytes: 128
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

from sys import stdin


class Tree():
    def __init__(self):
        self.root = None

    def insert(self, z):

        y = None
        x = self.root

        while x != None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right

        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def print_inorder(self):
        def rec(node):
            if not node:
                return
            else:
                rec(node.left)
                print("", node.key, end="")
                rec(node.right)

        rec(self.root)
        print()

    def print_preorder(self):

        def rec(node):
            if not node:
                return
            else:
                print("", node.key, end="")
                rec(node.left)
                rec(node.right)

        rec(self.root)
        print()


class Node():
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

    def __repr__(self):
        return "Node({}, {}, {})".format(
            self.val, self.left, self.right)


def main():
    _ = int(stdin.readline())
    T = Tree()

    for line in stdin:
        cmd, *args = line.split()
        if cmd == "insert":
            T.insert(Node(int(args[0])))
        elif cmd == "print":
            T.print_inorder()
            T.print_preorder()


main()



Measured memory_bytes: 105536
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		// 4 3
		// 1 2 3 4
		// 1 3
		// 2 3
		// 2 4
		Set<Integer> ans = new HashSet<>();
		for (int i = 0; i < n; i++) {
			ans.add(i + 1);
		}
		int[] heights = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			heights[i] = sc.nextInt();
		}
		
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (heights[b] >= heights[a]) {
				ans.remove(a);
			}
			if (heights[a] >= heights[b]) {
				ans.remove(b);
			}
		}
		System.out.println(ans.size());
	}
}

 
 

 
 
 
 


Measured memory_bytes: 68072
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: String,
    }
    let mut ans = String::new();
    for c in S.chars(){
        match c{
            '0' => {ans.push_str("0")},
            '1' => {ans.push_str("1")},
            'B' => {ans.pop();},
            _   => {},
        }
    }
    println!("{}", ans)
}


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

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

    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    REP(i, n) cin >> A[i];
    REP(i, n) cin >> B[i];
    REP(i, n) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for(int b = 0; b < n; b++){
        long long a = lower_bound(A.begin(), A.end(), B[b]) - A.begin();
        long long c = upper_bound(C.begin(), C.end(), B[b]) - C.begin(); 
        ans += a * (n - c);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	int N, Y; std::cin >> N >> Y;
	bool flag = false;

	rep(x, Y / 10000 + 1) {
		rep(y, Y / 5000 + 1) {
			int z = N - x - y;
			if (z >= 0 && x * 10000 + y * 5000 + z * 1000 == Y) {
				std::cout << x << " " << y << " " << z;
				flag = true;
				break;
			}
		}
		if (flag)break;
		if (x == Y / 10000)std::cout << "-1 -1 -1";
	}
		
	return 0;
}

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

const int maxn = 1e5+10;
int a[maxn];

int main()
{
	int n;
	scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		int cnt = 1;
		int t=1;
		int in=0;
		while(a[t]==a[0])
		{
			++t; 
		}
		if(t==n-1)
		{
			cout<<"1"<<endl;
			return 0;
		}
		if(a[t]>a[0])
		{
			in=1;
		}
		for(int i=t;i<n;i++)
		{
			if(in==1)
			{
				if(a[i]<a[i-1])
				{
					cnt++;
					int j=i+1;
					while(a[j]==a[i])
					{
						j++;
					}
						if(a[j]<a[i])
						{
							in=0;
						}
						else
						{
							in=1;
						}
					
				}
				
			}
			if(in==0)
			{
				if(a[i]>a[i-1])
				{
					cnt++;
					int j=i+1;
					while(a[j]==a[i])
					{
						j++;
					}
						if(a[j]>a[i])
						{
							in=1;
						}
						else
						{
							in=0;
						}
					
				}
			}
		}
		cout<<cnt<<endl;
	
	return 0;
 } 

Measured memory_bytes: 640
X, Y = map(int, input().split())
if X % Y == 0:
  ans = -1
elif Y % X == 0:
  ans = X * (Y//X + 1)
else:
  ans = X
if ans > 10**18:
  ans = -1
if X == 1 and Y != 1:
  ans = Y + 1
print(ans)

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

int main() {
  int n;
  cin >>n;
  vector<int>p(n);
  vector<int>q(n);
  rep(i,n) cin >>p[i];
  rep(i,n) cin >>q[i];
  vector<int>x(n);
  rep(i,n) x[i]=i+1;
  
  int sump=0,sumq=0;
  int cnt=0;
  do{
    cnt++;
    bool flagp=true;
    bool flagq=true;
    rep(i,n){
      if(x[i]!=p[i])flagp=false;
      if(x[i]!=q[i])flagq=false;
    }
    if(flagp)sump=cnt;
    if(flagq)sumq=cnt;
  }while(next_permutation(x.begin(),x.end()));
  cout << abs(sump-sumq) << endl;
  
}

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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N, K;
  int ans = 1;
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    ans = min(ans * 2, ans + K);
  }
  cout << ans << endl;
}


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

int n, m;
char arr[21][21];
bool chk[21][21];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int f(int sx, int sy)
{
    memset(chk, 0, sizeof chk);

    queue<pair<int, int>> q;
    q.push({ sx, sy });
    chk[sx][sy] = 1;

    int r = 0;
    for(int i = 0; !q.empty(); i++)
    {
        r = i;
        int sz = (int)q.size();
        for(int j = 0; j < sz; j++)
        {
            int x, y;
            tie(x, y) = q.front();
            q.pop();
            for(int d = 0; d < 4; d++)
            {
                int nx = x + dx[d];
                int ny = y + dy[d];
                if(0 <= nx && nx < n && 0 <= ny && ny < m && arr[nx][ny] == '.' && !chk[nx][ny])
                {
                    chk[nx][ny] = 1;
                    q.push({ nx, ny });
                }
            }
        }
    }

    return r;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++)
        scanf("%s", arr[i]);

    int r = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if(arr[i][j] == '.')
                r = max(r, f(i, j));

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


Measured memory_bytes: 256
h,n=map(int,input().split())
l={}
ans=0
for i in range(n):
    a,b=map(int,input().split())
    if a in l:
        l[a]=min(l[a],b)
    else:
        l[a]=b
d=[0]*10005
for i in range(h):
    for j in l:
        a,b=j,l[j]
        x=d[i]+b
        y=min(10004,i+a)
        if i==0 or (d[i]!=0 and d[y]==0):
            if d[y]==0:
                d[y]=x
            else:
                d[y]=min(d[y],x)
        elif d[i]!=0 and d[y]!=0:
            d[y]=min(d[y],x)

for i in range(h,10005):
    if ans==0:
        ans=d[i]
    elif d[i]!=0:
        ans=min(ans,d[i])
print(ans)


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

int main(){
  int n;
  cin >> n;
  
  if (n%4 == 0)
    cout << "Yes" << endl;
  else{
    int m = n/4 + 1;
    int ans = 0;
    for (int i=0 ; i<m ; i++){
      if ((n-4*i)%7 == 0){
        ans = 1;
        break;
      }
    }
    
    if (ans == 1)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans=0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0;i < n;i ++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    for(int i = 0;i < n;i ++){
        if(i==n-1) ans += p[i]/2;
        else ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;

    if(n == 3 || n == 5 || n == 7){
        cout << "YES" <<endl;
    }else{
        cout << "NO"<<endl;
    }

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    fun toBinaryNumberCharArray(num: Long): String {
        return String.format("%0${n}d", java.lang.Long.toBinaryString(num).toLong())
    }

    val axy = Array(n) { mutableListOf<Pair<Int, Int>>() }
    (0 until n).forEach {
        val a = readLine()!!.toInt()
        for (i in 1..a) {
            val (x, y) = readLine()!!.split(' ').map(String::toInt)
            axy[it].add(Pair(x, y))
        }
    }
    var flag = (1L shl n) - 1L
    while (flag >= 0) {
        val sf = toBinaryNumberCharArray(flag)
        var index = 0
        var check = true
        for (c in sf) {
            if (c == '1') {
                val syo = axy[index]
                for (xy in syo) {
                    val (x, y) = xy
                    if (sf[x - 1].toString() != y.toString()) check = false
                }
            }
            index++
        }
        if (check) {
            println(sf.count { it == '1' })
            return
        }
        flag--
    }
    println(0)
}

Measured memory_bytes: 120380
#include <iostream>
#include <vector>
#include <algorithm> 

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

using namespace std;

const int inf = 100001;

int main(void) {
	int n, m, r;
	cin >> n >> m >> r;

	vector<vector<long long int>> dist(n, vector<long long int>(n, n*inf));
	vector<int> rs(r);

	rep(i, r) {
	  cin >> rs[i];
		rs[i]--;
	}

	rep(i, m) {
	  int a,b,c;
		cin >> a >> b >> c;
		a--; b--; //0-index
		dist[a][b] = c;
		dist[b][a] = c;
	}

	rep(i,n) dist[i][i] = 0;

	rep(k, n) rep(i, n) rep(j, n) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}

	long long int ans = r*n*inf; //n*infはtestcase8でWA

	sort(rs.begin(),rs.end());
	do {
		long long int tans = 0;
		rep(i, r - 1) {
			tans += dist[rs[i]][rs[i + 1]];
		}
		ans = min(tans, ans);
	} while (next_permutation(rs.begin(), rs.end()));

	cout << ans << endl;
}


Measured memory_bytes: 512
def nCr_frL(n,r,mod):
    ret=[1,n%mod]
    for i in range(2,r+1):
        inv=pow(i,mod-2,mod)
        ret.append((ret[-1]*(n-i+1)*inv)%mod)
    return ret

N,K=map(int,input().split())
MOD=10**9+7
com1=nCr_frL(N,N,MOD) # nCi
com2=nCr_frL(N-1,N-1,MOD) # n-1Ci

if K>N-1:
    K=N-1
ans=0
for m in range(K+1):
    ans+=(com1[m]*com2[N-m-1])%MOD
print(ans%MOD)



Measured memory_bytes: 18952
#include<iostream>
using namespace std;
int main()
{
    int n,r;
    int wi[20];
    int lo[20];
    char c[20];
    int idx[20];
    while(cin >> n){
        for(int i=0;i<n;i++){
            cin >> c[i];
            wi[i] = 0;
            lo[i] = 0;
            idx[i] = i;
            for(int j=0;j<n-1;j++){
                cin >> r;
                if(r == 0) wi[i]++;
                if(r == 1) lo[i]++;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n-1;j++){
                if(wi[ idx[j] ] < wi[ idx[j+1] ]) swap(idx[j],idx[j+1]);
                else if(wi[ idx[j] ] == wi[ idx[j+1] ] && lo[ idx[j] ] > lo[ idx[j+1] ])
                    swap(idx[j],idx[j+1]);
            }
        }
        for(int i=0;i<n;i++) cout << c[idx[i]] << endl;
    }
    return 0;
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    if(n>1) n-=2;
    if(m>1) m-=2;
    cout << n*m << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    cin >> s;
    cout << count(s.begin(), s.end(), '2') << "\n";
    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

int main(){
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;

    long long int mc = min(c,d);
    long long int md = max(c,d);
    int i = mc;
    long long int r = md % mc;
    long long int sai = (mc*md);
  while(r!=0){
    md = mc;
    mc = r;
    r = md % mc;
  }
  sai = sai/mc;
//   show(sai);
  cout << b-a+1 - (((b)/c + (b)/d -(b)/sai) - ((a-1)/c + (a-1)/d -(a-1)/sai));


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		boolean b = true;
		for(int i = 0; i < s.length() && b; i++)
			b &= s.indexOf(s.charAt(i), i+1) == t.indexOf(t.charAt(i), i+1) ;
		System.out.println(b ? "Yes" : "No");
	}
}


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

const int N = 1e5 + 8;
const int mod = 1e9 + 7;
int n , a[N] , T;

int dp[101][N];

int add(int x , int y){return (x % mod + y % mod) % mod;}
int sub(int x , int y){return (x % mod - y % mod + mod) % mod;}

int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
    cin >> n >> T;
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }

    dp[0][0] = 1 ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 0 ; j <= T ; j++){
            int rem = j - a[i] - 1;
            if(rem < 0) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = sub(dp[i - 1][j] , dp[i - 1][rem]);
        }
        for(int u = 1 ; u <= T ; u++){
            dp[i][u] = add(dp[i][u] , dp[i][u - 1]);
        }
    }
    cout << dp[n][T] << endl;
  return 0;
}



/*for( int i = 1 ; i <= n ; i++ ){
        for( int j = 0 ; j <= T ; j++ ){
            for( int l = 0 ; l <= a[i] ; l++ )
                if( j >= l ){
                dp[i][j] += dp[i-1][j-l];
            }
        }
    }*/

Measured memory_bytes: 42688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1001001001;
const double EPS = 1e-10;
struct Edge { ll from, to, cost; };
using Graph = vector<vector<Edge>>;

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

    int n;
    cin>>n;
    cout<<n<<':';
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            n/=i;
            cout<<' '<<i;
        }
    }
    if(n!=1)cout<<' '<<n;
    cout<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll N;
	cin >> N;
	
	ll arr[N], l[N], r[N];
	REP(i, 0, N) cin >> arr[i];
	
	REP(i, 0, N){
		if(i == 0) l[0] = arr[i];
		else{
			l[i] = arr[i] + l[i-1];
		}
	}
	for(int i = N-1; i >= 0; i--){
		if(i == N-1) r[i] = arr[i];
		else{
			r[i] = arr[i] + r[i+1];
		}
	}
	
	ll ans = pow(10, 18);
	REP(i, 0, N-1){
		//cout << ans << " " << l[i] << " " << r[i+1] << " " << i << endl;
		ans = min(ans, abs(l[i]-r[i+1]));
	}
	cout << ans;
		

}


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

int cg(string&s){
	int cnt=0;
	for(int i=1;i<s.size();++i){
		if(s.at(i-1)==s.at(i))s.at(i)='*',++cnt;
	}
	return cnt;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; int k; cin>>s>>k;
	string fir=s; int fsc=cg(fir);
	string odd=fir.back()+s; int odc=cg(odd);
	string eve=odd.back()+s; int evc=cg(eve);
	cout<<fsc+1L*k/2*odc+1L*(k-1)/2*evc<<"\n"s;
}


Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
  double r;
  cin >> r;
  double length = 2 * r * M_PI;
  double circle = r * r * M_PI;
  cout << setprecision(20) << circle << " " << length << "\n";
}

Measured memory_bytes: 1288
N, M = map(int, input().split())

if M <= N:
	print(0)
elif M == 2:
	if N == 1:
		X_list = [int(_) for _ in list(input().split())]
		print(abs(X_list[0]-X_list[1]))
	else:
		print(0)
else:
	X_list = [int(_) for _ in list(input().split())]

	X_list.sort()
	X_list.reverse()

	X_diff_list = [X_list[i-1]-X_list[i] for i in range(1, M)]
	X_diff_list.sort()
	X_diff_list.reverse()

	answer = sum(X_diff_list)

	if N == 1:
		print(answer)
	else:
		for n in range(N-1):
			answer -= X_diff_list[n]
		print(answer)


Measured memory_bytes: 13320
#include "bits/stdc++.h"
using namespace std;
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1369
??????????????????

???ICPC??\??´?????????????????£???????????¨????????°?????????????????????????????????????????°???????????????????????¢???
????£??????????????????????????????§???????????¶?????????????????????????????????????????????????????????????????????????????¢??????
???????°???\???????????????1????????????????????????????????????????§??????§??????????????????????????¢???????¨?????????????
????????????????????°???????£??????????????????????????????¨??????????????¨????¨±?????????????????°???????????????

?????????????????¢???????????????????????????, ????£???????????????????????????????????????????????????????????????°?????????
??????????????????????????????????????¨?????°??????????????????????£?????????????????????\????????????????????¨?¢???????????????¨??????
??????????????¢?????°????????????????????¢??????????????????????????£??????????????????
*/
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> line(200000, 0);
	vector<int> min_line(n, 0), max_line(n, 0); // min~max_line[i] = i????????????????????°?????§??????????????????or???????????????
	for (int i = 0; i < m;i++) {
		int x, y; cin >> x >> y;
		line[x] = y;
	}
	for (int i = 0; i < n;i++) {
		min_line[i] = max_line[i] = i;
	}
	for (int i = 0; i < 200000;i++) {
		if (line[i] == 0)continue;
		min_line[line[i] - 1] = min_line[line[i]] = min(min_line[line[i] - 1], min_line[line[i]]);
		max_line[line[i] - 1] = max_line[line[i]] = max(max_line[line[i] - 1], max_line[line[i]]);
	}
	cout << max_line[0] - min_line[0] + 1;
	for (int i = 1; i < n;i++) {
		cout << " " << max_line[i] - min_line[i] + 1;
	}
	cout << endl;
}

Measured memory_bytes: 5176
#include <stdio.h>
#define MAX 150

int n,next[MAX][MAX];

int search(int i,int j)
{
  int flag=0;
    for(int k=1;k<=n;k++)
    {
      if(next[i][k]==j)flag=1;
    }
  if(flag==1)return 1;
  else return 0;
}

int main()
{
  int i,j,t[MAX],tn;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d%d",&t[i],&tn);
    for(j=1;j<=tn;j++)scanf("%d",&next[i][j]);//iの次の人たち
  }

  for(i=1;i<=n;i++) //１行目、２行目
  {
    for(j=1;j<=n;j++)
    {
     if (search(i,j)==1)printf("1");
     else printf("0");
     if(j!=n)printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	int n,l,r,a[100005],ans=0;
	cin>>n;
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++){
		cin>>l>>r;
		int x=r-l+1;
		ans+=x;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640