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

#define LL long long
#define pa pair<int,int>
using namespace std;
const int inf = 2147483647;
const int N = 200001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

char s1[N], s2[N];

int main() {
	int H = read(), W = read(), n = read();
	int sx = read(), sy = read();
	scanf("%s%s", s2 + 1, s1 + 1);
	int xl = 1, xr = H, yl = 1, yr = W;
	for(int i = n; i >= 1; i--) {
		if(s1[i] == 'U') xr = _min(xr + 1, H);
		else if(s1[i] == 'D') xl = _max(xl - 1, 1);
		else if(s1[i] == 'L') yr = _min(yr + 1, W);
		else yl = _max(yl - 1, 1);
		if(s2[i] == 'U') xl++;
		else if(s2[i] == 'D') xr--;
		else if(s2[i] == 'L') yl++;
		else yr--;
		if(xl > xr || yl > yr) {puts("NO"); return 0;}
	} if(xl <= sx && sx <= xr && yl <= sy && sy <= yr) puts("YES");
	else puts("NO");
	return 0;
}



Measured memory_bytes: 640
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int cnt[5005],ret[5005];
vector<int>edge[5005];
int main()
{
	srand((unsigned int)time(NULL));
	int n,m; scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int a,b; scanf("%d %d",&a,&b);
		cnt[b]++;
		edge[a].pb(b);
	}
	queue<int>que;
	for(int i=1;i<=n;i++)
	{
		if(!cnt[i]) que.push(i);
	}
	bool ex=false; int id=1;
	while(!que.empty())
	{
		ex|=(que.size()>1);
		int x=que.front();  que.pop();
		ret[id++]=x;
		for(int i=0;i<edge[x].size();i++)
		{
			cnt[edge[x][i]]--;
			if(!cnt[edge[x][i]])
			{
				que.push(edge[x][i]);
			}
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",ret[i]);
	printf("%d\n",ex);
	return 0;
}

Measured memory_bytes: 1940
# https://beta.atcoder.jp/contests/abc065/tasks/abc065_b

import sys


def model():
    e = list(map(int, sys.stdin))
    cur = e[1]
    for i in range(e[0]):
        if cur == 2:
            print(i + 1)
            break
        cur = e[cur]
    else:
        print(-1)


def input_lines():
    """hell?"""
    lines = sys.stdin.readlines()
    for i in range(1, int(lines[0])+1):
        yield i, int(lines[i].strip())


def solve():
    d = {i: button for i, button in input_lines()}
    count = 1
    index = 1

    while True:
        try:
            prev = index
            index = d[index]

            if index is None:
                print(-1)
                exit()
            elif index == 2:
                print(count)
                exit()
            d[prev] = None
            count += 1
        except KeyError:
            print(-1)
            exit()


if __name__ == '__main__':
    solve()
    # model()


Measured memory_bytes: 24228
#include<bits/stdc++.h>
using namespace std;
int a[101][2];
int main(){
	int n;
	bool flag=false;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i][1]>>a[i][2];
	}
	for(int i=0;i<n-2;i++){
		if((a[i][1]==a[i][2])&&(a[i+1][1]==a[i+1][2])&&(a[i+2][1]==a[i+2][2])){
			flag=true;
			break;
		}
	}
	if(flag){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3592
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int x, y;
    cin >> x >> y;

    bool flg = false;
    rep(i, x + 1){
        if(i * 2 + (x - i) * 4 == y){
            flg = true;
        }
    }

    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define YES_RTN s_cout("Yes");return 0
#define NO_RTN  s_cout("No");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int   x, y, i, flg;
	int   g1[8] = { 1,3,5,7,8,10,12 };
	int   g2[5] = { 4,6,9,11 };
	int   g3 = 2;

	i_cin2(x, y);
	if (x == y && x == g3) { YES_RTN; }

	flg = 0;
	rept(i, 0, 4) {
		if (g2[i] == x || g2[i] == y)  flg++;
	}
	if (flg == 2) { YES_RTN; }
	flg = 0;
	rept(i, 0, 7) {
		if (g1[i] == x || g1[i] == y)  flg++;
	}
	if (flg == 2) { YES_RTN; }
	NO_RTN;
	}
	
