akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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...)); }
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); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    REP (i, N - 2) {
        if (S.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

/*
Nがたかだが15。それぞれが正直者か不親切かでbit全探索
*/

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

    vector<vector<pair<int, int>>> P(N);

    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        for (int j = 0; j < a; j++)
        {
            pair<int, int> p;
            cin >> p.first; cin >> p.second;

            P[i].push_back(p);
        }
    }

    int maxv = 0;
    for (int tmp = 0; tmp < (1<<N); tmp++)
    {
        bitset<15> s(tmp);
        int cnt = 0;
        bool consistent = true;
        for (int i = 0; i < N; i++)
        {
            if (s.test(i))
            {
                cnt++;
                for (auto p : P[i])
                {
                    if (s.test(p.first-1) && p.second == 1) {
                        continue;
                    }
                    else if (!s.test(p.first-1) && p.second == 0) {
                        continue;
                    }
                    else
                    {
                        consistent = false;
                        break;
                    }
                }
            }
            if (!consistent) break;
        }
        if (consistent) {
            maxv = max(maxv, cnt);
        }
    }
    cout << maxv << endl;
}

Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local points = {}
local all_point = 0
for i = 1, n do
    points[i] = io.read("*n")
    all_point = all_point + points[i]
end

table.sort(points, function(x, y) return x > y end)

if points[m] >= all_point / (4 * m) then
    print("Yes")
else
    print("No")
end

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e6+5;
vector<ll> v;
ll n,b;

template <typename T> T gcd(T a, T b) {
  if(b == 0) return a;
  return gcd(b, a%b);
}

template <typename T> T lcm(T a, T b) {
  return a / gcd(a, b) * b ;
}

template <typename T> T L_C_M(const vector<T> &list)
{
    if (list.size() < 2) return list[0];

    T a = list[0];
    for (size_t i = 1; i < list.size(); ++i) {
        a = lcm(a, list[i]);
    }
    return a;
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n) {
    cin >> b;
    v.push_back(b);
  }
  ll d = L_C_M(v);
  cout << d << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,s,c,z,max;
	scanf("%d",&a);
	scanf("%d",&b);
	max=-100;
	s=a+b;
	c=a-b;
	z=a*b;
	if(max<s){
		max=s;
	}
	if(max<c){
		max=c;
	}
	if(max<z){
		max=z;
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 128
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  if op == "+":
    print(a + b)
  elif op == "-":
    print(a - b)
  elif op == "*":
    print(a * b)
  elif op == "/":
    print(a // b)
  else:
    break


Measured memory_bytes: 5596
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
int main() {
	ll N, M;
	cin >> N >> M;
	printf("%lld\n", min(N + (M - 2 * N) / 4, M / 2));
	return 0;
}

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

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

struct node *null;

struct node *listSearch(int key)
{
	struct node *cur = null->next;
	while(cur!=null&&cur->key!=key)
	{
		cur =cur->next;
	}
	return cur;
}

void init(){
	
	null=(struct node*)malloc(sizeof(struct node));
	null->next=null;
	null->prev=null;
}

void printList()
{
	struct node *cur=null->next;
	int isf=0;
	while(cur!=null)
	{
		if(isf++)putchar_unlocked(' ');
		printf("%d",cur->key);
		cur=cur->next;
	}
	putchar_unlocked('\n');
}

void deleteNode(struct node *t)
{
if(t==null) return;
t->prev->next=t->next;
t->next->prev=t->prev;
free(t);
}
void deleteFirst()
{
	deleteNode(null->next);
}
void deleteLast()
{
	deleteNode(null->prev);
}
void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void insert(int key)
{
	struct node *x=(struct node*)malloc(sizeof(struct node));
	x->key=key;
	x->next=null->next;
	null->next->prev=x;
	null->next=x;
	x->prev=null;
}
int main(void)
{
	int key,n,i;
	char com[20];
	null=(struct node*)malloc(sizeof(struct node));
	null->next=null;
	null->prev=null;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%s",com);
		if(strlen(com)>6)
		{
			if(com[6]=='F')
			{
				deleteFirst();
			}
			else
			{
				deleteLast();
			}
		}
		else
		{
			scanf("%d",&key);
			
			if(com[0]=='d')
				{
					deleteKey(key);
				}
			else
			{
				insert(key);
			}
			
		}
	}
	printList();
	return 0;
}


	



Measured memory_bytes: 33036
#include<stdio.h>
int main(){
	int i,n,j,k,o,count=0;
	int a[1000001];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	int left=0,right=n-1;
	int cur=n/2;
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d",&o);
		left=0,right=n-1;
		while(1){
			if(left==right-1||left==right){
				if(a[left]==o||a[right]==o) count++;
				break;
			}
			if(o==a[cur]||o==a[cur+1]){
				count++;
				break;
			}
			if(o>a[cur]){
				left=cur;
				cur=(left+right)/2;
			}
			if(o<a[cur]){
				right=cur;
				cur=(left+right)/2;
			}
		}
	}
	printf("%d\n",count);
} 


