akhauriyash/Code-Regression huggingface dataset:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7


alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

n = INT()

temp = 26
count = 0

while True:
    count += 1
    if n < temp:
        break
    n -= temp
    temp *= 26

n-= 1

ans = [0]*count
for i in range(count-1, -1, -1):
    kotae = n//(26**i)
    amari = n%(26**i)
    ans[i] = kotae
    n = amari

if ans[-1] == -1:
    ans = ans[:count-1]
for i in range(len(ans)-1, -1, -1):
    print(alp[ans[i]], end="")

Measured memory_bytes: 77388
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
bool second_smaller(const pll& left, const pll& right) {
    return left.second < right.second;
}
#endif


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

    int N, K; cin >> N >> K;
    vi A(N); REP(i, N) cin >> A[i];

    map<int, int> mp;
    REP(i, N) mp[A[i]]++;
    int sz = mp.size();
    if (sz <= K) {
        cout << 0 << endl;
        return 0;
    }

    vector<pii> v;
    for(auto p : mp) v.push_back(pii(p.first, p.second));
    
    sort(v.begin(), v.end(), second_smaller);

    int ans = 0;
    REP(i,sz-K) ans += v[i].second;    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12660
class Dice():
    def __init__(self,rot,Face):
        self.rot= rot
        self.Face = Face
    def Rotate(rot,Face):
        r=len(rot)
        intFace=[int(Face[i]) for i in range(6)]

        for i in range(r):
            Temp=[intFace[i] for i in range(6)]

            if rot[i]== "E":
                intFace[0]=Temp[3]
                intFace[1]=Temp[1]
                intFace[2]=Temp[0]
                intFace[3]=Temp[5]
                intFace[4]=Temp[4]
                intFace[5]=Temp[2]

            elif rot[i]== "W":
                intFace[0]=Temp[2]
                intFace[1]=Temp[1]
                intFace[2]=Temp[5]
                intFace[3]=Temp[0]
                intFace[4]=Temp[4]
                intFace[5]=Temp[3]

            elif rot[i]== "N":
                intFace[0]=Temp[1]
                intFace[1]=Temp[5]
                intFace[2]=Temp[2]
                intFace[3]=Temp[3]
                intFace[4]=Temp[0]
                intFace[5]=Temp[4]

            elif rot[i]== "S":
                intFace[0]=Temp[4]
                intFace[1]=Temp[0]
                intFace[2]=Temp[2]
                intFace[3]=Temp[3]
                intFace[4]=Temp[5]
                intFace[5]=Temp[1]

        return intFace
#returnしてなかったわ インデント幅も注意

Face = input().split()
q=int(input())
intFace=[int(Face[i]) for i in range(6)]
j=0
output=[0 for i in range(q)]
while True:
    if j>=q:
        break
    else:
        rot=""
        faces =input().split()#入力を受け付ける
        #上面を合わせる回転を探す。
        if faces[0]==Face[0]:
            rot=""

        if faces[0]==Face[1]:
            rot+="N"

        if faces[0]==Face[2]:
            rot+="W"

        if faces[0]==Face[3]:
            rot+="E"

        if faces[0]==Face[4]:
            rot+="S"

        if faces[0]==Face[5]:
            rot+="NN"
    dice=Dice(rot,Face)
    tempFace= Dice.Rotate(rot,Face)#上面だけ合ってる
    non_intFace=[f"{tempFace[i]}" for i in range(6)]
    D= ["","NWS","NWSNWS","NWSNWSNWS",] #横に0回～3回回す。
    #前面を合わせる
    for i in range(4):
        temp2=Dice.Rotate(D[i],tempFace)
        if temp2[1]==int(faces[1]):
            finFace=temp2
            break
    output[j]=finFace[2]
    j+=1
for i in range(q):
    print(output[i])



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  
  vector<int> sc[26];
  vector<int> tc[26];  
  string s,t;
  cin >> s >> t;
  bool ok=true;
  int n=s.size();
  rep(i,n){
    int ind=s[i]-'a';
    sc[ind].pb(i);
  }
  for(int i=0; i<26; i++){
    for(int j=0; j<sc[i].size(); j++){
      if(t[sc[i][j]]!=t[sc[i][0]]) ok=false;
    }
  }

  rep(i,n){
    int ind=t[i]-'a';
    tc[ind].pb(i);
  }
  for(int i=0; i<26; i++){
    for(int j=0; j<tc[i].size(); j++){
      if(s[tc[i][j]]!=s[tc[i][0]]) ok=false;
    }
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;

}


