akhauriyash/Code-Regression huggingface dataset:
local n = io.read("*n")
local edge = {}
local srccnt = {}
for i = 1, n * n do
  edge[i] = {}
  srccnt[i] = 0
end
local function getindex(a, b)
  if a < b then
    return (a - 1) * n + b
  else
    return (b - 1) * n + a
  end
end
for i = 1, n do
  local prvidx = getindex(i, io.read("*n"))
  for j = 2, n - 1 do
    local nxtidx = getindex(i, io.read("*n"))
    edge[prvidx][nxtidx] = true
    srccnt[nxtidx] = srccnt[nxtidx] + 1
    prvidx = nxtidx
  end
end
local tasks = {}
for i = 1, n * n do
  if next(edge[i]) and srccnt[i] == 0 then
    table.insert(tasks, i)
  end
end
local day = 0
local matched = 0
while 0 < #tasks do
  day = day + 1
  local ng = false
  local newtasks = {}
  for i = 1, #tasks do
    local src = tasks[i]
    matched = matched + 1
    for dst, _unused in pairs(edge[src]) do
      srccnt[dst] = srccnt[dst] - 1
      if srccnt[dst] == 0 then
        table.insert(newtasks, dst)
      end
    end
    if ng then break end
  end
  if ng then break end
  tasks = newtasks
end
if matched * 2 ~= n * (n - 1) then
  day = -1
end
print(day)


Measured memory_bytes: 117100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int num[n];
    rep(i,n) cin >> num[i];
    reverse(num,num+n);
    rep(i,n){
        cout << num[i] << (i==n-1 ? '\n' : ' ');
    }
}


Measured memory_bytes: 3044
#include <stdio.h>
int main(void){
long max, min, sum,  n;
int c, i;
max = 0;
min = 0;
sum = 0;
scanf("%d", &c);
if( c > 0 ) {
scanf("%ld", &n);
max = n;
min = n;
sum = n;
}
for( i = 1; i < c; ++i) {
scanf("%ld", &n);
sum+=n;
min = n > min ? min : n;
max = n < max ? max : n;
}
printf ("%ld %ld %ld\n", min, max, sum );
return 0;
}

Measured memory_bytes: 1032
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
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);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    cout<<a[k-1];
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int[] a = new int[3];
		a[0] = parseInt(sc.next());
		a[1] = parseInt(sc.next());
		a[2] = parseInt(sc.next());
		sc.close();
		Arrays.parallelSort(a);
		if(a[0]==5&&a[1]==5&&a[2]==7) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}
}


Measured memory_bytes: 21588
INF = 10 ** 9 + 7
N, K = map(int, input().split())

ans = 0
mx = 0
mn = 0

for i in range(N+1):
  mx += N-i
  mn += i
  if i + 1 >= K:
    ans += (mx - mn + 1) % INF

