akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

#define NUM 2147483647

int N;
int* table;

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = min(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_min = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N,Q,command,left,right;
	table = new int[500000];
	N = 1;

	scanf("%d %d",&first_N,&Q);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			update(left,right);
		}else{
			printf("%d\n",query(left,right,0,0,N-1));
		}
	}

	return 0;
}

Measured memory_bytes: 3732
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;

void main(){
	auto num_str = readln.chop;
	auto check_tri = (string target){
		return target[0] == target[1] && target[1] == target[2];
	};
	auto answer = check_tri(num_str[0..3]) || check_tri(num_str[1..4]) ? "Yes" : "No";
	writeln(answer);
}

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

using namespace std;
typedef long long LL;

const int N=2e5+10;

struct Node
{
	int x,y;
	Node (int x=0,int y=0):x(x),y(y){}
	bool operator < ( const Node &A ) const { return x<A.x || (x==A.x && y<A.y); }
}P[N],Q[N<<1];

int n,Mx,Mn;

void Init()
{
	scanf("%d",&n);
	Mx=-1e9-10,Mn=1e9+10;
	for (int i=1;i<=n;++i)
	{
		scanf("%d%d",&P[i].x,&P[i].y);
		if (P[i].x>P[i].y) swap(P[i].x,P[i].y);
		Mx=max(P[i].y,Mx); Mn=min(P[i].x,Mn);
	}
}

int app[N],cnt;

void Add(int pos,int v)
{
	if (app[pos]) cnt--;
	app[pos]+=v;
	if (app[pos]) cnt++;
}

bool Can(int pos)
{
	if (cnt!=n) return 0;
	if (app[pos]>1) return 1;
	else return 0;
}

void Solve()
{
	int XMx=Mx,XMn=Mx,YMx=Mn,YMn=Mn;
	for (int i=1;i<=n;++i)
		XMn=min(XMn,P[i].y),YMx=max(YMx,P[i].x);
	LL ans=1ll*(XMx-XMn)*(YMx-YMn);
	int top=0;
	for (int i=1;i<=n;++i) Q[++top]=Node(P[i].x,i),Q[++top]=Node(P[i].y,i);
	sort(Q+1,Q+top+1);
	int h=1;cnt=0;
	for (int i=1;i<=top;++i)
	{
		Add(Q[i].y,1);
		while (Can(Q[h].y)) Add(Q[h].y,-1),++h;
		if (cnt==n) ans=min(ans,1ll*(Mx-Mn)*(Q[i].x-Q[h].x));
	}
	printf("%lld\n",ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, a, b;
	cin>>n>>a>>b;
	if(a>b || (n==1&&a!=b)) cout<<0<<endl;
	else cout<<(n-1)*b+a-(b+(n-1)*a)+1<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 呼び出し
func main() {
	// 共通
	sc := NewScanner()

	// *** NextInt
	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()
	d := sc.NextInt()
	e := sc.NextInt()

	fmt.Println(ka(a)+ka(b)+ka(c)+ka(d)+ka(e)+kb(a,b,c,d,e))
}

// ======================= 以下ライブラリ ========================

// *** int
func ka(n int) int {
	a := n%10
	return n - a
}

func kb(a,b,c,d,e int) int{
	aa := a%10
	bb := b%10
	cc := c%10
	dd := d%10
	ee := e%10

	ls := []int{aa,bb,cc,dd,ee}
	sort.Ints(ls)

	count := 0
	for i:=0; i<5; i++{
		if ls[i] != 0 && count == 0{
			count += ls[i]
		} else if ls[i] != 0 && count > 0 {
			count += 10
		}
	}

	return count
}

func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

// *** int64
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

// **** float
func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

// *** []int 一行読み取って
func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

// *** string 一行読み読み取って
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}


// ====================以下共通部分==================================
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}

func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}

func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

Measured memory_bytes: 640
N = int(input()) 
s = [input().split() for i in range(3)]

A = [int(i) for i in s[0]]
B = [int(i) for i in s[1]]
C = [int(i) for i in s[2]]

sum1 = sum(B)

for i in range(N-1):
    if (A[i] + 1) == A[i+1]:
        sum1 += C[A[i]-1]


print(sum1) 



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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;


inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);

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