Measured memory_bytes: 3000
import math
import sys
s = input()
def isACGT(n):
    for i in range(len(n)):
        if (n[i] != 'A' and n[i] != 'C' and n[i] != 'G' and n[i] != 'T'):
            return False
    return True
ans=0
for i in range(len(s)):
    for j in range(1, len(s)+1):
        if (isACGT(s[i:j]) and len(s[i:j]) > ans):
            ans = len(s[i:j])
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define N 100

static const int W=0;
static const int G=1;
static const int B=2;

int M[N][N],color[N],d[N],f[N];
int n,t=0;

void dfs_init(int u){
  int v;
  color[u] = G;
  t++;
  d[u] = t;
  for (v=0;v<n;v++){
    if(M[u][v] == 0)continue;
    if(color[v] == W){
      dfs_init(v);
    }
  }
  color[u] = B;
  t++;
  f[u] = t;
}

void dfs(){
  int i, u;
  for(i=0;i<n;i++)color[i] = W;
 
  for(u=0;u<n;u++){
    if(color[u] == W)dfs_init(u);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}


int main(){
  int i,j;
  int u,k,v; 
  
  scanf("%d", &n);
  for (i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j] = 0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
}



Measured memory_bytes: 2728
import sys
import numpy as np

def solve(S):
	M = 2019
	t = 1
	ans = 0
	c = np.zeros(M, dtype=np.int64)
	c[0] = 1
	r = 0
	for d in S:
		r = (d * t + r) % M
		ans += c[r]
		c[r] += 1
		t = t * 10 % M
	return ans



def cc_export():
	from numba.pycc import CC
	cc = CC('my_module')
	cc.export('solve', 'i8(i4[:])')(solve)
	cc.compile()

if __name__ == '__main__':
	import sys
	if sys.argv[-1] == 'ONLINE_JUDGE':
		cc_export()
		exit(0)
	from my_module import solve
	S = sys.stdin.buffer.readline().decode('utf-8').rstrip()
	S = np.array([int(d) for d in S[::-1]], dtype=np.int32)
	print(solve(S))


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  VI l(n);
  REP(i, n){
    cin >> l[i];
  }
  int ans = 0;
  int y = 0;
  REP(i, n){
    ans++;
    y += l[i];
    if(y > x) break;
    else if(i == n-1) ans++;
  }
  out(ans);
  return 0;
}


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

using lint = long long;

const int maxn = 1 << 18, inf = 1e9;
struct segt {
    int t[maxn*2], lazy[maxn*2];
    void init() {
    	fill(t, t+maxn*2, inf);
    }
    int merge(int a, int b) { return min(a, b); }
    void propagate(int s, int e, int x) {
    	if (lazy[x] and s != e) {
    		int l = lazy[x];
    		t[2*x] = min(t[2*x], l);
    		lazy[2*x] = lazy[2*x] ? min(lazy[2*x], l) : l;
    		t[2*x+1] = min(t[2*x+1], l);
    		lazy[2*x+1] = lazy[2*x+1] ? min(lazy[2*x+1], l) : l;
    		lazy[x] = 0;
    	}
    }
    void update(int s, int e, int x, int l, int r, int v) {
    	propagate(s, e, x);
    	if (l <= s and e <= r) {
    		lazy[x] = v;
    		t[x] = min(t[x], v);
    	} else if (l <= e and s <= r) {
    		int m = (s+e) / 2;
    		update(s, m, 2*x, l, r, v);
    		update(m+1, e, 2*x+1, l, r, v);
    		t[x] = merge(t[2*x], t[2*x+1]);
    	}
    }
    void update(int l, int r, int v) { return update(0, maxn-1, 1, l, r, v); }
    int query(int s, int e, int x, int p) {
    	propagate(s, e, x);
    	if (s == e) return t[x];
		else {
    		int m = (s+e) / 2;
    		if (p <= m) return query(s, m, 2*x, p);
    		else return query(m+1, e, 2*x+1, p);
    	}
    }
    int query(int p) { return query(0, maxn-1, 1, p); }
} tleft, tup;

