akhauriyash/Code-Regression huggingface dataset:
def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i+1 for i, e in enumerate(XS)} 
n,m=map(int,input().split())
s=[[] for i in range(n+1)]
p=[0]*m
y=[0]*m
for i in range(m):
    p[i],y[i]=map(int,input().split())
    s[p[i]].append(y[i])
for i in range(1,n+1):
    s[i]=compress(s[i])
for i in range(m):
    print("0"*(6-len(str(p[i]))),p[i],"0"*(6-len(str(s[p[i]][y[i]]))),s[p[i]][y[i]],sep="")

Measured memory_bytes: 59052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int n, ans = 1000000;
	cin >> n;
	for (int i = 1;i < n;i++) {
		int b = n - i, a = i, sum = 0;
		while (true) {
			if (b == 0)break;
			sum += b % 10;
			b /= 10;
		}

		while (true) {
			if (a == 0)break;
			sum += a % 10;
			a /= 10;
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S;
  int Q;
  while (cin >> S >> Q) {
    string F, B;
    int flip = 0;
    for (int q = 0; q < Q; q++) {
      int T;
      cin >> T;
      if (T == 1) {
        flip ^= 1;
        swap(F, B);
      } else {
        int w;
        char C;
        cin >> w >> C;
        if (w == 1) {
          F.push_back(C);
        } else {
          B.push_back(C);
        }
      }
    }
    if (flip) reverse(S.begin(), S.end());
    string res = string(F.rbegin(), F.rend()) + S + B;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1348
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {
	int a;
	cin >> a;
if(a >= 1000) cout << "ABD";
  else cout << "ABC";
	return 0;
}


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

int main()
{
  int n, i;
  cin >> n;
  int p[n];
  for(i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  int max = 0;
  int sum = 0;
  int check;
  for(i = 0; i < n; i++)
  {
    if(p[i] > max)
    {
      max = p[i];
      check = i;
    }
  }
  p[check] /= 2;
  for(i = 0; i < n; i++)
  {
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N){
	ll x = -1;
	rep(i, N+1) {
		if (floor(i * 1.08) == N) x = i;
	}
	if (x == -1) cout << ":(" << endl; else cout << x << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()

if n==1:
    print(0)
    exit()

ans = Decimal(str(sum(arr)/n)).quantize(Decimal("0"),rounding=ROUND_HALF_UP)
cnt=0
for i in range(n):
    cnt+=(ans-arr[i])**2

print(cnt)






Measured memory_bytes: 64364
N = input()
s = len(N)
i = 0
count = 0
while i < s - 1:
    count += 9 * (10 ** i)
    i += 2
n = int(N)
if s % 2 == 1:
    count += n - (10 ** (s - 1)) + 1
print(count)

Measured memory_bytes: 3060
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

k,q = map(int, input().split())
d = list(map(int, input().split()))
for i in range(q):
    n,x,mod = map(int, input().split())
    dd = [di%mod if di%mod else mod for di in d]
    a,b = divmod(n-1, k)
    tmp = x%mod + a*sum(dd) + sum(dd[:b])
    print(n-1-tmp//mod)

Measured memory_bytes: 64476
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    rep(i, a + 1) rep(j, b + 1)
    {
        int d = x - 500 * i - 100 * j;
        if (d < 0)
        {
            break;
        }
        if (d % 50 == 0 && d / 50 <= c)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> a(3);
  rep(i,s.size()){
    if(s.at(i)=='R'){
      a.at(0)++;
    }
    if(s.at(i)=='G'){
      a.at(1)++;
    }
    if(s.at(i)=='B'){
      a.at(2)++;
    }
  }
  ll ans=a.at(0)*a.at(1)*a.at(2);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(2*j-i<n && s.at(i)!=s.at(j) && s.at(i)!=s.at(2*j-i) && s.at(j)!=s.at(2*j-i)){
        ans--;
      }
    }
  }  
  cout << ans;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Weight Range
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));

		words = br.readLine().split(" ");

		int[] A = new int[N * 2];
		for (int i = 0; i < N; i++) {
			A[i] = A[i + N] = parseInt(words[i]);
		}

		int lcm = lcm(N, M);
		int ans = 0;

		for (int i = 0; i < lcm; i += M) {
			int[] a = Arrays.copyOfRange(A, i % N, i % N + M);
			Arrays.sort(a);
			ans += a[M - 1] - a[0];
		}

		System.out.println(ans);
	}

	static int gcd(int a, int b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	static int lcm(int a, int b) {
		return a * (b / gcd(a, b));
	}
}

Measured memory_bytes: 32404
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define all(x) (x).begin(),(x).end()

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

int main()
{
	int n,d;
	cin >> n >> d;
	cout << (n+2*d)/(2*d+1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	long long A,B,C,X;
	cin>> A >> B >> C >> X;
	long long count = 0;
	for (int i = 0; i <= A; i++)
		for (int j = 0; j <= B; j++)
			for (int k = 0; k <= C; k++)
				if (i * 500 + j * 100 + k * 50 == X)
					count++;
	cout<< count <<endl;
	return 0;	
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


struct FenwickTree(T) {
    private {
        int _size;
        T[] _data;
    }

    this(int N) {
        _size = N;
        _data = new T[](_size + 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= _size) {
            _data[i] += x;
            i += i & (-i);
        }
    }

    T sum(int r) {
        T res = 0;
        while (r > 0) {
            res += _data[r];
            r -= r & (-r);
        }
        return res;
    }
}

unittest {
    auto ft = FenwickTree!(int)(10);
    ft.add(0, 3);
    ft.add(2, 4);
    ft.add(5, 1);
    assert(ft.sum(0) == 0);
    assert(ft.sum(1) == 3);
    assert(ft.sum(2) == 3);
    assert(ft.sum(3) == 7);
    assert(ft.sum(5) == 7);
    assert(ft.sum(6) == 8);
}



void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]);
    auto as = a.dup.sort();

    bool check(int x) {
        auto b = a.map!(ai => ai <= x ? 1 : 0).array;
        auto s = new int[](N + 1);
        foreach (i ; 1 .. N + 1) {
            s[i] = s[i - 1] + b[i - 1];
        }
        auto ft = FenwickTree!(int)(3*N + 1);
        long cnt;
        foreach (i ; 0 .. N + 1) {
            int p = 2 * s[i] - i + N;
            cnt += ft.sum(p);
            ft.add(p, 1);
        }
        debug {
            writefln("cnt: %s", cnt);
        }
        return 2L * cnt > 1L * N * (N + 1) / 2;
    }

    int ng = -1, ok = N;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        int x = as[mid];
        (check(x) ? ok : ng) = mid;
    }

    auto ans = as[ok];
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

void secondsort(vector<pair<int,int>> &v){
    for(int i=0;i < v.size();i++){
        swap(v.at(i).first,v.at(i).second);
    }
    sort(v.begin(),v.end());
    for(int i=0;i < v.size();i++){
        swap(v.at(i).first,v.at(i).second);
    }
}

int main(){
    int n,ans=0,x;
    cin >> n;
    vector<pair<int,int>> r(n);//赤い点の位置
    vector<pair<int,int>> b(n);

    for(int i=0;i < n;i++){
        cin >> r.at(i).first >> r.at(i).second;
    }
    for(int i=0;i < n;i++){
        cin >> b.at(i).first >> b.at(i).second;
    }//input
    
    sort(r.begin(),r.end());//x座標でソートしておく
    secondsort(b);//青点はy座標で
    
    while(r.size()!=0){//赤点が消えるまで
        bool erased=false;
        vector<int>  rflag(r.size(),0);//可能ペアの個数
        
        for(int i=0;i < r.size();i++){//ある赤点を見て}
            
            for(int j=0;j < b.size();j++){
                if(r.at(i).first < b.at(j).first && r.at(i).second < b.at(j).second){
                    rflag.at(i)++;
                    x=j;    
                }//ある赤点を含む可能ペアの個数をカウント
            }
            
            if(rflag.at(i)==1){//可能ペアが一つだったらペアをつくって消す
                ans++; //cout << r.at(i).first <<b.at(x).first<<endl;
                r.erase(r.begin()+i);
                rflag.erase(rflag.begin()+i);
                i--;
                b.erase(b.begin()+x);
                erased=true;
            }else if(rflag.at(i) == 0){//ペアがない奴はそのまま消去
                r.erase(r.begin()+i);
                rflag.erase(rflag.begin()+i);
                i--;
                erased=true;
            }
        }
        
        if(erased){
            continue;//どれか一つでも赤点を消したときはもう一度見て（可能ペアが一つになってるかも）
        }

        if(r.size()!=0){//残った赤の点は可能ペアを2つ以上持つので
            for(int i=r.size()-1;-1<i;i++){
                for(int j=0;j < b.size();j++){
                    if(r.at(i).first < b.at(j).first && r.at(i).second < b.at(j).second){
                    //cout << r.at(i).first <<':'<<endl;
                    r.erase(r.begin()+i);;
                    b.erase(b.begin()+j);
                    ans++; 
                    goto label;//適当にペア作って繰り返し←ここだめ 
                    //最も右の赤点と、そこから選べる最も下の青点が最適
                    }
                }    
            }    
        }
label:
    continue;
    }
    
    cout << ans << endl;
}

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

int LinearSearch(int numT, int numS, const int S[], const int T[]) {
	int num = 0;
	for (int t = 0; t < numT; t++) {
		for (int s = 0; s < numS; s++) {
			if (S[s] == T[t]) {
				num++;
				break;
			}
		}
	}
	return num;
}

int main() {
	int numS, numT;
	int S[10000], T[500];

	cin >> numS;
	for (int i = 0; i < numS; i++) {
		cin >> S[i];
	}
	cin >> numT;
	for (int i = 0; i < numT; i++) {
		cin >> T[i];
	}

	int num = LinearSearch(numT, numS, S, T);

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 3104
N,K = [int(x) for x in input().split()] 
########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
 

######今回は二進数に変換######
x2 = Base_10_to_n(N, K)
print(len(x2))

Measured memory_bytes: 38256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) {
  cout << N/3 << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
keys = []
for i in range(n):
    keys.append(i+1)
dic = {key: val for key,val in zip(keys,a)}
dic_sorted = sorted(dic.items(),key = lambda x:x[1])
for i in range(n):
    print(dic_sorted[i][0],end=" ")


Measured memory_bytes: 27064
#define mod 1000000007
#define MOD 100000000000000007  //233333333333333333
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-8;
const int N=1e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
inline ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
//int st[4][2]={1,0,0,1,-1,0,0,-1};
//int head[N],tot;
//struct edge{int to,next;}e[N<<1];
//void add(int u,int v){e[tot].to=v;e[tot].next=head[u];head[u]=tot++;}
//unordered_map<int,ll>q;
//map<int,ll>q;
//vector<int>vt[N];
//priority_queue<int>q;
int t,cas;
int n,m,k;
int main()
{
	
	string s;
	map<string,int>q;
	q["SUN"]=7,q["MON"]=6,q["TUE"]=5,q["WED"]=4,q["THU"]=3,q["FRI"]=2,q["SAT"]=1;
	while(cin>>s)
	{
		printf("%d\n",q[s]);
	}
}


Measured memory_bytes: 760
a = 3.times.map { gets.split.map &:to_i }
n = gets.to_i
b = n.times.map { gets.to_i }

s = Hash.new(0)
seen = [[false,false,false],[false,false,false],[false,false,false]]

3.times do |y|
  3.times do |x|
    s[a[y][x]] = [y,x]
  end
end

b.each do |i|
  next unless s.keys.include? i
  y,x = s[i]
  seen[y][x] = true
end

lines = [
  [[0,0],[1,0],[2,0]],
  [[0,1],[1,1],[2,1]],
  [[0,2],[1,2],[2,2]],
  [[0,0],[0,1],[0,2]],
  [[1,0],[1,1],[1,2]],
  [[2,0],[2,1],[2,2]],
  [[0,0],[1,1],[2,2]],
  [[0,2],[1,1],[2,0]]
]

lines.each do |line|
  ans = true
  line.each do |point|
    y,x = point
    ans = false unless seen[y][x]
  end
  if ans
    puts "Yes"
    exit
  end
end

puts "No"


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

int main(){
  int t;
  cin >> t;
  while(t--){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    int a = 0, b = 0;
    for(int i=0;i<n-1;i++){
      a = max(a,h[i+1]-h[i]);
      b = min(b,h[i+1]-h[i]);
    }
    cout << a << " " << -b << endl;
  }
}

Measured memory_bytes: 1196
N=int(input())
a=[int(i) for i in input().split()]

counter = [0]*(10**5+10)
ans = 0
for i in range(N):
#    print('a[i]=')
#    print(a[i])
    if a[i] < 10**5 + 3:
        counter[a[i]] += 1
#        print('hoge')
    else:
        ans += 1
#    print(ans)
for i in range(10**5+3):
    if counter[i] < i:
        ans += counter[i]
 #       print(counter[i])
    else:
        ans += counter[i] - i
 #       print(counter[i]-i)
#    print(ans) 
 
print(ans)

    

    

Measured memory_bytes: 14024
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, m, ps[N];
ll ans;
Map map;

int main() {
    cin >> n >> m;
    map[0] = 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &ps[i]);
        (ps[i] += ps[i - 1]) %= m;
        ans += map[ps[i]];
        map[ps[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n,m,a,b;
    P island[100005];
    cin >> n >> m;
    rep(i,m){
        cin >> a >> b;
        island[i] = P(b,a);
    }
    sort(island,island+m);
    int cnt = 0;
    a = 1;
    rep(i,m){
        if (a <= island[i].second){
            cnt++;
            a = island[i].first;
        }
    }
    PRINT(cnt);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;cin>>N>>M;
    vector<LP> a(N);
    REP(i,N){
        cin>>a[i].first;
        a[i].second=i;
    }
    UnionFind uni(N);
    REP(i,M){
        int x,y;
        cin>>x>>y;
        uni.merge(x,y);
    }
    if(2*(N-M-1)>N){
        cout<<"Impossible"<<endl;
        return 0;
    }
    else if(M==N-1){
        cout<<0<<endl;
        return 0;
    }
    VSORT(a);
    set<int> st;
    ll ans = 0;
    int cnt = 0;
    REP(i,N){
        if(st.count(uni.root(a[i].second))){
            if(cnt<N-M-2) ans+= a[i].first,cnt++;
        }
        else{
            st.insert(uni.root(a[i].second));
            ans += a[i].first;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main(void){
  int i, n;
  cin >> n;
  for(i = 1; i <= 9; i++){
    if(n > i * 9){
      continue;
    }
    if(n%i == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
  
}


Measured memory_bytes: 256
def main():
    N = int(input())
    least_significant_digit = N % 10
    if least_significant_digit in [2, 4, 5, 7, 9]:
        print("hon")
    elif least_significant_digit in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61816
s = input()
p = input()

def get_ring(index):
    global s
    for _ in range(len(s)):
        yield s[index]
        
        if index < len(s) - 1:
            index += 1
        else:
            index = 0
            
for i in range(len(s)):
    if s[i] != p[0]:
        continue
    
    off = 0
    for char in get_ring(i):
        if p[off] != char:
            break
        off += 1
        if off == len(p):
            break
        
    if off == len(p):
        print("Yes")
        break
    
else:
    print("No")


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 200000

class UnionFind{
private:
  std::vector<int> data_array;
public:
 const int root(int id){
    if(data_array[id] >= 0)
      return data_array[id] = root(data_array[id]);
    else
      return id;
  }
  UnionFind(size_t size) : data_array(size,-1){}
  // unionは予約語
  bool union_(int lhs, int rhs){
    lhs = root(lhs);
    rhs = root(rhs);
    bool is_union = (lhs != rhs);
    if(is_union){
      if( data_array[lhs] > data_array[rhs]){  std::swap(lhs,rhs);  }
      data_array[lhs] += data_array[rhs];
      data_array[rhs] = lhs;
    }
    return is_union;
  }
  bool find(int lhs, int rhs){
    return ( root(lhs) == root(rhs) );
  }
};

int N, K, L;

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

	UnionFind ufR( N );
	UnionFind ufT( N );

	for( int i = 0; i < K; i++ ) {
		int p, q;
		cin >> p >> q;
		p--;
		q--;
		ufR.union_( p, q );
	}
	for( int i = 0; i < L; i++ ) {
		int r, s;
		cin >> r >> s;
		r--;
		s--;
		ufT.union_( r, s );
	}

	map< pair<int, int>, int > m;
	for( int i = 0; i < N; i++ ) {
		m[ make_pair( ufR.root( i ), ufT.root( i ) ) ]++;
	}

	for( int i = 0; i < N; i++ ) {
		cout << m[ make_pair( ufR.root( i ), ufT.root( i ) ) ];
		if( i < N - 1 ) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    long long n, k;
    cin >> n >> k;

    // case 1: a < b
    long long ret = (n - k) * (n - k + 1) / 2 - (k == 0 ? n : 0);

    // case 2: a >= b
    for (long long b=k+1; b<=n; b++) {
        long long rem = n % b;
        ret += (n - rem - b) / b * (b - k); // full groups
        ret += max(rem - k + 1, 0LL);   // partial group
    }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t, n, m, s = 0;
    cin >> n >> m;
    vector<lli> v;
    for1(i, 0, n)
    {
        lli k;
        cin >> k;
        v.pb(k);
        s += k;
    }
    sort(all(v));

    lli o = s / (4 * m);
    if (s % (4 * m) == 0)
    {
        o -= 1;
    }
    lli a = v[n - m];
    // cout << o << a << endl;
    if (a > o)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int main(){
 	int x=0;
  	int n;
  	cin>>n;
  int a[n+1];
  int pr=0;
  for(int i=1;i<=n;i++)
    cin>>a[i];
 	int x1=0,x2=0;
  for(int i=1;i<=n-1;i++)
  {
    if(a[i]>a[i+1] and x1==0)
      x1=i;
    else if(a[i]>a[i+1] and x1!=0)
      x2=i+1;
  }
  swap(a[x1],a[x2]);
  for(int i=1;i<=n-1;i++)
   if(a[i]>a[i+1])
     x=1;
  if(x==0)
    puts("YES");
  else puts("NO");
}

Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0;
for i in range(n):
    x = sum(a1[0:n - i]) + sum(a2[n - i - 1: n])
    if(x > ans):
        ans = x;
print(ans)


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

int main(){
  int N,X,m[100];
  cin >> N >> X;
  int Answer,Smallest = 100000; Answer = N;
  for (int i = 0; i < N; i++){
    cin >> m[i];
    X -= m[i];
    if (Smallest > m[i]){
      Smallest = m[i];
    }
  }
  cout << Answer + X/Smallest <<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	string s;
	cin >> s;
	string t = s;
	reverse(t.begin(), t.end());
	int begin, end;
	int x = s.size();
	REP(i, x) {
		if (s[i] == 'A') {
			begin = i;
			break;
		}
	}
	REP(i, x) {
		if (t[i] == 'Z') {
			end = x - i;
			break;
		}
	}
	cout << end - begin << endl;
}



Measured memory_bytes: 772
#include <stdio.h>
#include <math.h>
#include <iostream>
#include<string>
#include<vector>
#include <algorithm>
#define REP(a,b) for (int i = a; i <= (b); i++)
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	if (a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0)) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 1000500
#define mod 998244353
int fr[N],ifr[N],n,m,as;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d%d",&n,&m);
	fr[0]=ifr[0]=1;for(int i=1;i<=m*2;i++)fr[i]=1ll*fr[i-1]*i%mod,ifr[i]=pw(fr[i],mod-2);
	for(int i=0;i<=m;i++)
	{
		if(i*2<m||i<n)continue;
		int s1=i*2-m,s2=m-i+s1-n;
		if(i*2==m)
		{
			as=(as+1ll*fr[m-1]*ifr[i]%mod*ifr[m-1-i])%mod;
			if(s1>=n||m-i-s2-2<0)continue;
			as=(as-1ll*fr[m-1]*ifr[i+s2+1]%mod*ifr[m-i-s2-2]%mod+mod)%mod;
			continue;
		}
		as=(as+1ll*fr[m]*ifr[i]%mod*ifr[m-i])%mod;
		if(s1>=n||m-i-s2-1<0)continue;
		as=(as-1ll*fr[m]*ifr[i+s2+1]%mod*ifr[m-i-s2-1]%mod+mod)%mod;
	}
	printf("%d\n",as);
}//

Measured memory_bytes: 7936
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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


fn main() {
   input!{
      H:i32,
      W:i32,
      X:i32,
      Y:i32,
   }
   if ( ( ( ( H * W ) % 2 ) == 1 ) & ( ( ( X + Y ) % 2 ) == 1 ) ) {
      println!("No")
   } else {
      println!("Yes")
   }
}


Measured memory_bytes: 5024
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


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

  int n;
  string s;

  cin >> n;
  cin >> s;

  int r = 0, b = 0;
  rep(i, n) {
      if (s[i] == 'R') ++r;
      else ++b;
  }

  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Competition
{
    public class Program
    {
        static void Main(string[] args)
        {
            var dg = Console.ReadLine().Split(' ');
            var D = int.Parse(dg[0]);
            var G = long.Parse(dg[1]);
            long[] p = new long[D];
            long[] c = new long[D];
            for (var i = 0; i < D; i++)
            {
                long[] pc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                p[i] = pc[0];
                c[i] = pc[1];
            }
            long res = 1 << 29;
            for(int bit = 0; bit < (1 << D); bit++)
            {
                long sum = 0;
                long num = 0;
                for(int i = 0; i < D; i++)
                {
                    if((bit & (1 << i)) == (1 << i))
                    {
                        sum += c[i] + p[i] * 100 * (i + 1);
                        num += p[i];
                    }
                }
                if (sum >= G)
                {
                    res = Math.Min(res, num);
                }else
                {
                    for (int i = D - 1; i >= 0; i--)
                    {
                        if ((bit & (1 << i)) == (1 << i)) continue;
                        for (int j = 0; j < p[i]; j++)
                        {
                            if (sum >= G) break;
                            sum += 100 * (i + 1);
                            ++num;
                        }
                    }
                    res = Math.Min(res, num);
                }
            }
            Console.WriteLine(res);
        }

    }
}


Measured memory_bytes: 13396
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <algorithm>
// #include "./Debug.h"

namespace AtCoder {
	using Input = std::vector<std::string>;
	using Num = std::vector<int>;

	Input input(void) {
		Input result;
		{
			std::string buf = "", row = "";
			std::getline(std::cin, buf);
			for (unsigned int i = 0; i < buf.size(); i++) {
				if (' ' == buf[i]) {
					result.push_back(row);
					row = "";
				} else {
					row += buf[i];
				}
			}
			result.push_back(row);
		}
		return result;
	}

	Num replaceToInteger(Input original = { "" }) {
		Num result;
		for (unsigned int i = 0; i < original.size(); i++) {
			result.push_back(atoi(original[i].c_str()));
		}
		return result;
	}
}

int main(void) {

	AtCoder::Num s = AtCoder::replaceToInteger(AtCoder::input());

	const int n = s[0];

	int ans = 0;

	if (10 > n) {
		ans = n;
	} else if (100 > n) {
		ans = 9;
	} else if (1000 > n) {
		ans = 9;
		ans += n - 99;
	} else if (10000 > n) {
		ans = 909;
	} else if (100000 > n) {
		ans = 909;
		ans += n - 9999;
	} else {
		ans = 90909;
	}

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

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = sc.nextInt();
    int cnt = 1;
    for (int i = 0; i < N - 1; i++) {
      int C = sc.nextInt();
      if (C >= max) {
        max = Math.max(max, C);
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}


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

#define MAX 500000
#define NIL -2000000001
struct becs{
  int id,key,p,l,r;
};
typedef struct becs node;
node A[MAX];

void inp(int a,int u){
  if(u==NIL  || a==u)return;
  if(A[a].key<A[u].key){
    A[a].p=u;
    inp(a,A[u].l);
    if(A[u].l==NIL)A[u].l=a;
    return;
  }
  else{
    A[a].p=u;
    inp(a,A[u].r);
    if(A[u].r==NIL)A[u].r=a;
    return;
  }
}

void primid(int a){
  if(A[a].l!=NIL)primid(A[a].l);
  printf(" %d",A[a].key);
  if(A[a].r!=NIL)primid(A[a].r);
}

void pripri(int a){
  printf(" %d",A[a].key);
  if(A[a].l!=NIL)pripri(A[a].l);
  if(A[a].r!=NIL)pripri(A[a].r);
}

void find(int a,int u){
  if(a==A[u].key)printf("yes\n");
  else if(a<A[u].key){
    if(A[u].l!=NIL)find(a,A[u].l);
    else printf("no\n");
  }
  else if(a>A[u].key){
    if(A[u].r!=NIL)find(a,A[u].r);
    else printf("no\n");
  }
}

int main(){
  int a,b=0,i,j;
  char c[100];
  scanf("%d",&a);
  for(i=0;i<a;i++){
    A[i].id=A[i].p=A[i].l=A[i].r=NIL;
  }
  for(i=0;i<a;i++){
    scanf(" %s",c);
    if(strcmp(c,"insert")==0){scanf("%d",&A[b].key);A[b].id=b;inp(b,0);b++;}
    else if(strncmp(c,"find",4)==0){
      scanf(" %d",&j);
      find(j,0);
    } 
    else if(strncmp(c,"print",5)==0){primid(0);printf("\n");pripri(0);printf("\n");}
  }
}



Measured memory_bytes: 11492
#include<stdio.h>
int max(int a,int b){
	if(a>b) return a;
	return b;
}
int main(void){
	char s[100100]={0};
	int k;
	int i;
	int n;
	int ok=0,ng=100100,mid;
	scanf("%s",s);
	while(ng-ok>1){
		mid=(ok+ng)>>1;
		if(s[mid]){
			ok=mid;
		}else{
			ng=mid;
		}
	}
	n=ng;
	k=n;
	for(i=1;s[i];i++){
		if(s[i]!=s[i-1]&&max(i,n-i)<=k){
			k=max(i,n-i);
		}
	}
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int N, i, x, l[100000] = {0}, r[100000] = {0};
	do{
		scanf("%d", &N);
	}while(N < 1 || N > 1000);

	for(i = 0; i < N; i++){
		do{
			x = 0;
			scanf("%d%d", &l[i], &r[i]);
		}while(l[i] < 1 || l[i] > r[i] || r[i] > 100000);
	}

	int n = 0;
	for(i = 0; i < N; i++){
		n += r[i] - l[i] + 1;
	}
	printf("%d\n", n);

	return 0;
}

Measured memory_bytes: 896
NT=input()
NT=NT.rstrip().split(" ")
N=int(NT[0])
T=int(NT[1])

cnt=0
sa=0
min=0
max=0

L=input()
L=L.rstrip().split(" ")
min=int(L[0])
for i in range(1,len(L)):
    if int(L[i])<min:
        min=int(L[i])
    s=int(L[i])-min
    if s>sa:
        sa=s
        cnt=1
    elif s==sa:
        cnt+=1
    
    #print(cnt,sa,max,min)
print(cnt)
        
    

Measured memory_bytes: 12068
package main

import ."fmt"

func main() {
	var a,b,c,d int
	Scanf("%d%d%d%d",&a,&b,&c,&d)
	l := a + b
	r := c + d
	if l > r{
		Println("Left")
	}else if l < r{
		Println("Right")
	}else{
		Println("Balanced")
	}
}


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

int main(){
	int N;
  	cin>>N;
  	int *arr = new int[N];
  	for(int i =0;i<N;i++)
		cin>>arr[i];
    sort(arr,arr+N);
  	float val = 0;
  	val = (arr[0]+arr[1])/((float)2);
  	for(int i =2;i<N;i++){
    	val = (val+arr[i])/((float)2);
    }
  	cout<<val<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,m;
  cin>>n>>m;
  int hash[n+1]={0} , tmp[m];
  for(int i=0;i<=n;i++)
    hash[i]=-1;
  int countA=0, countW=0;
  string str[m];
  for(int i=0;i<m;i++)
  {
    cin>>tmp[i]>>str[i];
    if(str[i]=="AC")
    {
      if(hash[tmp[i]]==-1)
      {
        hash[tmp[i]]=i;
        countA++;
      }
    }
  }

  for(int i=0;i<m;i++)
  {
    if(str[i]=="WA")
    {
      if(hash[tmp[i]]!=-1&&hash[tmp[i]]>i)
      {
        countW++;
      }
    }
  }

  cout<<countA<<" "<<countW<<endl;


  
}

Measured memory_bytes: 6528
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a+b==c || b+c==a) || c+a==b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int dist(pair<int, int> &a, pair<int, int> &b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}

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

  vector<pair<int, int>> s(N), c(M);
  for (int i = 0; i != N; ++i) {
    cin >> s[i].first >> s[i].second;
  }
  for (int i = 0; i != M; ++i) {
    cin >> c[i].first >> c[i].second;
  }

  for (int i = 0; i != N; ++i) {
    cout << min_element(begin(c), end(c),
                [&](pair<int, int> &a, pair<int, int> &b) {
                  return dist(a, s[i]) < dist(b, s[i]);
                }
                ) - begin(c) + 1
         << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int odd=n-n/2;
      ld ans=(ld)odd/(ld)n;
      cout<<fixed<<setprecision(8)<<ans;
}
// I never lose. I either win or I learn

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

int main() {
  int N; cin >> N;
  int K; cin >> K;
  vector<int> height(N);
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (height.at(i) >= K) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;

class Program
    {
        static void Main(string[] args)
        {
            string[] val = Console.ReadLine().Split();
            int A = int.Parse(val[0]);
            int B = int.Parse(val[1]);

            var num = new int[3];
            
            num[0] = A + B;

            num[1] = A - B;

            num[2] = A * B;

            int max = num.Max();

            Console.WriteLine(max.ToString());
        }
    }

Measured memory_bytes: 13268
# coding: utf-8
TLE_COST = 1010

N, T = [int(s) for s in input().strip().split()]

cost = TLE_COST
for _ in range(N):
    c, t = [int(s) for s in input().strip().split()]
    if t <= T and c < cost:
        cost = c

if cost != TLE_COST:
    print(cost)
else:
    print("TLE")


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

long long divnum2(long long a){
    long long count = 0;
    while(a != 0 && a % 2 == 0){
        a /= 2;
        count++;
    }
    return count;
}

int main(){

    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    long long ans = 0;
    for(int i = 0; i < N; i++) if(a[i] % 2 == 0) ans += divnum2(a[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384