akhauriyash/Code-Regression huggingface dataset:
// 'By Anki'
 
#include<bits/stdc++.h>
// #include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000007LL
typedef unsigned long long ull;
#define M 10004
using u64= uint64_t;

ll mod(ll n){
  if(n<0)return n+lim;
  else return n%lim;
}


int main()
{
fast
ll t=1LL;
// cin>>t;
while(t--)
{
  ll n,k;
  cin>>n>>k;
  vector<ll>v(n);
  for(auto &x:v)cin>>x;
  sort(all(v));
  ll ans=1LL;
  if(v[n-1]<0 && k&1)for(ll i=0;i<k;i++)ans=(ans*v[n-i-1])%lim;
  else
  {
    ll i=0,j=n-1;
    while(k)
    {
      if(k>1){
        if(v[i]*v[i+1]>v[j]*v[j-1])ans=(((v[i]*v[i+1])%lim)*ans)%lim,i+=2,k-=2;
        else ans=(ans*v[j])%lim,j--,k--;
      }
      else ans=(ans*v[j])%lim,k--,j--;
      // wr(ans)
    }
    // cout<<(ans+lim)%lim;
    
  }
  cout<<(ans+lim)%lim;
  

}
} 

Measured memory_bytes: 4728
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        // long a = sc.nextInt();
        // long b = sc.nextInt();
        // long c = sc.nextInt();
        // System.out.println(4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
        BigInteger a = BigInteger.valueOf(sc.nextLong());
        BigInteger b = BigInteger.valueOf(sc.nextLong());
        BigInteger c = BigInteger.valueOf(sc.nextLong());
        System.out.println(c.compareTo(a.add(b))>0  && a.multiply(b).multiply(BigInteger.valueOf(4)).compareTo(c.subtract(b).subtract(a).pow(2))<0 ? "Yes" : "No");
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

