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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		// temp += n % 10;
		n = n / 10;
		temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}
bool ispalin(int n) {


	string  str = to_string(n);
	// cout<<str<<endl;


	for (int i = 0; i < str.size() / 2; ++i)
	{
		/* code */
		// watch2(str[i],str[str.size()-i-1]);
		if (str[i] != str[str.size() - i - 1]) {
			return false;
		}
	}


	return true;


}

int main() {
	int i,  n, m, k;
	int sum = 0;
	c_p_c();
	cin>>k>>n;
	int a[n];
	fo(i,n) cin>>a[i], sum+=a[i];
	if(sum>=k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3960
#include <stdio.h>

int main(void) {
    int n,check,answer;
        scanf("%d", &n);
        check = n/1000;
        answer = 1000*(check + 1)-n;
        if(answer==1000){
          answer =0;
        }
        printf("%d\n",answer);
        return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
using namespace std;

int verts[200000];
bool visited[200000];
vector<int> edges[200002];
int V = 0;
int k[100000];


void addEdge(int f,int t){
  edges[f].push_back(t);
}

void deleteBFS(){
  queue<int> q;
  int f,t,ind;
  q.push(0);
  while(!q.empty()){
    //cout << "--" << endl;
    f = q.front();
    //cout << f << endl;
    q.pop();
    if (visited[f] == true){
      continue;
    }
    visited[f] = true;
    for (int i=0; i< edges[f].size(); i++){
      t = edges[f][i];
      //cout << t << endl;
      if (visited[t] == false){
        q.push(t);
      }
    } 
  }
}

int main(){
  int n,m;
  int l;
  cin >> n >> m;
  for (int i=0; i<n; i++){
    cin >> k[i];
    for(int j=0; j<k[i]; j++){
      cin >> l;
      l = l+n-1;
      addEdge(i,l);
      addEdge(l,i);
    }
  }
  for (int i=0;i<n+m;i++){
    visited[i] = false;
  }
  deleteBFS();
  for(int i=0; i<n; i++){
    if (visited[i] == false){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 9464
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum R = [
    "SUN": 7,
    "MON": 6,
    "TUE": 5,
    "WED": 4,
    "THU": 3,
    "FRI": 2,
    "SAT": 1
];

void main()
{
    writeln(R[readln.chomp]);
}

Measured memory_bytes: 256
import sys
from pprint import pprint

S = sys.stdin.readline().strip()
S = S[::-1]

n = len(S)
r = [0] * 2019
acum = [0] * (len(S)+1)
r[0] += 1
for i, s_i in enumerate(S):
    acum[i+1] = int(s_i) * pow(10, i, 2019) + acum[i]
    acum[i+1] %= 2019
    r[acum[i+1]] += 1
# print(acum)

ans = 0
for r_i in r:
    ans += r_i * (r_i - 1) // 2
print(ans)

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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  int count = 0;
  for(int i = A; i <= B; i++){
  	if(i % K == 0){

      count++;
    }   
  }
  if(count > 0){
    cout << "OK" << endl;
  }
  else cout << "NG" << endl;
}

Measured memory_bytes: 3620
<?php
 
fscanf(STDIN, '%d', $count);
$min = 0;
$prev = 0;
$profit = 0;
for ($i = 0; $i < $count; $i++) {
    fscanf(STDIN, '%d', $input_num);
    if ($i === 0) {
        $min = $input_num;
        continue;
    } elseif ($i === 1) {
        $profit = $input_num - $min;
        $prev = $input_num;
        continue;
    }
 
    if ($prev < $min) {
        $min = $prev;
    }
 
    $result = $input_num - $min;
    $prev = $input_num;
 
    if ($result > $profit) {
        $profit = $result;
    }
}
 
echo $profit;

?>



Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include<queue>
#include<utility>

using namespace std;

int main()
{
  queue<pair<string, int>> jobs;
  int n, q;
  cin >> n >> q;
  string name; int duration;
  while (cin >> name >> duration) jobs.emplace(name, duration);
  int time = 0;
  while (!jobs.empty()) {
    time += q;
    auto j = jobs.front(); jobs.pop();
    j.second -= q;
    if (j.second <= 0) {
      cout << j.first << " " << time+j.second << endl;
      time += j.second;
    }
    else
      jobs.push(j);
  }
}


Measured memory_bytes: 6224
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

unsigned long long pow(long long base, long long power);

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

/*
    Special functions:
        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

int main(){
    quicken();

    string str; cin >> str;
    transform(all(str), str.begin(), ::tolower);
    sort(all(str));

    cout << (str=="abc" ? "Yes" : "No");

    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2);
    ans *= ans; /// ans = (ans%mod)*(ans%mod);

    if(power&1) return ans*base; /// (ans%mod)*(base%mod);
    return ans;
}


Measured memory_bytes: 256
n = int(input())

itv = []
for i in range(n):
    x, l = map(int, input().split())
    s = x-l
    t = x+l
    itv.append([t, s])
itv.sort()

ass = 1
tt = itv[0][0]
for i in range(1, n):
    if tt <= itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)


Measured memory_bytes: 60580
h, n = gets.split.map(&:to_i)
a, b = n.times.map{gets.split.map(&:to_i)}.transpose

INF = 10**8
max_a = a.max
dp = Array.new(h + max_a + 1, INF)
dp[0] = 0

0.upto(h) do |i|
  n.times do |j|
    if dp[i + a[j]] > dp[i] + b[j]
      dp[i + a[j]] = dp[i] + b[j]
    end
  end
end

puts dp[h..-1].min


Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector
using namespace std;

int main()
{
    ll t,i,n;
    ll a,b,c;
    cin>>n;
    map<string,ll> mp;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    vl<pair<ll,string>> p;
    for(auto itr=mp.begin();itr!=mp.end();itr++)
    {
        p.pb({itr->second,itr->first});
    }
    sort(p.rbegin(),p.rend());
    if(p.size()==1)
    {
        cout<<p[0].second;
        return 0;
    }
    //for(i=0;i<p.size();i++) cout<<p[i].first<<" "<<p[i].second<<endl;
    vl<string> v;
    for(i=1;i<p.size();i++)
    {
        ll n1,n2;
        n1=p[i-1].first;
        n2=p[i].first;
        if(n1==n2) v.pb(p[i-1].second);
        else 
        {
            v.pb(p[i-1].second);
            break;
        }
    }
    if(p[p.size()-1].first==p[p.size()-2].first && p.size()>1 && p[p.size()-1].first==p[0].first) v.pb(p[p.size()-1].second);
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++) cout<<v[i]<<endl;
}

Measured memory_bytes: 41128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n,r;
  while(cin>>n>>r,n+r) {
    vector<int> a;
    REP(i,n)
      a.push_back(i+1);
    REP(i,r) {
      int p, q;
      cin >> p >> q;
      REP(j,q) {
        a.push_back(a[n-p-q+1]);
        a.erase(a.end()-p-q);
      }
      // FOR(j,a)
      //   cout << *j << " ";
      // cout << endl;
    }
    cout << a[n-1] << endl;
  }
}

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

#define ll long long int 

const ll N = 2e5+7 ;
ll dp[N] ;

ll min_cost(ll h[] , ll n){
	if( n <= 0 ){
		dp[0] = 0 ;
		return dp[0] ;
	}
	
	if(	dp[n] != -1) return dp[n] ;

	if( n == 1 ) {
		dp[1] = 0;
		return dp[1] ;
	}
	if( n == 2 ) {
		dp[2] = abs(h[2] - h[1]) ;
		return dp[2] ;
	}

dp[n] = min(min_cost(h,n-2) + abs(h[n] - h[n-2]) , min_cost(h,n-1) + abs(h[n] - h[n-1])) ;
	return dp[n] ;
}


void solve(ll n ) {
	ll h[n+2] ;
	for(int i = 1; i <= n ; i++ ){
		cin >> h[i] ;
	} 
	memset(dp , -1 , sizeof(dp) ) ;
	cout << min_cost(h,n) ;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n ; cin >> n ;
    solve(n) ;
    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a%3==0||b%3==0||(a+b)%3==0){
		printf("Possible\n");
	}else{
		printf("Impossible\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
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 n = int.Parse(input.ReadLine());
        var s = input.ReadLine();

        int r = 0;
        for(int i = 1; i<n; i++) {
            var a = s.Substring(0, i);
            var b = s.Substring(i, n - i);
            r = Math.Max(r, Count(a, b));
        }

        return r;
    }

    static int Count(string a, string b) {
        var hash = new HashSet<char>();
        foreach(var aa in a) {
            hash.Add(aa);
        }

        var hash2 = new HashSet<char>();
        foreach(var bb in b) {
            if(hash.Contains(bb) && !hash2.Contains(bb)) {
                hash2.Add(bb);
            }
        }
        return hash2.Count;
    }

    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: 13396
# coding: utf-8
# Here your code
stack1=[] # \????????????????????????????¨???¶
stack2=[] #???stack1???????????????????????¨??¢???????¨???¶
sum=0
for i,c in enumerate(input()):
    if c =="\\":
        stack1.append(i)
    elif c=="/":
        if stack1:
            poped = stack1.pop()
            res = i-poped
            sum += res
            while stack2 and stack2[-1][0]>poped:
                res+=stack2.pop()[1]
            stack2.append([poped,res])
    
print(sum)
print(len(stack2),*(a for j,a in stack2))

Measured memory_bytes: 8272
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;



int main(void)
{
    long N;
    scanf("%ld", &N);
    long T, A;
    scanf("%ld %ld", &T, &A);

    long H[1000] = {0};
    long i;
    for(i=0; i<N; i++) {
        scanf("%ld", &(H[i]));
    }

    long iMin = -1;
    double dValMin=HUGE_VAL;
    for(i=0; i<N; i++) {
        double dVal = fabs(A - (T - H[i]*0.006));
        if (dVal < dValMin) {
            dValMin = dVal;
            iMin = i;
        }
    }
    printf("%d\n", iMin+1);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int a, b, c;

  cin >> a >> b >> c;
  
  if (a == b && a == c && b == c)      cout << 1 << endl;
  else if (a != b && a != c && b != c) cout << 3 << endl;
  else                                 cout << 2 << endl;

  return 0;
}


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

void _main() {
    string S;
    cin >> S;
    REP (i, S.size() - 1) {
        if (S[i] == S[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return;
        }
    }
    REP (i, S.size() - 2) {
        if (S[i] == S[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return;
        }
    }
    cout << -1 << " " << -1 << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
int n,m;
vector<int> v[100010];
int d[100010];
int dp[100010];

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		d[b]++;
	}
	stack<int> st;
	for(int i=1;i<=n;i++)
		if(d[i]==0)
			st.push(i);
	while(!st.empty()){
		int x=st.top();
		st.pop();
		for(int i=0;i<v[x].size();i++){
			int ne=v[x][i];
			if(dp[x]+1>dp[ne])
				dp[ne]=dp[x]+1;
			d[ne]--;
			if(d[ne]==0)
				st.push(ne);
		}
	}
	int maxn=0;
	for(int i=1;i<=n;i++)
		maxn=max(maxn,dp[i]);
	cout<<maxn;
	return 0;
}


Measured memory_bytes: 6528
n = int(input())
l = list(map(int, input().split()))
cnt = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if not len(set([a, b, c])) == 3:
                continue
            if abs(a-b) < c < a + b:
                cnt += 1
                
print(cnt)

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


int main() {
  int a, b;
  cin >> a >> b;
  int b_digit;
  for (int i = 0; i <= 3; ++i) {
    int div = b / pow(10, i);
    if (div == 0) {
      b_digit = i;
      break;
    }
  }
  int result = a * pow(10, b_digit) + b;
  int num = 1, c;
  bool flg = false;
  do {
    c = pow(num, 2);
    if (c == result) {
      flg = true;
    }
    ++num;
  } while (c < result);
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
char a[100005];
int main()
{
    int len,p=0,g=0;
    cin>>a;
    len=strlen(a);
    for(int i=0;i<len;i++)
    {
        if(a[i]=='g')
        g++;
    }
    p=len-g;
    cout<<(g-p)/2;
    return 0;
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    cin>>n>>k;
    ll a[n];
    rep(i,0,n)    
    {
        a[i]=k+i;
        cnt+=a[i];
    }
    ans=LLONG_MAX;
    rep(i,0,n){
        if(abs(cnt-(cnt-a[i]))<ans){
            ans=min(ans,abs(cnt-(cnt-a[i])));
            t=cnt-a[i];
        }

    }
    ret(t)

    return 0;
}

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

int main() {
    int A, B, WA, WB, WC, max;
    cin >> A >> B;

    WA= 2*A - 1;
    WB= 2*B - 1;
    WC= A + B;

    max = WA;
    if(WB > WA){
        max = WB;
    }
    if(WC > max){
        max = WC;
    }

    cout << max << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


public class Main{
   
   

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[]a=new int[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        int x=1;
        int sum=0;
        if(N>1){
        for(int i=0;i<N-1;i++){
            if(a[i]==a[i+1]){
                x++;
            }else{
                if(x>a[i]){
                    sum+=x-a[i];
                }
                if(x<a[i]){
                    sum+=x;
                }
                x=1;
            }
            if(i==N-2){
                if(x>a[i]){
                    sum+=x-a[i];
                }
                if(x<a[i]){
                    sum+=x;
                }
                x=1;

            }
        }}else{
            if(a[0]==1){
                sum=0;
            }else{
                sum=1;
            }
        }
        System.out.println(sum);

    }

        
        
    }


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

int main(void) {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(n, k - q);
	for (int i = 0; i < q; i++) {
		int b;
		cin >> b;
		b--;
		a[b]++;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a-c) <= d||(abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes";
	}
	else cout << "No";
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

const int INF = 830252521;

#define V_MAX 25252
struct edge{int to,cap,rev;};
vector<edge> g[V_MAX];
bool used[V_MAX];
void add_edge(int from,int to,int cap){
  g[from].push_back((edge){to,cap,g[to].size()});
  g[to].push_back((edge){from,0,g[from].size()-1});
}
int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  REP(i,g[v].size()){
    edge &e = g[v][i];
    if(!used[e.to]&&e.cap>0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int h,w;
char mp[125][125];
int dd[] = {1,0,-1,0,1};

int main(){
  scanf("%d%d",&h,&w);
  REP(i,h)scanf("%s",mp[i]);
  // flow
  int s=2*h*w;
  int t=2*h*w+1;
  REP(i,h)REP(j,w){
    int id = i*w + j;
    int x=2*id,y=2*id+1;
    if(mp[i][j]=='X'){
      if(i==0||i==h-1||j==0||j==w-1){
        puts("-1");
        return 0;
      }
      add_edge(s,x,INF);
      add_edge(x,y,INF);
    }else{
      add_edge(x,y,1);
    }
    if(i==0||i==h-1||j==0||j==w-1){
      add_edge(y,t,INF);
    }
    REP(d,4){
      int ni=i+dd[d],nj=j+dd[d+1];
      if(ni<0||ni>=h||nj<0||nj>=w)continue;
      int nid = ni*w + nj;
      add_edge(y,2*nid,INF);
    }
  }
  int flow = 0;
  while(true){
    REP(i,V_MAX)used[i]=false;
    int f = dfs(s,t,INF);
    if(f==0)break;
    flow += f;
  }
  printf("%d\n",flow);
  return 0;
}


Measured memory_bytes: 3840
s = gets.strip
if s.length < 3
  puts 0
  exit
end

ans = 0
ca = 0
i = 0
while i < s.length - 2
  if s[i, 3] == 'ABC'
    ans += (ca + 1)
    s[i + 2] = 'A'
    i += 2
    next
  else
    if s[i] == 'A'
      ca += 1
    else
      ca = 0
    end
    i += 1
  end
end
puts ans


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
double a[40007],b[40007],c[40007],sv[40007];
int n,id[40007],idx[40007];
int bit[40007];
void update(int pos){
	for(int i=pos;i<=n;i+=i&(-i)) bit[i]++;
}
int get(int pos){
	int ret=0;
	for(int i=pos;i>=1;i-=i&-(i)) ret+=bit[i];
	return ret;
}
bool cmp(int x,int y){
	return ((-a[x]/b[x]<-a[y]/b[y]) || (-a[x]/b[x]==-a[y]/b[y] && c[x]/b[x]>c[y]/b[y]));
}
bool cmp2(int x,int y){
	return ((sv[x]>sv[y]) || (sv[x]==sv[y] && x>y));
}
double solve(){
	for(int i=1;i<=n;i++) id[i]=i;
	sort(id+1,id+1+n,cmp);
	//for(int i=1;i<=n;i++) cout<<id[i]<<"\n";
	double l=-1e9,r=1e9;
	double mid=(l+r)/2.0;
	for(int t=1;t<=90;t++){
		for(int i=1;i<=n;i++){
			int x=id[i];
			idx[i]=i;
			bit[i]=0;
			sv[i]=(-a[x]/b[x])*mid+c[x]/b[x];
		}
		sort(idx+1,idx+1+n,cmp2);
		int cur=0;
		for(int i=1;i<=n;i++){
			cur+=(i-1)-get(idx[i]);
			update(idx[i]);
		}
		//cout<<cur<<endl;
		if(cur<(n*(n-1)/2+1)/2) l=mid;
		else r=mid;
		mid=(l+r)/2.0;
	}
	return mid;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<(fixed)<<setprecision(15)<<solve();
	cout<<" ";
	for(int i=1;i<=n;i++) swap(a[i],b[i]);
	cout<<(fixed)<<setprecision(15)<<solve();
}
//I'm suck at geometry :'(


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

    int n,k;
    cin >> n >>k;
    string s;
    cin >> s;
    s[k-1] = s[k-1] + 'a' - 'A';
    cout << s <<endl;  
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String first_s = s.substring(0,2);
    String last_s = s.substring(2,4);
    int first = Integer.parseInt(first_s);
    int last = Integer.parseInt(last_s);

    if (0 < first && first <= 12 && 0 < last && last <= 12) {
      System.out.println("AMBIGUOUS");
    } else if (0 < last && last <= 12) {
      System.out.println("YYMM");
    } else if (0 < first && first <= 12) {
      System.out.println("MMYY");
    } else {
      System.out.println("NA");
    }
  }

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e6+1;
int dp[N][2];
int n;
string s;
int solve(int idx,int carry){
	if(idx == n){
		return carry;
	}
	if(dp[idx][carry]!=-1)
		return dp[idx][carry];
	int val = s[idx]-'0';
	val+=carry;
	int ans = 1e9;
	if(val<10){
		ans = min(ans,val+solve(idx+1,0));
	}
	ans = min(ans,10 - val + solve(idx+1,1));
	dp[idx][carry] = ans;
	return ans;
}
signed main()
{
	fast;
	memset(dp,-1,sizeof(dp));
	cin>>s;
	n = (int)s.size();
	reverse(all(s));
	cout<<solve(0,0);
}   

Measured memory_bytes: 63900
a,v =map(int, input().split())
b,w =map(int, input().split())
t=int(input())

if a*b<0:
    if a > 0:
        d = a-b
    else:
        d = b-a
else:
    d = a-b
if d < 0:
    d = -d
if v > w:
    d2 = v-w
else:
    d2 = w-v
if  (v > w) and (d2*t < d):
    print("NO")
elif v <= w:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string s;
  cin>>s;
  int n=s.size();
  string judge="Yes";
  rep(i,n){
      if(i%2==0){
        if(s[i]=='L'){
            judge="No";
            break;
        }
      }
      if(i%2==1){
        if(s[i]=='R'){
            judge="No";
            break;
        }
      }
  }
  cout<<judge<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 998244353

int main() {
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
	for(ll i=0;i<h;i++){
		ll ch=0;
		if(i>=b){
			ch=abs(ch-1);
		}
		for(ll j=0;j<w;j++){
			ll ch2=ch;
			if(j>=a){
				ch2=abs(ch2-1);
			}
			cout << ch2;
		}
		cout<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=100+5;
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
void file()
{
	#ifndef ONLINE_JUDGE
		freopen("a.in","r",stdin);
		freopen("a.out","w",stdout);
	#endif
}
void work()
{
	char s[10];
	scanf("%s",s);
	For(i,0,strlen(s)-2)
	{
		if(s[i]=='A'&&s[i+1]=='C'){printf("Yes\n");return;}
	}
	printf("No\n");
}
int main()
{
	//file();
	work();
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
l = [[] for _ in range(n)]
ab = []
for _ in range(m):
  a, b = map(int, input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
  ab.append((a, b))
seen = [False]*n
def dfs(v):
  for i in l[v]:
    if not seen[i]:
      seen[i] = True
      dfs(i)
ans = 0
for a, b in ab:
  l[a-1].remove(b-1)
  l[b-1].remove(a-1)
  c = 0
  for i in range(n):
    if not seen[i]:
      dfs(i)
      c += 1
  if c > 1:
    ans += 1
  seen = [False]*n
  l[a-1].append(b-1)
  l[b-1].append(a-1)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, K, H[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    sort(H, H + N);

    int ans = inf;
    rep(L, 0, N - K + 1) {
        int R = L + K - 1;
        chmin(ans, H[R] - H[L]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define F(i, n) for(int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200*1000+47;

VI G[MAX];
int A[MAX];

bool ok;


LL DFS(int v, int p)
{
    LL val = A[v];
    bool leaf = (SZ(G[v]) == 1);
    if (!leaf)val *= 2;
    LL ans = val;
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (to == p)continue;
        LL res = DFS(to, v);
        if (!leaf && res * 2 > val)ok = false;
        ans -= res;
    }
    
    if (!leaf && ans * 2 > val)ok = false;
    if (ans < 0)ok = false;
    return ans;
}

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)scanf("%d", A + i);
    
    FOR(i, 0, n-1)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        G[a].PB(b);
        G[b].PB(a);
    }
    ok = true;
    if (DFS(0, -1) == 0 && ok)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    
    return 0;
}











Measured memory_bytes: 15104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            var groups = RunLengthEncoding(s).ToArray();
            var res = new List<long>();
            for (int i = 0; i < groups.Length; i += 2)
            {
                long rCnt = groups[i].Item2;
                long lCnt = groups[i + 1].Item2;
                for (int r = 0; r < rCnt - 1; r++) res.Add(0);
                if ((rCnt + lCnt) % 2 == 0)
                {
                    res.Add((rCnt + lCnt) / 2);
                    res.Add((rCnt + lCnt) / 2);
                }
                else if (rCnt % 2 == 0)
                {
                    // 全体がODDかつRがEven
                    res.Add((rCnt + lCnt - 1) / 2);
                    res.Add((rCnt + lCnt + 1) / 2);
                }
                else
                {
                    // 全体がODDかつRがOdd
                    res.Add((rCnt + lCnt + 1) / 2);
                    res.Add((rCnt + lCnt - 1) / 2);
                }
                for (int l = 0; l < lCnt - 1; l++) res.Add(0);
            }
            Console.WriteLine(string.Join(" ", res));
        }

        static IEnumerable<Tuple<char, long>> RunLengthEncoding(string s)
        {
            // initialize
            char c = s[0];
            long cnt = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (c == s[i]) cnt++;
                else
                {
                    yield return Tuple.Create(c, cnt);
                    cnt = 1;
                }
                c = s[i];
            }
            // finalize
            yield return Tuple.Create(c, cnt);
        }
    }
}


Measured memory_bytes: 24540
#include <iostream>
#include <string>

using namespace std;


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

int w,h;
int map[21][21];

int count;
int init_x,init_y;

void dfs(int x,int y) {
  
  //cout << x << " " << y << endl;

  if(x<0 || x>=w || y<0 || y>=h) return;

  //if(map[x][y]==2) map[x][y]=0;

  if(map[x][y]>0) return;

  map[x][y]=3;

  count++;

  for(int i=0;i<4;i++) dfs(x+dx[i],y+dy[i]);

}

int main() {

  string buf;

  while(cin >> w >> h) {

    if(w==0 && h==0) break;

    getline(cin,buf);

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

      getline(cin,buf);

      for(int j=0;j<w;j++) {

	switch(buf[j]) {

	case '.':
	  map[j][i]=0;
	  break;

	case '#':
	  map[j][i]=1;
	  break;

	case '@':
	  map[j][i]=0;
	  init_x=j;
	  init_y=i;
	  break;

	}

      }

    }
    /*
    for(int i=0;i<h;i++) {

      for(int j=0;j<w;j++) {

	cout << map[j][i];

      }

      cout << endl;

    }
    
    cout << endl;

    cout << map[5][7] << endl;
    */
    count=0;

    dfs(init_x,init_y);
    /*
    cout << init_x << " " << init_y << endl;
    
    for(int i=0;i<h;i++) {

      for(int j=0;j<w;j++) {

	cout << map[j][i];

      }

      cout << endl;

    }
    */
    cout << count << endl;

  }

  return 0;

}

Measured memory_bytes: 0
sx, sy, tx, ty = map(int, input().split())
lx1 = sx-1
ly1 = sy
lx2 = tx
ly2 = ty+1
rx1 = tx+1
ry1 = ty
rx2 = sx
ry2 = sy-1
ans = ""
sign = ['U', 'R', 'D', 'L', 'L', 'U', 'R', 'D', 'R', 'D', 'L', 'U']
road = [ty-sy, tx-sx, sy-ty, sx-tx, -1, ly2-ly1, lx2-lx1, -1, 1, ry2-ry1, rx2-rx1, 1]
for i in range(12):
    ans += sign[i]*abs(road[i])
print(ans)


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

int main() {
  int n;
  cin >> n;
  unordered_map<int, int> counter;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    counter[d]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    if (counter[t] == 0) {
      cout << "NO" << endl;
      return 0;
    }
    counter[t]--;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      ll n;
      cin>>n;
      ll dp[n+1][3];
      memset(dp,0,sizeof(dp));
      for(int i=1;i<=n;i++)
      {
      	  ll a,b,c;
      	  cin>>a>>b>>c;

      	  dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
      	  dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
      	  dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);

      }

      cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;

        
  }




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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int niza[n];
    int zbir=0;
    for(int i=0; i<n; i++)
    {
        cin>>niza[i];
        zbir+=niza[i];
    }
    sort(niza,niza+n);
    if(niza[n-1]<zbir-niza[n-1])
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 100;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    cins(all(a));
    vector<vector<bool>> down(n,vector<bool>(k+1,0)),up(n,vector<bool>(k+1,0));
    rep(i,n) down[i][0] = up[i][0] = 1;
    rep(i,n-1){
        rep(j,k+1){
            if (down[i][j]){
                down[i+1][j] = down[i+1][min(k,j+a[i])] = 1;
            }
            if (up[i][j]){
                up[i+1][j] = up[i+1][min(k,j+a[n-i-1])] = 1;
            }
        }
    }
    vector<vector<int>> l(n),r(n);
    rep(i,n){
        rep(j,k+1){
            if (down[i][j]) l[i].push_back(j);
            if (up[i][j]) r[i].push_back(j);
        }
    }
    rep(i,n){
        l[i].push_back(INF);
        r[i].push_back(INF);
    }
    int ans = 0;
    rep(i,n){
        if (a[i] >= k) continue;
        bool ok = 1;
        int c = k-a[i];
        rep(j,l[i].size()-1){
            int s = *lower_bound(all(r[n-i-1]),c-l[i][j]);
            if (s+l[i][j] < k) ok = 0;
        }
        if (ok) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 239872
def f(li):
    ret = [0] * 3
    for e in li:
        if e % 4 == 0:
            ret[2] += 1
        elif e % 2 == 0:
            ret[1] += 1
        else:
            ret[0] += 1

    return ret


def solve(li):
    cnt = f(li)
    q = [1] * cnt[0] + [2] * cnt[1] + [4] * cnt[2]

    fin = []
    for i in range(len(li)):
        if i % 2:
            fin.append(q.pop())
        else:
            fin.append(q.pop(0))

    bl = True
    for i in range(len(li) - 1):
        if fin[i] * fin[i+1] % 4 != 0:
            bl = False

    print("Yes" if bl else "No")


def main():
    n = int(input())
    a = list(map(int, input().split()))

    solve(a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14480
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int i;
    int sum;
    
    int N;
    cin >> N;
    vector<int> ls(N);
    for(i=0;i<N;i++) cin >> ls[i];
    
    sort(ls.begin(), ls.end());
    sum = accumulate(ls.begin(), ls.end()-1, 0);
    
    if(ls[N-1] < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256