int N, Q;

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

	cin >> N >> Q;

	tup.init();
	tup.update(0, N-1, N);
	tup.update(N, N, 1);
	tleft.init();
	tleft.update(0, N-1, N);
	tleft.update(N, N, 1);

	lint ans = (N-2) * (lint)(N-2);
	while (Q--) {
		int t, x;

		cin >> t >> x;

		if (t == 1) { // top
			int now = tup.query(x);
			tup.update(x, x, 1);
			tleft.update(1, now-1, x);
			ans -= now-2;
		} else { // left
			int now = tleft.query(x);
			tleft.update(x, x, 1);
			tup.update(1, now-1, x);
			ans -= now-2;
		}
	}

	cout << ans << '\n';
}

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


public class Main {

	private static final int BIG_NUM  = 2000000000;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int H,W;

		String work[] = new String[2];

		while(true){

			try {
				work = br.readLine().split("[\\s]+");
				if(work[0].equals("0") && work[1].equals("0"))break;

				H = Integer.parseInt(work[0]);
				W = Integer.parseInt(work[1]);

				for(int row = 0; row < H; row++){
					for(int col = 0; col < W; col++){
						System.out.printf("#");
					}
					System.out.printf("\n");
				}

				System.out.printf("\n");

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}




Measured memory_bytes: 61120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    string S, T;
    cin >> S >> T;
    int N = sz(S), M = sz(T);
    int cnt = 0;
    rep(i, N-M+1){
        int tmp = 0;
        rep(j, M){
            if(S[i+j] == T[j]) tmp++;
        }
        chmax(cnt, tmp);
    }
    cout << M-cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<char>> grid(h, vector<char>(w));
    rep(y, h) rep(x, w) cin >> grid[y][x];
    int ans = 0;
    rep(hi, 1 << w) {
        rep(vi, 1 << h) {

            vector<vector<char>> tmp = grid;

            rep(hj, w) {
                if ((hi >> hj) & 1) {

                    rep(y, h) {
                        tmp[y][hj] = 'r';
                    }

                }
            }

            rep(vj, h) {
                if ((vi >> vj) & 1) {
                    rep(x, w) {
                        tmp[vj][x] = 'r';
                    }
                }
            }

            int c = 0;
            rep(y, h) rep(x, w) {
                    if (tmp[y][x] == '#') c++;
                }
            if (c == k) ans++;


        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3640
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

A, B, C, D = LI()
time = [0]*100
time[A:B] = list(map(lambda x: x+1, time[A:B]))
time[C:D] = list(map(lambda x: x+1, time[C:D]))
print(time.count(2))

Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl

typedef complex<int> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()


VP e = {{+1,0}, {0,+1}, {-1,0}, {0,-1}};
string dir[4] = {"R","U","L","D"};

string command(Point cur, Point goal,int arm){
    Point result;
    double min_dist = 2e9;
    int min_dir = -1;
    if(arm == 0){
        if(cur == goal) return "";
        else arm = 1;
    }
    rep(i,4){
        Point nxt = cur + e[i]*arm;
        if (min_dist > abs(goal - nxt)){
            min_dist = abs(goal - nxt);
            result = nxt;
            min_dir = i;
        }
    }
    return dir[min_dir] + command(result, goal, arm/2);
}

int main(void){
    int n;
    cin>>n;
    vector<Point> ps(n);
    set<int> even_odd;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        ps[i] = Point(x,y);
        even_odd.insert((abs(x)+abs(y))&1);
    }
    if(even_odd.size()!=1){
        cout<<-1<<endl;
        return 0;
    }

    vector<string> commands(n);
    rep(i,n){
        commands[i] = command(Point(0,0), ps[i], 1<<30);
    }
    int m = commands[0].size();
    cout<<m<<endl;
    int arm = 1<<30;
    rep(i,m){
        cout<<arm<<(i == m-1 ? "\n": " ");
        arm = arm==1 ? 1 : arm/2;
    }

    rep(i,n){
        assert((int)commands[i].size() == m);
        cout<<commands[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)
	a := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	fmt.Println(a[k-1])
}


Measured memory_bytes: 512
while True:
    Str = list(input())
    if Str[0] == '-':
        break
    m = int(input())
    for i1 in range(m):
        h = int(input())
        for i2 in range(h):
            Str.extend(Str[0])
            Str.remove(Str[0])
    for i in range(len(Str)):
        print(Str[i], end = '')
    print()

Measured memory_bytes: 7792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i = 0;i < n;i++)
  {
    cin>>h[i];
  }
  vector<int> dp(n,1e9+5);
  dp[0] = 0;
  
  for(int i = 0;i < n;i++)
  {
    int p = i;
    for(int j = p+1;j < p+k+1;j++)
    {
      if(j<n)
      {
        dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
      }
    }
  }
  cout<<dp[n-1]<<"\n";
  
  
  
  return 0;
}

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

using namespace std;

int main()
{
    int N;
    while (cin >> N, N) {
        int res = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int sum = j * (2 * i + (j - 1) * 1);
                if (sum == N*2) {
                    res++;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())

ll F(ll n) {
    if ((n + 1) % 4 == 0) {
        return 0;
    } else if((n + 1) % 4 == 1) {
        return 0 ^ n;
    } else if ((n + 1) % 4 == 2) {
        return 1;
    } else {
        return 1 ^ n;
    }
}

void solve(ll A, ll B){
    cout << (F(A - 1) ^ F(B)) << endl;
}

int main() {
    ll A;
    scanf("%lld",&A);
    ll B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main() {
  string s, res="";
  cin >> s;

  for (int i=0; i<s.size(); i++) {
    if (s[i]=='C' || s[i]=='F') res+=s[i];
  }

  cout << (res.find("CF")!=string::npos ? "Yes": "No");
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};


int main(){
  string s;
  cin>>s;
  int n=s.size();
  rep(i,n-1){
    if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
      }
    }
  rep(i,n-2){
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
      }
    }
  cout<<-1<<" "<<-1<<endl;
  return 0;
  }

Measured memory_bytes: 512
#![allow(unused_imports)]
use proconio::input;
use proconio::marker::*;
use std::collections::VecDeque;

fn main() {
  input!{
    n: usize,
    m: usize
  }  
  if n == 1 && m == 1 {
    println!("1");
  } else if n > 1 && m == 1 {
    println!("{}", n - 2);
  } else if m > 1 && n == 1 {
    println!("{}", m - 2);
  } else {
    println!("{}", (n-2)*(m-2));
  }
}

Measured memory_bytes: 2116
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,A = inpl()
x = inpl()
nx = n * max(max(x),A)
dp = [[[0 for _ in range(n+5)] for i in range(nx+1)] for j in range(n+5)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(nx+1):
        for k in range(n):
            if j >= x[i]:
                dp[i+1][j][k+1] = dp[i][j-x[i]][k] + dp[i][j][k+1]
            else:
                dp[i+1][j][k] = dp[i][j][k]

ans = 0
for j in range(1,nx+1):
    for k in range(1,n+1):
        if j/k == A:
            ans += dp[n][j][k]
print(ans)

Measured memory_bytes: 118872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M){
        int u,v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
    }
    int S,T; cin >> S >> T;
    S--; T--;
    int dist[N][3];
    bool visited[N][3];
    rep(i,N)rep(j,3){
        dist[i][j] = -1;
        visited[i][j] = false;
    }
    queue<Pi> q;
    dist[S][0] = 0;
    q.push({S,0});
    while(!q.empty()){
        auto u = q.front().first;
        auto v = q.front().second;
        q.pop();
        for(int to : G[u]){
            int k = (v+1)%3;
            if(visited[to][k]) continue;
            visited[to][k] = true;
            dist[to][k] = dist[u][v]+1;
            q.push({to,k});
        }
    }
    if(dist[T][0] == -1) cout << -1 << endl;
    else cout << dist[T][0]/3 << endl;
}
    



Measured memory_bytes: 7168
#include<iostream>
#define rep(i,n) for(int i=0; i<n;i++)

using namespace std;

int main(){
  int N; cin >> N;
  int ary[N];
  rep(i,N){
    cin >> ary[i];
  }
  int cnt = 0;
  rep(i,N){
    if(ary[i] != i+1) cnt++;
  }
  if(cnt == 0 or cnt == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
$s=substr(<>,0,-1);$t=substr(<>,0,-1);
$n=length($s);$m=length($t);
$ans=10**9;
for($i=0;$i<$n-$m+1;$i++){
	$cnt=0;
	for($j=0;$j<$m;$j++){
		if(substr($s,$i+$j,1) ne substr($t,$j,1)){$cnt++;}
	}
	if($ans>$cnt){
		$ans=$cnt;
	}
}
print $ans

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> N >> M;
   Vec(P,lli,N+1,0);
   Vec(Q,int,N+1,1);
   rep(i,0,M){
      cin >> K;
      Q[K]=0;
   }
   P[0]=1;
   if(Q[1])P[1]=1;
   rep(i,2,N+1){
      if(Q[i])P[i]=(P[i-1]%mod+P[i-2]%mod)%mod;
   }
   Out(P[N]%mod);
}

Measured memory_bytes: 1408
import itertools

while True:
    n, x = [int(e) for e in input().split()]
    if n == 0 and x == 0:
        break
    
    can_list = itertools.combinations(range(1, n + 1), 3)
    
    answer_list = [can for can in can_list if sum(can) == x]
    
    print(len(answer_list))


Measured memory_bytes: 5836
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX 10002
struct edge {
  int s,t,w;
};
int p[MAX];
int root(int x){
    if(p[x]==x)return x;
    return p[x] = root(p[x]);
}

priority_queue <edge, vector<edge>,greater<edge> > que;
bool operator > (const edge a,const edge b){return a.w>b.w;};

int main(){
  int v,e,s,t,w,rs,rt,res=0;
  edge tmp;
  cin>>v>>e;
  for(int i=1;i<v+1;i++)p[i]=i;
  for (int i=0;i<e;i++){
    cin>>tmp.s>>tmp.t>>tmp.w;
    que.push(tmp);
  }
  while(!que.empty()){
    s = que.top().s;
    t = que.top().t;
    w = que.top().w;
    que.pop();
    rs=root(s);
    rt=root(t);
    if(rs==rt)continue;
    p[rs] = rt;
    res += w;
  }
  cout<<res<<endl;
  return 0;
}



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

aa=N//100
bb=N%100

if 1<=aa<=12 and 1<=bb<=12:
    print("AMBIGUOUS")
    
elif (aa==0 or aa>=13) and (bb==0 or bb>=13):
    print("NA")
elif  1<=aa<=12 and (bb==0 or bb>=13):
    print("MMYY")
else:
    print("YYMM")

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

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll dp[100][100001];
int a[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i <= a[0]; i++) dp[0][i] = 1;
    for(int i = 1; i < N; i++){
        ll tmp = 0;
        int l = 0;
        for(int j = 0; j <= K; j++){
            if(l < max(0, j-a[i])) {
                tmp -= dp[i-1][l];
                tmp %= MOD;
                tmp += MOD;
                tmp %= MOD;
                l++;
            }
            tmp += dp[i-1][j];
            tmp %= MOD;
            dp[i][j] = tmp;
        }
    }
    cout << dp[N-1][K] << endl;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main(){

	char s[101];
	int n;
	cin>>n;
	string s2,s3;
	rep(i,n/2){
		cin>>s[i];
		s2+=s[i];
	}
	for(int j=n/2; j<n;j++){
		cin>>s[j];
		s3+=s[j];
	}
	if(s2==s3)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
 	return 0;

}


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

int main() {
	int A, B;
	cin >> A >> B;

	if (A >= 13) {
		cout << B << endl;
		return 0;
	}
	if (A >= 6 && A<=12) {
		cout << B/2 << endl;
		return 0;
	}
	if (A <= 5) {
		cout << 0 << endl;
		return 0;
	}



}

Measured memory_bytes: 256
n = int(input())
a = []
x = 0
x_max = 0
for _ in range(n):
  x = int(input())
#  if x_max 
  a.append(x)

b = a.copy()  
b.sort(reverse=True)
a_max1 = b[0]
a_max2 = b[1] 

for i in a:
  if i == a_max1:
    print(a_max2)
  else:
    print(a_max1)
  


Measured memory_bytes: 14112
function Main(input) {
    var array = input.replace(/\r?\n+$/, '').split(/\s+/).map(Number);

    if ( array[0] == array[1] && array[0] == array[2] ) {
        console.log("1");
    } else if ( array[0] == array[1] || array[0] == array[2] || array[1] == array[2] ) {
        console.log("2");
    } else {
        console.log("3");
    }
}

var character = "";
process.stdin.on('data', function(char){ character += char });
process.stdin.on('end', function(){ Main(character); });
process.on('SIGINT', function() { Main(character); process.exit(0); });

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

//////////////////////////////////////////////////////
// 組み合わせ計算
// あまり大きな数字を入れると桁溢れする
//////////////////////////////////////////////////////
template <typename T>
T comb(T n, T r) {
  // 組み合わせ計算時のかぶっている部分を取り除く
  r = std::min(n - r, r);
  T result = 1;
  T div = 1;
  for (T i = 1; i <= r; ++i) {
    result = (result * (n - i + 1));
    // result = result / i;
    div = div * i;
  }
  return result / div;
}

//////////////////////////////////////////////////////
// 値が大きくなる時の対処用のクラス
// MODの値は適宜調整すること
//////////////////////////////////////////////////////
template <typename T, T MOD>
class mod_int {
 private:
  typedef mod_int<T, MOD> mint;
  constexpr T inverse(T x) {
    T pow = MOD - 2;
    T result = 1;
    while (pow) {
      if (pow & 1) result = result * x % MOD;
      pow >>= 1;
      x = x * x % MOD;
    }
    return result;
  }

 public:
  T val;
  // コンストラクタ
  constexpr mod_int() : val(0) {}
  constexpr mod_int(const mint &o) : val(o.val % MOD) {}
  constexpr mod_int(const T &o) : val(o % MOD) {}

  constexpr mint &operator+=(const mint &o) {
    val = (val + o.val) % MOD;
    return *this;
  }
  constexpr mint &operator-=(const mint &o) {
    val = (val + MOD - o.val) % MOD;
    return *this;
  }
  constexpr mint &operator*=(const mint &o) {
    val = (val * o.val) % MOD;
    return *this;
  }
  constexpr mint &operator/=(const mint &o) {
    val = (val * inverse(o.val)) % MOD;
    return *this;
  }

  constexpr mint &operator++() {
    val = (++val) % MOD;
    return *this;
  }

  constexpr mint &operator--() {
    val = (--val) % MOD;
    return *this;
  }

  constexpr mint operator+(const mint &o) const { return mint(*this) += o; }
  constexpr mint operator-(const mint &o) const { return mint(*this) -= o; }
  constexpr mint operator*(const mint &o) const { return mint(*this) *= o; }
  constexpr mint operator/(const mint &o) const { return mint(*this) /= o; }

  constexpr void operator=(const mint &o) { this->val = o.val; }
  constexpr void operator=(const int i) { this->val = i; }
  constexpr void operator=(const T i) { this->val = i; }

  constexpr bool operator<(const mint &o) const { return val < o.val; }
  constexpr bool operator<=(const mint &o) const { return val <= o.val; }
  constexpr bool operator==(const mint &o) const { return val == o.val; }
};

// ioのオーバーライド
template <typename T, T MOD>
std::istream &operator>>(std::istream &i, mod_int<T, MOD> &o) {
  i >> o.val;
  return i;
}
template <typename T, T MOD>
std::ostream &operator<<(std::ostream &i, const mod_int<T, MOD> &o) {
  i << o.val;
  return i;
}
// 使うクラスのおまじない
typedef mod_int<uint64_t, 1000 * 1000 * 1000 + 7> muint64_t;

int main() {
  int n, k;
  std::cin >> n >> k;

  muint64_t blue = k;
  muint64_t red = n - k;

  for (muint64_t i = 1; i <= k; ++i) {
    std::cout << comb(red + 1, i) * comb(blue - 1, i - 1) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, t = LI()
ans = 0
i = 1
while i*a <= t:
    ans += b
    i += 1
print(ans)

Measured memory_bytes: 65356
S = input()
s = set(S)
if ("N" in s and "S" not in s) \
 or ("S" in s and "N" not in s) \
 or ("W" in s and "E" not in s) \
 or ("E" in s and "W" not in s):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
int n,a[300000];
pii q[300000];
set<pii> S;
int main(){
	scanf("%d",&n);
	for (int i=0;i<1<<n;i++){
		scanf("%d",&a[i]);
		S.insert(pii(a[i],i));
    }
	set<pii>::iterator it;
	it=--S.end();
	q[1]=*it; S.erase(it);
	for (int i=1;i<=n;i++){
		int sz=1<<(i-1);
		sort(q+1,q+sz+1);
		reverse(q+1,q+sz+1);
		for (int j=1;j<=sz;j++){
			it=S.lower_bound(pii(q[j].fi,-1));
			if (it==S.begin())
				return puts("No"),0;
			q[j+sz]=*(--it);
			S.erase(it);
		}
	}
	puts("Yes");
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define ff fflush(stdout)
#define eps 1e-6
#define PI atan(1) * 4
#define mod 1000000007
#define inf 1000000000
using namespace std;
int main () {
	int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%d", &a);
	c = d = e = 0;
	for (i = 1; i <= a; i++) {
		scanf("%d", &b);
		if (!(b & 2) && !(b & 1)) c++;
		else if ((b & 2) && !(b & 1)) d++;
		else e++;
	}
	if (d == 0) {
		f = a / 2;
		if (c >= f) printf("Yes\n");
		else printf("No\n");
	} else {
		f = a - d;
		if (f & 1) f = f / 2 + 1;
		else f = f / 2;
		if (c >= f) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
A,B = map(int,input().split())
if A < 0 or A > 13 or B < 0 or B > 13:
    sys.exit()

if A == 1 or B == 1:
    if A == B:
        print("Draw")
    elif A == 1:
        print("Alice")
    elif B == 1:
        print("Bob")
    sys.exit()

if A > B:
    print("Alice")
elif B > A:
    print("Bob")
else:
    print("Draw")

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

int main(){
    int N;
    int max, min;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++) cin >> A[i];
    max = A[0];
    min = A[0];
    for(int i=1; i<N; i++){
        if(max < A[i]) max = A[i];
        if(min > A[i]) min = A[i];
    }
    cout << abs(max-min) << endl;
}

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

using namespace std;

int a, b, c, d;

int main(){
	cin >> a >> b >> c >> d;
	int i = 0;
	while(true){
		if(i % 2) a -= d;
		else c -= b;
		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}else if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		i++;
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,T;
    cin >> N >> T;
    vector<int> A(N);
    map<int,int> mp;
    int maxd = 0,mini = INF;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        mini = min(mini,A[i]);
        maxd = max(maxd,A[i] - mini);
        mp[A[i]] = i;
    }
    int cnt = 0;
    for(int i = 0;i < N;i++){
        int target = A[i] + maxd;
        if(i < mp[target])cnt++;
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 9984
// ABC132
// A - Fifty-Fifty
#include<bits/stdc++.h>

using namespace std;

int main(){
    string s;
    cin >> s;
    if((s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) ||
        (s[0]!=s[1] && s[0]==s[2] && s[1]==s[3]) ||
        (s[0]!=s[1] && s[0]==s[3] && s[1]==s[2])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#初期値
p1 = [0, 0]
p2 = [100, 0]
input_n = int(input())

def kock(n, p1, p2):
    if n == 0: return
    
    s = [0, 0]
    t = [0, 0]
    u = [0, 0]
    sin60 = (3 ** 0.5) / 2
    cos60 = (1 ** 0.5) / 2

    s[0] = ((2 * p1[0]) + (1 * p2[0])) / 3
    s[1] = ((2 * p1[1]) + (1 * p2[1])) / 3
    t[0] = ((1 * p1[0]) + (2 * p2[0])) / 3
    t[1] = ((1 * p1[1]) + (2 * p2[1])) / 3
    u[0] = (((t[0] - s[0]) * cos60) - ((t[1] - s[1]) * sin60)) + s[0]
    u[1] = (((t[0] - s[0]) * sin60) + ((t[1] - s[1]) * cos60)) + s[1] 

    kock(n-1, p1, s)
    print(f"{s[0]:.8f} {s[1]:.8f}")
    kock(n-1, s, u)
    print(f"{u[0]:.8f} {u[1]:.8f}")
    kock(n-1, u, t)
    print(f"{t[0]:.8f} {t[1]:.8f}")
    kock(n-1, t, p2)

print(f"{p1[0]:.8f} {p1[1]:.8f}")
kock(input_n, p1, p2)
print(f"{p2[0]:.8f} {p2[1]:.8f}")



Measured memory_bytes: 5720
sx, sy, tx, ty = map(int, input().split())

s = ''
s += 'U' * (ty - sy) + 'R' * (tx - sx)
s += 'D' * (ty - sy) + 'L' * (tx - sx)
s += 'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D'
s += 'R' + 'D' * (ty - sy + 1) + 'L' * (tx -sx + 1) + 'U'

print(s)


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <string>
#include <functional>
#include <sstream>
#include <vector>

class cCout
{
public:
    template <class T>
    cCout &operator<<(T v)
    {
        //std::cout << v;
        return *this;
    }
};
cCout cCom;
struct cProc
{
    cProc(std::string t_name, double t_time)
    {
        time = t_time;
        name = t_name;
    }
    cProc()
    {
        time = 0;
        name = "";
    }
    double time;
    std::string name;
};
template<class T>
class cQueue
{
private:
    int64_t max;
    int64_t nQueue;
    int64_t pHead;
    T *pBuff;

public:
    cQueue()
    {
        nQueue = 0;
        max = 1;
        pBuff = new T[1];
        pHead = 0;
    }
    void push(T v)
    {
        if (max <= nQueue)
        {
            int64_t tmax = max * 2 + 1;
            T *tpBuff = new T[tmax];
            int64_t i = 0;
            for (int64_t i = 0; i < nQueue; ++i)
            {
                int64_t io = (pHead + i) % max;
                tpBuff[i] = pBuff[io];
            }
            max = tmax;
            delete[] pBuff;
            pBuff = tpBuff;
            pHead = 0;
        }
        pBuff[(pHead + nQueue) % max] = v;
        ++nQueue;
    }
    T front()
    {
        return pBuff[pHead];
    }
    void pop()
    {
        pHead = (pHead + 1) % max;
        --nQueue;
    }
    void show()
    {
        cCom << "[";
        for (int64_t i = 0; i < nQueue; ++i)
        {
            int64_t iq = (pHead + i) % max;
        }
        cCom << "], " << pHead << " " << nQueue << " " << max << "\n";
    }
    bool empty()
    {
        return 0 == nQueue;
    }
};
#include <queue>
int main(int argc, char *argv[])
{
    cQueue<cProc> oQueue;
    cCom << "version 1.0.1\n";
    int n, q;

    std::cin >> n >> q;
    cCom << n << " " << q << "\n";
    for (int i = 0; i < n; i++)
    {
        double a = 0;
        std::string name;
        std::cin >> name;
        std::cin >> a;
        oQueue.push(cProc(name, a));
    }

    double t = 0;
    std::vector<cProc> vProc;
    while (!oQueue.empty())
    {
        //oQueue.show();
        cCom << " " << t << "\n";

        auto queue = oQueue.front();
        oQueue.pop();
        double dt = q;
        if (queue.time <= dt)
        {
            dt = queue.time;
            queue.time = t + dt;
            vProc.push_back(queue);
        }
        else
        {
            queue.time -= dt;
            oQueue.push(queue);
        }
        t = t + dt;
    }

    for (auto it : vProc)
    {
        std::cout << it.name << " " << it.time << "\n";
    }
    return 0;
}


Measured memory_bytes: 7636
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        d:usize,
        g:i64,
        pc: [(i64, i64); d],
    }
    let mut ans:i64 = 1<<60;
    for i in 0..1<<10 {
        let mut sum:i64 = g;
        let mut cnt:i64 = 0;
        for j in 0..d {
            if i & 1<<j !=0 {
                sum-=(j as i64 + 1)*100*pc[j].0 + pc[j].1;
                cnt+=pc[j].0;
            }
        }
        if sum<0 {
            ans = std::cmp::min(ans, cnt);
            continue;
        }
        for j in (0..d).rev() {
            if i & 1<<j ==0 {
                let cc = std::cmp::min(if sum%((j as i64+1)*100)==0 {sum/((j as i64+1)*100)} else {sum/((j as i64+1)*100) + 1}, pc[j as usize].0);
                cnt+=cc;
                if sum - cc*(j as i64+1)*100 <= 0 {
                    break;
                }else{
                    sum-=cc*(j as i64+1)*100;
                }
            }
        }
        ans = std::cmp::min(ans, cnt);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

typedef long long ll;

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

    int px = 0;
    int py = 0;
    int pt = 0;
    while (N--)
    {
        int t, x, y;
        cin >> t >> x >>y;

        int times = abs(x - px) + abs(y - py) + pt;
        if (times > t || (t - times) % 2 != 0)
        {
            puts("No");
            return 0;
        }

    }
    puts("Yes");

    return 0;
}

Measured memory_bytes: 256