akhauriyash/Code-Regression huggingface dataset:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0

SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
    if S[i] == "L":
        sc -= 1
    if sc <= 0:
        break
    if T[i] == "R" and sc < w:
        sc += 1
if sc <= 0:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "R":
        sc += 1
    if sc > w:
        break
    if T[i] == "L" and sc > 1:
        sc -= 1
if sc > w:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "D":
        sr += 1
    if sr > h:
        break
    if T[i] == "U" and sr > 1:
        sr -= 1
if sr > h:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "U":
        sr -= 1
    if sr <= 0:
        break
    if T[i] == "D" and sr < h:
        sr += 1
if sr <= 0:
    win = 1

if win:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3888
#include <bits/stdc++.h> 
using namespace std;
typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof(a))

LL d[55][3000];
int n,A;

int main()
{
	//freopen("test.txt","r",stdin);
	scanf("%d %d",&n,&A);
	d[0][0] = 1;
	F(i,1,n)
	{
		int x;
		scanf("%d",&x);
		for(int j=i;j>0;--j)
		{
			for(int k=n*A;k-x>=0;--k)
			{
				d[j][k] += d[j-1][k-x];
			}
		}
	}
	LL ans = 0;
	F(i,1,n) ans += d[i][i*A];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1408
N = int(input())
S = [input() for _ in range(N)]

I = ["M", "A", "R", "C", "H"]
L = [0] * 5

for i in S:
  for j in range(5):
    if i[0] == I[j]:
      L[j] += 1

ans = 0
for i in range(3):
  for j in range(i + 1, 4):
    for k in range(j + 1, 5):
      ans += L[i] * L[j] * L[k]

print(ans)

Measured memory_bytes: 9752
#include<stdio.h>

int main(void)
{
    int i,n;

    scanf("%d",&n);
    long long ans=0;
    for(i=1;i<=n;i++){
        if((i%3!=0)&&(i%5!=0)) ans+=i;}
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define mod 1000000007
#define N 100
typedef pair<int, int> pi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    set <int> s;
    for(int i=1; i<=9; i++)  {
      for(int j=1; j<=9; j++)  {
        s.insert(i*j);
      }
    }
    if(s.find(n)==s.end()) {
      cout<<"No";
    }
    else {
      cout<<"Yes";
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P_list = list(input().split())

for i in range(len(P_list)):
    P_list[i] = int(P_list[i]) / 2 + 0.5

tmp = sum(P_list[0:K])
ans = sum(P_list[0:K])

for j in range(len(P_list) - K):
    ans = max(ans, tmp - P_list[j] + P_list[j + K])
    tmp = tmp - P_list[j] + P_list[j + K]

print(ans)


Measured memory_bytes: 18116
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
ol(n*n*n);
return 0;
}



Measured memory_bytes: 256
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n>>a;
    int arr[n];
    for(int i=0;i<n;i++){
      cin>>arr[i];
    }

    sort(arr , arr + n);


    for(int i=0; i<a; i++) {

        ans += arr[i];
    }

    cout<<ans<<endl; 
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0]){
    int hit =0,blow = 0;
    for(int i=1;i<4;i++)
      cin >> a[i];
    for(int i=0;i<4;i++)
      cin >> b[i];
      for(int k=0;k<4;k++){
        for(int j=0;j<4;j++){
	  if(a[k]==b[j]){
	    if(k==j) hit++; 
	    else blow++;
	  }
	}
      }
      cout << hit <<" "<< blow <<endl;
  }
}
	    

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
    char a;
    string s,t;
    int i,j,b,c=0,f=0;
    cin >> s >> t;
    for (i=0;i<s.size();i++){
        for (j=i;j<s.size();j++){
            if (s[i]>s[j]){
                a=s[i];
                s[i]=s[j];
                s[j]=a;
            }
        }
    }
    for (i=0;i<t.size();i++){
        for (j=i;j<t.size();j++){
            if (t[i]<t[j]){
                a=t[i];
                t[i]=t[j];
                t[j]=a;
            }
        }
    }
    if (s.size()>t.size())
        b=t.size();
    else
        b=s.size();
    for (i=0;i<b;i++){
        if (s[i]==t[i]){
            c++;
            continue;
        }
        else if (s[i]<t[i]){
            cout << "Yes" << endl;
            f=1;
            break;
        }
        else{
            cout << "No" << endl;
            f=1;
            break;
        }
    }
    if (f==0){
        if (s.size()!=t.size()){
            if (c==s.size())
                cout << "Yes" << endl;
            if (c==t.size())
                cout << "No" << endl;
        }
        else
            cout << "No" << 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
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    string s;
    cin >> s;
    if(s[0] == s[1] || s[2] == s[1] || s[2] == s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc131.contest.atcoder.jp/tasks/abc131_a


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vector<pii> ppa, ppb;

pii tmp1[MAXN], tmp2[MAXN];
int top1, top2;

void correct(int n, int ind, vector<pii> &pp) {
	top1 = top2 = 0;
	REP(i, 0, n) {
		if (pp[i]._1 & (1 << ind)) {
			pp[i]._2 |= (1 << ind);
		}
		if (pp[i]._2 & (1 << ind)) {
			tmp2[top2++] = pp[i];
		} else {
			tmp1[top1++] = pp[i];
		}
	}
	REP(i, 0, top1) {
		pp[i] = tmp1[i];
	}
	REP(i, 0, top2) {
		pp[top1 + i] = tmp2[i];
	}
	
	/*REP(i, 0, n) {
		printf("%d %d\n", pp[i]._1, pp[i]._2);
	}
	putchar('\n');*/
}	

void solve(){
	int n;
	scanf("%d", &n);
	ppa.resize(n);
	ppb.resize(n);
	REP(i, 0, n) {
		scanf("%d", &ppa[i]._1);
	}
	REP(i, 0, n) {
		scanf("%d", &ppb[i]._1);
	}
	int ans = 0;
	REP(k, 0, 29) {
		ll cnta = 0, cntb = 0;
		REP(i, 0, n) {
			if (ppa[i]._1 & (1 << k)) {
				cnta++;
			}
			if (ppb[i]._1 & (1 << k)) {
				cntb++;
			}
		}
		ll tmp = cnta * (n - cntb) + cntb * (n - cnta);
		for(int i = 0, j = n - 1; i < n; i++) {
			for(; j >= 0 && ppb[j]._2 + ppa[i]._2 >= (1 << k); j--);
			tmp += (n - 1 - j);
		}
		if (tmp & 1) {
			ans |= (1 << k);
		}
		
		//printf("%d: %lld %lld %lld\n", k, cnta, cntb, tmp);
		
		correct(n, k, ppa);
		correct(n, k, ppb);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 5760
fun main(args: Array<String>) {
    abc058c()
}

fun abc058c() {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!!.toList().sorted().toCharArray() }

    val alphaCount = ('a'..'z').map { c ->
        Pair(c, sList.map { s -> s.count { sc -> sc == c } }.min()!!)
    }

    val answer = alphaCount.map { alp -> alp.first.toString().repeat(alp.second) }
        .joinToString(separator = "")

    println(answer)
}


Measured memory_bytes: 38372
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	int n; // nb
	int y; // yen
	cin >> n >> y;

	int a; // 10000
	int b; // 5000
	int c; // 1000

	for (a = 0; (10000 * a <= y) && (a <= n); a++) {
		for (b = 0; (10000 * a + 5000 * b <= y) && (a + b <= n); b++) {
			if (10000 * a + 5000 * b + 1000 * (n - a - b) == y) {
				cout << a << " " << b << " " << n - a - b;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 3624
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        temp = 0
        for d in range(D):
            temp += (X[i][d] - X[j][d])**2
        temp = temp**0.5
        if float.is_integer(temp):
            ans += 1 
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

//vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A*B >= C*D)
    {
        cout << A*B;
    }
    else
    {
        cout << C*D;
    }
}

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

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int yen = 0;
    rep(i, n){
        if (i+1 <= k){
            yen += x;
        }
        else yen += y;
    }
    cout << yen << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict

"""
(駅、会社)を頂点にグラフを持つ。頂点数O(M)。
そのまま辺を貼ると辺が多くなりすぎる。
(駅、会社) -> (駅、無属性) -> (駅、会社)
"""

L = 32
mask = (1 << L) - 1
N,M = map(int,input().split())
graph = defaultdict(list)
for _ in range(M):
    p,q,c = map(int,input().split())
    p <<= L
    q <<= L
    graph[p].append(p+c)
    graph[p+c].append(p)
    graph[q].append(q+c)
    graph[q+c].append(q)
    graph[p+c].append(q+c)
    graph[q+c].append(p+c)

INF = 10 ** 9
dist = defaultdict(lambda: INF)

start = 1 << L
goal = N << L

q = [start] # 0 が会社に属していない状態
dist[start] = 0
d = 0
q0 = []
q1 = []
while q:
    for x in q:
        if x & mask == 0:
            for y in graph[x]:
                if dist[y] <= d + 1:
                    continue
                dist[y] = d + 1
                q1.append(y)
        else:
            for y in graph[x]:
                if dist[y] <= d:
                    continue
                dist[y] = d
                q0.append(y)
    if q0:
        q = q0
        q0 = []
        continue
    q = q1
    q1 = []
    d += 1

answer = dist[goal]
if answer == INF:
    answer = -1
print(answer)

Measured memory_bytes: 166644
a = int(input())
while True:
    s = []
    for i in range(a):
        b,c,d,e = input().split()
        c = int(c)
        e = int(e)
        s.append([c*3+e,-(i),b])
    s.sort(reverse = True)
    for z in s:
        print(z[2]+","+str(z[0]))
    a = int(input())
    if a == 0:
        break
    else:
        print()


Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>

int main (){

	int case1 = 0,a = 0,b = 0,c = 0;
	int angka1 =0;
	int angka2 =0;
	int angka3 = 0;
	int angka4 = 0;		
	char kata[5];
	scanf("%d",&case1);
	
	for(a = 0; a<case1; a++){
		scanf("%s",kata);		
		if(kata[0] == 'A'){
			angka1 += 1;
		}
		else if(kata[0] == 'W'){
			angka2 +=1;
		}
		else if(kata[0] == 'T'){
			angka3 +=1;
		}	
		else if(kata[0] == 'R'){
			angka4 +=1;
		}
	}

	printf("AC x %d\n",angka1);
	printf("WA x %d\n",angka2);
	printf("TLE x %d\n",angka3);
	printf("RE x %d\n",angka4);

	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(void){
    int K,X;
    int stn=0;
    scanf("%d%d",&K,&X);
    for(int i=0;i<2*K-1;i++){
        stn=X-K+1+i;
        if(stn<-1000000 ||stn>1000000){
            ;
        }else{
            printf("%d ",stn);
        }
    }
    return 0;
}
    


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

int main(){
    string s;
    cin >> s;
    //最低一回は末尾を消す必要がある
    s.pop_back();

    int length,size;
    length = s.size();
    size = s.size();
    rep(i, size){
        if((length % 2 == 0) && (s.substr(0,length/2) == s.substr(length/2, length/2))){
            cout << length << endl;
            return 0;
        }
        else{
            s.pop_back();
            length = s.size();
        }
    }
}
        
    
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int n;
vector<int> t[100000]; //木
bool u[100000]; //訪れたかどうか
int p[100000]; //親ノード
int d[100000]; //深さ
int c[100000]; //塗れるマス数
int dfs(int i,int cd){ //現在地,深さ
  u[i]=true; //到達済み
  d[i]=cd; //深さ
  c[i]=1; //１マスカウント
  for(int v:t[i]){ //いけるマスでループ
    if(!u[v]){ //まだ訪れていない場合
      p[v]=i; //親を代入
      c[i]+=dfs(v,cd+1); //塗れるマス数を累積
    }
  }
  return c[i];
}
int main(){
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    t[a-1].push_back(b-1);
    t[b-1].push_back(a-1);
  }
  p[0]=-1;
  dfs(0,0);
  int k=(d[n-1]-1)/2; //snukeが接近できる回数
  int q=n-1; //snukeの現在地
  rep(i,k){ //snukeの最終到達点まで行く
    q=p[q];
  }
  int a=n-c[q]; //fennecが塗れるマス数
  int b=c[q]; //snukeが塗れるマス数
  if(a>b){ //同数ならsnukeの勝ち
    cout<<"Fennec"<<endl;
  }else{
    cout<<"Snuke"<<endl;
  }
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K, num=1;
  cin >> N>>K;

  for(int i =0; i<N; i++){
    if(num *2< num +K){
      num *=2;
    }else{
      num +=K;
    }
}
cout << num << endl;
}

Measured memory_bytes: 256
N = 2**input()
A = [int(raw_input()) for _ in xrange(N)]
while N > 1:
    for i in xrange(N/2):
        if A[i*2] > A[i*2+1]:
            A[i] = A[i*2] - A[i*2+1]
        elif A[i*2] == A[i*2+1]:
            A[i] = A[i*2]
        else:
            A[i] = A[i*2+1] - A[i*2]
    N /= 2
print A[0]


Measured memory_bytes: 11012
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		String a = sc.next();

		if (a.charAt(0)==a.charAt(1)||a.charAt(1)==a.charAt(2)||a.charAt(2)==a.charAt(3)) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
    int a,b,c;

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

    if(a>b){
        if(c>a){
            printf("%d",10*c+a+b);
        }else{
            printf("%d",10*a+b+c);
        }

    }else{
        if(c>b){
            printf("%d",10*c+b+a);
        }else{
            printf("%d",10*b+a+c);
        }
    };
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

string s;
li cnt[30];

int main() {
    cin >> s;
    li n = sz(s);
    rin{
        cnt[s[i] - 'a']++;
    }
    li res = 0;
    rep(i, 26) {
        res += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << n*(n - 1) / 2 - res + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
# xdatas = []
# ydatas = []

# while True:
#     x, y = map(int, input().split())

#     if x == 0 and y == 0:
#         break
#     else:
#         xdatas.append(x)
#         ydatas.append(y)

# for l in range(len(xdata)):
#     for i in range(xdata[l]):
#         for j in range(ydata[l]):
#             print("#", end="")
#         print()
#     print()

# for l in range(len(xdatas)):
#     for i in range(xdatas[l]):
#         for j in range(ydatas[l]):
#             if ydatas[0] or ydatas[-1]:
#                 print("#", end="")
#             else:
#                 print(".", end="")
#         print()

while True:
    H, W = map(int, input().split())

    if H == 0 and W == 0:
        break
    else:
        for h in range(H):
            for w in range(W):
                if h == 0 or h == H - 1:
                    print("#", end='')
                elif w == 0 or w == W - 1:
                    print("#", end='')
                else:
                    print(".", end='')
            print()
        print()



Measured memory_bytes: 7004
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[200002];
int main(){
  ll n,c=0;
  cin>>n;
  
  forn(i,n){
  cin>>a[i];
  if(a[i]==c+1)
  c++;
  }

  if(c==0) cout<<"-1";
  else cout<<(n-c);
}


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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    
    int x =  100 * r + 10 * g + b ;
  
    if ( x % 4 == 0) cout << "YES" << endl;    
    else  cout << "NO" << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N,sum=0; cin>>N;
  vector<pair<string,int>> S(N);
  rep(i,0,N){
    cin>>S[i].first>>S[i].second;
    sum+=S[i].second;
    }
  int ans=0;
  string X; cin>>X;
  rep(i,0,N){
    ans+=S[i].second;
    if(S[i].first==X)
      break;
    }
  cout<<sum-ans<<endl;
  }


Measured memory_bytes: 256
import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n  = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		String s = scan.next();

		int count = 0;
		int count_b = 0;

		char[] c = s.toCharArray();

		int [] d = new int [n];

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

			if(c[i]=='a') {
				if(count<(a+b)) {
					d[i] = 1;
					count++;
				}
			}else if(c[i]=='b') {
				if(count<(a+b)&&count_b<b) {
					d[i] = 1;
					count++;
					count_b++;
				}
			}

			if(d[i]==1) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}

}


Measured memory_bytes: 34996
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;

int main() {
    const double PI = 3.14159265358979;
    cout << fixed << setprecision(15);
    double a, b, h, m; cin >> a >> b >> h >> m;

    double h_t = 360 * h / 12 + 30 * m / 60;
    double m_t = 360 * m / 60;
    double theta;
    if (h_t > m_t) theta = h_t - m_t;
    else theta = m_t - h_t;
    double a_two = (a * a) + (b * b) - (2 * a * b * cos((PI / 180.0) * theta));
    cout << sqrt(a_two) << endl;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  int n;
  cin>>n;
string s1,s2;
cin>>s1>>s2;
for(int i=0;s1[i];i++)
cout<<s1[i]<<s2[i];
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
typedef long long				ll;
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int H, A;
	cin >> H >> A;
	cout <<  Ceil(H, A) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  char a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
  (a==f&&b==e&&c==d) ? cout<< "YES" : cout<< "NO";  
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) cin >> A[i];

	int k = 0;
	vector<pair<int, int>> V;
	V.pb(mp(0, 0));
	rep(i, N) {
		if (A[i] > k) {
			V.pb(mp(A[i], i + 1));
			k = A[i];
		}
	}
	ll B[100001] = {};
	int C[100001] = {};
	rep(i, N) {
		int k2 = lower_bound(V.begin(), V.end(), mp(A[i], 0)) - V.begin();
		B[k2] += A[i] - V[k2 - 1].first;
		C[k2]++;
	}


	int mae = V.back().first;
	ll l = C[(int)V.size()];
	ll kotae[100001] = {};
	for (int k = (int)V.size() - 2; k >= 0; k--) {
		kotae[V[k + 1].second] = B[k + 1] + l * (mae - V[k].first);
		mae = V[k].first;
		l += C[k + 1];
	}

	rep1(i, N) co(kotae[i]);

	Would you please return 0;
}

Measured memory_bytes: 4340
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,count=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	for(int i=1;i<n-1;i++)
	{
		if(a[i]<a[i-1])
		{
			if(a[i]>a[i+1])
			{
				count++;
			}
		}
		else
		if(a[i]<a[i+1])
		{
			if(a[i]>a[i-1])
			{
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
constexpr int INF = 1e9+7;
priority_queue<P, vector<P>, greater<P>> qu;
int ds[200005], H, W, a, b;
set<P> lv;
int main(){
	scanf("%d%d", &H, &W);
	rep(i,W){
		lv.emplace(i,i);
		qu.emplace(0,i);
	}
	rep(i,H){
		scanf("%d%d", &a, &b);
		auto tl = lv.lower_bound({a-1,0}), el = lv.lower_bound({b,0});
		if(tl != el){
			for(el--; tl != el; tl = lv.erase(tl)) ds[tl->second] = INF;
			auto[to, from] = *el;
			el = lv.erase(el);
			if(b != W){
				ds[from] = b - from;
				lv.emplace_hint(el, b, from);
				qu.emplace(b-from, from);
			}else ds[from] = INF;
		}
		while(!qu.empty()){
			auto [d, from] = qu.top();
			if(ds[from] != d) qu.pop();
			else break;
		}
		printf("%d\n", qu.empty() ? -1 : qu.top().first+i+1);
	}
}


Measured memory_bytes: 15424
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < 6) {
			System.out.println(0);
		}else if(a > 12) {
			System.out.println(b);
		}else {
			System.out.println(b/2);
		}

		}
	}

Measured memory_bytes: 21844
N = gets.to_i
as = N.times.map{gets.to_i}
max, max_2, max_index = 0, 0, []
as.each_with_index do |a, i|
  if a > max
    max, max_2 = a, max
    max_index = [i]
  elsif a == max
    max_index.push(i)
  elsif a > max_2
    max_2 = a
  end
end
if max_index.length >= 2
  N.times{print "#{max}\n"}
else
  N.times{|i|
    if max_index.include?(i)
      puts max_2
    else
      puts max
    end
  }
end

Measured memory_bytes: 6580
n = int(input())
s = []
for i in range(0, n):
    s.append(input())

c = 0
a = 0
b = 0
ab = 0

for i in range(0, n):
    for j in range(1, len(s[i])):
        if s[i][j-1:j+1] == "AB":
            c += 1
    if s[i][-1] == "A" and s[i][0] == "B":
        ab += 1
    else: 
        if s[i][0] == "B":
            b += 1
        if s[i][-1] == "A":
            a += 1
            
s = c

if ab > 0:
    s += ab - 1
    if a > 0:
        s += 1
        a -= 1
    if b > 0:
        s += 1
        b -= 1

s += min(a, b)

print(s)

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

using namespace std;

const int N = 1e5 + 100;

int a[N], l[N], r[N];
int n, ans;

int gcd(int a, int b) {
    return (b ? gcd(b, a % b) : a);
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
	cin >> a[i];
    for (int i = 1; i <= n; i++)
	l[i] = gcd(l[i - 1], a[i]);
    for (int i = n; i > 0; i--)
	r[i] = gcd(r[i + 1], a[i]);
    for (int i = 1; i <= n; i++)
	ans = max(ans, gcd(l[i - 1], r[i + 1]));
    return cout << ans, 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int odd = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a & 1)
            odd++;
    }
    if (odd & 1) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
//using P =pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};

int main()
{
    int N;
    cin >> N;
    
    
    double ans = (double) N * 2 * 3.1415926535;
    cout << setprecision(10)<<ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3768
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=1010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m;
struct Edge { int x,y; }a[N],b[N];
signed main()
{
    n=read(), m=read();
    for(ri int i=1;i<=n;i++) a[i].x=read(), a[i].y=read();
    for(ri int i=1;i<=m;i++) b[i].x=read(), b[i].y=read();
    for(ri int i=1;i<=n;i++)
    {
        int dis=1e18, pc=1;
        for(ri int j=1;j<=m;j++)
        {
            if(abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y)<dis)
            {
                dis=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
                pc=j;
            }
        }
        printf("%lld\n",pc);
    }
    return 0;
}

Measured memory_bytes: 3684
/**
 *    author:  math2do
 *    created: 20.04.2020 15:00:05 IST
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
constexpr T pi = T(3.1415926535897932385L);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin >> r;
  cout << fixed << setprecision(17) << 2 * pi <double> * r << endl;
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        vec[i] = x;
    }
    sort(vec.begin(), vec.end());
    vector<int> dp(k+1,0);
    
    for(int i = 1;i<k+1;i++){
        for(int j = 0;j<n;j++){
            if(i - vec[j] >= 0){
            if(dp[i - vec[j]] == 0){
                dp[i] = 1;
                break;
            }
            }
        }
    }
    
    string res = dp[k] == 1 ? "First":"Second";
    cout << res;
}









Measured memory_bytes: 640
/*
#include<iostream>
#include<queue>
#include<algorithm>
#define INF 999999999
using namespace std;

int res[101];
int G[101][101] = {0};

int main() {
    int n, u, v, k;
    std::queue<int> Q;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> u >> k;
        for (int j = 0; j < k; j++) {
            std::cin >> v;
            G[u - 1][v - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++) res[i] = INF;

    Q.push(0);
    res[0] = 0;

    while (! Q.empty()) {
        u = Q.front();
        for (int i = 0; i < n; i++) {
            if (G[u][i]) {
                Q.push(i);
                res[i] = std::min(res[i], res[u] + 1);
                G[u][i] = 0;
            }
        }
        Q.pop();
    }

    for (int i = 0; i < n; i++) {
        if (res[i] != INF) std::cout << i + 1 << " " << res[i] << "\n";
        else std::cout << i + 1 << " -1\n";
    }

    return 0;
}
*/

#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];   // 距離で訪問状態（color）を管理する

void bfs(int s) {
    queue<int> q;   // 標準ライブラリのqueueを使用
    q.push(s);
    for (int i = 0; i < n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0) continue;
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
    }
}

int main() {
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0; 
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,c,k;cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];
    sort(t.begin(),t.end());

    ll ans=0,key=0;
    while(1){
        ll var=t[key]+k;
        vector<ll>::iterator position;
        position = upper_bound(t.begin(), t.end(), var);
        ll ins = key;
        key = min((ll)(distance(t.begin(), position)), ins+c);
        ans++;
        if(key>=n) break;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h> /*6B*/
using namespace std; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){

int n; cin >> n;

vector<char> a(n);
vector<int> b(n);

rep(i, n)  cin >> a.at(i) >>  b.at(i);


vector<vector<bool>> c(4,vector<bool>(13,false));

rep(i, n){
    if (a.at(i) == 'S') c.at(0).at(b.at(i)-1) = true;
    if (a.at(i) == 'H') c.at(1).at(b.at(i)-1) = true;
    if (a.at(i) == 'C') c.at(2).at(b.at(i)-1) = true;
    if (a.at(i) == 'D') c.at(3).at(b.at(i)-1) = true;
}

rep(i, 4){
    rep(j, 13){
        if(c.at(i).at(j) == false ){ 
            if (i == 0) cout << 'S' << ' ' << j+1;
            else if (i == 1) cout << 'H' << ' ' << j+1;
            else if (i == 2) cout << 'C' << ' ' << j+1;
            else if (i == 3) cout << 'D' << ' ' << j+1;
            cout << endl;    
        }
    }
}
}


Measured memory_bytes: 3084
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
#define INF 10000000010

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

	int N;
	
	cin >> N;

	ll dp[N];
	dp[0] = 0;
	rep(i, N)
	{
		dp[i+1] = INF;
	}

	ll h[N];
	
	rep(i, N)
	{
		cin >> h[i];

		if (i > 0)
		{
			dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
			if (i > 1)
			{
				dp[i] = min(dp[i], dp[i-2]+abs(h[i] - h[i-2]));
			}
		}
	}

	cout << dp[N-1]<<endl;

	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,ans=1,i; cin>>n;
    string s; cin>>s;
    int c[26]={};
    for(i=0;i<n;i++) c[s[i]-'a']++;
    for(int i:c){ans*=i+1; ans%=1000000007;}
    cout<<ans-1;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if(A < C && C < B){
        cout << "Yes" << endl;
    }else if(B < C && C < A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int n, max1 = 0, max2 = 0;
  vector<int> a(200000);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (a[i] > max1)
    {
      max2 = max1;
      max1 = a[i];
    }
    else if (a[i] > max2)
      max2 = a[i];
  }
  for (int i = 0; i < n; i++)
    cout << (a[i] == max1 ? max2 : max1) << endl;
}

