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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    ll a,b,c; cin >> a >> b >> c;
    if(4*a*b < (c-a-b)*(c-a-b) && c-a-b > 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
//
// Created on 2020/07/14.
//


#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 <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string s;
    cin>>s;
    int yyyy= 0;
    yyyy += int(s[0] -'0') * 1000;
    yyyy += int(s[1] - '0') * 100;
    yyyy += int(s[2] -'0') *10;
    yyyy += int(s[3] - '0');
    int mm =( int(s[5] - '0') *10)  + int(s[6] - '0');
    int dd = (int(s[8] - '0') *10) +int(s[9] -'0');
    if(yyyy < 2019){
        cout<<"Heisei"<<endl;
        return 0;
    }
    if(yyyy == 2019){
        if(mm < 4){
            cout<<"Heisei"<<endl;
            return 0;
        }
        if(mm == 4){
            if(dd <= 30){
                cout<<"Heisei"<<endl;
                return 0;
            }
        }
    }
    cout<<"TBD"<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    bool flag=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='7')
        flag=1;
    (flag==1)?cout<<"Yes":cout<<"No";
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long M){
    cout << 24 + 24 - M << endl;
}

int main(){

    long long M;
    scanf("%lld",&M);
    solve(M);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main() {

    int n;
    string s;
    cin >> n >> s;

    /*思いついた人天才*/
    int right = 0;
    int left = 0;
    rep(i, n){
        if(s[i] == '('){
            right++;
        }
        else if(right != 0){
            right--;
        }
        else{
            left++;
        }
    }
    string l(left, '(');
    string r(right, ')');

    cout << l + s + r << endl;

    return 0;
}

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

class UnionFindTree {
private:
  int P[10000];
public:
  void init(int N) {
    for (int i=0; i<N; i++) {
      P[i]=i;
    }
  }
  int root(int a) {
    if (P[a]==a) {
      return a;
    } else {
      return (P[a]=root(P[a]));
    }
  }
  void unite(int a,int b) {
    P[root(a)]=root(b);
  }
  bool same(int a,int b) {
    return (root(a)==root(b));
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  UnionFindTree S;
  S.init(n);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (!com) {
      S.unite(x,y);
    } else {
      printf("%d\n",S.same(x,y));
    }
  }
  return 0;
}

Measured memory_bytes: 3296
#include <iostream>
using namespace std;
inline int sum(int a, int b) {
	int sum = 0;

	for (int i = a; i <= b; i++)
	{
		sum += i;
	}

	return sum;
}

int main() {
	int a, b;
	cin >> a >> b;

	cout << sum(1, (b - a - 1)) - a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}

}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int N;
int A[110];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    string ans = "APPROVED";
    for (int i = 0; i < N; ++i) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 == 0 || A[i] % 5 == 0) {

            } else {
                ans = "DENIED";
            }
        }
    }

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

Measured memory_bytes: 888
import java.io.*;
import java.util.*;

public class Main {

	static long m = (long) (1e9 + 7);

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String s = scn.next();
		String x = "ABC";
		int ans = 0;
		for (int i = 0; i + 3 <= n; i++) {
			if (s.substring(i, i + 3).equals(x))
				ans++;
		}
		System.out.println(ans);
	}

	static class Scanner {

		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long v = sc.nextLong();
		long b = sc.nextLong();
		long w = sc.nextLong();
		long t = sc.nextLong();
		long distance = Math.abs(a - b);
		if(distance / t  >  v - w)
			System.out.println("NO");
      else if(distance / t  ==  v - w){
       if(distance % t == 0)
         System.out.println("YES");
        else
          System.out.println("NO");
      }
		else
			System.out.println("YES");


	}

}


Measured memory_bytes: 35800
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