//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}




Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		List<Character> array1 = new ArrayList<Character>();
		List<Character> array2 = new ArrayList<Character>();

		for(int i=0;i<s.length();i++){
		array1.add(s.charAt(i));
		}
		
		for(int i=0;i<t.length();i++){
		array2.add(t.charAt(i));
		}
		Collections.sort(array1);
		Collections.sort(array2);
		Collections.reverse(array2);
		for(int i=0;i<Math.min(s.length(), t.length());i++){
			if(array1.get(i)<array2.get(i)){
				System.out.println("Yes");
				System.exit(0);
			}else if(array1.get(i) == array2.get(i)){
				continue;
			}else{
				System.out.println("No");
				System.exit(0);
			}
		}
		if(s.length() >= t.length()){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
		
	}
}


Measured memory_bytes: 23764
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine()
    val q = in.readLine().toInt

    val front = Array.ofDim[Char](200000)
    var frontCount = 0
    val rear = Array.ofDim[Char](200000)
    var rearCount = 0

    var reverse = false

    for {
      _ <- 0 until q
    } {
      in.readLine().split("\\s+").map(_.toCharArray()(0)) match {
        case Array('1') =>
          reverse = !reverse
        case Array('2', f, c) =>
          if (f == '1' && !reverse || f == '2' && reverse) {
            front(frontCount) = c
            frontCount += 1
          } else {
            rear(rearCount) = c
            rearCount += 1
          }
      }
    }

    if (reverse) {
      for {
        i <- (rearCount - 1) to 0 by -1
      } {
        out.print(rear(i))
      }
      out.print(s.reverse)
      for {
        i <- 0 until frontCount
      } {
        out.print(front(i))
      }
    } else {
      for {
        i <- (frontCount - 1) to 0 by -1
      } {
        out.print(front(i))
      }
      out.print(s)
      for {
        i <- 0 until rearCount
      } {
        out.print(rear(i))
      }
    }

    out.println()
    out.flush()
  }
}


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

typedef long long ll;
#define int ll
#define pb push_back
const int INF = 1e18;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n,w; cin>>n>>w;
	int knap[n+1][2];
	for(int i=1;i<=n;i++)
		cin>>knap[i][0]>>knap[i][1];

	vector<int> dp(w+1,0), next(w+1,0);

	for(int i=1;i<=n;i++){	
		for(int j=0; j+knap[i][0] <= w; j++)
			next[j+knap[i][0]] = max(next[j+knap[i][0]],dp[j] + knap[i][1]);

		for(int j=0;j<=w;j++)
			dp[j] = next[j];
	}
	
	int ans = 0;
	for(int i=0;i<=w;i++) 
		ans = max(ans,dp[i]);

	cout<<ans;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
int main(){
  long long n,k;
  cin>>n>>k;
  long long ans=0;
  for(long long i=k;i<=n+1;i++){
    long long mi=i*(i-1)/2;
    long long ma=i*(n+n-i+1)/2;
    ans+=(ma-mi+1);
    ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> hai_l(n);
  for(int i=0;i<n;i++){
    cin >> hai_l.at(i);
  }
  sort(hai_l.begin(),hai_l.end());
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum += hai_l.at(i);
  }
  if(sum>hai_l.at(n-1)){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if(op.equals("+")){
			System.out.println(a+b);
		}else{
		System.out.println(a-b);
		}
		sc.close();
	}
 }

Measured memory_bytes: 21076
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)

Measured memory_bytes: 230928
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n;
	std::vector<int> a;
	for(int i = 6;; i+= 5){
		bool f = true;
		for(int j = 2; j * j <= i; j++){
			if(i % j) continue;
			f = false;
		}
		
		if(f) a.push_back(i);
		if(a.size() == n) break;
	}
	
	for(auto v : a) cout << v << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