int main(){
  using namespace std;
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<int64_t>res;
  res.push_back(a*c);
  res.push_back(b*d);
  res.push_back(a*d);
  res.push_back(b*c);
  
  cout << *max_element(res.begin(), res.end());
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,k;

int main() {
    scanf("%d%d",&n,&k);
    int s1=0,s2=0;
    for (int i=1;i<=n;++i) {
        if (i%k==0) s1++;
        if (k%2==0 && i%k==k/2) s2++; 
    }
    printf("%lld\n",(LL)s1*s1*s1+(LL)s2*s2*s2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N =2e5+10;
const double pi=acos(-1.0);
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
ll a[N];
const ll mod=1e9+7;
ll sum[N];
signed main(){
    int n;
    si(n);
    for (int i = 1; i <=n ; ++i) {
        sl(a[i]);
    }
    for(int i=n;i>=1;i--){
        sum[i]=sum[i+1]+a[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        ans=(ans%mod+(a[i]%mod)*(sum[i+1]%mod)%mod)%mod;
    }
    pl(ans);
    return 0;
}

Measured memory_bytes: 6844
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int[] arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int K = in.i();
        out.println(arr[K-1]);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 21204
import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def main():
    N, K = map(int, input().split())
    ac = [0] * (N + 1)
    place = {0: 0}
    for i in range(N):
        a = int(input()) - K
        ac[i+1] = ac[i] + a * (10 ** 5) + 1
        place[ac[i+1]] = i+1
    ac.sort()
    ac_cmpr = [0] * (N+1)
    for i in range(N+1):
        ac_cmpr[place[ac[i]]] = i + 1
    bit = Bit(N+2)
    bit.add(ac_cmpr[0], 1)
    ans = 0
    for i in range(1, N+1):
        ans += bit.sum(ac_cmpr[i])
        bit.add(ac_cmpr[i], 1)

    print(ans)


if __name__=='__main__':
    main()


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

void solve() {
	ll n, d;
	cin >> n >> d;
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d) cnt++;
	}
	cout << cnt;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3648
S = input()
acgt = ["A", "C", "G", "T"]
ans = 0

for i in range(len(S)):
    res = 0
    if S[i] in acgt:
        while (i < len(S)) and (S[i] in acgt):
            res += 1
            i += 1
        ans = max(ans, res)
print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdbool.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
#include<list>
typedef long long ll;
using namespace std;
ll num[55] = { 0 };

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   long long a,b,k;
   scanf("%lld %lld %lld",&a,&b,&k);

   if(a>=k){
      a-=k;
   }else if(a+b>=k){
      k-=a;
      a=0;
      b-=k;
   }else{
      a=0;
      b=0;
   }
      printf("%lld %lld",a,b);
   return 0;
   
}


Measured memory_bytes: 3184
// atcoder/agc034/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, a, b, c, d;
  string s;
  while (cin >> n >> a >> b >> c >> d >> s) {
    s = "#" + s + "##";
    bool f = true;
    unless (a <= c && b <= d) {
      f = false;
    }

    if ((a < b && d < c) || (b < a && c < d)) {
      bool x = false;
      for (int i = max(a, b) - 1; i + 1 <= min(c, d); ++i) {
        x = x || (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.');
      }
      f = f && x;
    } else {
      for (int i = a; i + 1 <= c; ++i) {
        f = f && !(s[i] == '#' && s[i + 1] == '#');
      }
      for (int i = b; i + 1 <= d; ++i) {
        f = f && !(s[i] == '#' && s[i + 1] == '#');
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


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

s = 0
ans = 1
for i in range(1, N):
    d = A[i] - A[i - 1]
    if d * s < 0:
        ans += 1
        s = 0
        continue
    if d != 0:
        s = d
print(ans)

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

int main() {
    int A,B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    vector<int>x(5);
    x[0] = (A-1) % 10;
    x[1] = (B-1) % 10;
    x[2] = (C-1) % 10;
    x[3] = (D-1) % 10;
    x[4] = (E-1) % 10;
    sort(x.begin(), x.end());
    int ans = A + B + C + D + E;
    if(x[0] != 9){
        for (int i = 1; i < 5; ++i) {
            ans = ans + 9 - x[i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	/* code */
	int n,a;

	cin >> n;
	cin >> a;

	cout << n*n-a << endl;

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
  int i,j,k=0;
  int N;
  
  scanf("%d",&N);
  
  long A[N];
  
  for(i=0;i<N;i++){
    scanf("%d ",&A[i]);
    while(A[i] % 2 == 0){
      k++;
      A[i] /= 2;
    }
  }
  
  printf("%d\n",k);
  return 0;
}

  

Measured memory_bytes: 256
def gcd( a,b ):

	if b == 0:
		return a;
	else:

		return gcd( b, a%b);


n,x = map(int,input().split());

arr = list(map(int,input().split()))
arr.sort()

minn =0;
temp =0;

if n > 1:

	flag=0;
	
	for i in range(n):

		if i < n-1:
			temp = arr[i+1]-arr[i];
			minn = gcd(temp,minn);

	if minn==0:

		print( abs(x-arr[0]));

	for i in range(n):

		if x == arr[i]:
			flag=1;
			break;
		else:

			diff = abs(x-arr[i])
			if minn !=0 and diff%minn==0:
				flag=1;
				break;
	if flag==1:
		print(minn)
	else:

		maxx = 0;

		for i in range(n):

			diff = abs(x-arr[i]);
			temp = gcd(minn,diff);

			if temp > maxx:
				maxx = temp;
		print (maxx);
else:

	print (abs(x-arr[0]));


			




Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define forit(it,cont) for(auto it=cont.begin();it!=cont.end();it++)
#define for0(i,n) for(i=0;i<n;i++)
#define for1(i,n) for(i=1;i<=n;i++)
#define for0r(i,n) for(i=n-1;i>=0;i--)
#define for1r(i,n) for(i=n;i>=1;i--)
#define ll long long 
vector<ll> h(100010);
vector<ll> res(100010,INT_MAX);
int main()
{
	IOS;
	ll n,i,k=2,j;
	cin>>n;
	for0(i,n)
	cin>>h[i];
	res[0]=0;
	for(i=1;i<n;i++)
	{
		j=i-1;
		while(j>=i-k&&j>=0)
		{
			res[i]=min(res[i],(res[j]+abs(h[i]-h[j])));
			j--;
		}
	}
	cout<<res[n-1]<<endl;
	return 0;	
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<set>
using namespace std;
typedef long long ll;
const int pNmax = 1<<18;
int N;
ll A[pNmax];
int vec[pNmax][2];

int main(){
	cin >> N;
	for(int i=0; i<(1<<N); i++) cin >> A[i];
	for(int i=0; i<(1<<N); i++){
		vec[i][0] = vec[i][1] = -1;
	}

	vector<pair<ll, int> > t;
	set<int> s;
	for(int i=0; i<(1<<N); i++){
		s.insert(i);
		for(int k=0; k<18; k++){
			int n = i & ~(1<<k);
			//cout << i << " " << k << " " << n << endl;
			if(vec[n][0]>=0) s.insert(vec[n][0]);
			if(vec[n][1]>=0) s.insert(vec[n][1]);
		}
		for(set<int>::iterator it=s.begin(); it!=s.end(); it++){
			//cout << i << ":" << *it << " " << A[*it] << endl;
			t.push_back(make_pair(A[*it], *it));
		}
		sort(t.begin(), t.end());
		reverse(t.begin(), t.end());
		vec[i][0] = t[0].second;
		if(s.size() >= 2) vec[i][1] = t[1].second;
		s.clear();
		t.clear();
	}

	ll m = 0;
	for(int i=1; i<(1<<N); i++){
		if(A[vec[i][0]]+A[vec[i][1]] > m) m = A[vec[i][0]]+A[vec[i][1]];
		cout << m << endl;
	}

	return 0;
}


Measured memory_bytes: 7168
object Main extends App {
  val s = io.StdIn.readLine
  val a = s(0).asDigit
  val b = s(1).asDigit
  val c = s(2).asDigit
  val d = s(3).asDigit

  val ope = Seq("+", "-")
  val results = for {
    ope1 <- ope
    ope2 <- ope
    ope3 <- ope
    if ((ope1, ope2, ope3) match {
      case ("+","+","+") => a+b+c+d
      case ("+","+","-") => a+b+c-d
      case ("+","-","+") => a+b-c+d
      case ("+","-","-") => a+b-c-d
      case ("-","+","+") => a-b+c+d
      case ("-","+","-") => a-b+c-d
      case ("-","-","+") => a-b-c+d
      case ("-","-","-") => a-b-c-d
    }) == 7
  } yield s"$a$ope1$b$ope2$c$ope3$d=7"

  println(results.head)
}

Measured memory_bytes: 54668
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:

  int mH, mW;

  vector<vector<char>> table;
  vector<vector<int>> memo;
  int res;

  Tmp(int H, int W);
  void query(int h, int w);
  void reset();
  void rec(int h, int w, int x);
};

Tmp::Tmp(int H, int W)
  : mH(H)
  , mW(W)
  , table(H, vector<char>(W))
  , memo(H, vector<int>(W, -1))
  , res(-1)
{}

void Tmp::query(int h, int w)
{
  rec(h, w, 0);
  int ret{};
  for (auto& r : memo) {
    for (auto& c : r) {
      chmax(ret, c);
    }
  }
  chmax(res, ret);
  reset();
}

void Tmp::rec(int h, int w, int x)
{
  if (h < 0 || w < 0 || h >= mH || w >= mW) {
    return;
  }
  if (table[h][w] == '#') {
    return;
  }
  auto& m = memo[h][w];
  if (m == -1) {
    m = x;
  }
  else {
    if (!chmin(m, x)) {
      return;
    }
  }
  auto r = m;

  rec(h-1, w, r+1);
  rec(h+1, w, r+1);
  rec(h, w-1, r+1);
  rec(h, w+1, r+1);
}

void Tmp::reset()
{
  boost::for_each(memo, [](auto& r){
    boost::fill(r, -1);
  });
}


void solve(void)
{
  int H, W; cin >> H >> W;
  Tmp t(H, W);
  for (auto& row : t.table) {
    for (auto& cell : row) {
      cin >> cell;
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      t.query(i, j);
    }
  }
  auto res = t.res;
  auto ans = res;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int N,S;
int a[100000];

int main(){
  cin>>N>>S;
  for(int i=0;i<N;i++)
    cin>>a[i];

  int ans=1000000;
  int sum=0,cnt=0,j=0;
  
  for(int i=0;i<N;i++){
    
    while(sum<S&&j<N){
      sum+=a[j];
      cnt++;
      j++;
    }

    if(sum>=S)
      ans=min(ans,cnt);

    sum-=a[i];
    cnt--;
  }
  
  if(ans==1000000)ans=0;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n;
struct data{
	int id;
	long long num;
};
data b[N];
bool operator <(data p,data q)
{
	return p.num<q.num;
}
long long a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&b[i].num);
		b[i].id=i;
	}
	sort(b+1,b+n+1);
	long long ans=0;
	for(int i=1;i<=n;i++)
	if(b[i].id%2!=i%2)
	{
		ans++;
	}
	printf("%lld",ans/2);
	return 0;
}

Measured memory_bytes: 1792
import sys

def sieve(n):
    prime = [True] * (n + 1)
    prime[0] = prime[1] = False
    for i in xrange(2, int((n + 1) ** 0.5) + 1):
        if prime[i]:
            for j in xrange(i * i, n + 1, i):
                prime[j] = False
    return [i for i in xrange(2, n + 1) if prime[i]]

for line in sys.stdin:
    n = int(line)
    print len(sieve(n))

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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;j>=m;j--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
#define tlll tuple < ll ,ll,ll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) cout<<#a<<"=";for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}

const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;


/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

ll fast_pow(ll x,ll y,ll z){
    if(y==0)return 1%z;
    else if(y==1)return x%z;
    if(y%2==0){
        ll res = fast_pow(x,y/2,z);
        return (res*res)%z;
    }
    else{
        ll res = fast_pow(x,y/2,z);
        ll temp = (res*res)%z;
        return ((x%z)*temp)%z;
    }
}
int main() {
    godspeed
    string s;
    cin>>s;
    ll ans = 0;
    F(i,0,3){
        ll count = 0 ;

        while((s[i] == 'R') && i<3){
            count+=1;
            i++;
        }
        ans = max(ans,count);
    }
    cout<<ans<<endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> x(100000 + 2);
    int w;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        w = a.at(i);
        x.at(w)++;
        x.at(w + 1)++;
        if (w - 1 < 0)
        {
            continue;
        }
        x.at(w - 1)++;
    }
    sort(x.begin(), x.end());
    reverse(x.begin(), x.end());
    cout << x.at(0) << endl;
}

Measured memory_bytes: 1024
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  ans=[-1]*n

  q=collections.deque()
  v=[[] for _ in range(n)]
  for _ in range(m):
    a,b=LI()
    a-=1
    b-=1
    v[a].append(b)
    v[b].append(a)
    if a==0:
      q.append((0,b,0))
    elif b==0:
      q.append((0,a,0))

  while q:
    moto,nxt,stp=q.popleft()
    if ans[nxt]==-1:
      ans[nxt]=moto
    else:
      continue

    for x in v[nxt]:
      if ans[x]==-1:
        q.append((nxt,x,stp+1))

  if -1 in ans[1:]:
    print('No')
    exit()

  print('Yes')
  for x in ans[1:]:
    print(x+1)

main()
# print(main())


Measured memory_bytes: 123352
#include <stdio.h>
#include <math.h>

int main (void)
{
    long sunuke[100] = {0};
    int i, j, n, k, d, m, ans = 0;

    scanf("%d %d", &n, &k);

    for (i = 0; i < k; i++) {
        scanf("%d", &d);
        for (j = 0; j < d; j++) {
            scanf("%d", &m);
            sunuke[m-1]++;
        }
    }

    for (i = 0; i < n; i++) {
        if (sunuke[i] == 0) ans++;
    }

    printf("%d", ans);

    return 0;
}



Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());
    cout << a.back() << " ";
    int x = a[n - 2];
    for (int i = n - 2; i >= 0; --i)
    {
        if (a.back() % 2 == 1)
        {
            if (abs((a.back() / 2 + 1) - a[i]) < abs((a.back() / 2 + 1) - x))
                x = a[i];
        }
        else
        {
            int sr;
            if (a[i] <= a.back() / 2)
                sr = a.back() / 2;
            else
                sr = a.back() / 2 + 1;
            if (abs(sr - a[i]) < abs(sr - x))
                x = a[i];
        }
    }
    cout << x;
    return 0;
}


Measured memory_bytes: 640
n,x,y=map(int,input().split())
num=[]
for i in range(n-1):
    num.append(0)
for i in range(1,x):
    l=[]
    for j in range(i+1,x+1):
        l.append(j-i)
    for j in range(x+1,y):
        l.append(min(j-i,x-i+1+y-j))
    for j in range(y,n+1):
        l.append(x-i+1+j-y)
    for a in range(len(l)):
        num[l[a]-1]+=1
for i in range(x,y):
    l=[]
    for j in range(i+1,y+1):
        l.append(min(j-i,i-x+1+y-j))
    for j in range(y+1,n+1):
        l.append(l[y-i-1]+j-y)
    for a in range(len(l)):
        num[l[a]-1]+=1
for i in range(y,n):
    for j in range(i+1,n+1):
        num[j-i-1]+=1
for i in range(len(num)):
    print(num[i])

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

using namespace std;

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

    if (!a || !b)
    {
        printf ("Zero\n");
        return 0;
    }

    if (a < 0 && 0 < b) printf ("Zero\n");
    else if (a > 0 || (a - b) & 1) printf ("Positive\n");
    else printf ("Negative\n");

    return 0;
}


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

#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int dp[2002][2002];

int solve(int l, int r, int idx, ii a[], int n)
{
    if(idx == n)
        return 0;
    int &ans = dp[l][r];
    if(ans != -1)
        return ans;
    ans = max(abs(a[idx].second - l)*a[idx].first + solve(l + 1, r, idx + 1, a, n), abs(a[idx].second - r)*a[idx].first + solve(l, r - 1, idx + 1, a, n));   
    return ans;
}

int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n;
    SI(n);
    ii a[n];
    F(i, 0, n)
        SI(a[i].first);
    F(i, 0, n)
        a[i].second = i;
    sort(a, a + n, greater<ii>());
    memset(dp, -1, sizeof(dp));
    SO(solve(0, n - 1, 0, a, n));
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}


Measured memory_bytes: 35160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  cin >> n;
  n %= 10;
  if(n == 3)
    cout << "bon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
  return 0;
}


Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = int(1e9)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func uniqIntSlice(a []int) []int {
	m := make(map[int]struct{})
	for _, v := range a {
		m[v] = struct{}{}
	}
	u := []int{}
	for k := range m {
		u = append(u, k)
	}
	return u
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

//a:old b:new a>b -> a=b (update) more small
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func rec(dp, h []int, i int) int {
	if dp[i] < INF {
		return dp[i]
	}
	if i == 0 {
		return 0
	}
	res := INF
	chmin(&res, rec(dp, h, i-1)+abs(h[i]-h[i-1]))
	if i > 1 {
		chmin(&res, rec(dp, h, i-2)+abs(h[i]-h[i-2]))
	}
	dp[i] = res
	return dp[i]
}

func main() {
	n := nextInt()
	k := nextInt()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}
	dp := make([]int, n)
	for i := range dp {
		dp[i] = INF
	}
	dp[0] = 0

	for i := 1; i < n; i++ {
		for j := 1; j <= k && i-j>=0; j++ {
			chmin(&dp[i], dp[i-j]+abs(h[i]-h[i-j]))
		}
	}

	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2816
N, A, B = map(int, input().split())
if N <= A:
  print(N)
elif A == 0:
  print(0)
else:
  X = int(N / (A + B))
  Y = int(N % (A + B))
  if Y <= A:
    print(A * X + Y)
  else:
    print(A * X + A)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[111111];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(s[1]==s[len])
	{
		if(len&1)puts("Second");
			else puts("First");
	}
	else if(len&1)puts("First");
			else puts("Second");
	return 0;
}




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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    int n, k, s;
    cin >> n >> k >> s;

    if(n != k) {
        REP(i, k) cout << s << " ";
        if(s == 1000000000) s = 1;
        else s++;
        REP(i, n - k - 1) cout << s << " ";
        cout << s << endl;
    } else {
        REP(i, n - 1) cout << s << " ";
        cout << s << endl;
    }

     
    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
		//データの入力の準備
		Scanner sc  = new Scanner(System.in);
		
		while(true){
			//データの入力
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					System.out.print('#');
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s; cin >> s;
    int q; cin >> q;
    deque<char> deq;
    rep(i,s.size()) deq.push_back(s[i]);
    bool isReverse = false;
    rep(i,q){
        int t;cin >> t;
        if (t == 1){
            isReverse = !isReverse;
            // cout << s << endl;
        }
        else if (t == 2){
            int f;cin >> f;
            char c;cin >>c;
            if (f == 1){
                  if (!isReverse){
                      deq.push_front(c);
                  }else{
                      deq.push_back(c);
                  }
                
                // cout << s << endl;
            }
            else  {
                if (!isReverse){
                      deq.push_back(c);
                  }else{
                      deq.push_front(c);
                  }
                // cout << s << endl;
            }
        }
    }
    if (isReverse) reverse(deq.begin(),deq.end());
        rep(i,deq.size()){
            cout << deq[i];
        }
}


Measured memory_bytes: 896
#include<stdio.h>

int main()
{
	int n, m, ary[105][105], a[105];
	while(scanf("%d %d", &n, &m) != EOF)
	{
		for(int i = 0; i < n; i++)
		{
			int sum = 0;
			for(int j = 0; j < m; j++)
			{
				scanf("%d", &ary[i][j]);
				sum += ary[i][j]; 
			}
			ary[i][m] = sum;
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j <= m; j++)
			{
				printf("%d", ary[i][j]);
				if(j != m)
				{
					printf(" ");
				}
				
			}
			puts("");
		}
		for(int i = 0; i <= m; i++)
		{
			int sum = 0;
			for(int j = 0; j < n; j++)
			{
				sum += ary[j][i];

			}
			printf("%d", sum);
			
			if(i != m)
			{
				printf(" ");
			}
		}
		puts("");
	}
	
	return 0;
} 


Measured memory_bytes: 2728
N, M = [int(_) for _ in input().split()]
KL = [[int(_) for _ in input().split()] for _ in range(N)]

UF = list(range(M + 1))


def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    a[x] = a[y] = min(x, y)


def same(a, x, y):
    return find(a, x) == find(a, y)


for kl in KL:
    K, L = kl[0], kl[1:]
    for i in range(K - 1):
        unite(UF, L[i], L[i + 1])
for kl in KL:
    if not same(UF, KL[0][1], kl[1]):
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 21952
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
#define JAM(x) cout<< #x <<" = "<<x<<"\n"
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { ll a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
 
 
//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);




long long int power(long long int a,long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}



/*_______________________________________________*/
vector<int> par,cont,rnk;
int findp(int x)
{
    if(par[x]==-1)
    return x;
    return findp(par[x]);
}

void merge(int x,int y)
{
    int px,py;
    px=findp(x);
    py=findp(y);
    if(px==py)
    return ;
    if(rnk[px]<rnk[py])
    {
        cont[py]+=cont[px];
        par[px]=py;
    }
    else
    {
        cont[px]+=cont[py];
        par[py]=px;
    }
    if(rnk[px]==rnk[py])
    rnk[px]++;
    return ;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,i;
    cin>>n>>m;
    cont.resize(n+1,1);
    par.resize(n+1,-1);
    rnk.resize(n+1,0);
    for(i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        merge(x,y);
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        ans=max(cont[i],ans);
    }
    cout<<ans;
}


Measured memory_bytes: 5556
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int[] a = new int[5];
        for (int i = 0; i < 5; i++)
        {
            a[i] = sc.NextInt();
        }

        int min = int.MaxValue;
        int index = -1;
        for (int i = 0; i < 5; i++)
        {
            int mod;
            if (a[i] % 10 == 0)
            {
                mod = 10;
            }
            else
            {
                mod = a[i] % 10;
            }

            if (mod < min)
            {
                min = mod;
                index = i;
            }
        }

        int ans = 0;
        for (int i = 0; i < 5; i++)
        {
            if (i == index)
            {
                ans += a[i];
            }
            else
            {
                ans += (a[i] + 9) / 10 * 10;
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}


namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = end - 1; begin <= i; i--)		// repeat reverse

#endif

int main(void)
{
	ll n; cin >> n;
	vector<ll> d(n);

	if (n % 2 != 0)
	{
		cout << 0;
		return 0;
	}

	rep(i, 0, n)
		cin >> d[i];
	sort(all(d));

	if (d[n / 2 - 1] == d[n / 2])
	{
		cout << 0;
		return 0;
	}

	cout << d[n / 2] - d[n/2 - 1];

	return 0;
}


Measured memory_bytes: 1152
# -*- coding: utf-8 -*-

def main():
     k = int(input())

     runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     count = 0
     while(len(runrun) < k):
          target = runrun[count]
          num = target % 10
          if num != 0:
               runrun.append(target * 10 + num - 1)
          runrun.append(target * 10 + num)
          if num != 9:
               runrun.append(target * 10 + num + 1)

          count += 1
          # print(runrun)

     print(runrun[k-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 7268
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,i,j,k;
    int *a;
    scanf("%d",&n);
    a = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    k=-1;
    for(i=0;i<n-1;i++){
        if(a[i]<=a[n-1]){
            k++;
            j=a[i];
            a[i] = a[k];
            a[k] = j;
        }
    }
    j = a[k+1];
    a[k+1] = a[n-1];
    a[n-1]=j;
    j=k+1;
    for(i=0;i<n;i++){
        if(j==i){printf("[");}
        printf("%d",a[i]);
        if(j==i){printf("]");}
        if(i!=n-1){
            printf(" ");
        }
    }
    printf("\n");
    free(a);
    return 0;
}



Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

// F : T x T -> T
// G : T x E -> T
// H : E x E -> E
template<typename T, typename E, typename F, typename G, typename H>
struct SegL{
private:
    vector<T> node;
    vector<E> lazy;
    int n;
    T defVal;
    E defOp;
    F f;    // merge elements(T)
    G g;    // update element(T) 
    H h;    // merge operators(E)

public:
    SegL(int siz, T defVal, E defOp, F f, G g, H h) : defVal(defVal), defOp(defOp), f(f), g(g), h(h){
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, defVal);
        lazy.resize(2*n-1, defOp);
    }
    SegL(vector<T> v, T defVal, E defOp, F f, G g, H h) : defVal(defVal), defOp(defOp), f(f), g(g), h(h){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1, defVal);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void eval(int k){
        if(lazy[k] == defOp)    return;
        if(k < n-1){
            lazy[2*k+1] = h(lazy[2*k+1], lazy[k]);
            lazy[2*k+2] = h(lazy[2*k+2], lazy[k]);
        }
        node[k] = g(node[k], lazy[k]);
        lazy[k] = defOp;
    }

    void update(int a, int b, E x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k);
        if(b <= l || r <= a){
            return;
        }else if(a <= l && r <= b){
            lazy[k] = h(lazy[k], x);
            // eval(k); needless in RUQ+RMQ
        }else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k);
        if(b <= l || r <= a)    return defVal;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    auto f = [](int x, int y)->int{return x+y;};
    auto g = [](int x, int y)->int{return x+y;};
    auto h = [](int x, int y)->int{return x+y;};
    int defv = 0;
    int defop = 0;
    SegL<int, int, decltype(f), decltype(g), decltype(h)> seg(n, defv, defop, f, g, h);
    while(q--){
        int op;
        cin >> op;
        if(op == 0){
            int s, t, x;
            cin >> s >> t >> x;
            s--, t--;
            seg.update(s, t+1, x);
        }else{
            int i;
            cin >> i;
            i--;
            cout << seg.query(i, i+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4892
from collections import Counter
h,w=map(int,input().split())
s=""
for i in range(h):
  s+=input()
sc=Counter(s)
d=[0,0,0]
for v in sc.values():
    d[0]+=(v//4)*4
    d[1]+=2 if v%4>=2 else 0
    d[2]+=v%2

if w%2==0 and h%2==0:
  print("Yes" if d[0]==h*w else "No")
elif (w%2)*(h%2)==1:
  print("Yes" if d[1]<=(w-1)+(h-1) and d[2]==1 else "No")
elif w%2==0:
  print("Yes" if d[1]<=w and d[2]==0 else "No")
elif h%2==0:
  print("Yes" if d[1]<=h and d[2]==0 else "No")



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

int main() {
    int n;
    string s;
    cin >> n >> s;

    if(n%2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    int m = n/2;

    if(s.substr(0, m) == s.substr(m, m)) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using PP = pair<P, P>;
vector<int> A;
int N;

void Psort(P& pa)
{
    if (pa.first < pa.second)
    {
        int tmp = pa.first;
        pa.first = pa.second;
        pa.second = tmp;
    }
}

PP update(PP a, PP b)
{
    PP c;
    vector<P> lst{a.first, a.second, b.first, b.second};
    sort(lst.begin(), lst.end());
    c = make_pair(lst[3], lst[2]);
    if (lst[3].second == lst[2].second) c.second = lst[1];
    return c;
}

int main()
{
    cin >> N;
    vector<int> A(1 << N);
    vector<PP> seq(1 << N);
    for (int i = 0; i < (1 << N); i++)
    {
        cin >> A[i];
    }

    seq[0] = make_pair(make_pair(A[0], 0), make_pair(0, -1));

    int nowmax = 0;

    for (int i = 1; i < (1 << N); i++)
    {
        int digit = 0;
        int tmp = i;
        while (tmp)
        {
            tmp /= 2;
            digit++;
        }
        PP candidate = make_pair(make_pair(A[i], i), make_pair(0, -1));
        for (int d = 0; d < digit; d++)
        {
            if (((i>>d) & 1) == 0) continue;
            int dd = i - (1 << d);
            candidate = update(candidate, seq[dd]);
            // cout << i << " " << dd << endl;
        }
        seq[i] = candidate;
        nowmax = max(nowmax, seq[i].first.first + seq[i].second.first);
        cout << nowmax << endl;
    }
}


Measured memory_bytes: 8192
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    int ans = 0;
    int cnt;
    for (int i = 0; i < n; i += cnt) {
        cnt = 0;
        for (int j = i; j < n && a[i] == a[j]; j++) {
            cnt++;
        }

        if(a[i] == cnt){
            continue;
        }

        if(cnt > a[i]){
            ans += cnt - a[i];
        }else{
            ans += cnt;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100000
#define vmax 10000
#define sentinel 2000000000
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}

int main() {
    int n,a[MAX+1];
    cin>>n;
    a[0]=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        cout<<"node "<<i<<": key = "<<a[i]<<", ";
        if(parent(i)>=1) cout<<"parent key = "<<a[parent(i)]<<", ";
        if(left(i)<=n) cout<<"left key = "<<a[left(i)]<<", ";
        if(right(i)<=n) cout<<"right key = "<<a[right(i)]<<", ";
        cout<<endl;
    }
    return 0;
}






Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int arrayy[1000000] = {0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long s; cin >> s;
    long long a(s);
    arrayy[s] = 1;
    long long ct(1);
    while (1){
        if (a%2==0){
            a = a/2;
        }
        else{
            a = (3*a)+1;
        }
        ++ct;
        if (arrayy[a] != 0) break;
        arrayy[a] = 1;
    }
    cout << ct;
    return 0;
}

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

typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll INFLL = 0x3F3F3F3F3F3F3F3FLL;

int n;
int h[112345];
int bestAns[112345];

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 1 ; i <= n ; i ++)
		cin >> h[i];
	
	memset(bestAns, INF, sizeof bestAns);
	bestAns[1] = 0;
	
	for(int i = 2 ; i <= n ; i ++){
		bestAns[i] = bestAns[i - 1] + abs(h[i] - h[i - 1]);
		bestAns[i] = min(bestAns[i], bestAns[i - 2] + abs(h[i] - h[i - 2]));
	}
	
	cout << bestAns[n] << "\n";
	
	return 0;
}

Measured memory_bytes: 4408