int main(void){
	ll H,W,sum=0,c[52][52];
	char s[52][52];
	string st;
	scanf("%lld%lld",&H,&W);
	reg(i,1,H){
		cin>>st;
		reg(j,1,W){
			s[i][j]=st[j-1];
			if(s[i][j]=='.')sum++;
			c[i][j]=1e9;
		}
	}
	priority_queue<mp> Q;
	Q.push(make_pair(1,1));
	c[1][1]=0;
	while(!Q.empty()){
		mp v=Q.top();
		Q.pop();
		ll x=v.first, y=v.second;
		int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
		rep(i,4){
			if(c[x+dx[i]][y+dy[i]] > c[x][y]+1 && s[x+dx[i]][y+dy[i]]=='.'){
				Q.push(make_pair(x+dx[i],y+dy[i]));
				c[x+dx[i]][y+dy[i]]=c[x][y]+1;
			}
		}
	}
	// printf("%lld %lld\n",sum,c[H][W]);
	if(c[H][W]==1e9){
		printf("-1\n");
	}else{
		printf("%lld\n",sum-c[H][W]-1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
map<ll, int> mp;
int main() {
    int n;
    cin >> n;
    ll sum = 0;
    mp[0]++;
    ll ret = 0;
    for (int i = 1; i <= n; i++) {
        ll a;
        cin >> a;
        sum += a;
        ret += mp[sum];
        mp[sum]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 16048
#include<iostream>
#define PI 3.141592653589
using namespace std;
 
int main(){
    int n;
    cin >>n;
    int a[100];
    for ( int i = 0; i < n; i++ ){
        cin>>a[i];
    }
 
     
    for ( int i = 0; i < n; i++ ){
        if (i!=0){cout << " ";}
        cout << a[n-i-1];
    }
    cout << endl;
     
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
int main(int argc, char const* argv[])
{
	int m,d;
	cin >> m >> d;
	int c = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			int d1 = j % 10;
			int d2 = j/10;
			if (d1 > 1 and d2 > 1 and d1*d2 == i) {
				c++;
			}
		}
	}
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 896
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, k, tmp, one, ans = 0;
    vector<int> v;
    cin >> n >> k;
    rep(i, n){
        cin >> tmp;
        v.push_back(tmp);
        if(tmp == 1) one = i;
    }

    ans = ceil(1.0 * (v.size()-1) / (k - 1));
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long a, b, c, x, y;

int main(){
	scanf("%ld%ld%ld%ld%ld", &a, &b, &c, &x, &y);//aのほうが少ない, aはx枚
	if(x > y){
		int tmp = x;
		x = y;
		y = tmp;
		tmp = a;
		a = b;
		b = tmp;
	}
	if(c*2 > a + b){
		printf("%ld\n", a*x + b*y);
	}else{
		if(c*2 < b){
			printf("%ld\n", y*c*2);
		}else{
			printf("%ld\n", x*c*2 + (y-x) * b);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <stack>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	long long int DP[440][440];
	
	for(int i = 0; i < 440; i++){
		for(int j = 0; j < 440; j++){
			DP[i][j] = INF;
		}
	}
	
	DP[0][0] = 0;
	
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	
	for(int loop = 0; loop < N; loop++){
		int a, b, c;
		cin >> a >> b >> c;
		for(int i = 410; i >= a; i--){
			for(int j = 410; j >= b; j--){
				DP[i][j] = min(DP[i][j], DP[i - a][j - b] + c);
			}
		}
	}
	
	long long int ans = INF;
	
	for(int i = 1; i < 440; i++){
		for(int j = 1; j < 440; j++){
			if(i * Mb == j * Ma){
				ans = min(ans, DP[i][j]);
			}
		}
	}
	
	if(ans == INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	
	return 0;
}


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

using namespace std;

int main(){
    string S;
    cin >> S;

    if(S.size()%2==1){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]!='h'){
                cout << "No" << endl;
                return 0;
            }
        }else{
             if(S[i]!='i'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CO cout<<
#define EN <<endl
#define CI cin>>
using namespace std;

int main() {
	int a, b, c; CI a >> b >> c;
	if (a + b >= c) { CO "Yes" EN; }
	else CO "No" EN;
	return 0;
}

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

using namespace std;
void Output(const vector<int>& List)
{
    for(std::size_t i = 0; i < List.size(); ++i){
        if(i) std::cout << " ";
        std::cout << List[i];
    }
    std::cout << std::endl;
}
int  BubbleSort(vector<int> &A)
{
    int count = 0;
    for(int i = 0; i < A.size(); i++){
        for(int j = A.size()-1; j >= i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                count++;
            }
        }
    }
    return count;
}
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    int Count = BubbleSort(A);
    Output(A);
    std::cout << Count << std::endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 



const double PI = acos(-1);


int main() {
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double th = double(h*60+m)/720 *2*PI;
  double tm = double(m)/60 * 2*PI;
  double xh = a*cos(th), yh = a*sin(th);
  double xm = b*cos(tm), ym = b*sin(tm);
  double dx = xh-xm;
  double dy = yh-ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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


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



int n,a,b;
cin>>n>>a>>b;
int ans=(n)/(a+b) * a;
n%=(a+b);
ans+=min(a,n);
cout<<ans<<"\n";



  
}



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

using namespace std;

//#define FILE_IO

int N;
vector <int> edg[100005];
int h[100005];

bool cmp(int a, int b)
{
    return h[a] > h[b];
}

int DFS(int nod)
{
    for(auto nxt: edg[nod])
        DFS(nxt);
    sort(edg[nod].begin(), edg[nod].end(), cmp);
    for(int i = 0; i < edg[nod].size(); i++)
        h[nod] = max(h[nod], i + 1 + h[ edg[nod][i] ]);
    return h[nod];
}

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

    scanf("%d", &N);
    for(int i = 2; i <= N; i++)
    {
        int f;
        scanf("%d", &f);
        edg[f].push_back(i);
    }

    int ans = DFS(1);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 10752
n, k = map(int, input().split())
a = list(map(int, input().split()))


d = [[-1] * n for _ in range(70)]

for i in range(n):
    d[0][i] = a[i] - 1

for i in range(1, 70):
    for j in range(n):
        d[i][j] = d[i - 1][d[i - 1][j]]

dst = 0
while k:
    i = 70
    while pow(2, i) & k <= 0:
        i -= 1

    dst = d[i][dst]
    k -= pow(2, i)

print(dst + 1)


Measured memory_bytes: 198660
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

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

fn solve() {
    input! {
        a: i64,
        b: i64
    }

    if (a - b).abs() < 3 {
        println!("Yay!");
    } else {
        println!(":(");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

int main(){
    int N;
    cin >>N;
    int num=N%10;
    if(num==3){
        cout<<"bon"<<endl;
    }
    else if(num==0 || num==1 || num==6 || num==8) {
        cout<<"pon"<<endl;
    }
    else {
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3560
import sys
input = sys.stdin.readline

n,a,b=map(int,input().split())
res = []
if (b-a)%2==0:
    print(abs(b-a)//2)
    exit()
else:
    if min(a-1,n-b)==a-1:
        res.append(b-1)
        res.append((b-a-1)//2+a)
    else:
        res.append(n-a)
        res.append((b-a-1)//2+n-b+1)
print(min(res))


Measured memory_bytes: 3060
import sys
def main():
    for line in sys.stdin:
        F = line.split() #formula
        if F[1] == "?":
            break
        else:
            a = int(F[0])
            b = int(F[2])
            op = F[1]
            ans = 0
            if op == "+":
                ans = a + b
            elif op == "-":
                ans = a - b
            elif op == "/":
                ans = a // b
            elif op == "*":
                ans = a * b
            print(ans)
            

if __name__ == "__main__":
    main()

Measured memory_bytes: 7772
// https://atcoder.jp/contests/tenka1-2017-beginner/tasks/tenka1_2017_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    FOR(i, 1, 3501) FOR(j, i, 3501) {
        int ng = 1, ok = 3500;
        // NGとOKの境界を二分探索する
        while (ng + 1 != ok) {
            int x = (ng + ok) / 2;
            int t1 = 4 * i * j * x;
            int t2 = N * (i * j + i * x + j * x);
            if (t1 == t2) {
                cout << i << " " << j << " " << x << "\n";
                return 0;
            } else if (t1 > t2) {
                ok = x;
            } else {
                ng = x;
            }
        }
    }
    return 0;
}


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

int main(void){
	int n;
	int a;
	cin >> n;
	for (int i = 0; i < 10000; i++) {
		if (n <= 1000 * i) {
			cout << 1000 * i - n << endl;
			break;
		}
	}
	

	

return 0;
}

Measured memory_bytes: 3620
#include <cstdio>

char s[200005];
int used[200005][2];

int main()
{
    //freopen("a.in", "r", stdin);
    int n, k, c;
    scanf("%d%d%d", &n, &k, &c);
    scanf("%s", s);
    c++;
    int pos = 1, cnt = 0;
    while(pos <= n)
    {
        if(s[pos - 1] == 'o')
        {
            used[pos][0] = ++cnt;
            if(cnt == k) break;
            pos += c;
        }
        else pos++;
    }
    pos = n, cnt = k;
    while(pos)
    {
        if(s[pos - 1] == 'o')
        {
            used[pos][1] = cnt--;
            if(!cnt) break;
            pos -= c;
        }
        else pos--;
    }
    for(int i = 1; i <= n; i++)
    if(used[i][0] && used[i][0] == used[i][1])
        printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <unordered_map>
#include <list>
using namespace std;



int main() {
	
    int *H = new int[100001];
    int *B = new int[100001];
    int N,M;
    cin >> N >> M;

    for(int i=1;i<N+1;i++){
        cin >> H[i];
    }

    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        if(H[a] > H[b]){
            B[b]++;
        }else if(H[a] < H[b]){
            B[a]++;
        }else{
            B[b]++;
            B[a]++;
        }
    }
    int cnt = 0; 
    for(int i=1;i<N+1;i++){
        if(B[i] == 0){
            cnt++;
        }
    }
    cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define eps 1e-8
#define pi 3.14159265358979
#define LL long long
#define MP make_pair
#define PH push
#define PB push_back
#define PII pair<int,int>
#define VI vector<int>
#define X first
#define Y second
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define sqr(x) ((x)*(x))
#define CL(a) memset(a,0,sizeof a)
#define fr(i,n) for(int i=1;i<=n;i++)
#define FR(i,S,n) for(int i=S;i<=n;i++)
#define dr(i,n) for(int i=n;i;i--)
#define DR(i,n,S) for(int i=n;i>=S;i--)
#define SZ(x) ((int)(x).size())
#define rd(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
const int N=1111111;
const int M=998244353;
LL Pw(LL a,LL b,LL p){LL v=1;for(;b;b>>=1,a=a*a%p)if(b&1)v=v*a%p;return v;}
using namespace std;
int n,k,i,an,pw[N],ipw[N]; 
int C(int n,int m){return (m<0||n<m)?0:1ll*pw[n]*ipw[m]%M*ipw[n-m]%M;}
int cal(int n,int m,int k){
	if(k<=0)return 0;
	return (C(n+m,n)-C(n+m,m-k)+M)%M;
}
int main(){
	rd(n);rd(k);
	for(pw[0]=i=1;i<N;i++)pw[i]=1ll*pw[i-1]*i%M;
	ipw[N-1]=Pw(pw[N-1],M-2,M);
	for(i=N-1;i;i--)ipw[i-1]=1ll*ipw[i]*i%M;
	for(i=n;i<=k;i++)an=(an+C(k-1,i-1))%M;
	printf("%d",an);
}

Measured memory_bytes: 8960
open Printf
open Scanf

let id x = x

let n, k = scanf "%d %d" (fun n k -> n, k)

let negList = ref []
let posList = ref []
let zero = ref false

let () =
    for i = 1 to n do
        let v = scanf " %d" id in
        if v = 0 then
            zero := true
        else if v < 0 then
            negList := ~-v :: !negList
        else    
            posList := v :: !posList
    done;
    posList := List.rev !posList

let negA = Array.of_list !negList
let posA = Array.of_list !posList

let flipNeg rest =
    let result = ref max_int in
    if Array.length negA > 0 then
        for i = 0 to Array.length negA - 1 do
            let score = if rest - (i + 1) > 0 then
                if rest - (i + 1) - 1 < Array.length posA then
                    negA.(i) * 2 + posA.(rest - (i + 1) - 1)
                else
                    max_int
            else
                negA.(i)
            in
            result := min !result score
        done;
    !result

let flipPos rest =
    let result = ref max_int in
    if Array.length posA > 0 then
        for i = 0 to Array.length posA - 1 do
            let score = if rest - (i + 1) > 0 then
                if rest - (i + 1) - 1 < Array.length negA then
                    posA.(i) * 2 + negA.(rest - (i + 1) - 1)
                else
                    max_int
            else
                posA.(i)
            in
            result := min !result score
        done;
    !result

let () =
    let rest = if !zero then k - 1 else k in
    if rest > 0 then begin
        let x = flipNeg rest in
        let y = flipPos rest in
        printf "%d\n" (min x y)
    end else
        printf "%d\n" 0


Measured memory_bytes: 7168
from collections import Counter
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
counter = Counter(s for li in a for s in li)
g1 = g2 = 0
g4 = (H // 2) * (W // 2)
if H % 2 and W % 2:
    g1 = 1
    g2 = (H // 2) + (W // 2)
elif H % 2 == 0 and W % 2:
    g2 = H // 2
elif H % 2 and W % 2 == 0:
    g2 = W // 2

if g1:
    for c in counter:
        if counter[c] % 4 in {1, 3}:
            counter[c] -= 1
            break
for _ in range(g2):
    for c in counter:
        if counter[c] % 4 == 2:
            counter[c] -= 2
            break
if all(v % 4 == 0 for v in counter.values()):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3436
fn main() {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    let bytes = buffer.as_bytes();
    if &bytes[2] == &bytes[3] && &bytes[4] == &bytes[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=0,o=0,u=t,i=1,f=[0];u>0;){i*=10;var l=f[(o+=1)-1];o%2==1&&(l+=i-1-i/10+1),f.push(l),u=Math.floor(u/10)}n+=f[o-1],o%2==1&&(n+=t-i/10+1),console.log(n)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7620
#include <bits/stdc++.h>
using namespace std;
int N, x[2][100009], p[100009], z[2][100009]; long long v[2][100009];
int main() {
	scanf("%*d%*d%d", &N);
	for(int i = 0; i < N; i++) scanf("%d%d", &x[0][i], &x[1][i]);
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < N; j++) v[i][j] = 1LL << 60, p[j] = j;
		sort(p, p + N, [&](int j, int k) { return x[i][j] < x[i][k]; });
		for(int j = (N - 1) / 2; j <= N / 2; j++) {
			long long sum = 0;
			for(int k = 0; k < N; k++) sum += abs(x[i][p[j]] - x[i][k]) * 2;
			for(int k = 0; k < N; k++) {
				long long cost = sum - abs(x[i][p[j]] - x[i][k]);
				if(v[i][k] > cost) v[i][k] = cost, z[i][k] = x[i][p[j]];
			}
		}
	}
	long long ret = 1LL << 60; int lp = -1;
	for(int i = 0; i < N; i++) {
		long long c = v[0][i] + v[1][i];
		if(ret > c || (ret == c && (z[0][lp] > z[0][i] || (z[0][lp] == z[0][i] && z[1][lp] > z[1][i])))) ret = c, lp = i;
	}
	printf("%lld\n%d %d\n", ret, z[0][lp], z[1][lp]);
	return 0;
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
char next(char c){
  if (c == 'Z') return 'A';
  return (char)(c + 1);
}
int main(){
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); i++){
    for (int j = 0; j < N; j++){
      S[i] = next(S[i]);
    }
  }
  cout << S;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define Max zhi5968
typedef long long ll;
using namespace std;
 
int main ()
{
	int a[1000]={0},mn=9999999,mxi,mni,mx=-99999999,i,n;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>mx)
		{
			mx=a[i];
			mxi=i;
		}
		if(a[i]<mn)
		{
			mn=a[i];
			mni=i;
		}
	}
//	cout<<mn<<" "<<mni<<" "<<mx<<" "<<mxi<<endl;
	if(mx+mn>0)
	{
		cout<<2*n-2<<endl;
		for(i=1;i<=n;i++)
			if(i!=mxi)
				printf("%d %d\n",mxi,i);
		for(i=1;i<n;i++)
			printf("%d %d\n",i,i+1);
	}
	else if(mx+mn==0&&mn!=0)
	{
		cout<<2*n-1<<endl;
		printf("%d %d\n",mni,mni);
		for(i=1;i<=n;i++)
			if(i!=mni)
				printf("%d %d\n",mni,i);
		for(i=n;i>1;i--)
			printf("%d %d\n",i,i-1);
	}
	else
	{
		cout<<2*n-2<<endl;
		for(i=1;i<=n;i++)
			if(i!=mni)
				printf("%d %d\n",mni,i);
		for(i=n;i>1;i--)
			printf("%d %d\n",i,i-1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll n;
	cin >> n;
	string str;
	cin >> str;

	cout << ((n >= 3200) ? str : "red") << endl;
}

Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
xyc=[list(map(int, input().split())) for _ in range(M)]
mini=min(a)+min(b)
for i in range(M):
    if a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]<mini:
        mini=a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]
print(mini)

Measured memory_bytes: 38564
import collections
n,w = map(int,input().split())
d = []
for i in range(w):
	dtemp = list(map(int,input().split()))
	d.append(dtemp)

a = []
b = []
c = []
for i in range(n):
	temp = list(map(int,input().split()))
	if i%3 == 1:
		for k in range(n):
			if k %3 == 0:
				a.append(temp[k])
			elif k %3 == 1:
				b.append(temp[k])
			else:
				c.append(temp[k])
	elif i%3 == 2:
		for k in range(n):
			if k %3 == 0:
				b.append(temp[k])
			elif k %3 == 1:
				c.append(temp[k])
			else:
				a.append(temp[k])
	else:
		for k in range(n):
			if k %3 == 0:
				c.append(temp[k])
			elif k %3 == 1:
				a.append(temp[k])
			else:
				b.append(temp[k])
ac = collections.Counter(a)
bc = collections.Counter(b)
cc = collections.Counter(c)

ans = []
for i in range(1,w+1): #aについて
	for k in range(1,w+1): #bについて
		for e in range(1,w+1): #cについて
			if i != k and i != e and k != e:
				counter = 0
				for p in ac:
					if p != i:
						counter += ac[p]*d[p-1][i-1]
				for q in bc:
					if q != k and k != i:
						counter += bc[q]*d[q-1][k-1]
				for r in cc:
					if r != e and e != i and e != k:
						counter += cc[r]*d[r-1][e-1]
				ans.append(counter)
print(min(ans))

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

int main(){
  int n, pi;
  cin >> n;
  vector<int> pn(n);
  for(int i=0; i<n; ++i){
    cin >> pi;
    --pi;
    pn[pi] = i;
  }
  int ans = n -1, cnt = 1;
  for(int i=0; i<n-1; ++i){
    if(pn[i] < pn[i+1]) ++cnt;
    else cnt = 1;
    ans = min(ans, n-cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3992
n,m=map(int, input().split())
s=[list(map(int, input().split())) for _ in range(n)]
o=[list(map(int, input().split())) for _ in range(m)]
for a,b in s:
  k=[]
  for c,d in o:
    k.append(abs(a-c)+abs(b-d))
  print(k.index(min(k))+1)

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

int main(){
  int K,A,B;
  cin>>K>>A>>B;
  
  
  bool res = false;
  
  for(int i = A;i <= B;i++){
    if(i%K==0)res = true;
  
  }
  
  if(res){
    cout<<"OK";
  }else{
    cout<<"NG";
  
  }
  
  


	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
    int x,a,b;
    
    scanf("%d %d %d",&x,&a,&b);
    
    if(b-a<=0)
        printf("delicious\n");
    else if(b-a<=x)
        printf("safe\n");
    else
        printf("dangerous\n");
}


Measured memory_bytes: 128
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (_, M) = read!(usize, usize);
    let A = read![[i64]];

    let mut q = BinaryHeap::new();
    for a in A {
        q.push(a);
    }

    for _ in 0..M {
        if let Some(x) = q.pop() {
            q.push(x / 2);
        }
    }

    let sum = q.into_iter().sum::<i64>();

    println!("{}", sum)
}


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

int GCD(int x,int y){
  int tmp=x%y;
  while(tmp!=0){
    x=y;y=tmp;
    tmp=x%y;
  }
  return y;
}

int main(){
  int x,y;
  cin>>x>>y;
  cout<<GCD(x,y)<<endl;
}



Measured memory_bytes: 3100
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#include<algorithm>
#define debug(ARGS) cout << #ARGS << ": " << ARGS << endl;
#define ll long long

#define INF (int)1e7
#define p pair<int, int>
#define F 0
#define X -1
#define S -2

using namespace std;

int convert(char c){
  int ret;

  if('1' <= c && c <= '9') ret = c - '1' + 1;
  else if(c == '.') ret = F;
  else if(c == 'X') ret = X;
  else if(c == 'S') ret = S;
  else ret = -3;

  return ret;
}

p find_nest(vector< vector<int> > &v, int num){
  int h = v.size(), w = v[0].size();
  p ret;
  
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(v[i][j] == num) ret = p(i, j);

  return ret;
}

int count_minite(vector< vector<int> > v, int start, int end){
  int h = v.size(), w = v[0].size();
  int ret = -1;
  // vector< vector<bool> > m; m.resize(h); for(int i = 0; i < h; i++) m[i].resize(w, false);
  queue< pair< p, int> > q;
  q.push(pair< p, int>(find_nest(v, start), 0));

  while(!q.empty()){
    p here = q.front().first; 
    ret = q.front().second;
    q.pop();
    int y = here.first, x = here.second;
    
    if(v[y][x] == end) break;
    else if(v[y][x] == X) continue;

    v[y][x] = X;
    
    if(x > 0 && v[y][x-1] != X) q.push(pair< p, int>(p(y, x-1), ret+1));
    if(x < w - 1 && v[y][x+1] != X) q.push(pair< p, int>(p(y, x+1), ret+1));
    if(y > 0 && v[y-1][x] != X) q.push(pair< p, int>(p(y-1, x), ret+1));
    if(y < h - 1 && v[y+1][x] != X) q.push(pair< p, int>(p(y+1, x), ret+1));
  }
  
  return ret;
}

int main(){
  int h, w, n;
  cin >> h; cin >> w; cin >> n;
  vector< vector<int> > v;  
  v.resize(h); for(int i = 0; i < h; i++)  v[i].resize(w);
  int count = 0;

  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++){
      char c; cin >> c;
      v[i][j] = convert(c);
    }

  int start = S;  
  for(int i = 1; i <= n; i++){
    count += count_minite(v, start, i);
    start = i;
  }

  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 10704
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
  cout << fixed << setprecision(10);
  int n,k;
  vector<double> per;
  cin >> n >> k;
  for(int i = 1;i <= n ;i++){
    int j = i;
    int count = 0;
    double ans;
    for(;;){
      if(j >= k){
        break;
      }
      j *= 2;
      count++;
    }

    if(count == 0){
      ans = (1.0 / (double)n);
    }
    else{
      ans = (1.0 / (double)n) * pow(0.5,(double)count);
    }
    per.push_back(ans);
  }

  long double ans = 0.0;

  for(int i = 0;i < n ;i++){
    ans += per[i];
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 1400
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

int main(void) {
    int ans = 0;
    string s1, s2;
    cin >> s1;
    s2 = s1;
    reverse(s2.begin(), s2.end());
    rep(i, s1.length()) {
        if (s1[i] != s2[i]) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}


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


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

int main (){
  long long int n, d, d2, a[20000], e = 0, i;
  cin >> n;
  for (i = 0; i < n; i++)
    a[i] = 0;
  for (i = 0; i < n; i++){
    cin >> d >> d2;
    if (d == d2)
      a[i] = 1;
    if (i >= 2){
    	if (a[i] == 1 && a[i-1] == 1 && a[i-2] == 1){
      	cout << "Yes";
      	e = 1;
      	break;
    	}
    }
  }
  if (e != 1)
    cout << "No";
}

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

/*xからスタートして登場してなければx、あれば差1,それもあれば差2、、
っていうのを繰り返して登場してないのが出てくるまでwhile
値が+差なのか-差なのかもboolで持っておいて、登場してない方出力
目で見て考える分には良いんだけど
bool2つとかいう実装が大変めんどくさい方針でやってたからコードぐちゃぐちゃ。通ったけど
xの範囲が十分狭いからそんなことしなくても全部試しちゃった方が楽
差をどんどん広げていく感じ。min使いそうって思いついて欲しかった
差が小さい→登場してない、の順で確認
実装上手く行かなそうだったら他の方針考える*/

/*xは1-100だから出力としてあり得るのは0-101
0-101で登場してないのを全部試して
その中で最も差が小さいの、同じなら数が小さい方を出力する方針
登場してない→差が小さい、の順で確認。思いつかなかった*/
int main(){
  int x,n;
  cin >> x >> n;
  vector<int> d(102); //登場したかを判別する。0で初期化されてる
  rep(i,n){
    int p;
    cin >> p;
    /*なぜか==にしてたから1代入出来てなくて全部0のままになってて
    何も登場してないパターンになっててxと同じ値が出力されるようになってた*/
    d[p] = 1; //登場したら1入れる 
  }
  P ans(99999, -1);
  rep(i,102){
    if(d[i]==1) continue;
    //int dif = abs(x-i);
    //ans = min(ans, P(dif,i)); こっちの方が見やすい
    P dif(abs(x-i),i);
    /*pairをminで比較すると、まず1つ目(xとの差)を見て小さい方、
    同じ値の時だけ２つ目(その数自体)見て小さい方ってしてくれる
    今回やりたいことにぴったり！pairを知らなかった*/
    ans = min(ans, dif);
  }
  cout << ans.second << endl; //ans.first->abs(x-i), ans.second->i
}

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

using namespace std;

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

  int N; cin>>N;
  vector<int> A(N); for (auto& a : A) cin>>a;

  int n = 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == n)
      n++;
    else
      ans++;
  }
  if (n == 1)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S, T; cin >> S >> T;
  vector<LL> sumS(S.size() + 1), sumT(T.size() + 1);
  sumS[0] = 0, sumT[0] = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'A') sumS[i + 1] = sumS[i] + 1;
    else             sumS[i + 1] = sumS[i] + 2;
  }
  for (int i = 0; i < T.size(); ++i) {
    if (T[i] == 'A') sumT[i + 1] = sumT[i] + 1;
    else             sumT[i + 1] = sumT[i] + 2;
  }

  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (((sumS[b] - sumS[a-1]) % 3) == ((sumT[d] - sumT[c-1]))%3) cout << "YES" << endl;
    else                                                          cout << "NO" << endl;
  }
}


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

int main(void){
    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    for(int ai=0;ai<=a;ai++){
        for(int bi=0;bi<=b;bi++){
            for(int ci=0;ci<=c;ci++){
                ans += (x==500*ai+100*bi+50*ci);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"War\n":"No War\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[])
{
    map<int,int> a;
    int n,m,x,y,q,cnt=0;
    cin>>n>>m>>x>>y;
    rep(i,n)cin>>q,a[q]=1;
    rep(i,m){
        cin>>q;
        if(a[q]==1) yn(1),exit(0);
        a[q]=2;
    }
    if(a[x]==2||a[y]==1) yn(1),exit(0);
    a[x]=1,a[y]=2;
    for(auto q:a){
        cnt++;
        if(q.second==2&&cnt<=n+1) yn(1),exit(0);
    }
    yn(0);
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x,n;
    cin >> n;
    x=(n%10);
    if(x==2 || x==4 || x==5 || x==7 || x==9)
    {
        cout << "hon" << endl;
    }
    else if(x==0 || x==1 || x==6 || x==8)
    {
    cout << "pon" << endl;
    }
    else if(x==3){
        cout << "bon" << endl;
    }



}


Measured memory_bytes: 3640