Measured memory_bytes: 3852
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn=0x3f3f3f3f/100;
const ll INF=0x3f3f3f3f;
ll dp[2][maxn];
char s[maxn];
int main()
{
    scanf("%s",s+1);
    s[0]='0';
    int len=strlen(s+1);
    dp[0][len]=s[len]-'0';
    dp[1][len]=10-(s[len]-'0');
    for(int i=len-1;i>=0;i--)
    {
        dp[0][i]=min(dp[0][i+1]+(s[i]-'0'),dp[1][i+1]+(s[i]-'0'+1));
        dp[1][i]=min(dp[0][i+1]+10-(s[i]-'0'),dp[1][i+1]+10-(s[i]-'0'+1));
    }
    cout<<min(dp[0][0],dp[1][0])<<endl;
    return 0;
}


Measured memory_bytes: 19712
#include<stdio.h>
int main(){
  int i,cnt=0;
  int flag=0;
  char str[4];
  scanf("%s",str);
  for(i=0;i<3;i++){
    if(str[i]=='R' && flag == 0){
      cnt++;
      flag=1;
    }
    if(str[i]=='R' && flag == 1){
      if(str[i-1] == 'R'){
        cnt++;
      }
    }
  }
  printf("%d",cnt);
    
  return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;
    vector<ll> p(n);
    rep(i,n)cin >> p[i];
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        uf.unite(a-1,b-1);
    }
    ll res = 0;
    rep(i,n) {
        if(uf.same(i,p[i]-1))res++;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

vector<bool> b_sta(1e5+10,false);

ll gcd(ll m, ll n){
  return n ? gcd(n,m%n) : m;
}

ll lcm(ll m,ll n){
  return m / gcd(m,n) * n;
}
int main(){
  double l;
  cin >> l;
  printf("%.10lf\n" ,l*l*l / 27);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    string S;
    cin>>S;
    if(S == "ABC")cout<<"ARC";
    else cout<<"ABC";
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	ll n=s.length();
	for(int i=0;i<n;i+=2){
		cout << s[i];
	}
	cout << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int H, W, N;
    cin >> H >> W >> N;

    int k = max(H, W);
    cout << ((N + k - 1) / k) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[])
{
    int n;
    int ans;

    std::cin >> n;

    for (int a = 1; a < 10; a++) {
        for (int b = 1; b < 10; b++) {
            if (a * b == n) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;

    return 0;
}


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

ll extgcd(ll a,ll b,ll& x,ll& y){
  ll d = a ;
  if ( b != 0 ) {
    d = extgcd( b , a%b , y , x ) ;
    y -= ( a / b ) * x ;
  }else{
    x = 1 ; y = 0 ;
  }
  return d;
}
ll mod_inverse(ll a,ll m){
  ll x , y ;
  extgcd( a , m , x , y ) ;
  return ( m + x % m ) % m ;
}

ll combination(ll N,ll K){
  ll res = 1;
  for( int i = 0; i < K; i++ ) res = (res * ((N - i) % M )) % M;
  for( int i = 1; i <= K; i++ ) res = (res * mod_inverse(i,M)) % M;
  return res;
}

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

int main(){
	int sum=0,h,w,a1,a2,b1,b2,MIN=1e9;
	cin>>h>>w>>a1>>a2>>b1>>b2;
	r(i,9){
		int y=b1+h*dy[i];
		int x=b2+w*dx[i];
		MIN=min(MIN,abs(y-a1)+abs(x-a2));
	}
	r(i,9){
		int y=b1+h*dy[i];
		int x=b2+w*dx[i];
		if(abs(y-a1)+abs(x-a2)==MIN){
			sum+=combination(abs(y-a1)+abs(x-a2),abs(y-a1));
			sum%=M;
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if( A >= B && A-1 >= B)
    cout << A + A-1 << endl;
  else  if( A >= B && A-1 < B)
    cout << A + B << endl;
  else  if( A <= B && A <= B-1)
    cout << B + B-1 << endl; 
  else  if( A <= B && A > B-1)
    cout << B + A << endl;    
    
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin>>n;
    int a[n+1],b[n],c[n-1];
    REP(i,n){
        cin>>a[i];
    }
    REP(i,n){
        cin>>b[i];
    }
    REP(i,n-1){
        cin>>c[i];
    }
    a[n]=100;
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        /* code */
        ans+=b[a[i]-1];
        if (a[i]+1==a[i+1])
        {
            /* code */
            ans+=c[a[i]-1];
        }
        
    }
    cout<<ans<<endl;
   }


Measured memory_bytes: 256