print(ans % INF)


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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	int cnt4 = 0, cnt2 = 0;
	for (auto&& x : a) {
		if (x >= 4 && x % 4 == 0)cnt4++;
		else if (x >= 2 && x % 2 == 0)cnt2++;
	}
	cnt4 += (cnt2 / 2);
	cout << (cnt4 >= (n / 2) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

int main()
{
  int x;
  int max = 0;

  std::cin >> x;

  for (int i = 1; i < 32; ++i) {
    for (int j = 2; j < 11; ++j) {
      if ( x < pow(i, j)) {break;}
      if (max < pow(i, j)) {
        max = pow(i, j);
      }
    }
  }

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define maxn        998244353
#define mod         1000000007
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int solve()
{
  int n, x, t;
  cin >> n >> x >> t;
  cout << (n / x)*t + (n % x ? t : 0);
  return 0;
}
signed main()
{
  OJ();
  IOS
  //tc
  solve();
  //extime
  return 0;
}

Measured memory_bytes: 3572
#include<iostream>

using namespace std;

// カードの有無はbool配列に記録する。
// 入力でカードを確認したら配列の対応する箇所にtrueを代入。
// 最終的にfalseの箇所が足りないカードを示す。

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

	// インデックス0が無駄になるが、
	// 配列アクセス時の計算の煩雑さを防ぐために1多く確保
	bool cards[4][14] = {};

	for (int i = 0; i < n; ++i) {
		char suit;
		int num;
		cin >> suit >> num;
		int suit_num;
		switch (suit)
		{
		case 'S':
			suit_num = 0;
			break;
		case 'H':
			suit_num = 1;
			break;
		case 'C':
			suit_num = 2;
			break;
		case 'D':
			suit_num = 3;
			break;
		default:
			throw "input error";
		}

		cards[suit_num][num] = true;
	}
	for (int i = 0; i < 4; i++) {
		const char suit_char[4] = { 'S', 'H', 'C', 'D' };
		for (int j = 1; j <= 13; j++) {
			if (false == cards[i][j]) {
				cout << suit_char[i] << ' ' << j << endl;
			}
		}
	}
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    ll ans=n%k;
    ans=min(ans,abs(ans-k));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(){
double n,t,a;
  cin>>n>>t>>a;
  vector<double>h(n);
  double Min=100000000;int ans=0;
  for(int i=0;i<n;i++){
  	cin>>h[i];
    h[i]=t-h[i]*0.006;
    
    if(abs(h[i]-a)<Min){Min=abs(h[i]-a);ans=i+1;}
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int,input().split()))

for i in range(n):
	if a[i] % 2 == 0:
		if a[i] % 3 != 0 and a[i] % 5 != 0:
			print('DENIED')
			sys.exit()
print('APPROVED')


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

using namespace std;

int main() {
	long long n,a,b; cin >> n >> a >> b;
	vector<long long> x(n);
	for(auto&e:x) cin >> e;
	long long ans=0;
	for(int i=1;i<n;++i)
		ans+=min((x[i]-x[i-1])*a,b);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int main(){
  int a,x=1;
  cin>>a;
  cin>>s[0];
  for(int i=1;i<a;i++){
    cin>>s[i];
    if(s[i]!=s[i-1])
      x++;
  }
  cout<<x;
  return 0;
}

Measured memory_bytes: 384
N,K=map(int,input().split())
A=list(map(lambda x:int(x)%K,input().split()))
cum=[0]*(N+1)
for i in range(N):
    cum[i+1]=(cum[i]+A[i])

x=[(cum[i]-i)%K for i in range(N+1)]
dic={}
ans=0
for i in range(N+1):
    if i>=K:
        dic[x[i-K]]-=1
    ans+=dic.get(x[i],0)
    if not x[i] in dic:
        dic[x[i]]=1
    else:
        dic[x[i]]+=1
print(ans)

Measured memory_bytes: 114124
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <utility>
#define N 100020
using namespace std;

vector<pair<int, int> > e[N];
int o[N];
set<int> f;

void DFS(int x, int p, int k)
{
    int i, c;

    for(i = c = 0; i < (signed)e[x].size(); i ++)
        if(e[x][i].first != p)
        {
            if(c == k)
                c ++;
            o[e[x][i].second] = c;
            DFS(e[x][i].first, x, c ++);
        }

    return;
}

int main(void)
{
    int n, u, v;
    int i;

    scanf("%d", &n);
    for(i = 1; i < n; i ++)
    {
        scanf("%d %d", &u, &v);
        e[-- u].push_back(make_pair(-- v, i));
        e[   v].push_back(make_pair(   u, i));
    }
    DFS(0, 0, -1);

    for(i = 1; i < n; i ++)
        f.insert(o[i]);
    printf("%d\n", (int)f.size());
    for(i = 1; i < n; i ++)
        printf("%d\n", o[i] + 1);

    return 0;
}


Measured memory_bytes: 7416
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
#define KW(a) ((a)*(a))
using namespace std;
 
const int maxN = 1 << 20, mod = 1000000007;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }

long long qpow(long long a, long long b)
{
    long long res0 = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  multMod(res0, a);
        multMod(a, a);
    }
    return res0;
}

long long fact[maxN], tcaf[maxN];

long long cf(int n, int k)
{
	bool static initd = false;
	if (!initd)
	{
		fact[0] = 1;
		FOR(i, 1, maxN)
			fact[i] = fact[i - 1] * i % mod;
		tcaf[maxN - 1] = qpow(fact[maxN - 1], mod - 2);
		for (int i=maxN-1; i>0; i--)
			tcaf[i - 1] = tcaf[i] * i % mod;
		initd = true;
	}
	if (k < 0 or k > n)
		return 0;
	long long res0 = fact[n];
	multMod(res0, tcaf[k]);
	multMod(res0, tcaf[n-k]);
	return res0;
}


void solve()
{
	int x, y;
	scanf ("%d%d", &x, &y);
	int n = (x + y) / 3;
	if ((x + y) % 3 == 0)
		printf("%lld\n", cf(n, x-n));
	else
		printf("0\n");
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}



Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <cmath>
#define M 1000000007
using namespace std;

long long n,m,c=1,d=1,e;

int main()
{
	scanf("%lld %lld",&n,&m);
	if(abs(n-m)>=2)puts("0");
	else
	{
		for(int i=1;i<=n;i++)c=c*i%M;
		for(int i=1;i<=m;i++)d=d*i%M;
		if(n==m)printf("%lld\n",2*(c*d%M)%M);
		else printf("%lld\n",(c*d%M)%M);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

int main() {
    kekek();
    long long num;
    cin >> num;
    long long ans = LLINF;
    for (long long i = 1; i * i <= num; i++) {
        if (num % i == 0) {
            long long a = i;
            long long b = num / i;
            ans = min(ans, a + b - 2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	vector<int>B(N);
	vector<int>C(N - 1);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	for (size_t i = 0; i < N; i++)
	{
		cin >> B.at(i);
	}
	for (size_t i = 0; i < N - 1; i++)
	{
		cin >> C.at(i);
	}
	int point = 0;
	int AA;
	for (size_t i = 0; i < N - 1; i++)
	{
		AA = A.at(i) - 1;
		point += B.at(AA);
		if (A.at(i) == A.at(i + 1) - 1) point += C.at(AA);
	}
	AA = A.at(N - 1) - 1;
	point += B.at(AA);
	cout << point << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll power(ll x,ll y){
    ll res = 1;
    
    while(y>0){
        if(y&1)res = (res*x);
        y>>=1;
        x = (x*x);
    }
    return res;
}

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}

ll x;
int main(){
	fastio();
	int n;
	cin>>n;
	vector<ll> a(n+1);
	for(int i = 1; i<=n; i++)cin>>a[i];
	map<ll,ll> mp;
ll ans = 0;
	for(int i = 1; i<=n; i++){
		if(mp.find(i-a[i])!=mp.end())ans+=mp[i-a[i]];
		mp[i+a[i]]++;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 17140
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]

    def find(self, x):
        if self.parents[x] == x:
            return x
        ret = self.parents[x] = self.find(self.parents[x])
        return ret

    def is_family(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return False
        self.parents[root_x] = root_y
        return True


n, m = [int(i) for i in input().split()]
pp = [int(i)-1 for i in input().split()]
uf = UnionFind(n)
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    uf.union(x-1, y-1)

ans = 0
for i, p in enumerate(pp):
    if uf.is_family(i, p):
        ans += 1

print(ans)


Measured memory_bytes: 125932
#include <stdio.h>

int main(void){
  int a,b;
  int num=1;//現在の口の個数
  int count=0;

  scanf("%d %d", &a, &b);

  while(num<b){
    num+=a-1;
    count++;
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int ab = Integer.parseInt(sc.next());
    int bc = Integer.parseInt(sc.next());
    int ca = Integer.parseInt(sc.next());

    System.out.println(ab * bc / 2);

  }
}

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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;
template<typename T>
map<T, ll> prime_factorize(T x, map<T,ll> m){

  while(x%2==0){
    x/=2;
    m[2]++;
  }

  for(ll i=3;i*i<=x;i+=2){
    while(x%i==0){
      x/=i;
      m[i]++;
    }
  }
  if(x!=1) m[x]++;
  return m;
}


int main(){
  cout << setprecision(10);
  map<ll,ll> m;
  ll N;
  cin >> N;
  for(ll i = 2; i <= N; i++){
    m = prime_factorize(i, m);
  }
  int over_75 = 0;
  int over_25 = 0;
  int over_15 = 0;
  int over_5 = 0;
  int over_3 = 0;

  for(auto x: m){
    cerr << x.first << " " << x.second << endl;
    if(x.second >= 74){
      over_75++;
    }
    if(x.second >= 24){
      over_25++;
    }
    if(x.second >= 14){
      over_15++;
    }
    if(x.second >= 4){
      over_5++;
    }
    if(x.second >= 2){
      over_3++;
    }
  }
  ll ans = 0;
  // 75
  ans += over_75;
  // 25 * 3
  ans += over_25 * (over_3 - 1);
  // 15 * 5 
  ans += over_15 * (over_5 - 1);
  // 5 * 5 * 3
  ans += over_5 * (over_5 - 1) / 2 * (over_3 - 2);

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  string x, y;
  cin >> x >> y;
  if(x>y) cout <<">\n";
  else if(x<y) cout <<"<\n";
  else cout <<"=\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
mm, dd = list(map(int, input().split()))

cnt = 0
for m in range(1, mm + 1):
	for d in range(1, dd + 1):
		d1 = d % 10
		d2 = d// 10
		if d1 >= 2 and d2 >= 2 and d1 * d2 == m:
			cnt += 1
print(cnt)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N, K;cin >> N >> K;
    vll A(N);
    for(auto &a:A) cin >> a;
    cout << ceil((N - 1) / (double)(K - 1));
}

int main() {
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;
int a[9];
int main() {
  int N; cin >> N;

  for ( int i = 0; i < N; i++ ) {
    int tmp; cin >> tmp;
    if ( 1 <= tmp && tmp <= 399 ) a[0]++;
    else if ( 400 <= tmp && tmp <= 799 ) a[1]++;
    else if ( 800 <= tmp && tmp <= 1199 ) a[2]++;
    else if ( 1200 <= tmp && tmp <= 1599 ) a[3]++;
    else if ( 1600 <= tmp && tmp <= 1999 ) a[4]++;
    else if ( 2000 <= tmp && tmp <= 2399 ) a[5]++;
    else if ( 2400 <= tmp && tmp <= 2799 ) a[6]++;
    else if ( 2800 <= tmp && tmp <= 3199 ) a[7]++;
    else  a[8]++;
  }

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

  //cout << cnt << endl;
  //  cout << a[8] << endl;

  int maxans,minans;
  if ( cnt == 0 ) {
    minans = 1;
    maxans = a[8];
  } else if ( cnt < a[8] ) {
    minans = cnt;
    maxans = cnt+a[8];
  } else if ( cnt == a[8]) {
    minans = a[8];
    maxans = cnt+a[8];
  }else {
    minans = cnt;
    maxans = cnt+a[8];    
  }

  cout << minans << " " << maxans << endl;
  return 0;
}


Measured memory_bytes: 256
main(){int n,a,b,c;scanf("%d",&n);while(n>0){n--;scanf("%d %d %d",&a,&b,&c);a=a*a;b=b*b;c=c*c;if(a+b==c)printf("YES\n");else if(a+c==b)printf("YES\n");else if(b+c==a)printf("YES\n");else printf("NO\n");}return 0;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007

const int maxn = 100010;
int n, arr[maxn], dp[maxn];

int fun(int idx)
{
	if (idx >= n)
		return 0;
	if (dp[idx] != -1)
		return dp[idx];

	int ch1 = inf, ch2 = inf;
	if (idx + 1 <= n)
	{
		ch1 = abs(arr[idx] - arr[idx + 1]) + fun(idx + 1);
	}
	if (idx + 2 <= n)
	{
		ch2 = abs(arr[idx] - arr[idx + 2]) + fun(idx + 2);
	}
	return dp[idx] = min(ch1, ch2);
}

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	memset(dp, -1, sizeof(dp));

	int ans = fun(1);
	cout << ans;
}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 9840
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int a,b,c;
int ans;

int main(){
  cin >> a >> b >> c;
  if(a>b) swap(a,b);
  if(b>c) swap(b,c);
  if(a>b) swap(a,b);
  ans += c-b;
  a += c-b;
  b = c;
  if((c-a)%2==0) ans += (c-a)/2;
  else ans += (c-a)/2+2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int a,b;
  cin>>a>>b;
  if(a<b){
    std::swap(a,b);
  }
  if((a-b)%2==0){
    cout<<b+(a-b)/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }

  return 0;
}


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

int main() {
  int k;
  int n;
  cin>>k>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int m=0;
  for(int j=1;j<n;j++){
    if(a.at(j)-a.at(j-1)>m){
      m=a.at(j)-a.at(j-1);
    }
  }
  if(k+a.at(0)-a.at(n-1)>m){
    m=k+a.at(0)-a.at(n-1);
  }
  cout<<(k-m)<<endl;
}


Measured memory_bytes: 1024
def print_ans(ans)
    ans.each do |arr|
        puts arr.join(" ")
    end
end

H, W, K = gets.chomp.split.map(&:to_i)
cake = []
H.times do
    cake << gets.chomp.split("")
end
ans = Array.new(H).map{Array.new(W, 0)}
num = 1

# →
H.times do |h|
    tmp = 0
    W.times do |w|
        if cake[h][w] == "#" then
            tmp = num
            num += 1
        end
        ans[h][w] = tmp
    end
end

# ←
H.times do |h|
    (W-2).downto(0) do |w|
        ans[h][w] = ans[h][w+1] if ans[h][w] == 0
    end
end

# ↓
(1...H).each do |h|
    W.times do |w|
        ans[h][w] = ans[h-1][w] if ans[h][w] == 0
    end
end

# ↑
(H-2).downto(0) do |h|
    W.times do |w|
        ans[h][w] = ans[h+1][w] if ans[h][w] == 0
    end
end

print_ans(ans)

Measured memory_bytes: 21260
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> a;
  vector<int> b;

  int num;
  rep(i, n) {
    cin >> num;

    if (i % 2 == 0) a.push_back(num);
    else b.push_back(num);
  }

  if (n == 1) {
    cout << a[0] << endl;
  }
  else if (n % 2 == 0) {
    for (int i = b.size() - 1; i >= 0; i--) {
      cout << b[i] << " ";
    }

    for (int i = 0; i < a.size(); i++) {
      cout << a[i];
      if (i == a.size() - 1) cout << endl;
      else cout << " ";
    }
  } else {
    for (int i = a.size() - 1; i >= 0; i--) {
      cout << a[i] << " ";
    }

    for (int i = 0; i < b.size(); i++) {
      cout << b[i];
      if (i == b.size() - 1) cout << endl;
      else cout << " ";
    }
  }

  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

class Count {
public:
	Count(string key)
		: key_(key)
		, count_(1)
	{

	}

	string key_;
	int count_;
};

int main()
{
	int N = 0, M = 0;

	cin >> N;
	vector<string> vctS(N);
	for (auto& elem: vctS) {
		cin >> elem;
	}


	cin >> M;
	vector<string> vctT(M);
	for (auto& elem : vctT) {
		cin >> elem;
	}

	vector<Count> vctCount;
	for (auto& s : vctS) {
		bool isFound = false;
		for (auto& count : vctCount) {
			if (s == count.key_) {
				++count.count_;
				isFound = true;
			}
			

		}
		if (isFound == false) {
			vctCount.push_back(Count(s));
		}
	}
	for (auto& count : vctCount) {
		for (const auto& t : vctT) {
			if (count.key_ == t) {
				--count.count_;
			}
		}
	}
	int max = 0;
	for (int i = 0; i < vctCount.size(); ++i) {
		int curCount = vctCount[i].count_;
		if (curCount > max) {
			max = curCount;
		}
	}

	cout << max;
			
#if 0


	//map<string, int> mapCout;

	
	
	
	for (auto& s : vctS) {
		for (auto& mapS : mapCount) {
			if(s == map)
		}


	}



	int n = 0;

	cin >> n;
#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
int main(){

    int n;
    string s;
    cin >> n;
    cin >> s;
    ll wa;
    wa = count(all(s),'R')*count(all(s),'G')*count(all(s),'B');
    ll cnt = 0;
    rep(i,n-2) for(int j=i+1; j<n-1; j++){
        int k = 2*j-i;
        if(k >= n) continue;
        if(s.at(i)==s.at(j)) continue;
        if(s.at(j)==s.at(k)) continue;
        if(s.at(k)==s.at(i)) continue;
        cnt++;
    }
    cout << wa-cnt << endl;

}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble(); double B = sc.nextDouble(); double C = sc.nextDouble(); double D = sc.nextDouble();

        if(Math.ceil(A/D)>=Math.ceil(C/B)){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 37316
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	int a[n];
	REP(i, 0, n) scanf("%d", &a[i]);

	ll ans[2][n];
	REP(i, 0, n) ans[0][i] = i+1;
	REP(i, 0, n) ans[1][i] = 1e9-i;

	REP(i, 0, n) ans[1][a[n-i-1]-1] -= i;

	int pre0 = 1e9+1, pre1 = 0;
	for(int i=n-1; i>=0; i--){
		int move = std::min(pre0-1-ans[0][i], ans[1][i]-pre1-1);
		ans[0][i] += move;
		ans[1][i] -= move;
		pre0 = ans[0][i];
		pre1 = ans[1][i];
	}	

	REP(i, 0, n) printf("%ld ", ans[0][i]);puts("");
	REP(i, 0, n) printf("%ld ", ans[1][i]);puts("");
	return 0;
}




Measured memory_bytes: 4152
#include <stdio.h>
int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        printf("a < b\n");
    }
    if(a>b)
    {
        printf("a > b\n");
    }
    if(a==b)
    {
        printf("a == b\n");
    }
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i <= 1000; i++) {
    if (i * 8 / 100 == A && i * 10 / 100 == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  if (N != 1){
    rep(i,N-1){
      if(S[i]!=S[i+1]) ans++;
    }
  }
  cout << ans << endl;
}

  



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

int main() {
    int n;
    cin >> n;
    int R[n];
    int maxv = -1e9;
    for (int i = 0; i < n; i++) cin >> R[i];
    
    int minv = R[0];
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
}


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

int main(void)
{
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;++i) cout<<s<<" ";
    for(int i=k;i<n;++i){
        if(s==1000000000) cout<<s-1<<" ";
        else cout<<s+1<<" ";
    }
    return 0;
}

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

const ll mod = 998244353;

int dis[100000 + 10];

ll ksm(ll a, ll b)
{
	ll ans = 1;
	while( b )
	{
		if(b & 1) ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ans;
}

int main()
{
	ll n;
	cin>>n;
	ll x;
	ll maxn=0;
	dis[0]=1;
	cin>>x;
	ll flag=0;
	if(x != 0)
	{
		flag = 1;
	}
//	printf("YES");
	for(ll i=1; i<n; i++)
	{
		cin>>x;
		if(x == 0) flag = 1;
		maxn=max(maxn, x);
		dis[x]++;
	}
//	printf("NO");	
//	cout<<maxn<<endl;
	if(flag)
	{
		printf("0");
	}
	else
	{
		ll ans=1;
		for(ll i=1; i < maxn; i++)
		{
			if(dis[i] == 0)
			{
				flag = 1;
			}
			ans=ans*ksm(dis[i], dis[i+1])%mod;
		}
		if(flag) printf("0");
		else cout<<ans;
	}	
//	printf("YEs");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 

int main() 
{
	fastio
	//t_case
	{
		ll sum=0,f=1,ans=0,n,m=1,mx=-inf,mn=inf,x,y,k  ; //cin>>n; 
		string str; cin>>str;
		if (str[str.length()-1]=='s') {
			cout<<str;
			cout<<"es";
		}
		else cout<<str<<'s';
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main() {
  int n, t, e;
  int x[100];
  cin >> n >> t >> e;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < n; ++i) {
    if (((t - e) / x[i] + 1) * x[i] <= t + e) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
vector <ll> g[100][100];
ll visited[100][100];
ll dfs(ll i,ll j,ll cnt){
    for(auto itr=g[j][i].begin();itr!=g[j][i].end();++itr){
        if(visited[j][*itr]==0){
            visited[j][*itr]=1;
            cnt=dfs(*itr,j,cnt+1);
        }
    }
    return cnt;
}

int main(){
    ll N,M;
    cin >> N >> M;
    ll i,j;
    ll a,b;
    for(i=0;i<M;i++){
        cin >> a >> b;
        for(j=0;j<M;j++){
            if(i!=j){
                g[j][a-1].push_back(b-1);
                g[j][b-1].push_back(a-1);
            }
        }
        for(j=0;j<N;j++){
            visited[i][j]=0;
        }
    }
    ll ans=0;
    for(j=0;j<M;j++){
        visited[j][0]=1;
        if(dfs(0,j,1)!=N)ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<map<int, int>>num(n);
  vector<ed>es(m);
  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    num[a][c]++;
    num[b][c]++;
  }
  int cnt=0;
  rep(i,n)
  {
    int tn=cnt++;
    for(auto &p:num[i])p.second=cnt++;
    num[i][-1]=tn;
  }
  vector<int>dist(cnt+2,-1);
  vector<vector<P>>edge(cnt+2);
  rep(i,n)
  {
    int t=num[i][-1];
    for(auto p:num[i])
    {
      if(p.first==-1)continue;
      int tn=p.second;
      edge[t].push_back({1,tn});
      edge[tn].push_back({0,t});
    }
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    edge[to].push_back({0,from});
    edge[from].push_back({0,to});
  }
  int start=num[0][-1],end=num[n-1][-1];
  priority_queue<P,vector<P>,greater<P>>q;
  q.push({0,start});
  while(!q.empty())
  {
    P tp=q.top();q.pop();
    if(dist[tp.second]!=-1)continue;
    dist[tp.second]=tp.first;
    for(P nn:edge[tp.second])
    {
      if(dist[nn.second]!=-1)continue;
      q.push({nn.first+tp.first,nn.second});
    }
  }
  cout<<dist[end]<<endl;



  return 0;

}


Measured memory_bytes: 64116
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  string s;
  getline(cin,s);
  if((s[2]==s[3]) && (s[4]==s[5]))
    {
    cout<<"Yes"<<endl;
    }
  else
    {
    cout<<"No"<<endl;
    }
  return 0;
  }

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3=0, y3=0, x4=0, y4=0;
	int dx = x2 - x1;
	int dy = y2 - y1;
		x3 = x2 - dy;
		y3 = y2 + dx;
		x4 = x3 - dx;
		y4 = y3 - dy;

	cout << x3 <<" "<< y3 <<" "<< x4 <<" "<< y4 << endl;
	return 0;
}





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

long long int n,a,b  , x[200009];
int main()
{
	cin>>n>>a>>b ;
	long  long ans=0 ;
	for(long long int i=0;i<n;i++)
	cin>>x[i] ;
	for(long long int i=1;i<n;i++)
	{
		long long int temp = x[i]- x[i-1] ;
		long long int temp2 = min(temp*a , b) ;
		ans+= temp2 ; 
	}
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

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

    int n, m, r;
    cin >> n >> m >> r;

    int target_cities[8];
    for (int i = 0; i < r; i++)
        cin >> target_cities[i];

    const i64 inf = 1e9;
    i64 dist[201][201] = {};
    for (int v = 1; v <= n; v++)
        for (int u = 1; u <= n; u++)
            if (u != v)
                dist[u][v] = inf;

    for (int i = 0; i < m; i++)
    {
        int u, v, c;
        cin >> u >> v >> c;

        dist[u][v] = c;
        dist[v][u] = c;
    }

    for (int k = 1; k <= n; k++)
        for (int v = 1; v <= n; v++)
            for (int u = 1; u <= n; u++)
                if (dist[v][u] > dist[v][k] + dist[k][u])
                    dist[v][u] = dist[v][k] + dist[k][u];

    sort(target_cities, target_cities + r);

    i64 min_dist = 1e18;
    do
    {
        i64 cur_dist = 0;
        for (int i = 0; i + 1 < r; i++)
        {
            const int u = target_cities[i];
            const int v = target_cities[i + 1];

            cur_dist += dist[u][v];
        }

        min_dist = min(min_dist, cur_dist);

    } while (next_permutation(target_cities, target_cities + r));

    cout << min_dist;
}

Measured memory_bytes: 640
#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()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

int main(){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else if(s=="ARC"){
        cout<<"ABC"<<endl;
    }

}

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

int beki_10(int i){
  int kaesu=1;
  if(i==0)
    return 1;
  else{
    for(int j=0; j<i; j++)
      kaesu*=10;
  }
  return kaesu;
}


int main(){
  int N;
  cin >> N;
  int f=0;
  int n=N;
  for(int i=8; i>=0; i--){
    f+=n/beki_10(i);
    n%=beki_10(i);
  }
  if(N%f==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
	string a, b;


	cin >> a >> b;

	if (a.length() > b.length()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.length() < b.length()) {
		cout << "LESS" << endl;
		return 0;
	}
	else for (int i = 0; i < a.length(); i++) {
		if ((int)a[i] > (int)b[i]) {
			cout << "GREATER" << endl;
			return 0;
		}
		else if ((int)a[i] < (int)b[i]) {
			cout << "LESS" << endl;
			return 0;
		}
	}
	cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
#ALDS1_1_A
n = int(input())
a = [int(i) for i in input().split()]
for i in range(1,n):
  print(" ".join([str(t) for t in a]))
  key = a[i]
  j = i - 1
  while j >= 0 and a[j] > key:
    a[j+1] = a[j]
    j -= 1
  a[j+1] = key
print(" ".join([str(t) for t in a]))


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

int main(){
  int a, b;
  while(1){
    cin >> a >> b;
    if ( a == 0 && b == 0 ){
      break;
    }else if ( a < b ){
      cout << a << " " << b << endl;
    }else if ( a > b ){
      cout << b << " " << a << endl;
    }else if ( a == b ){
      cout << a << " " << b << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdio.h>

int main()
{
    char s[10];
    scanf("%s", s);

    if(strcmp(s, "Sunny") == 0)
        printf("Cloudy\n");
    else if(strcmp(s, "Cloudy") == 0)
        printf("Rainy\n");
    else
        printf("Sunny\n");
    return 0;
}


Measured memory_bytes: 128
N = int(input())
a = list(map(int,input().split()))

ans = 0
while any(map(lambda x: x >= N, a)):
    a.sort(reverse=True)
    k = (a[0] - N)//N + 1
    ans += k
    a[0] -= k*N
    for i in range(1,N):
        a[i] += k

print(ans)

Measured memory_bytes: 3060
s = gets.chomp
o = []
e = []
s.chars.each_with_index do |c, i|
  if i % 2 == 0
    o.push c
  else
    e.push c
  end
end
puts o.all?{|c| ['R', 'U', 'D'].include? c} && e.all?{|c| ['L', 'U', 'D'].include? c} ? 'Yes' : 'No'


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

using namespace std;
int main(void){
    int n;
    cin >> n;
    map<string, int> m;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        // greenbin -> beeginnr のように並びかえる処理
        sort(s.begin(), s.end()); // 同じアナグラムならソートされると同じ文字列になる
        m[s]++; // 同じアナグラムの個数 (s がもともと greenbin なら m["begginnr"]++; になってる) 
    }
    
    long long ans = 0LL;
    
    // SiとSj (i < j) が同じアナグラム　<=> 同じアナグラムの中から2つ文字列を選んで 前の方から Si, Sjにする
    // なので同じアナグラムの中から二つ選ぶような場合の数、 同じアナグラムがa個あるなら aC2 = a*(a-1)/2
    for(auto i:m){
        long long a = i.second;
        ans += a*(a-1)/2;
    }
    
    // 出力
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	vector<ll> a(n+1);
	for(int i = 0;i <= n;i++){
		cin >> a[i];
	}

	vector<ll> v_max(n+1);
	vector<ll> v_min(n+1);
	v_max[n] = a[n];
	v_min[n] = a[n];
	for(int i = n - 1;i >= 0;i--){
		v_min[i] = (v_min[i+1] + 1) / 2 + a[i];
		v_max[i] = v_max[i+1] + a[i];
	}

	if(v_min[0] > 1){
		cout << -1 << endl;
	}
	else{
		ll ans = 0;
		ll v = 1;
		for(int i = 0;i <= n;i++){
			ans += min(v,v_max[i]);
			v = min(v,v_max[i]) - a[i];
			v *= 2;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

ll powl(ll a, ll b){
    if(b==0) return 1;
    else return a*powl(a,b-1); 
}

int main(){
    ll a,b; cin >> a >> b;
    ll keta=1;
    ll ans=0;
    ll tmpa=a;
    ll tmpb=b;
    while(tmpb>0){
        ll L=powl(2,keta-1);
        ll ftra=a-(a%L);
        ll ftrb=b-(b%L);
        ll numa=(ftra/L)%2;
        ll numb=(ftrb/L)%2;
        if(keta==1){
            if(numb==1 && ((b-a)%4==0 || (b-a)%4==1)) ans+=1;
            if(numb==0 && ((b-a)%4==1 || (b-a)%4==2)) ans+=1;
            tmpb/=2;
            keta++;
            continue;
        }
        ll tmp=0;
        if(numa%2) tmp+=((a-ftra)%2);
        if(numb%2) tmp+=((b-ftrb+1)%2);
        if(tmp%2) ans+=L;
        keta++;
        tmpb/=2;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256