Measured memory_bytes: 2824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll H, W; int M; cin >> H >> W >> M;
  vector<int> hc(H,0);
  vector<int> wc(W,0);
  set<pair<int,int>> st;
  rep(i,M){
    int h,w; cin >> h >> w;
    h--;w--;
    hc[h]++;
    wc[w]++;
    st.insert({h,w});
  }
  int wm=0;
  int hm=0;
  rep(i,H) chmax(hm,hc[i]);
  rep(i,W) chmax(wm,wc[i]);
  ll ans = wm+hm-1;
  vector<int> ww,hh;
  rep(i,H) if(hc[i]==hm) hh.pb(i);
  rep(i,W) if(wc[i]==wm) ww.pb(i);
  if(sz(hh)*sz(ww)>1e8) ans++;
  else{
    rep(y,sz(hh)){
      rep(x,sz(ww)){
        if(!st.count({hh[y],ww[x]})){
          ans++;
          cout << ans << endl;
          return 0;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23796
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, i, j, k, a, b, c, ans, p;
	cin >> n;
	vector<int> x(n);
	for (i = 0; i < n; i++) cin >> x[i];

	bool valid = true;
	for (i = 1; i < n; i++) {
		if (x[i] <= x[i - 1]) valid = false;
	}

	if (valid) ans = 1;
	else {
		a = 2; b = n * 2;
		while (a < b) {
			c = (a + b) / 2;
			bool solved = true;

			map<int, int> last, curr;
			last[x[0]] = 0;

			for (i = 1; i < n; i++) {
				if (x[i] > x[i - 1]) {
					swap(last, curr);
					curr[x[i]] = 0;
				}
				else {
					swap(last, curr);
					while (!curr.empty() && (curr.rbegin()->first > x[i])) curr.erase(curr.rbegin()->first);
					p = x[i];
					while (1) {
						curr[p]++;
						if (curr[p] >= c) {
							if (p == 1) {
								solved = false;
								break;
							}
							curr[p] = 0;
							p--;
						}
						else break;
					}
					if (!solved) break;
				}
				swap(last, curr);
			}

			if (solved) b = c;
			else a = c + 1;
		}
		ans = a;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int64_t count = 0;
  int black=0;
  bool start=false;
  int64_t ans = 0;
  int check=1;
  for(int i=0;i<str.size();i++){
    if((str.at(i)=='W')&&(!check)){
      ans+=i-count-black;
      count++; 
    }else if(str.at(i)=='B'){
      if(check){
        black=i;
        check=0;
      }
    }
  }
  cout << ans << endl;    

}



Measured memory_bytes: 640
n = gets.to_i

ab = []
f = Array.new(n+1){[]}
d = Array.new(n+1, 0)
(n-1).times do |i|
    a, b = gets.split.map(&:to_i)
    f[a] << i
    f[b] << i
    ab << [a, b]
    d[a] += 1
    d[b] += 1
end

ans = Array.new(n-1)
que = [d.index(d.max)]
color = Array.new(n+1){[]}
max_color = 0

while x = que.shift
    c = 1

    f[x].each do |i|
        next if ans[i]
        y = ab[i][0] == x ? ab[i][1] : ab[i][0]

        while c == color[x][0]
            c += 1
            color[x].shift
        end

        ans[i] = c
        color[y] << c
        max_color = c if max_color < c
        que << y
        c += 1
    end
end

puts max_color, ans

Measured memory_bytes: 28668
a,b = list(map(int,input().split()))

b_new = ""
a_new = ""

if a<b:
    for i in range(b):
        a_new = a_new + str(a)
    print(a_new)
else:
    for i in range(a):
        b_new = b_new + str(b)
    print(b_new)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define mx 10000000000001000
long long k, a, n;

int main(){
cin >> k;
for(int i =2; i<=50; i++){
    a=k%i;
    if(k/i +1 <=mx){
        cout << i << endl;
        for(int j=1; j<=a; j++){
        cout << i-1 +(k/i) + i - a+1 << " ";}
        for(int j=a+1; j<=i; j++){
            cout << i-1 + (k/i) - a << " ";
        }
    break;
    }
}

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
int main(){
  ll n; cin >> n;
  ll sum = 0;
  for(ll i=1 ; i*i<=n ; i++){
    if((n-i)%i==0 && ((n-i)/i) > i) sum += (n-i)/i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array([[int(x) for x in input().split()] for _ in range(2)])
ans = 0
for i in range(1,N+1):
  #print(A[0,:i],A[1,i-1:])
  ans = max(ans,sum(A[0,:i])+sum(A[1,i-1:]))
print(ans)

Measured memory_bytes: 12492
S = input()
N = len(S)
judge = True
for i in range(len(S)//2):
    if S[i] != S[len(S) - i - 1]:
        judge = False
        break


if judge:        
    for i in range(int((len(S)-1)/2)):
  
        if S[i] != S[int((len(S)-1)/2)- 1 - i]:
            judge = False
            break
        elif S[int((N+3)/2)-1 + i] != S[N-1-i]:
            judge = False
            break

if judge:
    print("Yes")
else:
    print("No")

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

int main() {
    int N; cin >> N;
    map<vector<int>,int> m;
    ll ans=0;
    rep(i,N){
        string S; cin >> S;
        vector<int> data(26);
        rep(j,S.size()){
            int k; k=S[j]-'a';
            data[k]++;
        }
        m[data]++;
    }
    for(auto p:m){
        ll count; count=p.second;
        ans+=count*(count-1)/2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 18944
import itertools
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

odds = []
evens = []
for i in range(n):
    if i%2 == 0:
        odds.append([a[i],i])
        evens.append([b[i],i])
    else:
        odds.append([b[i],i])
        evens.append([a[i],i])

odds = sorted(odds)
evens = sorted(evens)
#print("odss =",odds)
#print("evens =",evens)

inds = [i for i in range(n)]

ans = 10000000000
exist = 0
#print("開始")
half = (n-1)//2 + 1
for v in  itertools.combinations(inds,half):
    #print("start")

    #print(v)
    real_v = [odds[i][1] for i in v]
    #vに入らなかった方を生成する
    real_nokori = []

    for i in range(n):
        if not (evens[i][1] in real_v):
            real_nokori.append(evens[i][1])
    
    nokori = []
    for i in range(n):
        if evens[i][1] in real_nokori:
            nokori.append(i)

    #print(v,nokori)


    moge = 1
    if n%2 == 0:
        for i in range(half):
                if evens[nokori[i]][0] < odds[v[i]][0]:
                    moge = 0
    else:
        for i in range(n-half):
                if evens[nokori[i]][0] < odds[v[i]][0]:
                    moge = 0

    for i in range(half-1):
        if evens[nokori[i]][0] > odds[v[i+1]][0]:
            moge = 0

    if moge != 1:
        continue
    else:
        exist = 1

    tar = []
    for i in range(n):
        if i%2 == 0:
            tar.append(real_v[i//2])
        else:
            tar.append(real_nokori[(i-1)//2])
    dist = 0
    for i in range(n):
        for mo in range(i+1,n):
            if tar[mo] < tar[i]:
                dist += 1
    if dist < ans:
        ans = dist
if exist:
    print(ans)
else:
    print(-1)

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const long long MOD=1e9+7;
signed main(){
	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;
}

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

la = 0

for i in range(n-1):
    tmp = abs(a[i] - a[i+1])
    la = max(la, tmp)
la = max(a[0] + (k-a[n-1]), la)
print(k - la)



Measured memory_bytes: 26444
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int ans = 0;
		int prevB = sc.nextInt();
		int now = 0;
		ans += prevB;

		for(int i = 1; i < n-1 ; i++){
			now = sc.nextInt();
			ans += (int)(Math.min(now,prevB));
			prevB = now;
		}

		ans += prevB;

		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int A[500005],n;
void maxHeapify(int i){
	int l = 2*i;
	int r = 2*i+1;
	int largest;
	if(l<=n && A[l]>A[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r<=n && A[r]>A[largest]){
		largest = r;
	}
	if(largest != i){
		swap(A[i],A[largest]);
		maxHeapify(largest);
	}
}


int main(){
	cin >> n;
	FOR(i,1,n+1)cin>>A[i];
	for(int i=n/2;i>=1;i--){
		maxHeapify(i);
	}
	FOR(i,1,n+1){
		cout << " " << A[i];
	}
	cout << '\n';
}



Measured memory_bytes: 5008
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

vl len;
vl p;

ll dfs(int n,ll x) {
  ll l = len[n];
  
  if(l <= x) return p[n];
  if(x == 0) return 0;
  if((l+1)/2 <= x) {
    ll ans = 0;
    ans += p[n-1];
    ans++;
    ans += dfs(n-1,x-(l+1)/2);
    return ans;
  }
  return dfs(n-1,x-1);
}
  
int main() {
  int N;
  ll X;
  cin >> N >> X;
  len = vl(N+1,1);
  srep(i,1,N+1){
    len[i] = 3 + 2 * len[i-1];
  }
  p = vl(N+1,1);
  srep(i,1,N+1) {
    p[i] = 1 + p[i-1] * 2;
  }
  cout << dfs(N,X) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

int32_t main() {
    IOS;
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-02 04:41:18
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  string s; cin >> s;
  vector<set<int>> vs(26);
  for (int i = 0; i < n; ++i) {
    int pos = s[i] - 'a';
    vs[pos].insert(i);
  }

  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int op; cin >> op;
    if (op == 1) {
      int pos; cin >> pos; --pos;
      char next; cin >> next;
      if (s[pos] == next) continue;
      char cur = s[pos];
      s[pos] = next;
      vs[cur - 'a'].erase(pos);
      vs[next - 'a'].insert(pos);
    } else {
      int ans = 0;
      int l, r; cin >> l >> r; --l; --r;
      for (int j = 0; j < 26; ++j) {
        auto it = vs[j].lower_bound(l);
        if (it == vs[j].end()) continue;
        ans += *it <= r;
      }
      cout << ans << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 24220
use std::io::*;

fn main() {
    let mut stdin = stdin();
    let mut buf: [u8; 6] = [0; 6];
    let _ = stdin.read(&mut buf);
    let s: Vec<char> = buf.into_iter().map(|c| *c as char).collect();
    if s.get(2).unwrap() == s.get(3).unwrap() && s.get(4).unwrap() == s.get(5).unwrap() {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int n;
int g[505][505];

// [l, r)
void rec(int l, int r, int lv){
    if(r-l == 1) return;
    int mid = (l+r)/2;
    for(int i=l;i<mid;i++){
        for(int j=mid;j<r;j++){
            g[i][j] = lv;
            g[j][i] = lv;
        }
    }
    rec(l,mid,lv+1);
    rec(mid,r,lv+1);
    return;
}

int main() {
    cin >> n;
    rec(0,n,1);
    REP(i,n){
        for(int j=i+1;j<n;j++){
            cout << g[i][j] << " \n"[j==n-1];
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define lli                      int long long
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define mp                       make_pair
#define all(v)                   v.begin(),v.end()
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define sort(t)                  sort(t.begin(),t.end())
#define mem(a,b)                 memset(a,b,sizeof a)
#define t_c(t)                          for(int z=1;z<=t;z++)
#define p_c                             printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define sf                       scanf
#define pf                       printf
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define MX                       10000005
#define inf                      10000000000000000+7
#define M                        1000000002
#define MINI                     -1000000003
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//int kx[]={+2,+2,-2,-2,+1,+1,-1,-1};     //Knights move
//int ky[]={+1,-1,+1,-1,+2,-2,+2,-2};     //Knights move


//#define for(i,a,n)    for(int i=a;i<n;i++)
//it=myset.find(20);
//int a[8]= {0,0,-1,1,-1,1,-1,1};
//int b[8]= {-1,1,0,0,-1,1,1  ,-1};


int main()
{
    int i,j,n,a;
    cin>>n;
    cin>>a;
    int g=a;
    for(i=1;i<n;i++)
    {
       cin>>a;
       g=gcd(g,a);
    }
    cout<<g<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t H, W;
	if (scanf("%" SCNu64 "%" SCNu64, &H, &W) != 2) return 1;
	if (H == 1 || W == 1) {
		puts("1");
	} else if (H % 2 == 0) {
		printf("%" PRIu64 "\n", (H / 2) * W);
	} else if (W % 2 == 0) {
		printf("%" PRIu64 "\n", (W / 2) * H);
	} else {
		uint64_t mareitaso = ((H / 2) + (H / 2 + 1)) * (W / 2);
		if (W % 2 != 0) {
			mareitaso += H / 2 + 1;
		}
		printf("%" PRIu64 "\n", mareitaso);
	}
	return 0;
}


Measured memory_bytes: 1704
#include<stdio.h>
#include<string.h>
char s[11];
int main()
{
    gets(s);
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') //这判断没什么好说的
    printf("Yes\n");//回车。。。
    else 
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Nmax = 1000000;

int main() {
    ll n;
    cin >> n;

    vector<ll> v;  // nの約数を入れるvector

    for(ll i = 1LL; i*i <= n; i++) {
        if(n%i == 0) {
            v.push_back(i-1);
            if(i*i != n) {
                v.push_back(n/i - 1);
            }
        }
    }

    ll ans = 0;
    rep(i, v.size()) {
        if(v[i] != 0) {
            ll a = n/v[i];
            ll b = n%v[i];
            if(a == b) {
                ans += v[i];
            }
        }
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll m=1e9+7;
ll power(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1) res=(res*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return res;
}
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int c=0,d1,d2,f=0;
		for(int i=0;i<n;i++)
		{
			cin>>d1>>d2;
			if(d1==d2) c++;
			else c=0;
			if(c>=3) f=1;
		}
		if(f) cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 3652
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var ary = ToIntArray(input.ReadLine(), n);

        long c = 0;

        foreach(var a in ary) {
            if (a % 2 == 1) continue;
            var ax = a;
            while(ax % 2 == 0) {
                ax /= 2;
                c++;
            }
        }

        return c;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

int main() {
    int n, m, s, c;
    cin >> n >> m;
    bool flag=true;
    vector<int> a(9,-1);
    for(int i=0; i<m; i++) {
        cin >> s >> c;
        if(s==1 && c==0 && n != 1) {
            flag=false;
            break;
        }
        else if(a.at(s-1) != -1 && a.at(s-1) != c) {
            flag=false;
            break;
        }
        else a.at(s-1)=c;
    }
    if(flag) {
        for(int i=0; i<n; i++) {
            if(a.at(i) != -1) cout << a.at(i);
            else if(i==0 && n != 1) cout << "1";
            else cout << "0";
        }
    }
    else cout << -1;
}

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

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main()
{
  int n, m;
  int C[MMAX + 1];
  int T[NMAX + 1];

  cin >> n >> m;

  for (int i = 1; i <= m; i++)
  {
    cin >> C[i];
  }
  for (int i = 0; i <= NMAX; i++)
  {
    T[i] = INFTY;
  }

  T[0] = 0;
  for (int i = 1; i <= m; i++)
  {
    for (int j = 0; j + C[i] <= n; j++)
    {
      T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
    }
  }

  cout << T[n] << endl;

  return 0;
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#include <atcoder/convolution>

int main(){
    using namespace std;
    cout << []{
        using fp = atcoder::static_modint<998244353>;
        const unsigned long N{[]{unsigned long ret; cin >> ret; return ret;}()};
        const auto semifact{[&N]{
            vector<fp> ret(N + 1);
            ret[0] = 1;
            for(unsigned long i{1}; i <= N; ++i)ret[i] = ret[i - 1] * (2 * i - 1);
            return ret;
        }()};
        vector<fp> r{[&N, &semifact]{
            const auto fact{[&N]{
                vector<fp> ret(2 * N + 1);
                ret[0] = 1;
                for(unsigned long i{1}; i <= 2 * N; ++i)ret[i] = ret[i - 1] * i;
                return ret;
            }()};
            const auto ifact{[&N, &fact]{
                vector<fp> ret(2 * N + 1);
                ret.back() = 1 / fact.back();
                for(unsigned long i{2 * N}; i--; )ret[i] = ret[i + 1] * (i + 1);
                return ret;
            }()};
            const auto& binom{[&fact, &ifact](const unsigned long n, const unsigned long r) -> fp {
                return ifact[r] * ifact[n - r] * fact[n];
            }};
            const auto& comp{[](const vector<fp>& a, const vector<fp>& b) -> bool {
                return a.size() > b.size();
            }};
            priority_queue<vector<fp>, vector<vector<fp>>, decltype(comp)> pq(comp, [&N, &binom, &semifact]{
                vector<unsigned long> hist(100000);
                for(unsigned long i{0}, h; i < 2 * N; ++i){
                    cin >> h;
                    ++hist[h - 1];
                }
                vector<vector<fp>> ret{{1}};
                for(const auto& i : hist)if(i > 1){
                    const auto& sz{i / 2 + 1};
                    vector<fp> tmp(sz);
                    for(unsigned long j{0}; j < sz; ++j)tmp[j] = binom(i, 2 * j) * semifact[j];
                    ret.emplace_back(move(tmp));
                }
                return ret;
            }());
            while(pq.size() > 1){
                vector<fp> f{pq.top()};
                pq.pop();
                vector<fp> g{pq.top()};
                pq.pop();
                pq.emplace(atcoder::convolution(move(f), move(g)));
            }
            return pq.top();
        }()};
        fp ret{0};
        for(unsigned long i{size(r)}; i--;)ret = r[i] * semifact[N - i] - ret;
        return ret.val();
    }() << endl;
    return 0;
}


Measured memory_bytes: 6376
import java.util.Scanner;

class Main{

public static int area(int x, int y) {
	return x* y;
	}
public static int perimeter(int x, int y) {
	return x + x + y + y;
	}
	
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int p = scanner.nextInt();
int q = scanner.nextInt();

System.out.println(area(p,q) + " " + perimeter(p,q));
}
}



Measured memory_bytes: 26120
#include <iostream>
#include <algorithm>

using namespace std;

#define ll long long

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

    ll a, b, n;
    cin >> a >> b >> n;
    cout << (a * min(b - 1, n)) / b << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    int road[n] = {};
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        road[a[i]-1]++;
        road[b[i]-1]++;        
    }
    for (int i = 0; i < n; i++) {
        cout << road[i] << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
  int i,j,n;
  char s[27];
  scanf("%s",s);
  n=strlen(s);
  for (i=0; i<n; i++) {
    for (j=i+1; j<n; j++) {
      if (s[i]==s[j]) {
        printf("no\n");
        return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long r;
    cin >> r;
    cout << 3*r*r << endl;
}

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

using namespace std;

bool isprime(long long n){
    if(n==1)return false;
    else
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}

int main(){
    long long n;
    cin>>n;
    while(!isprime(n)){
        n++;
    }
    cout<<n;
	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 締切の近いものから詰め込む

import numpy as np

N = int(readline())
AB = np.array(read().split(),np.int64)

A = AB[::2]; B = AB[1::2]

ind = B.argsort(); A = A[ind]; B = B[ind]

answer = 'Yes' if np.all(A.cumsum() <= B) else 'No'
print(answer)

Measured memory_bytes: 36448
#include <cstdio>
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
	int alph[26];
	for(int i = 0; i < 7; i++){
		alph[i] = 0;
	}
	for(int i = 7; i < 16; i++){
		alph[i] = 1;
	}
	for(int i = 16; i < 20; i++){
		alph[i] = 0;
	}
	alph[20] = 1;
	alph[21] = 0;
	alph[22] = 0;
	alph[23] = 0;
	alph[24] = 1;
	alph[25] = 0;
	int cnt=0, j=0, k=-1;
	while(1){
		j = getchar();
		if(j == '#'){
			break;
		} else if(j == '\n'){
			cout << cnt << endl;
			cnt = 0;
			j = 0;
			k = -1;
		} else {
			int l;
			l = j - 'a';
			if(k == -1){
				k = alph[l];
			}
			else if(k != alph[l]){
				cnt++;
				k = alph[l];
			}
		} 
	}
	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double

using namespace std;

int main()
{
    fastio;

    ll n;
    cin >> n;

    vector<ll> a(n);

    for(ll i=0;i<n;i++) cin >> a[i];

    ll cost = INT_MAX;
    for(ll i=-100;i<101;i++){
        ll temp = 0;
        for(ll j=0;j<n;j++){
            temp += (a[j]-i)*(a[j]-i);
        }
        cost = min(cost, temp);
    }

    cout << cost;

    return 0;
}

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


ans, r = 0, 0
SUM, XOR = 0, 0

for l in range(N):
    while (r < N) and (SUM + A[r] == XOR ^ A[r]):
        SUM += A[r]
        XOR ^= A[r]
        r += 1

    ans += (r - l)
    SUM -= A[l]
    XOR ^= A[l]

print(ans)


Measured memory_bytes: 24584
# S H C D

ary = Array.new(52)
n = gets.chomp.to_i
# for i in 0..52 do
#   ary[i] = false
# end
for i in 0..n do
  if i != 0

    str = gets.chomp.split(" ")
    case str[0]
    when "S"
      ary[0  + str[1].to_i] = true
    when "H"
      ary[13 + str[1].to_i] = true
    when "C"
      ary[26 + str[1].to_i] = true
    when "D"
      ary[39 + str[1].to_i] = true
    end
  end
end

for i in 1..52 do
  if  ary[i] != true

    case ( (i - 1) / 13)
    when 0
      puts "S " + (i).to_s
    when 1
      puts "H " + (i - 13).to_s
    when 2
      puts "C " + (i - 26).to_s
    when 3
      puts "D " + (i - 39).to_s
    end
  end
end


Measured memory_bytes: 6876
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int index,i;
        int temp;
        int min = 0;
        int max = 0;
        long sum = 0;
        
        i = 0;
        
        index = scanner.nextInt();
        temp = scanner.nextInt();
        
        min = temp;
        max = temp;
        sum += temp;
        i++;
        
        while(i < index){
            
            temp = scanner.nextInt();
            
            if(temp < min){
                min = temp;
            }
            if(temp > max){
                max = temp;
            }
            
            sum += temp;
            i++;    
        }
        System.out.println(min + " " + max + " " + sum);
    }
}


Measured memory_bytes: 42036
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int q=sc.nextInt();
		int[] a=new int[n];
		int sum=0;
		for(int i=0; i<q; i++){
			int b=sc.nextInt()-1;
			sum++;
			a[b]++;
		}
		for(int i=0; i<n; i++){
			if(a[i]-sum<=-k){
				System.out.println("No");
			}else{
				System.out.println("Yes");
			}
		}
	}
}


Measured memory_bytes: 67380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vi T(N), A(N);
    cin >> T >> A;
    vector<bool> checkT(N, false), checkA(N, false);
    checkT[0] = true;
    for (int i = 1; i < N; i++) if (T[i - 1] != T[i]) checkT[i] = true;
    checkA[N - 1] = true;
    for (int i = N - 2; i >= 0; i--) if (A[i] != A[i + 1]) checkA[i] = true;
    int ans = 1;
    for (int i = 0; i < N; i++) {
        if ((checkT[i] && T[i] > A[i]) || (checkA[i] && A[i] > T[i])) {
            cout << 0 << endl;
            return 0;
        }
        if (!(checkA[i] || checkT[i])) ans = (ans * min(T[i], A[i])) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
dic = {n:0 for n in range(1,N+1)}

for i in range(K):
    d = int(input())
    A = inputlist()
    for j in range(d):
        dic[A[j]] +=1
ans= 0
for i in range(1,N+1):
    if dic[i] == 0:
        ans +=1
print(ans)

Measured memory_bytes: 9140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		int A = GetInt();
		int B = GetInt();
		Console.WriteLine(Math.Min(N * A, B));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

#define H 100
#define W 100

char board[H][W];

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

	for( int i = 0; i < H/2; i++ ) {
		for( int j = 0; j < W; j++ ) {
			board[i][j] = '#';
		}
	}

	for( int i = H/2; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			board[i][j] = '.';
		}
	}

	for( int i = 0; i < H/2; i += 2 ) {
		for( int j = 0; j < W; j += 2 ) {
			a--;
			if( a <= 0 ) {
				break;
			}
			board[i][j] = '.';
		}
	}

	for( int i = H/2 + 1; i < H; i += 2 ) {
		for( int j = 0; j < W; j += 2 ) {
			b--;
			if( b <= 0 ) {
				break;
			}
			board[i][j] = '#';
		}
	}

	cout << H << " " << W << endl;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			cout << board[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.text.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String msg = "No";
		int N = sc.nextInt();
		int array[] = new int[N];
		int count = 0;
		for (int i = 0; i < N; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if (i == 0) {
				count++;
				continue;
			}
			for (int j = i - 1; j >= 0; j--) {
				if (array[i] < array[j]) {
					break;
			} else if(j == 0) {
						count++;
				}
			}
		}
		
		
		System.out.println(count);
	}
}

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

using ll = long long;
using cd = complex<double>;

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

    int n, ret = 0;
    cin >> n;

    for(int i = 1; i < n; ++i)
        if(i < n - i)
            ++ret;

    cout << ret << endl;




    return 0;
}



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

#define ll long long
#define ld long double
#define ull unsigned long long

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    string O, E;
    cin >> O >> E;
    int n = O.size(), m = E.size();

    for (int i = 0; i < m; ++i)
    {
        cout << O[i] << E[i];
    }
    if (n > m)
        cout << O[n - 1];
    cout << '\n';

    return 0;
}

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

using namespace std;
typedef long long ll;

struct jie
{
    int x,w;
}mp[100005];
int a[100005],b[100005];
int main()
{
    int n,l,T,ans=0,i;
    scanf("%d %d %d",&n,&l,&T);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&mp[i].x,&mp[i].w);
    }
    for(i=0;i<n;i++)
    {
        if(mp[i].w==1)
        {
            ans+=(mp[i].x+T)/l;
        }
        else
        {
            ans+=(mp[i].x-T)/l;
            if((mp[i].x-T)%l<0)
            {
                ans--;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        if(mp[i].w==1)
        {
            a[i]=(mp[i].x+T)%l;
        }
        else
        {
            a[i]=((mp[i].x-T)%l+l)%l;
        }
    }
    sort(a,a+n);
    ans=(ans%n+n)%n;
    for(i=ans;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    for(i=0;i<ans;i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;

    cout<<min(N,K)*X+max(0ll,N-K)*Y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
long long ans;
int x;

int main () {
    scanf("%d", &x);

    ans += 1000LL * (x / 500);
    x %= 500;
    ans += 5 * (x / 5);

    cout << ans << endl;
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
heights = list(map(int, input().split()))
flags = [True] * n
count = 0
for _ in range(m):
  roots = list(map(int, input().split()))
  if heights[roots[0] - 1] > heights[roots[1] - 1]:
    flags[roots[1] - 1] = False
  elif heights[roots[0] - 1] < heights[roots[1] - 1]:
    flags[roots[0] - 1] = False
  else:
    flags[roots[1] - 1] = False
    flags[roots[0] - 1] = False
for flag in flags:
  if flag:
    count += 1
print(count)

Measured memory_bytes: 20000
import java.math.BigDecimal;
import java.util.Scanner;
 
public class Main {    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = "1";
        BigDecimal biga = new BigDecimal(s);
        BigDecimal one = new BigDecimal(s);
        String[] array = new String[n];
        for(int i=0;i<n;i++){
            array[i] = sc.next();
            if(array[i].equals("0")){
                System.out.println(0);
                sc.close();
                return;
            }
        }
        for(int i=0;i<n;i++){
            BigDecimal bigb = new BigDecimal(array[i]);
            biga = biga.multiply(bigb);
            if(biga.subtract(one).toString().length()>18){
                System.out.println(-1);
                sc.close();
                return;
            }
            biga.add(one);
        }
        String aa = biga.toString();
        long bb = Long.parseLong(aa);
        System.out.println(bb);
        sc.close();
    }
}

Measured memory_bytes: 65548
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;


int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(w+2,vector<int>(h+2));
    int sum=0;
    rep(i,h){
        rep(j,w) {
            cin >> a.at(j+1).at(i+1);
            sum+=a.at(j+1).at(i+1);
        }
    }
    queue<pair<pair<int,int>,pair<int,int>>> q;
    pair<pair<int,int>,pair<int,int>> v;
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
            if (a.at(j).at(i)%2==1 && j!=w){
                v.first.first=i;v.first.second=j;
                v.second.first=i;v.second.second=j+1;
                a.at(j+1).at(i)+=1;
                q.push(v);
            }
            if (a.at(j).at(i)%2==1 && j==w && i!=h){
                v.first.first=i;v.first.second=j;
                v.second.first=i+1;v.second.second=j;
                a.at(j).at(i+1)+=1;
                q.push(v);
            }
        }
    }
    cout << q.size() << endl;
    while(!q.empty()){
        v=q.front();
        q.pop();
        cout << v.first.first << " " << v.first.second << " " << v.second.first << " " << v.second.second << endl;
    }
}


Measured memory_bytes: 5120