akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<30
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int v,e,r;
vector<pii> g[MAX];

void dijkstra(){
  int d[MAX];
  priority_queue<pii,vector<pii>,greater<pii> > pq;
  fill(d,d+MAX,inf);
  d[r]=0;
  pq.push(mp(0,r));

  while(pq.size()){
    pii u=pq.top();
    pq.pop();
    if(d[u.s]<u.f)continue;

    FOR(i,0,g[u.s].size()){
      int next=g[u.s][i].f;
      int cost=d[u.s]+g[u.s][i].s;
      if(cost<d[next]){
        d[next]=cost;
        pq.push(mp(cost,next));
      }
    }
  }
  FOR(i,0,v){
    if(d[i]==inf)printf("INF\n");
    else printf("%d\n",d[i]);
  }
  return;
}

int main()
{
  scanf("%d%d%d",&v,&e,&r);
  FOR(i,0,e){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    g[a].pb(mp(b,c));
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 13084
N = int(input())

AB = [(-1, -1)] * N

for i in range(N):
    a, b = map(int, input().split())
    AB[i] = (a, b)

AB = sorted(AB, key=lambda x: x[1])
# print(AB)

enable = True
now = 0

for a, b in AB:
    if (now + a) <= b:
        now += a
    else:
        enable = False
        break

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

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

ll gcd(ll a, ll b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main(){
    ll a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

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


struct UnionFind {
  vector<int> par; //par[i]:iの親の番号

  //最初は全てが根であるとする。-1のときに根である。
  UnionFind(int N) : par(N, -1){}

  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
  int root(int x) {
    if(par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  //xとyが同じ集合に属するか
  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<int> a(m);
  vector<int> b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  rep(i,m){
    UnionFind uf(n);
    rep(j,m){
      if(i == j) continue;
      uf.merge(a[j], b[j]);
    }
    if(uf.size(0) < n) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// C - GCD on Blackboard
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define MAX 100000

int N;
vi A(MAX+1), L(MAX+1), R(MAX+1), M(MAX+1);

int gcd(int a, int b){
	if(a<b) swap(a,b);
	while(b){ int r = a%b; a = b; b = r; }
	return a;
}

int main(){
	cin>>N;
	for(int n=1; n<=N; ++n) cin>>A[n];
	for(int n=0; n<N; ++n) L[n+1] = gcd(L[n], A[n]);
	for(int n=N; n>=0; --n) R[n] = gcd(R[n+1], A[n]);
	for(int n=1; n<=N; ++n) M[n] = gcd(L[n], R[n+1]);
	int maxi = 0;
	for(int n=1; n<=N; ++n) maxi = max(maxi,M[n]);
	cout<< maxi <<endl;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;

  int tot = 0;
  if (X == 1 && Y == 1) {
    cout << 1000000 << endl;
    return 0;
  }

  if (X == 1)
    tot += 300000;
  else if (X == 2)
    tot += 200000;
  else if (X == 3)
    tot += 100000;

  if (Y == 1)
    tot += 300000;
  else if (Y == 2)
    tot += 200000;
  else if (Y == 3)
    tot += 100000;

  cout << tot << endl;
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	dstring[] arr = ["a"];
	foreach(i; 0..N-1) {
		dstring[] tmp;
		foreach(s; arr) {
			auto n = s.to!(dchar[]).sort().uniq.array.length.to!uint;
			foreach(dchar c; 'a'..'a'+n+1) {
				tmp ~= (s ~ c);
				debug writefln("%s %d", s ~ c, n);
			}
		}
		arr = tmp;
	}
	arr.sort();
	arr.each!writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 13948
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):
    count = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            count += 1
    result = min(count + K * 2, N-1)
    print(result)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()

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

int main(){
  int c500 = 500;
  int c100 = 100;
  int c50 = 50;
  
  int a,b,c,t;
  cin >> a >> b >> c >> t;
  
  int count = 0;
  for (int i=0; i<=a; i++){
    for (int j=0; j<=b; j++){
      for (int k=0; k<=c; k++){
        if (c500*i + c100*j + c50*k == t)
          count++;
      }
    }
  }
  
  cout << count;
}




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

using namespace std;

signed main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << a << '\n';
    return 0;
  }
  if (a % 2 == b % 2) {
    if (a % 2 == 1) {
      int c = (b - a) / 2;
      cout << ((c & 1) ^ a) << '\n';
    } else {
      int c = (b - a) / 2;
      cout << ((c & 1) ^ b) << '\n';
    }
  } else {
    if (a % 2 == 0) {
      int c = (b - a + 1) / 2;
      cout << (c & 1) << '\n';
    } else {
      int c = a ^ b;
      a++; b--;
      if (a <= b) {
        c ^= (((b - a + 1) / 2) & 1);
      }
      cout << c << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var list = new List<int[]>();
        for (int i = 0; i < n; i++)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            list.Add(inp);
        }
        list = list.OrderByDescending(f => f[2]).ToList();
        var ans = new int[101][];
        for (int i = 0; i <= 100; i++) ans[i] = new int[101];
        for (int i = 0; i <= 100; i++)
        {
            for (int j = 0; j <= 100; j++)
            {
                ans[i][j] = list[0][2] + Math.Abs(i - list[0][0]) + Math.Abs(j - list[0][1]);
            }
        }
        for (int k = 1; k < list.Count(); k++)
        {
            for (int i = 0; i <= 100; i++)
            {
                for (int j = 0; j <= 100; j++)
                {
                    if (list[k][2] == 0 && (Math.Abs(list[k][0] - i) + Math.Abs(list[k][1] - j) + list[k][2] < ans[i][j])) ans[i][j] = 0;
                    else if (list[k][2] != 0 && Math.Abs(list[k][0] - i) + Math.Abs(list[k][1] - j) + list[k][2] != ans[i][j]) ans[i][j] = 0;
                }
            }
        }
        var top = new int[3];
        for (int i = 0; i <= 100; i++)
        {
            for (int j = 0; j <= 100; j++)
            {
                if (top[2] < ans[i][j])
                {
                    top[0] = i;
                    top[1] = j;
                    top[2] = ans[i][j];
                }
            }
        }
        Console.WriteLine(string.Join(" ", top));
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <vector>
using namespace std;
int n, m, u, v, s, x[9];
vector<int> g[9];

void f(int p, int q) {
	if(q==n) {s++; return;}
	x[p] = 1;
	for(int i=0; i<g[p].size(); i++)
		if(!x[g[p][i]]) f(g[p][i], q+1);
	x[p] = 0;
}

int main() {
	cin>>n>>m;
	while(m--) {
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	f(1, 1);
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    N += 2;
    vector<int> A(N, 0);
    for (int i = 1; i < N - 1; i++) {
      cin >> A[i];
    }
    vector<int> sum(N);
    sum[0] = 0;
    for (int i = 1; i < N; i++) {
      sum[i] = sum[i - 1] + abs(A[i - 1] - A[i]);
    }
    for (int i = 1; i < N - 1; i++) {
      int ans =
          sum[i - 1] + abs(A[i + 1] - A[i - 1]) + (sum[N - 1] - sum[i + 1]);
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n); 
    int t = 0;
    for(int i=0; i<n; i++) cin >> a[i], t += a[i];
    sort(a.begin(), a.end(), greater<int>());
    if(a[m-1] * 4 * m >= t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

int main(int argc, char *argv[])
{
	int N;
	pair<int, int> p[100005];

	cin >> N;

	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		p[i] = make_pair(A, i + 1); 
	}
	sort(p, p + N);

	for (int i = 0; i < N; i++) {
		printf("%d ", p[i].second);
	}
	puts("");

	return 0;
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int x;
    cin >> x;
    long long h = 0;
    while (x >= 500) {
        x -= 500;
        h += 1000;
    }
    while (x >= 5) {
        x -= 5;
        h += 5;
    }
    cout << h << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
  IOS();
	VI v;
	ll n;cin>>n;
	REP(i,n){
		ll tmp;cin>>tmp;
		v.pb(tmp);
	}
	sort(ALL(v));
	ll ans=0,fg=true;
	while(SZ(v)){
		if(fg) ans+=v.back();
		else ans-=v.back();
		v.pob();
		fg=!fg;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   String N = sc.next();
 
   int count =0;
   for(int i=0;i<3;i++)
   {
     if(N.charAt(i)=='1') count++;
   }
 
   System.out.println(count);
 }
}

Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}



int main(){
ll N; cin >> N;
ll ans = INF;
for(ll i = 1; i <=sqrt(N);i++){
    if(N % i == 0){
    chmin(ans,i +(N / i) - 2);
}
}
cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import *
from collections import *

INF = float('inf')

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
"""

def main():
    N = int(input())
    print(N ** 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val k = sc.nextLong()
  val a = (1..n).map { sc.nextLong() }

  val map = mutableMapOf<Long, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp+1)
  }

  val values = map.values.sorted()
  val size = values.size

  if (size <= k) {
    println(0)
    return
  }

  val over = size - k
  var count = 0
  for (i in 0 until over.toInt()) {
    count += values[i]
  }

  println(count)
}


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

int main() {
  int n, a = 1, b = 1;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  rep(i, n){
    a *= 3;
    if(v[i] % 2 == 0) b *= 2;
  }
  cout << a - b << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

K, S = map(int, readline().split())

ans = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        Z = S - X - Y
        if 0 <= Z and Z <= K:
            ans += 1
print(ans)

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

using namespace std;

int main() {
    unordered_set<long long> s;
    int h, w;
    cin >> h >> w;
    vector<int> cr(h), cc(w);
    int m;
    cin >> m;
    for (int i = 0 ; i < m; ++i) {
        int r, c;
        cin >> r >> c;
        --r; --c;
        ++cr[r]; ++cc[c];
        s.insert(1LL * r * w + c);
    }
    vector<pair<int, int>> rs, cs;
    for (int i = 0; i < h; ++i) if (cr[i]) rs.emplace_back(cr[i], i);
    for (int i = 0; i < w; ++i) if (cc[i]) cs.emplace_back(cc[i], i);
    sort(rs.rbegin(), rs.rend());
    sort(cs.rbegin(), cs.rend());
    int ans = 0, l = cs.size();
    for (auto r : rs) {
        int best = -1;
        for (int i = 0; i < l; ++i) {
            int tot = r.first + cs[i].first;
            if (tot <= ans) break;
            if (s.find(1LL * r.second * w + cs[i].second) != s.end()) {
                --tot;
                ans = max(ans, tot);
            } else {
                ans = max(ans, tot);
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 27488
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
 
 
 
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	int sum = 0;
	rep(i, N) sum += A[i];
	int cnt = 0;
	rep(i, N) if (A[i]*M*4 >= sum) { cnt++; }
	bool ans = false;
	if (cnt >= M) {
		ans = true;
	}
	
	puts(ans ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

class Dice2{
public:
	Dice2(){
		number = new int[6];
		relative = new int[55];
		relative[31] = relative[43] = relative[24] = relative[12] = 0;
		relative[3] = relative[20] = relative[52] = relative[35] = 1;
		relative[1] = relative[40] = relative[54] = relative[15] = 2;
		relative[4] = relative[10] = relative[51] = relative[45] = 3;
		relative[2] = relative[30] = relative[53] = relative[25] = 4;
		relative[21] = relative[42] = relative[34] = relative[13] = 5;
 	};
	~Dice2(){
		delete[] number;
		delete[] relative;
	};

	void setNumber(int index,int num){
		number[index] = num;
	};

	int returnRight(int top,int front){
		int top_index,front_index;
		for(int i = 0; i < 6; i++){
			if(number[i] == top)
				top_index = i;
			if(number[i] == front)
				front_index = i;
		}
		return number[relative[10*top_index+front_index]];
	}
private:
	int* number;
	int* relative;
};

int main(){
	Dice2 dice2;
	int x,q,top,front;
	for(int i = 0; i < 6; i++){
		scanf("%d",&x);
		dice2.setNumber(i,x);
	}
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%d %d",&top,&front);
		printf("%d\n",dice2.returnRight(top,front));
	}
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
double p[4000];
double dp[4000][4000];

signed main() {
  cin >> N;
  for (ll i=1; i<=N; i++)
    cin >> p[i];
  dp[1][0] = 1.0-p[1];
  dp[1][1] = p[1];
  for (ll i=1; i<=N; i++) {
    for (ll j=0; j<=i; j++) {
      ll ni = i+1;
      if (ni > N) 
        continue;
      // ni番目が裏
      dp[ni][j] += dp[i][j] * (1.0-p[ni]);
      // ni番目が表
      dp[ni][j+1] += dp[i][j] * p[ni];
    }
  }
  double res = 0.0;
  for (ll i=(N+1)/2; i<=N; i++) {
    res += dp[N][i];
  }
  printf("%.10f\n", res);
  return 0;
}


Measured memory_bytes: 92672
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld double
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
ll mod=1e9+7;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }


ll dp[1<<21]={0};

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll ar[n+1][n+1];
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			cin>>ar[i][j];
		}
	}
	dp[0]=1;
	for(ll i=1,x;i<(1<<n);i++){
		x=0;
		for(ll j=0;j<n;j++) if(i&(1<<j)) x++;
		for(ll j=0;j<n;j++){
			if(i&(1<<j)){
				if(dp[i^(1<<j)]!=0 && ar[j+1][x]==1) dp[i]=(dp[i]+dp[i^(1<<j)])%mod;
			}
		}
	}
	cout << dp[(1<<n)-1] << "\n";
	return 0;
}

Measured memory_bytes: 16640
n,t = [int(i) for i in raw_input().split()]

a = [int(i) for i in raw_input().split()]

good = []

mmm = []

mmm.append(a[n-1])

for i in range(n-1):
    mmm.append(max(mmm[i],a[n-i-2]))

mmm.reverse()

for i in range(len(a)-1):
    good.append(mmm[i+1]-a[i])

m = max(good)

count = 0

for g in good:
    if g==m:count+=1

print count

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;

  if (n>=10){
    cout<<k<<endl;
    return 0;
  }else{
    cout<<(k+(100*(10-n)))<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  if(n<0)return 0;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N;
  string s;
  cin>>s;
  N=s.size();
  mat dp(N+1,vec(4,0));
  dp[0][0]=1;
  rep(i,N){
    if(s[i]=='?'){
      dp[i+1][0]=dp[i][0]*3%mod;
      rep(j,3){
        dp[i+1][j+1]=(dp[i][j]+dp[i][j+1]*3)%mod;
      }
    }else{
      rep(j,4)dp[i+1][j]=dp[i][j];
      (dp[i+1][s[i]-'A'+1]+=dp[i][s[i]-'A'])%=mod;
    }
  }
  print(dp[N][3]);
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
const int mod = 1e9 + 7;

int n, col[MAXN];
char str[MAXN];

int main(){
	cin >> n >> str;
	for(col[0] = 0; col[0] < 2; col[0]++){
		for(col[1] = 0; col[1] < 2; col[1]++){
			for(int i=2; i<n; i++){
				int msk = (str[i-1] == 'x');
				msk += 4 - col[i-1] - col[i-2];
				msk %= 2;
				col[i] = msk;
			}
			if((str[0] == 'x') == (col[0] + col[1] + col[n-1]) % 2 &&
				(str[n-1] == 'x') == (col[n-2] + col[n-1] + col[0]) % 2){
				for(int j=0; j<n; j++) printf("%c", col[j] == 1 ? 'W' : 'S');
				puts("");
				return 0;
			}
		}
	}
	puts("-1");
}


Measured memory_bytes: 896
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 1e5 + 10;
int n, m;
int x[maxN], y[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int pX = 0;
    int pY = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    for (int i = 1; i + 1 <= n; i++) {
        int delta = (x[i + 1] - x[i]) % mod;
        pX = sum(pX, mult(delta, mult(i, n - i)));
    }
    for (int i = 1; i <= m; i++) {
        cin >> y[i];
    }
    for (int i = 1; i + 1 <= m; i++) {
        int delta = (y[i + 1] - y[i]) % mod;
        pY = sum(pY, mult(delta, mult(i, m - i)));
    }
    cout << mult(pX, pY);
    return 0;
}

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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORALL(i, n) for(ll i = 0; i < n; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n;
	ll mod = 1e9 + 7;
	cin >> n;
	ll ans = 0;
	ll temp = 1;
	FORALL(i, n) {
		temp = (temp * 10) % mod;
	}	 
	ans = temp;

	temp = 1;
	FORALL(i, n) {
		temp = (temp * 9) % mod;
	}
	temp = (temp * 2) % mod;

	ans = (ans + 1000000007 - temp) % mod;

	temp = 1;
	FORALL(i, n) {
		temp = (temp * 8) % mod;
	}

	ans = (ans + temp) % mod;


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

Measured memory_bytes: 3608
#include <stdio.h>

int is_odd(int N) {
    int keta = 0;
    while (((N / 10) > 0) || (N % 10 > 0)) {
        keta += 1;
        N /= 10;
    }
    return (keta % 2 == 1);
}

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (is_odd(i))
            ans++;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
n = gets.to_i
a = gets.split.map(&:to_i)
b=Array.new(n,0)

n.times{|t|
  c = 1
  f = n - (t+1)
  k = 0
  until a[c*(f+1)-1] == nil do
    k += b[c*(f+1)-1]
    c += 1
  end
  if k%2 != a[f] then
    b[f] = 1
  end
}
puts b.inject(:+)
b.each_with_index{|t,i|
 if t == 1 then
  print i+1 , " "
 end
}

Measured memory_bytes: 20484
#include<bits/stdc++.h>
using namespace std;
#define INF 1e18L + 7
void max_self(long long&a,long long b){
    a = max(a,b);
}
void min_self(long long&a,long long b){
    a = min(a,b);
}
int main(){
    int n,W;
    cin>>n>>W;
    vector<pair<int,int>>item(n,{0,0});
    for(int i=0;i<n;i++){
        cin>>item[i].first>>item[i].second;
    }
    long long Sum =0;
    for(auto &x:item){
        Sum+=x.second;
    }
    vector<long long>KS(Sum+1,INF);
    KS[0]=0;
    for(int i = 0;i<n;i++){
        for(int v_base=Sum-item[i].second;v_base>=0;v_base--){
            min_self(KS[v_base+item[i].second],KS[v_base]+item[i].first);
        }
    }
    long long ans =0;
    for(int i=0;i<KS.size();i++){
        if(KS[i]<=W){
            ans = i;
        }
    }
    cout<<ans;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x/11)*2;
	if(x%11 >6){
		ans+=2;
	}else if(x%11 > 0){
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
int n,k,h[maxn],dp[maxn];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>h[i];
	memset(dp,0x3f3f3f3f,sizeof(dp));
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j>=1)
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));	
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}
//---Phoenix-ZH 

Measured memory_bytes: 4336
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll n,k; cin >> n >> k; bool isfinish = false;
  vl lamp(n); vl lampsum(n);
  rep(i,n) cin >> lamp[i];
  
  
  ll i=0;
  while(!isfinish and i < k){
    for(ll j=0; j < n; j++){
      lampsum[max(0LL,j-lamp[j])]++;
      if(lamp[j]+j+1 < n){
        lampsum[lamp[j]+j+1]--;
      }
    }
    
    ll nowluks = lampsum[0]; lamp[0] = lampsum[0];
    for(ll j=1; j < n; j++){
      nowluks = nowluks + lampsum[j];
      lamp[j] = nowluks;
    }
    
    bool flag = true;
    rep(i,n){
      if(lamp[i] != n){
        flag = false; 
        break;
      }
    }
    
    if(flag) isfinish = true;
    
    rep(j,n){
      lampsum[j] = 0;
    }
    
    i++;
  }
  
  for(ll x : lamp){
    cout << x << ' ';
  }
 
  cout << endl;
  
}

Measured memory_bytes: 6432
#include<iostream>
#include<string>
#include<vector>

int main() {
	char a;
	std::cin >> a;
	std::string alphabet = "abcdefghijklmnopqrstuvwxyz";

	int flag = 0;
	for (int i = 0; i < 26; i++) {
		if (alphabet.at(i) == a) {
			flag = 1;
			break;
		}
	}

	if (flag == 0) {
		std::cout << "A" << std::endl;
	}
	else
	{
		std::cout << "a" << std::endl;
	}
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void) {
  int n,p,num;
  int i = 0;
  int k = 0;
  int No[50]={0};                    //立候補者ナンバー
  int winer[9999];                   //出力用配列


  while(1){

    scanf("%d %d", &n, &p);          //立候補者数と小石の数を読み取り

    for (i = 0; i < n; i++){         //?配列を宣言すると同時に
      No[i] = 0;                     //?全ての要素を0に初期化したはずですが
    }                                //?この三行がないとうまく実行できないのは何ででしょう

    if(n==0 && p==0){                //(0 0)が入力されるとループ終了
      break;
    }
    if(n<3 || n >50 || p<2 || p>50){ //不適切な数字が入力されるループ終了
      break;
    }

    num = p;                         //pの値をコピー

    while (1){
      if (i == n){                   //iは現在碗を持っている立候補者を指す
	i = 0;                       //一周回ったらiをリセットする
      }
      if (num != 0){                 //碗に小石が入っている場合は　そのうち1個を取り　手許に置く
	num--;
	No[i]++;
      }
      else{
	num = No[i];                 //碗が空の場合は，手許に小石があればその全部を碗に入れる
	No[i] = 0;
      }
      if (No[i] == p){                //ある候補者が碗に残った最後の小石を取り出し　かつ他のどの候補者の手元にも小石がない場合
	winer[k] = i;                 //すなわち誰か一人が全ての小石を持つ場合　ゲーム終了
	k++;                          //現在碗を持つ立候補者のナンバーiを出力配列winerに書き込み
	break;                        //ループ終了
      }
      i++;                            //碗を次の人に渡す
    }
  }

  for(i=0;i<k;i++){                   //出力
    printf("%d\n", winer[i]);
  }

  return 0;
}

Measured memory_bytes: 604
import java.util.Scanner; 
public class Main {
    
    public static void main (String [] args) {
        
        // Scannerをインスタンス化
        Scanner sc = new Scanner(System.in);
        
        // 入力値の格納
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        // 数値の計算
        int plus = A + B;
        int minus = A - B;
        int multiple = A * B;
        
        // 条件分岐
        if (plus >= minus && plus >= multiple){
           System.out.println(plus); 
        } else if (minus >= plus && minus >= multiple) {
            System.out.println(minus);
        } else{
            System.out.println(multiple);
        }
        sc.close();
    }
}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define int ll
#define MOD (ll)(1e9+7)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

inline bool check(const string &s,int n){
	For(i,0,n/2-1) if(s[i]!=s[i+n/2]) return false;
	return true;
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin>>s;
	for(int i=s.size()-2;i>0;i-=2){
		if(check(s,i)){
			cout<<i<<"\n";
			return 0;
		}
	}
}












Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <list>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <random>
#include <queue>
#include <fstream>
#include <iterator> // std::back_inserter
#include <chrono>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <float.h>
#include <cassert>
#include <functional>

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    long long int ans=9223372036854775807;
    int max = 1, min = 100;

    cin >> N;

    int a[N];

    for(int i=0; i<N; i++){
        cin >> a[i];
        if(max < a[i]) max = a[i];
        if(min > a[i]) min = a[i];
    } 

    for(int i = min; i<max+1; i++){
        int can = 0;
        for(int j=0; j<N; j++){
            can += (a[j] - i)*(a[j] - i);
        }
        if(ans > can) ans = can;
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <bitset>
#include <vector>
using namespace std;

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

    int A[4];
    for(int i = 0; i < 4; i++)
    {
        A[i] = s[i] - '0';
    }

    for(int i = 0; i < 1<<3; i++)
    {
        stringstream ss;
        ss << static_cast<bitset<3>>(i);
        string sss = ss.str();

        int ans = A[0];
        vector<string> v;
        ostringstream oss;
        oss << A[0];
        v.push_back(oss.str());
        for(int j = 1; j < 4; j++)
        {
            if(sss[j-1] == '0')
            {
                ans += A[j];
                v.push_back("+");
            }
            else if(sss[j-1] == '1')
            {
                ans -= A[j];
                v.push_back("-");
            }
            ostringstream oss;
            oss << A[j];
            v.push_back(oss.str());
        }

        if(ans == 7)
        {
            for(int i = 0; i < v.size(); i++)
            {
                cout << v[i];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

int main() {
  int n,ans=0;
  cin>>n;
  vector<int> p(n);
  for(int i=0; i<n; i++) {
    cin>>p[i];
    ans += p[i];
  }
  sort(p.begin(),p.end());
  p[n-1]/=2;
  ans -= p[n-1];
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(string,s);
  map<int,int> mp;
  REP(i,s.size()){
    mp[s[i]]++;
  }

  int cnt = 0;
  bool ok = true;
  EACH(mi,mp){
    ok &= (mi.second == 2);
    ++cnt;
  }

  OUT((ok&&cnt==2)?"Yes":"No")BR;
  
  return 0;
}


Measured memory_bytes: 764
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

a = s.count('a')
b = s.count('b')
c = s.count('c')

print('YES' if max(a, b, c) <= min(a, b, c) + 1 else 'NO')

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

int a,b;

int main()
{
	cin>>a>>b;
	
	int k;
	int p=b;
	
	while(p){
		k++;
		p/=10;
	}
	
	for(int i=1;i<=k;i++) a*=10;
	int fi=a+b;
	if(sqrt(fi)==int(sqrt(fi))) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

const int maxn = 2e5+100;

int h,w,n,x,y;
char s1[maxn];
char s2[maxn];
int ans=0;
int L[maxn],R[maxn],U[maxn],D[maxn];
int main()
{
	cin>>h>>w>>n;
	cin>>x>>y;
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	ans=0;
	/*for(int i=1;i<=n;i++)
	{
		if(s[i]=='L') L[i]++;
		if(s[i]=='R') R[i]++;
		if(s[i]=='U') U[i]++;
		if(s[i]=='D') D[i]++;
		L[i]+=L[i-1];R[i]+=R[i-1];
		U[i]+=U[i-1];D[i]+=D[i-1];
	}*/
	for(int i=1;i<=n;i++)
	{
		if(s1[i]=='L') ans++;
		if(ans>=y){
			cout<<"NO"<<endl;
			return 0;
		}
		if(s2[i]=='R')
		{
			if(ans<0&&abs(ans-1)==w-y+1) continue;
			ans--;
		} 
	}
	ans=0;
	//cout<<"111111"<<endl;
	for(int i=1;i<=n;i++)
	{
		if(s1[i]=='U') ans++;
		if(ans>=x){
			cout<<"NO"<<endl;
			return 0;
		}
		if(s2[i]=='D')
		{
			if(ans<0&&abs(ans-1)==h-x+1) continue;
			ans--;
		} 
	}
	//cout<<"22222222222"<<endl;
	ans=0;
	for(int i=1;i<=n;i++)
	{
		if(s1[i]=='R') ans++;
		if(ans>=w-y+1){
			cout<<"NO"<<endl;
			return 0;
		}
		if(s2[i]=='L')
		{
			if(ans<0&&abs(ans-1)==y) continue;
			ans--;
		} 
	}
	//cout<<"333333333333333"<<endl;
	ans=0;
	for(int i=1;i<=n;i++)
	{
		if(s1[i]=='D') ans++;
		if(ans>=h-x+1){
			cout<<"NO"<<endl;
			return 0;
		}
		if(s2[i]=='U')
		{
			if(ans<0&&abs(ans-1)==x) continue;
			ans--;
		} 
	}
	//cout<<"4444444444444444444444444444444444444"<<endl;
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main()
{
  int a,b,i;
  int coin = 0;
  
  scanf("%d %d",&a,&b);
  
  for(i = 0;i < 2;i++){
    if(a > b){
      coin += a;
      a--;
    }else{
      coin += b;
      b--;
    }
  }
      
  printf("%d",coin);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll x;
    cin >> x;
    ll price=100,ans=0;
    while(price<x){
        price+=(price/100);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int constexpr maxn = 2999 + 10;
int n;
double p[maxn];
double dp[maxn][maxn];
bool done[maxn][maxn];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> p[i];
}

double prob(int i, int h) {
    if(i == 0) {
        if(h > n/2) return 1.0;
        else return 0.0;
    }
    if(done[i][h]) return dp[i][h];

    dp[i][h] = p[i] * prob(i - 1, h + 1) + (1.0 - p[i]) * prob(i - 1, h);
    done[i][h] = true;
    return dp[i][h];
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    cout.precision(10);
    cout << fixed;
    cout << prob(n, 0) << endl;
}


Measured memory_bytes: 78592