long long gekoa[200000] = {};
long long gyaku(long long n) {
	if (gekoa[n]) return gekoa[n];
	long long ans = 1;
	long long now = n;
	long long hoge = n;
	long long geko = MAX_MOD - 2;
	while (geko != 0) {
		if (geko % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		geko /= 2;
	}
	return gekoa[hoge] = ans;
}
long long cost_front[300000] = {};
long long cost_back[300000] = {};
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<long double> a;
	REP(i, n) {
		long double tmp;
		cin >> tmp;
		a.push_back(log2(tmp));
	}
	vector<long double> b;
	REP(i, n) {
		b.push_back(a[i]+(long double)2.0);
	}
	long long now_itr = 0;
	cost_front[0] = 1;
	for (int i = 1; i < n; ++i) {
		cost_front[i] = cost_front[i - 1] + 1;
		while (b[i] > b[i - 1]) {
			for (int q = i - 1; q >= 0; --q) {
				cost_front[i] += 2;
				b[q] += (long double)2.000000000;
				if (q == 0 || b[q] <= b[q - 1]) {
					break;
				}
				if (b[q] > b[q - 1]) {
					if (now_itr == q) {
						cost_front[i] += 2 * now_itr;
						break;
					}
					else {
						if (now_itr == q - 1) {
							cost_front[i] += 2 * (now_itr+1);
							now_itr = i - 1;
							break;
						}
					}
				}
			}
		}
	}
	now_itr = n - 1;
	for (int i = n - 2; i >= 0; --i) {
		cost_back[i] = cost_back[i + 1];
		while (a[i] > a[i + 1]) {
			for (int q = i + 1; q < n;++q) {
				cost_back[i] += 2;
				a[q] += (long double)2.000000000;
				if (q == n-1 || a[q] <= a[q + 1]) {
					break;
				}
				if (a[q] > a[q + 1]) {
					if (now_itr == q) {
						cost_back[i] += 2 * (n - 1 - now_itr);
						break;
					}
					else {
						if (now_itr == q + 1) {
							cost_back[i] += 2 * (n - 1 - now_itr + 1);
							now_itr = i + 1;
							break;
						}
					}
				}
			}
		}
	}
	long long ans = cost_back[0];
	for (int i = 1; i <= n; ++i) {
		ans = min(ans, cost_back[i] + cost_front[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12652
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	int n; cin >> n;
	int cnt = 0;
	REP1C(i, n)
	{
		int a; cin >> a;
		if (i != a)
			++cnt;
	}

	if (cnt <= 2)
		YES();
	else
		NO();
}


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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    string k;
    k.push_back(s[0]);
    s.erase(s.begin());
    for(int i=0;i<s.size();i++){
        if(s[i]!=k[k.size()-1]){
            k.push_back(s[i]);
        }
    }
    cout<<k.size();


    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;

int me[40000],enemy[40000];

void func(){

	for(int i = 0; i < N; i++)scanf("%d",&me[i]);
	for(int i = 0; i < N; i++)scanf("%d",&enemy[i]);

	sort(me,me+N,greater<int>() );
	sort(enemy,enemy+N,greater<int>());

	int me_index = 0,me_win_count = 0;
	int ans = BIG_NUM;


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

		while(me_index <= N-2){
			if(enemy[i] >= me[me_index]){
				me_index++;
				break;
			}else{
				me_win_count++;
				if(me_win_count >= (me_index+1)/2+1){
					ans = me_index+1;
					break;
				}
				me_index++;
			}
		}

		if(me_index >= N-1 || ans != BIG_NUM)break;
	}

	if(ans == BIG_NUM){
		printf("NA\n");
	}else{
		printf("%d\n",ans);
	}
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/
//================== INPUT ========================
int N,M;
vector<pii> v;
//=================================================
void input()
{
    cin>>N>>M;
    v = vector<pii> (M);
    rep(i,M){
        cin>>v[i].first>>v[i].second;
    }
}

//=================================================
void solve()
{
    sort(v.begin(),v.end(), [](const pii &a, const pii &b){
        return a.second<b.second;});

int ans = 0;
int prv = INF;
    rep(i,M){
       // cout<<"i: "<<i << "v: "<<v[i].first<<","<<v[i].second<<endl;
        if (prv >= v[i].first && prv <= v[i].second){
            continue;
        }
        else {
            ++ans;
            prv = v[i].second - 1;
        }
    }
    cout<<ans<<endl;


}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1792
n, m = map(int, input().split())
h = list(map(int, input().split()))

a = list()
b = list()

for x in range(0, m):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)

check = [0]*n

for x, y in zip(a, b):
    if check[x-1] != -1:
        if h[x-1] > h[y-1]:
            check[x-1] = 1
        else:
            check[x-1] = -1
    if check[y-1] != -1:
        if h[x-1] < h[y-1]:
            check[y-1] = 1
        else:
            check[y-1] = -1

print(len(list(filter(lambda x: x != -1, check))))


Measured memory_bytes: 23184
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let mut a: Vec<char> = sc.read::<String>().chars().collect();
    let mut b: Vec<char> = sc.read::<String>().chars().collect();
    let mut c: Vec<char> = sc.read::<String>().chars().collect();
    a.reverse();
    b.reverse();
    c.reverse();
    let mut e = a.pop();
    let mut ans = ' ';
    loop {
        match e {
            Some(x) => {
                ans = e.unwrap();
                e = match x {
                    'a' => a.pop(),
                    'b' => b.pop(),
                    'c' => c.pop(),
                    _ => None,
                };
            }
            None => break,
        }
    }
    println!("{}", (ans as u8 - 32) as char);
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> s(n);
    rep(i, n) cin >> s[i];
    int q;
    cin >> q;
    ll ans = 0;
    rep(i, q)
    {
        ll target;
        cin >> target;
        int left = -1;
        int right = (int)s.size();
        while(right - left > 1){
            int mid = (left + right) / 2;
            if(s[mid]==target) {
                ans++;
                break;
            }
            if(s[mid] >= target){
                right = mid;
            }else
            {
                left = mid;
            }
            //cout << "left : " << left << "right : " << right << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  vll color(9, 0);
  for(int i = 0; i < N; i++){
    ll a;
    cin >> a;
    ll b = min(a/400, 8LL);
    color.at(b)++;
  }
  ll counter = 0;
  for(int i = 0; i < 8; i++){
    if(color.at(i) != 0) counter++;
  }
  cout << max(1LL, counter) << ' ' << counter + color.at(8) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 4e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 998244353;
 
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;

ll n;cin>>n;

ll a[n];repup(0,n-1,i)cin>>a[i];

ll ans[n];
ans[0]=0;ans[1]= abs(a[1]-a[0]);
repup(2,n-1,i){
	ans[i]= min(ans[i-1]+abs(a[i]-a[i-1]), ans[i-2]+abs(a[i]-a[i-2]));
}

cout<<ans[n-1];
}

Measured memory_bytes: 1792
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
    	int n=ni(),arr[]=new int[n+1],L=Integer.MAX_VALUE,R=-1;
    	long res=0l,sum=Long.MAX_VALUE;

    	for(int i=1;i<=n;i++){
    		arr[i]=ni();
    		L=Math.min(L, arr[i]);
    		R=Math.max(R, arr[i]);
    	}

    	for(int i=L;i<=R;i++){
    		res=0l;
    		for(int j=1;j<=n;j++)
    			res+=(i-arr[j])*(i-arr[j]);
    		sum=Math.min(sum, res);
    	}
    	pn(sum);
    }


   	static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    	//oj = System.getProperty("ONLINE_JUDGE") != null;
    	if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
	
	
	

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ll long long
#define inf 0x7fffffff
#define MOD 998244353
using namespace std;
const int maxn=100010;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return f*x;
}

int n,q,m;
ll a[maxn],b[maxn],c[maxn],ans[maxn],num[maxn];

inline int nex(ll x){
	int l=1,r=m+1,mid;
	while (l<r){
		mid=l+r>>1;
		if (x<c[mid])l=mid+1;else r=mid;
	}
	return l;
}

int main(){
	//freopen("text.in","r",stdin);
	//freopen("text1.out","w",stdout);
	memset(ans,0,sizeof(ans));
	memset(num,0,sizeof(num));
	n=read();q=read();
	for (int i=1;i<=n;++i)a[i]=i;
	for (int i=1;i<=q;++i)b[i]=read();b[0]=n;
	c[m=1]=b[q];
	for (int i=q-1;i>=0;--i)if (b[i]<c[m])c[++m]=b[i];
	num[1]=1;
	for (int i=1;i<m;++i){
		ll x=num[i],y=c[i];int j=i+1;
		while (j<=m){
			num[j]+=y/c[j]*x;
			y%=c[j];
			j=nex(y);
		}
		if (y)ans[y]+=x;
	}
	ans[c[m]]+=num[m];
	for (int i=n-1;i;--i)ans[i]+=ans[i+1];
	for (int i=1;i<=n;++i)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  ll num[26];
  for (int i = 0; i < 26; i++) num[i] = 0; 
  int N = (int)S.size();
  for (int i = 0; i < N; i++) {
    num[S[i] - 'a']++;
  }
  ll ans = 1;
  ans += (N * (N-1LL)) / 2LL;
  for (int i = 0; i < 26; i++) {
    if (num[i] <= 1) {
      continue;
    }
    ans -= (num[i] * (num[i]-1LL)) / 2LL;
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long int
#define endl '\n'

void solve()
{
    ll n,ans=0;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    ll t = (pow(10,9)+7);
    ll  pre = arr[0];
    for(ll i=1;i<n;i++)
    {
    	ans = (ans+(arr[i]*pre)%t)%t;
    	pre = (arr[i] + pre)%t;
    }
   // cout<<ans<<endl;
    
    cout<<(ans);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef JAY
        freopen("C:/Users/jayra/Desktop/cp/input.txt","r",stdin);
        freopen("C:/Users/jayra/Desktop/cp/output.txt","w",stdout);
    #endif
	 {
        solve();
   }
}

Measured memory_bytes: 5176
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a1 = Integer.parseInt(sc.next());
		int a2 = Integer.parseInt(sc.next());
		int a3 = Integer.parseInt(sc.next());
		
		System.out.println((a1+a2+a3) >= 22 ? "bust": "win");
	}
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
      cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3116
// Last Change: 01/14/2019 01:21:06.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

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

  const string key = "keyence";

  const int size = key.size();
  string subF, subB;
  for (int i = 1; i <= size; i++) {
    subF = key.substr(0, i);
    subB = key.substr(i, size - i);
    int pos = (int)S.find(subF);
    if (pos != -1) {
      int pos2 = (int)S.find(subB, pos + i);
      while (pos2 != -1) {
        if (pos == 0 and pos2 + subB.size() == S.size()) {
          cout << "YES" << endl;
          return 0;
        } else {
          int hoge = pos2 + i;
          pos2 = (int)S.find(subB, hoge);
        }
      }
    }
  }

  cout << "NO" << endl;
  return 0;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  
  for (int i=n-2; i>=0; i--){
      if (arr[i]-arr[i+1] > 1){
          cout << "No";
          return 0;
      }else if (arr[i]-arr[i+1] == 1){
          arr[i]--;
      }
  }
  cout << "Yes";
  return 0; 
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int main()
{
	int h, w;
	while (cin >> h >> w)
	{
		if (h == 0 && w == 0)
		{
			break;
		}

		for (int i = 0; i < w; i++)
		{
			cout << '#';
		}
		cout << endl;

		for (int i = 1; i < h - 1; i++)
		{
			cout << '#';
			for (int j = 1; j < w - 1; j++)
			{
				cout << '.';
			}
			cout << '#' << endl;
		}

		for (int i = 0; i < w; i++)
		{
			cout << '#';
		}
		cout << endl << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
char c[1003][1003];
long long vis[1003][1003],res=100000000000000,x1,y2,n,m,k=0;
vector<pair<long long,long long>>v1,v2;

void dfs(long long x, long long y, long long sum)
{
    vis[x][y]=1;
    v1.push_back({x,y});
    if(x==x1 && y==y2)
    {
        res=min(res,sum);
    }
    if(x<(n-1) && vis[x+1][y]==0 && c[x+1][y]=='.')
    dfs(x+1,y,sum);
     if(y<(m-1) && vis[x][y+1]==0 && c[x][y+1]=='.')
    dfs(x,y+1,sum);
    if(x>=1 && vis[x-1][y]==0 && c[x-1][y]=='.')
    dfs(x-1,y,sum);
     if(y>=1 && vis[x][y-1]==0 && c[x][y-1]=='.')
    dfs(x,y-1,sum);
  
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long i,j,sum=0,count=0,ans=0,x=0,y=0,l,r;
      cin>>n>>m;
      cin>>x>>y;
      cin>>l>>r;
      x--;
      y--;
      l--;
      r--;
      x1=l;
      y2=r;
     for(i=0;i<n;i++)
     {
         for(j=0;j<m;j++)
         cin>>c[i][j];
     }
     dfs(x,y,sum);
      if(res==0)
     {cout<<res; return 0;}
     
     k=0;
     sum=0;
     while(res==100000000000000)
     {
         sum++;
         long long g=v1.size();
         
         for(int h=k;h<g;h++)
         {
              for(int i=v1[h].first-2;i<=(v1[h].first+2);i++)
                 {
                   for(int j=v1[h].second-2;j<=(v1[h].second+2);j++)
                     {
                       
                        if(i>=0 && i<n && j>=0 && j<m && vis[i][j]==0 && c[i][j]=='.')
                        {
                           
                           dfs(i,j,sum);
                        }
                     }
                 }
         }

          k=g;
         if(k==v1.size())
         break;
        
     }
     if(res==100000000000000)
     cout<<-1;
     else
     cout<<res;

	return 0;
}

Measured memory_bytes: 18764
import math
# スペース区切りの整数の入力
A, B, H, M = map(int, input().split())

Arad = (60.0 * H + M) * 2 * math.pi / (12.0 * 60.0)
Brad = M * math.pi / 30.0


Ax = A * math.cos(-Arad+ math.pi/2)
Ay = A * math.sin(-Arad+math.pi/2)
Bx = B * math.cos(-Brad+math.pi/2)
By = B * math.sin(-Brad+math.pi/2)

print(math.sqrt((Ax - Bx)**2 + (Ay - By)**2))


Measured memory_bytes: 9508
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    input()
    C=Counter(map(int,input().split()))
    C=[v for k,v in C.most_common()[::-1]]
    n=len(C)
    for i in range(n):
        if(C[i]==1): continue
        C[i]=1 if(C[i]&1) else 2
        if(i<n-1 and C[i]==2):
            C[i+1]-=1
    print(n-(C[-1]==2))
resolve()

Measured memory_bytes: 73068
#include <iostream>

int main () {
char c[4];
  for (int i = 0; i < 4;++i){
  std::cin >> c[i];
  }
  
  for (int i = 0; i < 3;++i){
  if (c[i] == c[i+1]){
  std::cout << "Bad" << std::endl;
    return 0;
  }
  }
  std::cout << "Good" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n);
  vector<int> wa(n);
  for(int i = 0; i < m; i++){
    int p;
    string s;
    cin >> p >> s;
    p--;
    if(ac[p]) continue;
    if(s == "AC"){
      ac[p] = 1;
    }
    else{
      wa[p]++;
    }
  }
  int AC = 0, WA = 0;
  for(int i = 0; i < n; i++){
    AC += ac[i];
    if(ac[i]) WA += wa[i];
  }
  cout << AC << " " << WA << endl;
}


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)

// for vector
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<int>())
#define RSORTS(x) sort(ALL(x), greater<string>())
#define FIND(x, n) find(ALL(x), n)
#define VFOR(e, x) for (auto &e : x)

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

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

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  int a = 0;            \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;

#define INPUTA(n, a) \
  int n = 0;         \
  cin >> n;          \
  vector<int> a(n);  \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }

int main()
{
  OPTIMIZE_CIN_COUT();

  // INPUT1(N);
  // INPUT2(A, B);
  // INPUT3(A, B, C);
  INPUTS(S);
  // INPUTA(N, A);
  // INPUTB(X, Y, B);

  if (S[S.size() - 1] == 's')
  {
    cout << S + "es";
  }
  else
  {
    cout << S + "s";
  }
}


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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }
}

void calculate(){
    int n,l;
    Input::input(n,l);
    vector<string> s(n);
    Input::inputVec(s);
    Sort(s);
    rep(i,n){
        cout << s[i];
    }
    cout << '\n';
}

int main(int,char**){
    calculate();    
}




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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	for(int i = 1; i < 1000; i++)
	{
		if(0.5*i*(i + 1) - a > 0 && 0.5*i*(i + 1) - a == 0.5*(i + 1)*(i + 2) - b)
		{
			cout << 0.5*i*(i + 1) - a << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
let () =
  Scanf.scanf "%s %s" @@ fun s t ->
  let ss = s ^ s in
  Array.init (String.length s) (fun i -> String.sub ss i (String.length t) = t)
  |> Array.fold_left (||) false
  |> fun b -> print_endline (if b then "Yes" else "No")

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()

void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
    	cout<<k<<"\n";
    }
    else if(k>a && k<=b)
    {
    	 cout<<a<<"\n";
    }
    else
    {
    	 int l=a+b;
    	 k-=l;
    	 cout<<(a-k)<<"\n";
    }
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

Measured memory_bytes: 3652
A,B,C,X,Y = map(int, input().split())
price = 0
if A+B > C*2:
    if X < Y:
        price += X * C * 2
        if B > C*2:
            price += (Y-X) * C*2
        else:
            price += (Y-X) * B

    else:
        price += Y * C * 2
        if A > C*2:
            price += (X-Y) * C*2
        else:
            price += (X-Y) * A

else:
    if A > C*2:
        price += X * C * 2
    else:
        price += X * A
    if B > C*2:
        price += Y * C * 2
    else:
        price += Y * B

print(price)


Measured memory_bytes: 3188
N, K = map(int,input().split())
p = list(map(int, input().split()))

s=[0]*(N+1)
for i in range(N):
    s[i + 1] = s[i] + p[i]

Max = 0
for i in range(N):
    Sum=0
    if i+K<=N:
        Sum = s[K+i] - s[i]
        if Sum > Max:
            Max = Sum
            index = i
    else:
        break
Sum=0
for i in range(K):
    kitai=1/2*p[index+i]*(p[index+i]+1)
    kitai = kitai / p[index+i]
    Sum+=kitai
print(Sum)

Measured memory_bytes: 24804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		Nums = new ArrayDeque<Integer>();
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	ArrayDeque<Integer> Nums;

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		String[] strArr = str.split(" ");
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0)
				Nums.addLast(Integer.parseInt(strArr[i]));
			else
				Nums.addFirst(Integer.parseInt(strArr[i]));
		}

		String sep = "";
		for (int i = 0; i < N; i++) {
			if (N % 2 == 0)
				System.out.print(sep + Nums.poll());
			else
				System.out.print(sep + Nums.pollLast());

			if ("".equals(sep))
				sep = " ";
		}
		System.out.println();
	}

	public void solve() {

	}
}