/*bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/

template<class T> inline T gcd(T a,T b)//NOTES:gcd(   __gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

const int MAX_N = 2345;

int main() {
    int R,G;
    scanf("%d%d",&R,&G);
    printf("%d\n",2*G-R);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N; cin>>N;
    string S; cin>>S;
    int mx=0;;
    for(int i=1;i<N;i++){
        int ans =0;
        map<char,int>mp1;
        map<char,int>mp2;
        for(int j=0;j<i;j++){
            mp1[S[j]]++;
        }
        for(int k=i;k<N;k++){
            mp2[S[k]]++;
        }
        for(auto p:mp1){
            for(auto q:mp2){
                if(p.first==q.first)ans++;
            }
        }
        mx =max(ans,mx);
    }
    cout<<mx<<endl;

}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    a.at(i) -= i + 1;
  }
  
  sort(a.begin(), a.end());
  
  ll b;
  if(n % 2 == 1) b = a.at(n / 2);
  else b = (a.at(n / 2 - 1) + a.at(n / 2)) / 2;
  
  ll ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a.at(i) - b);
  }
  
  ll keep = 0;
  b++;
  for(int i = 0; i < n; i++){
    keep += abs(a.at(i) - b);
  }
  ans = min(ans, keep);
  
  keep = 0;
  b -= 2;
  for(int i = 0; i < n; i++){
    keep += abs(a.at(i) - b);
  }
  ans = min(ans, keep);
  
  cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N;
  cin>>N;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin>>v[i];
  ll t = 2;
  ll ans = 0;
  for(ll i = 0; i < N; i++){
    if(i==0) ans+=v[i]-1;
    else{
      ans+=(v[i]-1)/t;
      if(v[i]==t) t++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int x,y;
    cin>>n;
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            rep(k,1,n+1)
            {
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum;
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest);
        res%=rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};

signed main(){
  int k;cin>>k;
  string s;cin>>s;
  int l=s.size();
  Nums lib(l+k+10);
  int res=0;
  rep1(i,l+k){
    if(i<l)continue;
    int buf=1;
    buf*=lib.myPow(25,i-l,MOD);
    buf%=MOD;
    buf*=lib.myPow(26,l+k-i,MOD);
    buf%=MOD;
    buf*=lib.comb(i-1,l-1,MOD);
    buf%=MOD;
    res+=buf;
    res%=MOD;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 21656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int n, a, b, c; cin >> n >> a >> b >> c;
  vi target = {a, b, c};
  vi arr(n);
  rep(i,n) cin >> arr[i];

  int ans = 1e4;
  rep(tmp,(1<<(2*n))) {
    bitset<16> s(tmp);

    vi cnt(4, 0), sum(4, 0);
    rep(i,n) {
      int j = s[2*i] + 2 * s[2*i+1];
      ++cnt[j];
      sum[j] += arr[i];
    }
    if (cnt[0] * cnt[1] * cnt[2] == 0) continue;

    int mp = 0;
    rep(i,3) {
      mp += 10 * (cnt[i] - 1);
      mp += abs(sum[i] - target[i]);
    }
    ans = min(ans, mp);
  }
  
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
bool eq(double a, double b) { return fabs(a - b) < EPS; }

struct point
{
	double x, y;
	point(double x = 0, double y = 0) :x(x), y(y) {};

	point operator + (point p) { return point(x + p.x, y + p.y); }
	point operator - (point p) { return point(x - p.x, y - p.y); }
	point operator * (double s) { return point(x * s, y * s); }
	point operator / (double s) { return point(x / s, y / s); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator < (const point &p) const
	{
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const point &p) const
	{
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};

double dot(point a, point b)
{
	return a.x*b.x + a.y*b.y;
}

double cross(point a, point b)
{
	return a.x*b.y - a.y*b.x;
}

int ccw(point a, point b, point c)
{
	b = b - a; c = c - a;
	if (cross(b, c) > EPS) return 1;//???????¨????????????????a,b,c??¨?????¶
	if (cross(b, c) < -EPS) return -1;//???????¨????????????????a,c,b??¨?????¶
	if (dot(b, c) < 0) return 2;//??´?????????c,a,b??????????????¶
	if (b.norm() < c.norm()) return -2;//??´?????????a,b,c??????????????¶
	return 0;//??´?????????a,c,b??????????????¶
}

struct line
{
	point a, b;
	line(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0) :a(point(x1, y1)), b(point(x2, y2)) {};

	point univec() { return (b - a) / (b - a).norm(); }
};

bool isis_ss(line s, line t)
{
	return (ccw(s.a, s.b, t.a)*ccw(s.a, s.b, t.b) <= 0 &&
			ccw(t.a, t.b, s.a)*ccw(t.a, t.b, s.b) <= 0);
}

int main()
{
	int q;
	cin >> q;
	while (q--)
	{
		int a[8];
		REP(i, 8) cin >> a[i];
		line s(a[0], a[1], a[2], a[3]);
		line t(a[4], a[5], a[6], a[7]);
		if (isis_ss(s, t)) puts("1");
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 1108
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

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

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

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    bool flag = false;
    Rep(i,n){
        cin >> a[i];
        if(a[i]%2!=0){
            flag = true;
        }
    }
    if(flag){
        cout << "first" << endl;
    }
    else{
        cout << "second" << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;


int Input[200100];
int Temp[200100];
int Ans[200100];

// Enumerate divisors
void enum_div(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      Temp[i] = (Temp[i] + 1) % 2;
      if (i * i != n) {
        res.push_back(n/i);
        Temp[n/i] = (Temp[n/i] + 1) % 2;
      }
    } 
  }
  // sort(res.begin(), res.end());
  // return res;
}


int main(){
  int N; cin >> N;
  
  memset(Input, 0, sizeof(Input));
  memset(Ans, 0, sizeof(Ans));
    
  for (int i = 1; i <= N; i++) {
    cin >> Input[i];
  }

  
  for (int i = N; i >= 1; i--) {
    if (Temp[i] != Input[i]) {
      Ans[i]++;
      enum_div(i);
    }
    // for (int k = 1; k <= N; k++) {
    //   cout << Temp[k] << " ";
    // }
    // cout << endl;
    // for (int k = 1; k <= N; k++) {
    //   cout << Ans[k] << " ";
    // }
    // cout << endl;
    // cout << endl;
  }

  vector<int> T;
  for (int i = 1; i <= N; i++) {
    if (Ans[i]) {
      T.push_back(i);
    }
  }

  cout << T.size() << endl;
  if (T.size() != 0) {
    for (auto x: T) {
      cout << x << " ";
    }
    cout << endl;
  }

  // int ans = 0;
  // set<int> A;
  // for (int i = 1; i <= N; i++) {
  //   if (Ans[i]) {
  //     ans++;
  //     A.insert(i);
  //   }
  // }

  // if (ans == 0) {
  //   cout << ans << endl;
  // } else {
  //   cout << ans << 
  // }

  // for (int i = 1; i <= N; i++) {
  //   cout << Ans[i] << endl;
  // }

}


Measured memory_bytes: 3960
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int [] a = new int [n];
		for(int i = 0; i < n; i++){ a[i] = sc.nextInt(); }
		long count = 0;
		
		if(a[0] > x){ count = count + (a[0] - x);
					  a[0] = a[0] - (a[0] - x); }
		
		for(int i = 0; i < n-1; i++){
		if(a[i] + a[i+1] > x ){ count = count + ((a[i] + a[i+1]) - x);
								a[i+1] = a[i+1] - ((a[i] + a[i+1]) - x); }}
		
		System.out.println(count);
	}}

Measured memory_bytes: 50644
S = input()
S = [i for i in S]

if ( S == list(reversed(S))):
    S1 = S[:int((len(S)-1)/2)]
    if (S1 == list(reversed(S1))):
        S2 = S[int((len(S)+3)/2)-1:]
        if(S2 == list(reversed(S2))):
            print("Yes")
        else:        
            print("No")        
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3060
let (>>=) xs f = List.map f xs |> List.concat
let lower_bound p arr =
  let len = Array.length arr in
  let rec f l r =
    if l+1 >= r then r
    else
      let m = (l+r) / 2 in
      if p arr.(m) then f l m else f m r
  in f (-1) len
let lower_bound' p arr =
  let idx = lower_bound p arr in
  if idx >= Array.length arr then [] else [arr.(idx)]
let sign = compare 0
let () =
  Scanf.scanf "%d %d %d" @@ fun a b q ->
  let s = Array.init a (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let t = Array.init b (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let s' = Array.init a (fun i -> s.(a-1-i)) in
  let t' = Array.init b (fun i -> t.(b-1-i)) in
  let xs = Array.init q (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  xs |> Array.iter @@ fun x ->
    ((lower_bound' ((<=) x) s @ lower_bound' ((>=) x) s') >>= fun sh ->
     (lower_bound' ((<=) x) t @ lower_bound' ((>=) x) t') >>= fun tp ->
       let v, w = min (abs (sh-x)) (abs (tp-x)), max (abs (sh-x)) (abs (tp-x)) in
       if sign (sh-x) * sign (tp-x) >= 0 then [w] else [2*v + w])
    |> List.fold_left min 10101010101010 |> Printf.printf "%d\n"


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  ll L, R;
  cin >> L >> R;
  if (2500 <= R - L) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> A(0);
  for (int i = L; i <= R; i++) {
    A.push_back(i % 2019);
  }
  ll mn = INF;
  REP(i, A.size() - 1) {
    for (ll j = i + 1; j < A.size(); j++){
      mn = min(mn, A[i]*A[j]%2019);
    }
  }
  cout << mn << endl;
}

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

int main() {
    char S[30];
    cin >> S;
    int year=0,month=0,day=0;
    sscanf(S,"%d/%d/%d",&year,&month,&day);
    if(month > 4){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i, n, t[100];
	
	i=-1;
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)
		{
			printf("%d\n",t[i]);
			i--;
		}
		else
		{
			i++;
			t[i]=n;
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=1e5+5;
const int INF=1500000000;
typedef pair<int,int> pii;
int n,zo,oz,abf,bbf;
long long ans;
pii amn,bmn;
int a[N],b[N];
set<pii> A,B;
vector<pii> used;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		A.insert(make_pair(x,i));
		B.insert(make_pair(y,i));
	}
	for(int i=1;i<=n;i++){
		amn=make_pair(INF,INF);bmn=make_pair(INF,INF);
		if(!A.empty()) amn=*A.begin();
		if(!B.empty()) bmn=*B.begin();
		if(amn<bmn){
			a[amn.second]=1;
			ans+=1ll*amn.first;
			A.erase(A.begin());
			used.push_back(amn);
		}else{
			b[bmn.second]=1;
			ans+=1ll*bmn.first;
			B.erase(B.begin());
			used.push_back(bmn);
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]==0&&b[i]==1) zo++;
		if(a[i]==1&&b[i]==0) oz++;
	}
	if(oz+zo==n&&oz!=n&&zo!=n){
		amn=make_pair(INF,INF);bmn=make_pair(INF,INF);
		if(!A.empty()) amn=*A.begin();
		if(!B.empty()) bmn=*B.begin();
		pii nxt=min(amn,bmn);
		if(nxt.second!=used[used.size()-1].second){
			ans+=1ll*nxt.first;
			ans-=1ll*used[used.size()-1].first;
		}else{
			long long ans1=ans+1ll*nxt.first-1ll*used[used.size()-2].first;
			if(nxt==amn) A.erase(A.begin());
			else B.erase(B.begin());
			amn=make_pair(INF,INF);bmn=make_pair(INF,INF);
			if(!A.empty()) amn=*A.begin();
			if(!B.empty()) bmn=*B.begin();
			pii nxt=min(amn,bmn);
			long long ans2=ans+1ll*nxt.first-1ll*used[used.size()-1].first;
			ans=min(ans1,ans2);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11516
#include<iostream>
using namespace std;
int main(){
int P,Q,R;
cin>>P>>Q>>R;
if(P<=R&&Q<=R){
    cout<<P+Q;
}
else if (Q<=P&&R<=P){
    cout<<Q+R;
}
 
else if (P<=Q&&R<=Q){
    cout<<P+R;
}
return 0;
}

Measured memory_bytes: 256
import collections
h,w=map(int,input().split())
a=""
for i in range(h):
    a+=input()
f,o=1,0
for i in collections.Counter(a).values():
    f+=i//4
    o+=i%4%2
print(["No","Yes"][f>(h//2)*(w//2) and o<=h%2*w%2])

Measured memory_bytes: 38640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() - 1 }
    val used = mutableSetOf(0)
    var cur = 0
    while (true) {
        cur = t[cur]
        if (used.contains(cur) || cur == 1) {
            break
        }
        used.add(cur)
    }
    println(if (cur == 1) used.size else -1)
}

Measured memory_bytes: 56280
# dp[c1][c2][c3]=
# 		(1個の皿がc1枚、2個の皿がc2枚、3個の皿がc3枚あるとき、全て食べるまでの操作回数の期待値)

N = int(input())
A = list(map(int, input().split()))
cnt1 = A.count(1)
cnt2 = A.count(2)
cnt3 = A.count(3)

dp = [[[-1] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 0

# dp[c1][c2][c3]=1
# 	+dp[c1−1][c2][c3]∗(1個の皿が選ばれる確率)
# 	+dp[c1+1][c2−1][c3]∗(2個の皿が選ばれる確率)
# 	+dp[c1][c2+1][c3−1]∗(3個の皿が選ばれる確率)
# 	+dp[c1][c2][c3]∗(0個の皿が選ばれる確率)
# ↓式変形↓
# dp[c1][c2][c3]=1/(1−(0個の皿が選ばれる確率))
# 			+ dp[c1−1][c2][c3]*(1個の皿が選ばれる確率)/(1−(0個の皿が選ばれる確率))
# 			+ dp[c1+1][c2−1][c3]*(2個の皿が選ばれる確率)/(1−(0個の皿が選ばれる確率))
# 			+ dp[c1][c2+1][c3−1]*(3個の皿が選ばれる確率)/(1−(0個の皿が選ばれる確率))


def func(c1, c2, c3):
    if dp[c1][c2][c3] != -1:
        return dp[c1][c2][c3]

    # 繰り返し登場するので先に計算しておく
    prob0 = (N - c1 - c2 - c3) / N

    temp = 1 / (1 - prob0)
    if c1 > 0:
        temp += func(c1 - 1, c2, c3) * (c1 / N) / (1 - prob0)
    if c2 > 0:
        temp += func(c1 + 1, c2 - 1, c3) * (c2 / N) / (1 - prob0)
    if c3 > 0:
        temp += func(c1, c2 + 1, c3 - 1) * (c3 / N) / (1 - prob0)

    dp[c1][c2][c3] = temp
    return temp


print(func(cnt1, cnt2, cnt3))


Measured memory_bytes: 402760
#include <bits/stdc++.h>
using namespace std;
int main(){
string s,t;
  cin >> s >> t;
  int n=s.size();
  bool alf=false;
  for (int i=0;i<n;i++){
  	char a=s[n-1];
    s = a+ s;
    s.pop_back();
    if (s==t) alf=true;
  }
  if (alf)cout <<"Yes"<< endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
#pragma endregion
const int maxn = 105;
bool dp[int(1e7 + 5)][2];
int n, k, a[maxn];
bool dfs(int x, bool f) {
    if (dp[x][f]) return dp[x][f];
    bool flag = 0;
    rep(i, 1, n) if (x >= a[i]) {
        if (!dfs(x - a[i], 1 - f))
            flag = 1;
    }
    return dp[x][f] = flag;
}
int main() {
    IO;
    cin >> n >> k;
    rep(i, 1, n) cin >> a[i];
    cout << (dfs(k, 0) ? "First\n" : "Second\n");
}

Measured memory_bytes: 9548
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    temp=input()
    temp=list(map(int,list(temp.split(" ")))) 
    temp = sorted(temp,key = lambda x:-x)
    print(temp[0]*10+temp[1]+temp[2])

if __name__ == '__main__':
    main()


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

int mod = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    vector<int> min_list(N);
    int mini = mod;
    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        mini = min(mini, list[i]);
        min_list[i] = mini;
    }
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if (list[i] <= min_list[i])
            count++;
    }
    cout << count;
}

Measured memory_bytes: 1792
#include <climits>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

#define st first
#define nd second

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MAXN = 1E5 + 10;

int R, C, n;
vector<PII> E[MAXN << 1];
ll val[MAXN << 1];
bool vis[MAXN << 1];
bool flag = true;
ll m[2];

void DFS(int u, int type){
	vis[u] = true;
	m[type] = min(m[type], val[u]);
	for (int v, i = 0; i < E[u].size(); ++i){
		if (vis[v = E[u][i].st]){
			flag &= val[u] + val[v] == E[u][i].nd;
			continue;
		}
		val[v] = E[u][i].nd - val[u];
		DFS(v, !type);
	}
}

int main(){
	scanf("%d%d%d", &R, &C, &n);
	for (int u, v, w, i = 0; i < n; ++i){
		scanf("%d%d%d", &u, &v, &w);
		v += R;
		E[u].push_back(PII(v, w));
		E[v].push_back(PII(u, w));
	}

	for (int i = 1; flag && i <= R + C; ++i)
		if (!vis[i]){
			val[i] = 0;
			m[0] = m[1] = LLONG_MAX;
			DFS(i, 0);
			flag &= m[0] + m[1] >= 0;
		}
	puts(flag ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 14464
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

// lib/join.hpp
#ifndef JOIN_HPP
#define JOIN_HPP


namespace tools {
  template <typename Iterator>
  std::string join(const Iterator begin, const Iterator end, const std::string delimiter) {
    std::ostringstream ss;
    std::string current_delimiter = "";
    for (Iterator it = begin; it != end; ++it) {
      ss << current_delimiter << *it;
      current_delimiter = delimiter;
    }
    return ss.str();
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  const i64 all = std::accumulate(a.begin(), a.end(), static_cast<i64>(0), std::bit_xor<i64>());
  std::vector<i64> answers(N);
  for (i64 i = 0; i < N; ++i) {
    answers[i] = all ^ a[i];
  }
  std::cout << tools::join(answers.begin(), answers.end(), " ") << std::endl;
  return 0;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int a, b, c;

int main(){
	cin >> a >> b >> c;
	
	for(int i = a; i < a+c && i <= b; i++){
		cout << i << endl;
	}
	for(int i = b-c+1; i <= b; i++){
		if(i <= a+c-1) continue;
		cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(NULL);
ios::sync_with_stdio(false);
 string s;
 cin>>s;
 cout<<s[0]<<s[1]<<s[2]<<s[3]<<" "<<s[4]<<s[5]<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<"\n";

 return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	x := make([][]int, N)
	y := make([][]int, N)
	as := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&as[i])
		x[i] = make([]int, as[i])
		y[i] = make([]int, as[i])
		for j := 0; j < as[i]; j++ {
			fmt.Scan(&x[i][j], &y[i][j])
			x[i][j]--
		}
	}
	max := 0
	for i := 0; i < 2<<N; i++ {
		// ビットが立っている時、正直者
		consistent := true
		count := 0
		for j := 0; j < N; j++ {
			if i>>j&1 == 0 {
				continue
			}
			count++
			for k := 0; k < as[j]; k++ {
				if y[j][k] == 1 && i>>x[j][k]&1 == 0 {
					consistent = false
					break
				}
				if y[j][k] == 0 && i>>x[j][k]&1 == 1 {
					consistent = false
					break
				}
			}
			if !consistent {
				break
			}
		}
		if consistent && max < count {
			max = count
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int n,r,c;

bool edge(int x, int y){
    return (x == 0 || x == c || y == 0 || y == r);
}

int val(int x, int y){
    if(x == 0){
        return 2*c+2*r-y;
    }else if(x == c){
        return c+y;
    }else if(y == 0){
        return x;
    }else{
        return 2*c+r-x;
    }
}

map<int, P> mp;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> c >> r >> n;
    rep(i,n){
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(edge(x1,y1) && edge(x2,y2)){
            int u = val(x1,y1), v = val(x2,y2);
            mp[min(u,v)] = P(i,0);
            mp[max(u,v)] = P(i,1);
        }
    }
    stack<int> st;
    each(it,mp){
        if(it.se.se == 0){
            st.push(it.se.fi);
        }else{
            int val = st.top();
            st.pop();
            if(val != it.se.fi){
                cout << "NO\n";
                return 0;
            }
        }
    }
    cout << "YES\n";
    return 0;
}


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

#define ll long long
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll mod = 1000000007;
ll INF = 1e9 + 5;

int main(){
    FAST;
    string s,t;
    cin >> s;
    cin >> t;
    int n = s.length();
    int m = t.length();
    vector<vector<int>> dp(n+1,vector<int> (m+1,0));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    //cout << dp[n][m];
    int i = n,j = m,index = dp[n][m]-1;
    char output[dp[n][m]];
    while(j>0 && i>0)
    {
        if(s[i-1] == t[j-1])
        {
            output[index] =  s[i-1];
            index--;
            i--;
            j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    for(int i=0;i<dp[n][m];i++) cout << output[i];
    return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>
#include <ctype.h>
 
int
main (
  int   argc,
  char *argv[ ]
  )
{
  int res = 0;
 
  for ( ; ; )
  {
    const int ch = getchar ( );
 
    if ( isdigit ( ch ) )
    {
      res += ch - '0';
    }
    else
    {
      if ( res == 0 ) break ;
 
      printf ( "%d\n", res );
      res = 0;
    }
  }
 
  return ( 0 );
}


Measured memory_bytes: 2032
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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


  int k, x; cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; ++i) {
    cout << i << " ";
  }
  cout << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,i,j,k,n,m,x,y;
    cin>>n>>m>>k;
    vector<ll>u,v,a,b;
    for(i=0;i<n;i++)
    {
        cin>>x;
        u.push_back(x);
    }
    for(i=0;i<m;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    a.push_back(0);
    b.push_back(0);
    for(i=0;i<n;i++)
    {
        a.push_back(a[i]+u[i]);
    }
    for(i=0;i<m;i++)
    {
        b.push_back(b[i]+v[i]);
    }
    ll bst=m,ans=0;
    for(i=0,j=m;i<=n;i++)
    {
        if(a[i]>k)
        {
            break;
        }
        while((b[j]+a[i]>k)&&j>=0)
        {
            j--;
        }
            ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11128
import java.util.Arrays
import java.util.ArrayList

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (n, k) = reader.readLine()!!.split(" ").map{it.toInt()}
    val s = reader.readLine()!!

    val sb = StringBuilder(s)
    if (s[k-1] == 'A') {
        sb[k-1] = 'a'
    } else if (s[k-1] == 'B') {
        sb[k-1] = 'b'
    } else {
        sb[k-1] = 'c'
    }

    println(sb)
}


Measured memory_bytes: 33868
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int N; scanf("%d", &N);
  int *X = new int[N];
  int *Y = new int[N];
  for(int i = 0; i < N; i++) {
    scanf("%d%d", X+i, Y+i);
  }
  if(N%2) {
    printf("NA\n");
    return 0;
  }
  int x = X[0] + X[N/2];
  int y = Y[0] + Y[N/2];
  for(int i = 1; i < N/2; i++) {
    if(x != X[i] + X[i+N/2] ||
       y != Y[i] + Y[i+N/2]) {
      printf("NA\n");
      return 0;
    }
  }
  printf("%.5f %.5f\n", x/2.0, y/2.0);
  return 0;
}

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

using namespace std;

main(){
	int a,b;
	while(cin>>a>>b){
		int s=1;
		int g=0;
		int d=a+b;
		while(d >= 1){
		d=d/10;
		g=g+1;
	}
	printf("%d\n",g);
	}
}


Measured memory_bytes: 3228
import java.util.*;

class Main{
	public static void main(String[] Args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		@SuppressWarnings("unchecked")
		LinkedList<Integer>[] la = new LinkedList[n];
		for(int i = 0; i < n; i++) la[i] = new LinkedList<Integer>();
		for(int i = 0; i < q; i++){
			int op = sc.nextInt();
			if(op == 0){
				int t = sc.nextInt();
				int x = sc.nextInt();
				la[t].add(x);
			}else if(op == 1){
				int t = sc.nextInt();
				ListIterator<Integer> it = la[t].listIterator();
				for(int j = 0; j < la[t].size(); j++){
					System.out.print(it.next());
					if(j != la[t].size() - 1) System.out.print(" ");
				}
				System.out.print("\n");
			}else{
				int t = sc.nextInt();
				la[t].clear();
				la[t] = new LinkedList<Integer>();
			}
		}
	}
}



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

int H, W;
string S[400];
int P[160000];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
long long white_cnt[160000], black_cnt[160000];

int root(int x){
  if(P[x] == x){
    return x;
  }
  return P[x] = root(P[x]);
}

bool is_same_set(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  P[root(x)] = root(y);
}

void init(){
  for(int i = 0; i < 400*400; i++){
    P[i] = i;
  }
}

int main(){
  init();
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      for(int i = 0; i < 4; i++){
	int h_ = h + dx[i], w_ = w + dy[i];
	if(h_ >= 0 && h_ < H && w_ >= 0 && w_ < W && S[h][w] != S[h_][w_]){
	  unite(h * W + w, h_ * W + w_);
	}
      }
    }
  }
  for(int i = 0; i < H * W; i++){
    root(i);
  }
  for(int i = 0; i < H * W; i++){
    if(S[i / W][i % W] == '.'){
      white_cnt[root(i)]++;
    }else{
      black_cnt[root(i)]++;
    }
  }
  long long ans = 0;
  for(int i = 0; i < H * W; i++){
    ans += white_cnt[i] * black_cnt[i];
  }
  /*for(int i = 0; i < H * W; i++){
    cout << root(i) << endl;
    }*/
  cout << ans << endl;
}


Measured memory_bytes: 3584