Measured memory_bytes: 83384
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N;
    cin >> N;
    vector<int> L(N,0);

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

    int cnt = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if((L[i]!=L[j])&&(L[j]!=L[k])&&(L[k]!=L[i])&&(i!=j)&&(j!=k)&&(k!=i)){
                    if((L[i]+L[j]>L[k])&&(L[j]+L[k]>L[i])&&(L[k]+L[i]>L[j]))
                    cnt++;
                }
            }
        }
    }

    cout << cnt /6 << endl;

    return 0;

}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b&&b>=c){
		cout<<a-c<<endl;
	}
	else if(a>=c&&c>=b){
		cout<<a-b<<endl;
	}
	else if(b>=c&&c>=a){
		cout<<b-a<<endl;
	}
	else if(b>=a&&a>=c){
		cout<<b-c<<endl;
	}
	else if(c>=a&&a>=b){
		cout<<c-b<<endl;
	}
	else if(c>=b&&b>=a){
		cout<<c-a<<endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

using Pair = pair<int, int>;

int main() {
  int N, T;
  cin >> N >> T;
  vector<Pair> ps;
  int c, t;
  for(int i = 1; i <= N; ++i) {
    cin >> c >> t;
    if(t <= T) {
      ps.push_back(Pair(c, i));
    }
  }
  if(ps.size() == 0) {
    cout << "TLE" << endl;
    return 0;
  }

  sort(ps.begin(), ps.end());
  cout << ps[0].first << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if (B==1){
    cout << 0 << endl;
  }
  else if(A>=B){
    cout << 1 << endl;
  }
  else{
    int num = 1;
    int cnt = A;
    while(true){
      cnt=cnt+A-1;
      num++;
      if(cnt>=B){
        break;
      }
    }
    cout << num << endl;
  }
    
    
}

Measured memory_bytes: 384
N = gets.chomp.to_i

max_cake = N/4

can_buy = false
max_cake.times do |i|
  if N%4 == 0
    can_buy = true
    break
  elsif (N-(4*(i))) % 7 == 0
    can_buy = true
    break
  end
end

if can_buy
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
n, d = map(int, input().split())
x = [[None for _ in range(d)] for _ in range(n)]
cnt = 0

for i in range(n):
    x[i] = list(map(int, input().split()))

for i in range(n - 1):
    for j in range(i + 1, n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] - x[j][k]) ** 2
        if (distance ** 0.5).is_integer():
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int []A = new int[3];
		for(int i = 0; i < 3; i++) {
			A[i] = scan.nextInt();
		}
		scan.close();
		int ans = 0;

		// 0
		int t = Math.abs(A[1] - A[0]);
		t += Math.abs(A[2] - A[1]);
		ans = t;

		t = Math.abs(A[2] - A[0]);
		t += Math.abs(A[1] - A[2]);
		ans = Math.min(ans, t);

		// 1
		t = Math.abs(A[0] - A[1]);
		t += Math.abs(A[2] - A[0]);
		ans = Math.min(ans, t);

		t = Math.abs(A[2] - A[1]);
		t += Math.abs(A[0] - A[2]);
		ans = Math.min(ans, t);

		// 2
		t = Math.abs(A[0] - A[2]);
		t += Math.abs(A[1] - A[0]);
		ans = Math.min(ans, t);

		t = Math.abs(A[1] - A[2]);
		t += Math.abs(A[0] - A[1]);
		ans = Math.min(ans, t);




		System.out.println(ans);
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int flag = 0;
    for(int i = 0; i < N; i++){
        if(a[i] % 2 == 0){
            if(a[i] % 5 != 0 && a[i] % 3 != 0) flag = 1;
        }
    }
    if(flag == 0) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256