akhauriyash/Code-Regression huggingface dataset:
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
//	   cin>>t;
      

	      while(t--)
{
	/*
5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO*/
ll n,m;
cin>>n;
string s[n];
map<char,ll> M;
ll ans=0;
fo(i,n)
{
    cin>>s[i];
    M[s[i][0]]++;
}
ans+=M['M']*M['A']*M['R'];
ans+=M['M']*M['A']*M['C'];
ans+=M['M']*M['A']*M['H'];
ans+=M['M']*M['R']*M['C'];
ans+=M['M']*M['R']*M['H'];
ans+=M['M']*M['C']*M['H'];
ans+=M['A']*M['R']*M['C'];
ans+=M['A']*M['R']*M['H'];
ans+=M['A']*M['C']*M['H'];
ans+=M['R']*M['C']*M['H'];



cout<<ans;
ee;
}
return 0;
}















Measured memory_bytes: 6668
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>
#include <regex.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)<0?-(a):(a))
#define alloc(type,size) calloc(sizeof(type),size)

#define MOD 11

int main(void){
	int n,k;

	int m = 4,w;
	int i,j;
	int res = 0;


	scanf("%d%d",&n,&k);
	i = n - 2;
	if(i <= 0){
		printf("0\n");
		return 0;
	}
	while(i > 0){
		w = m;
		for(j=0;j<5;j++){
			if(w == k) res++;
			w = (w + 9) % MOD;
		}
		if(m == k) {break;}
		m = (m + 8) % MOD;
		i--;
	}
	if(i == 0){
		printf("%d\n", res);
		return 0;
	}
	res += i/MOD * 5;
	m = (m + 8) % MOD;
	i--;
	i = i % MOD;
	while(i > 0){
		w = m;
		for(j=0;j<5;j++){
			if(w == k) res++;
			w = (w + 9) % MOD;
		}
		m = (m + 8) % MOD;
		i--;
	}
	printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=200020,mod=998244353;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
inline int qmo(int x){return x+(x>>31?mod:0);}
int n,at=1,stk[maxn],tp;
ll aa[maxn],bb[maxn],a[maxn],b[maxn],g[maxn];
long double ans;
int main(){
	n=read();
	FOR(i,1,n) aa[i]=read();
	FOR(i,1,n) bb[i]=read();
	FOR(i,1,n) if(aa[i]>aa[at]) at=i;
	FOR(i,1,n){
		int pos=(i-at+1+n)%n;
		if(!pos) pos=n;
		a[pos]=aa[i],b[pos]=bb[i];
	}
	a[n+1]=a[1];b[n+1]=b[1];
	FOR(i,3,n+1) g[i]=2*g[i-1]-g[i-2]-2*b[i-1];
	ROF(i,n+1,1){
		a[i]+=g[i];
		while(tp>=2){	
			ll x_1=stk[tp]-stk[tp-1],y_1=a[stk[tp]]-a[stk[tp-1]];
			ll x_2=i-stk[tp-1],y_2=a[i]-a[stk[tp-1]];
			if(x_1*y_2-x_2*y_1<=0) tp--;
			else break;
		}
		stk[++tp]=i;
	}
	FOR(i,1,tp-1) ans+=1.0L*(a[stk[i+1]]+a[stk[i]])*(stk[i]-stk[i+1]+1)/2-a[stk[i]];
	FOR(i,1,n) ans-=g[i];
	printf("%.10lf\n",(double)ans/n);
}

Measured memory_bytes: 11908
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;

    int a[N],cnt[100001];
    for(int i =0;i<100001;i++) cnt[i] = 0;

    for(int i=0;i<N;i++){
        cin >> a[i];
        cnt[a[i]]++;
        cnt[a[i]+1]++;
        if(a[i]==0){
            continue;
        }
        cnt[a[i]-1]++;
    }
    int max = *max_element(cnt,cnt+100001);
    cout << max << endl;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  
  vector <int> l(n);
  for (int i = 0; i < n; i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  int ans = 0;
  for (int i = 0; i < k; i++){
    ans += l.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 10000011
int main(){
	int a,b,c;
    in>>a>>b>>c;
    out<<MAX(c-(a-b),0)<<ln;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
#include <cmath>
#include <stack>
#include <bitset>
#include <queue>

using namespace std;

#define int long long

const int INF = 1e18;

bool func(int x, vector<int>& p) {
    for(int i = 0; i < p.size(); i++) {
        if(p[i] == x) return true;
    }
    return false;
}

signed main() { 
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    int diff = 0;
    while(true) {
        if(!func(x - diff, p)) {
            cout << x - diff << endl;
            return 0;
        } else if(!func(x + diff, p)) {
            cout << x + diff << endl;
            return 0;
        }
        diff++;
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());

        var dict = new Dictionary<string, int>();

        for (var i = 0; i < input; i++)
        {
            var str = Console.ReadLine();
            if (dict.ContainsKey(str))
            {
                dict[str] += 1;
            }
            else
            {
                dict.Add(str, 1);
            }
        }

        var maxNum = dict.Values.Max();
        var maxList = dict.Where(_ => _.Value == maxNum).Select(_ => _.Key).ToList();
        maxList.Sort(StringComparer.Ordinal);

        foreach (var d in maxList)
        {
            Console.WriteLine(d);
        }
    }
}

Measured memory_bytes: 40796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)





int N, W;
int v[100], w[100];
//-----------------------------------------------------------------
int dp[101][10001];
int main() {
	cin >> N >> W;
	rep(i, 0, N) cin >> v[i] >> w[i];

	// init
	rep(i, 0, 101) rep(j, 0, 10001) dp[i][j] = -1;
	dp[0][0] = 0;

	// dp loop
	rep(i, 0, N) rep(j, 0, W + 1) if (0 <= dp[i][j]) {
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		if (j + w[i] <= W) {
			dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
		}
	}

	// get ans
	int ans = -1;
	rep(j, 0, W + 1) ans = max(ans, dp[N][j]);
	cout << ans << endl;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		200050

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2147483647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

//
int main(){
	string S;cin >> S;

	int r=0,b=0;
	REP(i,S.size())
		if(S[i]=='0')++r;
		else ++b;

	cout << (S.size()-abs(r-b)) << endl;

	return 0;
}




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

int main() {
    int k, s;
    cin >> k >> s;
    int res = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            if (x + y <= s && s <= x + y + k) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n,x = gets.chomp.split.map(&:to_i)

# レベルiの層の厚さをt[i]に、レベルiのパテ数の合計をp[i]に格納する
@t = [1]
@p = [1]
n.times do
    @t << @t.last*2+3
    @p << @p.last*2+1
end

def f(n,x)
    if n == 0
        return 1
    else
        case x
        when 1
            return 0
        when 2..@t[n-1]+1
            return f(n-1,x-1)
        when @t[n-1]+2
            return @p[n-1] + 1
        when @t[n-1]+3..@t[n]-1
            return @p[n-1]+1+f(n-1,x-2-@t[n-1])
        when @t[n]
            return @p[n]
        end
    end
end

p f(n,x)

Measured memory_bytes: 1788
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
MOD=10**9+7
def divc(x,y): return -(-x//y)
def divf(x,y): return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers"""
    is_prime = [True] * MAX_NUM
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(MAX_NUM):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_NUM, i):
                is_prime[j] = False
    return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    s = IS()
    x, y = MII()
    ff = s.split('T')
    ffx = [len(f) for f in ff[::2]]
    ffy = [len(f) for f in ff[1::2]]

    nx = ffx.pop(0)
    ny = 0

    ffx.sort(reverse=True)
    ffy.sort(reverse=True)

    for fx in ffx:
        if x >= nx: nx += fx
        else: nx -= fx
    for fy in ffy:
        if y >= ny: ny += fy
        else: ny -= fy

    if nx == x and ny == y: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
N = int(input())
A = list(input())
ans = A.count("R")*A.count("G")*A.count("B")
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2*j-i
    if k<N and A[k] != A[i] and A[k] != A[j] and A[i] != A[j]:
      ans -= 1
print(ans)

Measured memory_bytes: 68240
/// d.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,k;
    fi>>n>>k;
    static char str[1 << 20];
    fi>>(str + 1);
    static deque < int > D;
    for (int i = 1;i <= n;++i)
        D.pb(str[i] == 'B');
    int rev = 0;
    auto go = [&](void)
    {
        if (D.front() == rev)
            D.pop_front(),D.push_front(rev ^ 1);
        else
        {
            D.pop_front();
            rev ^= 1;
            D.push_back(rev);
        }
    };
    for (int i = 1;i <= n + n && k;++i)
        go(),--k;
    if (k & 1) go();
    for (auto it : D)
        putchar((it ^ rev) + 'A');
    puts("");
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
  string S;
  cin >> S;
  
  sort(S.begin(),S.end());
  
  if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  vector<int>	h(n);
  for(int i=0;i<n;i++)	cin >> h[i];
  
  h[0]--;
  for(int i=1;i<n;i++){
    if(h[i]==h[i-1])	continue;
    if(h[i-1]<h[i])	h[i]--;
    else{
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10, INF = 1e9;

long long last[2 * MAXn], cnt[2 * MAXn], n, ar[MAXn], psum[MAXn];

bool check(int a) {
	fill_n(last, 2 * MAXn, -1);
	fill_n(cnt, 2 * MAXn, 0);
	fill_n(psum, MAXn, 0);
	long long psum1 = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		if (ar[i] > a)
			psum1--;
		else
			psum1++;
		int hp = last[psum1 + MAXn] + 1;
		
		if (psum[hp] < psum1) {
			cnt[psum1 + MAXn] += (i - hp);
		}
		ans += cnt[psum1 + MAXn] + (psum1 > 0);
		last[psum1 + MAXn] = i;
		psum[i] = psum1;
	}
//	cout << ans << endl;
	long long hp2 = (n * (n + 1)) / 2;
	return hp2 / 2 + (hp2 % 2) < ans;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	if (n == 1)
		return cout << ar[0],0;
	
	int st = 0, en = INF + 10;
	while(st + 1 < en) {
		int med = (st + en) / 2;
		if (check(med))
			en = med;
		else
			st = med;
	}
	cout << en;
}

Measured memory_bytes: 4992
/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
*/
function Main(input) {
  //write here!
  var flag = false;
  var N = Math.ceil(input/7);
  var M = 0;
  while(N>=0){
    if(N*7+M*4==input){
      flag = true;
      break;
    }else{
      N--;
      while((N*7+M*4)<input){
      M++;
      }
    }
  }
  if(flag) console.log("Yes");
  else console.log("No");
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}
function pf(n) {
    var result = {};
    
    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;

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

  std::cin >> S;

  bool flag = S[0] == S[1] && S[1] == S[2];
  if(!flag){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N);
    for (int n = 0; n < N; n++) {
        cin >> x[n];
    }
    int ans = 100'000'000;
    for (int P = 1; P <= 100; P++) {
        int tmp = 0;
        for (int n = 0; n < N; n++) {
            tmp += (x[n] - P)*(x[n] - P);
        }
        ans = min(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;

int p[50];
int main()
{
loop:
  memset(p, 0, sizeof p);
  int m, n, t = 0, sm;
  cin >> n >> m;
  sm = m;
  if(!(m || n))
    return 0;
  while(1)
  {
    if(!m)
    {
     m = p[t];
     p[t] = 0;
    }
    else
    {
      p[t]++; 
      m--;
      if(m == 0 && p[t] == sm)
      {
        cout << t << endl;
        break;
      }
    }
    t = (t + 1) % n;
  }
  goto loop;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main() {
    ll x;
    cin>>x;
    ll sum=0;
    for(int i=1;i<=x;i++){
        sum+=i;
        if(sum>=x){
            cout<<i;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    long long n,x[10],y[10],i,total=1,j,l,dx,dy,k;
    double total2=0.0,p,q;
    cin>>n;
    for(j=2;j<=n;j++)
    {
        total*=j;
    }
    l=total/n;
    q=(double)l;
    for(i=1;i<=n;i++)
    {
        cin>>x[i]>>y[i];        
    }
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            dx=x[j]-x[i];
            dy=y[j]-y[i];
            k=(dx*dx)+(dy*dy);
            p=sqrt((double)k);
            total2+=(p*q*2.0);
        }
    }
    cout<<fixed<<showpoint<<setprecision(10)<<total2/(double)total<<endl;
    return 0;
}

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

int main(){
  int n,m,i,j,k,xmax;
  while(1){
    xmax=0;
    cin >> n >> m;
   
    if(n == 0 && m == 0)break;
    int MP[m+1][n+1];
    /*
    for(i=1;i<=m;i++){
      for(j=1;j<=n;j++){
	if(i == 1 || j == 1){
	  MP[i][j]=1;
	}else{
	  MP[i][j]=-1;
	}
      }
    }
    */
 for(i=0;i<=m;i++){
      for(j=0;j<=n;j++){
	MP[i][j]=0;
      }
    }
 MP[1][1]=1;        


    cin >> k;

    int No[k+1][2];
    for(i=0;i<k;i++){
      cin >>No[i][0] >> No[i][1]; 
      MP[No[i][1]][No[i][0]]=-1;
    }

    if(n == 1 && m ==1){
      cout << 1 << endl;
      continue;

    }
    

    for(i=1;i<=m;i++){
      for(j=1;j<=n;j++){
	if(i==1 && j==1)continue;
	if(MP[i][j] == -1){continue;}
	else if(MP[i][j-1] == -1 && MP[i-1][j] == -1)MP[i][j]=0;
	else if(MP[i][j-1] == -1)MP[i][j]=MP[i-1][j];
	else if(MP[i-1][j] == -1)MP[i][j]=MP[i][j-1];
	else{
	  MP[i][j]=MP[i-1][j]+MP[i][j-1];
	  xmax=max(xmax,MP[i][j]);
	}

      }
    }

    /* 
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++)cout << MP[i][j] << "**" ;
    cout << endl;
    }
    */
    
    cout << xmax << endl;
    
  }
  return 0;
}

Measured memory_bytes: 0
s,x=gets.split;a=[*0..9]-gets.split.map(&:to_i)
(puts s;exit)if !j=(0...s.size).find{|i|!a.find{|e|e==s[i].to_i}}
k=j.downto(0).find{|i|x=a.find{|e|e>s[i].to_i}}||-1
puts"#{k<0?a[0]>0?a[0]:a[1]:s[0...k]+x.to_s}"+a[0].to_s*(s.size-k-1)

Measured memory_bytes: 1788
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     pii             pair<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n, x)     (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     nshow(x,n)      for(int zz=0;zz<n;++zz)cout<<x[zz]<<" ";cout<<"\n";
#define     show2(x)        for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m;
    cin>>n>>m;

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

    int sum=accumulate(all(v),0ll);

    int cnt=0;
    for(int i=0;i<n;++i)
    {
        int tmp=4ll*v[i]*m;
        if(tmp>=sum)
            ++cnt;
    }

    if(cnt>=m)
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using namespace std;

int main(){
    int p,n;
    cin>>p>>n;
    map<int,int>penalty;
    set<int>ac;
    for(int i=0;i<n;i++)
    {
        int k;
        string s;
        cin>>k>>s;
        if(s=="AC")
        {
         ac.insert(k);
        }
        else
        {
            if(ac.count(k)==0)
                ++penalty[k];
        }
    }
    long int ans=0;
    for(map<int,int>::iterator it=penalty.begin();it!=penalty.end();it++)
    {
        if(ac.count(it->first)==1)
        ans+=(it->second);
    }
    cout<<ac.size()<<" "<<ans;
	return 0;
}


Measured memory_bytes: 8120
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	double a;
  	cin >> a;
  	cout << fixed << setprecision(12);
  	cout << pow(a/3,3) << endl;
}


Measured memory_bytes: 384
module S =
  Set.Make (struct
      type t = int
      let compare = compare
    end)

let id x = x

let init n f =
  let rec loop i l = if i < n then loop (i + 1) (f i :: l) else l in
  List.rev (loop 0 [])

let rec is_sorted = function
    [] -> true
  | [_] -> true
  | x :: y :: l -> if compare x y <= 0 then is_sorted (y :: l) else false

let n = Scanf.scanf " %d" id
let m = Scanf.scanf " %d" id
let q = Scanf.scanf " %d" id
let a =
  init q (fun _ -> Scanf.scanf " %d" id)
  |> List.rev

let () =
  let cnt = Array.make (m + 1) 0 in
  let nxt = Array.make (m + 1) None in
  let root = ref (-1) in
  let f (cur, ts) a =
    if cnt.(a) > 0 then
      let nxt = match nxt.(a) with
          Some nxt -> nxt
        | None -> raise (Failure "") in
      let () = cnt.(a) <- cnt.(a) - 1;
               cnt.(nxt) <- cnt.(nxt) + 1 in
      (cur, ts)
    else
      match nxt.(a) with
        Some _ -> (cur, ts) (* do nothing *)
      | None -> match cur with
                  None -> let () = root := a;
                                   nxt.(a) <- Some 0;
                                   cnt.(a) <- cnt.(0);
                                   cnt.(0) <- 0 in
                          (Some a, S.remove a ts)
                | Some cur -> let () = nxt.(cur) <- Some a;
                                       nxt.(a) <- Some 0;
                                       cnt.(a) <- cnt.(0);
                                       cnt.(0) <- 0 in
                              (Some a, S.remove a ts) in
  let () = cnt.(0) <- n - 1 in
  let (_, ts) = List.fold_left f (None, S.of_list (init m (fun i -> i + 1))) a in
  let hs =
    let rec loop i f l =
      match nxt.(i) with
        None -> l
      | Some nxt -> if cnt.(i) > 0 || f then
                      loop nxt true (i :: l)
                    else
                      loop nxt f l in
    List.rev (loop !root false []) in
  let mx = List.fold_left max min_int hs in
  let mn = try S.min_elt ts with Not_found -> max_int in
  if is_sorted hs && mx <= mn then
    print_endline "Yes"
  else
    print_endline "No"

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

using namespace std;

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

  bool ismm1 = false, ismm2 = false;
  int a1 = atoi(S.substr(0,2).c_str());
  int a2 = atoi(S.substr(2,2).c_str());

  if(a1>=1 && a1<=12)
    ismm1 = true;
  if(a2>=1 && a2<=12)
    ismm2 = true;

  if(ismm1)
    {
      if(ismm2)
	cout << "AMBIGUOUS" << endl;
      else
	cout << "MMYY" << endl;
    }
  else
    {
      if(ismm2)
	cout << "YYMM" << endl;
      else
	cout << "NA" << endl;	
    }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    if (s[len(s) - 1] == 's') {
        s += "es";
    }
    else {
        s += "s";
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h> 
using namespace std; 
#define llt long long int
#define mod 1000000007

int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(b>a&&c>b){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	while(a>=b&&k>0){
		b=b*2;
		k--;
	//	cout<<11<<endl;
	}
	while(c<=b&&k>0){
		c=c*2;
		k--;
	//	cout<<"111"<<endl;
	}
	if(b>a&&c>b)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,n,t,a,b,c,l,r,q;
    double p;
    cin>>x>>p;
    y=p*100+0.00001;
    x=x*y;
    cout<<x/100<<'\n';
}







Measured memory_bytes: 3624
function Main(input) {
    const lines = input.split("\n");
    const [n, m] = lines.shift().split(' ').map(v => +v);

    let result = Array(n).fill(false);

    try {
        lines.forEach(l => {
            let [s, c] = l.split(' ');
            s -= 1;
            if (result[s] !== false && result[s] != c) {
                throw 0;
            }
            result[s] = c;
        });
        if (n != 1 && result[0] === '0') throw 0;
        if (result[0] === false) result[0] = n == 1 ? 0 : 1;
        result = result.map(v => v === false ? 0 : v);
        console.log(result.join(''));
    } catch (_) {
        console.log(-1);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	int n,k,r,s,p,ans=0;
	cin>>n>>k;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	char a[n+1];
	for(int i=0;i<n;i++)
	{
		if(i-k>=0)
		{
			if(t[i]==t[i-k])
			{
				if(i+k<n)
				{
					if(t[i]=='r')
					{
						if(a[i-k]=='p')
						{
							if(t[i+k]=='p')
								a[i]='r';
							else 
								a[i]='s';
						}
						else
							a[i]='p';
					}
					else if(t[i]=='p')
					{
						if(a[i-k]=='s')
						{
							if(t[i+k]=='s')
							a[i]='p';
						    else
							a[i]='r';
					    }
					    else
					        a[i]='s';
					}
					else
					{
						if(a[i-k]=='r')
						{
							if(t[i+k]=='r')
								a[i]='s';
							else
								a[i]='p';
						}
						else
							a[i]='r';
					}
				}
				else
				{
					if(t[i]=='r')
					{
						if(a[i-k]!='p')
							a[i]='p';
						else
							a[i]='r';
					}
					else if(t[i]=='p')
					{
						if(a[i-k]!='s')
							a[i]='s';
						else
							a[i]='p';
					}
					else if(t[i]=='s')
					{
						if(a[i-k]!='r')
							a[i]='r';
						else
							a[i]='s';
					}

				}
			}
			else
		    {
				if(t[i]=='r')
					a[i]='p';
				else if(t[i]=='p')
					a[i]='s';
				else if(t[i]=='s')
					a[i]='r';
		    }
		}
		else
		{
			if(t[i]=='r')
				a[i]='p';
			else if(t[i]=='p')
				a[i]='s';
			else if(t[i]=='s')
				a[i]='r';
		}
	}
	for(int i=0;i<n;i++)
	{
		if(t[i]=='p'&&a[i]=='s')
			ans+=s;
		else if(t[i]=='r'&&a[i]=='p')
			ans+=p;
		else if(t[i]=='s'&&a[i]=='r')
			ans+=r;
	}
	cout<<ans<<endl;

	
	
}


Measured memory_bytes: 592
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;



int main(){
  int h,w,n,ans;
  scanf("%d%d%d",&h,&w,&n);
  
  char tem[h][w];
  int sx, sy;
  for(int i=0;i<h;i++){
    scanf("%s", tem[i]);
  for(int j=0;j<w;j++){
    if('S'==tem[i][j]){sx=i; sy=j;}
  }
  }
  // printf("%d %d\n",sx,sy);
ans=0;
for(int j=1;j<=n;j++){
  // printf("%d %d %d\n",sx,sy,ans);
    queue<int> colx;
    queue<int> coly;
    queue<int> colt;
    queue<int> hx;
    queue<int> hy;
    queue<char> hc;
    colx.push(sx);
    coly.push(sy);
    colt.push(ans);
   // printf("%d %d\n",sx,sy);
  while(1){
    int x, y, time;
    x=colx.front();
    y=coly.front();
    time=colt.front();
    colx.pop();
    coly.pop();
    colt.pop();

    // printf("%d %d?????¢?´¢\n",x,y);
    // printf("%d????????????????????????%d???\n", j, time);

    //???
    if(x!=0){
      if(((int)tem[x-1][y]-48)==j){
sx=x-1;sy=y;ans=time+1;
 while(!hx.empty()){
      tem[hx.front()][hy.front()]=hc.front();
      hx.pop();hy.pop();hc.pop();
}
 break;
}
      else if(tem[x-1][y]!='X'&&tem[x-1][y]!='@'){
        colx.push(x-1);
        coly.push(y);
        colt.push(time+1);
    hx.push(x-1);
    hy.push(y);
    hc.push(tem[x-1][y]);
    tem[x-1][y]='@';
      }
    }
      //???
    if(y!=0){
      if(((int)tem[x][y-1]-48)==j){sx=x;sy=y-1;ans=time+1;  
	while(!hx.empty()){
      tem[hx.front()][hy.front()]=hc.front();
      hx.pop();hy.pop();hc.pop();
} break;}
      else if(tem[x][y-1]!='X'&&tem[x][y-1]!='@'){
        colx.push(x);
        coly.push(y-1);
        colt.push(time+1);
    hx.push(x);
    hy.push(y-1);
    hc.push(tem[x][y-1]);
    tem[x][y-1]='@';
      }
    }
      //???
    if(y!=w-1){
      if(((int)tem[x][y+1]-48)==j){sx=x;sy=y+1;ans=time+1;     
	while(!hx.empty()){
      tem[hx.front()][hy.front()]=hc.front();
      hx.pop();hy.pop();hc.pop();
} break;}
      else if(tem[x][y+1]!='X'&&tem[x][y+1]!='@'){
        colx.push(x);
        coly.push(y+1);
        colt.push(time+1);
    hx.push(x);
    hy.push(y+1);
    hc.push(tem[x][y+1]);
    tem[x][y+1]='@';
      }
    }
      //???
    if(x!=h-1){
      if(((int)tem[x+1][y]-48)==j){sx=x+1;sy=y;ans=time+1;    
	while(!hx.empty()){
      tem[hx.front()][hy.front()]=hc.front();
      hx.pop();hy.pop();hc.pop();
}
 break;
}
      else if(tem[x+1][y]!='X'&&tem[x+1][y]!='@'){
        colx.push(x+1);
        coly.push(y);
        colt.push(time+1);
    hx.push(x+1);
    hy.push(y);
    hc.push(tem[x+1][y]);
    tem[x+1][y]='@';
      }
    }
  }
}

printf("%d\n",ans);

return 0;


}

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

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

 if( a > b ){
  cout << "a > b" << endl;
 }else if( a < b ){
  cout << "a < b" << endl;
 }else{
  cout << "a == b" << endl;
 }

 return 0;
}

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

int main() {
  int N, A, B;
  cin >> N;
  A = N % 1110;
  B = N % 1000;
 if (A >=1 && A <= 9 )
   cout << "Yes" << endl;
 else if (B % 111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <algorithm>
#include <cstring> 
using namespace std;

typedef struct restaurant{
	char cityname[11];
	int score;
	int location; //the order of input
}rest;//define restaurant struct

int N;// total restaurant

void input(rest *restaurant);
void citysort(rest *restaurant);
void selectsort(int start,int end,rest *restaurant);
void scoresort(rest *restaurant);
void output(rest *restaurant);

int main(){
	rest restaurant[100];	
	input(restaurant);
	citysort(restaurant);
	scoresort(restaurant);
	output(restaurant);
	return 0;
}

void input(rest *restaurant){//information input 
	scanf("%d",&N);      
	for(int i=0;i<N;i++){
		(restaurant+i)->location=i+1;
		scanf("%s %d",(restaurant+i)->cityname,&((restaurant+i)->score));
	}
}

void citysort(rest *restaurant){//sort cityname
	int i,j,k;
	rest t;//temporary struct variable
	for(i=0;i<N-1;i++){//selection sort
		k=i;
		for(j=i+1;j<N;j++){
			if(strcmp((restaurant+k)->cityname,(restaurant+j)->cityname)>0)
				k=j;
		}
		if(k!=i){
			t=*(restaurant+i);
			*(restaurant+i)=*(restaurant+k);
			*(restaurant+k)=t;
		}
	}
}

void selectsort(int start,int end,rest *restaurant){        //selection sort
// start is firt date index and end is last date index
	if(start==end) return ;
	int i,j,k;
	rest t;//temporary struct variable
	for(i=start;i<end;i++){
		k=i;
		for(j=i+1;j<=end;j++){
			if( ( (restaurant+k)->score ) < ( (restaurant+j)->score ) ){
				k=j;
			}
		}
		if(k!=i){
			t=*(restaurant+i);
			*(restaurant+i)=*(restaurant+k);
			*(restaurant+k)=t;
		}
	}
}

void scoresort(rest *restaurant){
	int start=0,end;
	for(end=1;end<N;end++){
		if( ( strcmp(  (restaurant+start)->cityname,(restaurant+end)->cityname ) ) == 0  ) continue;
		selectsort(start,end-1,restaurant);
		start=end;
	}
	selectsort(start,end-1,restaurant);
}

void output(rest *restaurant){
	for(int i=0;i<N;i++)
	printf("%d\n",(restaurant+i)->location);
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	int doubletCount = 0;
	string output = "No";
	for (int i = 0; i < N; i++) {
		int D1, D2;
		cin >> D1 >> D2;
		if (D1 == D2) {
			doubletCount++;
			if (doubletCount >= 3) output = "Yes";
		} else {
			doubletCount = 0;
		}
	}
	cout << output << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
	cin>>s;
	LL k,ans=0,l=s.length();
	cin>>k;
	if(l==1){
		cout<<k/2;
		return 0;
	}
	if(k==1){
		FOR(i,1,l){
			if(s[i]==s[i-1]){
				ans+=1;
				i++;
			}
		}
		cout<<ans<<endl;
		return 0;
	}

	LL kk=k/2,kkk=k%2;
	vector<int> used(l*3,0);
	string ss=s+s;
	FOR(i,1,2*l){
		if(ss[i]==ss[i-1]){
			ans+=kk;
			used[i]=1;
			i++;
			//cerr<<i<<" ";
		}
	}
	cerr<<endl;
	if(used[l]==1&&used[2*l-1]==0){
		ans=0;
		FOR(i,1,l){
			if(s[i]==s[i-1]){
				ans+=1;
				i++;
			}
		}
		ans+=k-1;
		FOR(i,2,l){
			if(s[i]==s[i-1]){
				ans+=k-1;
				i++;
			}
		}
		cerr<<"test"<<endl;
		cout<<ans;
		return 0;
	}
	cerr<<ans<<endl;
	FOR(i,1,l){
		if(s[i]==s[i-1]){
			ans+=kkk;
			i++;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n =int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
a.append(0)
a.insert(0,0)
b = [0]*(n+2)
c = [0]*(n+2)
for i in range(1,n+1):
    b[i] = max(a[i],b[i-1])
    c[n+1-i] = max(a[n+1-i],c[n+2-i])
for i in range(1,n+1):
    print(max(b[i-1],c[i+1]))

Measured memory_bytes: 15676
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,p;
long long m,v,a[100100],b[100100],del[100100],cur,vote;
bool ok(int x){
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		del[i]=0;
	}
	cur=a[x]+m;
	vote=m*v-m;
	b[x]+=m;
	int tmp=x;
	while(tmp>1&&b[tmp]>b[tmp-1]){
		swap(b[tmp],b[tmp-1]);
		tmp--;
	}
	int xxx;
	for(int i=1;i<=n;i++)
		if(b[i]==cur){
			xxx=i;
			break;
		}
	xxx--;
	if(xxx>=p)
		return false;
	for(int i=n;i>xxx+1;i--){
		long long delta=min((cur-b[i]),m);
		vote-=delta;
		del[i]=delta;
		b[i]+=delta;
		if(vote<=0){
			return true;
		}
	}
	for(int i=1;i<=xxx;i++){
		vote-=m;
		b[i]+=m;
		if(vote<=0){
			return true;
		}
	}
	int pztqm=xxx;
	for(int i=xxx+2;i<=n;i++){
		vote-=(m-del[i]);
		if(b[i]+(m-del[i])>cur)
			pztqm++;
		if(vote<=0){
			if(pztqm<p)
				return true;
		}
	}
	return false;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int l=1,r=n,mi;
	while(l<r){
		mi=(l+r+1)/2;
		if(ok(mi))
			l=mi;
		else
			r=mi-1;
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 2560
R, G, B, N = map(int, input().split())

res = 0
for r in range((N+1)//R+1):
    for g in range((N+1)//G+1):
        if (N - (R*r + g*G))%B == 0 and  N - (R*r + g*G) >= 0 :
            res += 1
    
print(res)

Measured memory_bytes: 40556
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b){
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
	fastio;
	int n,i,j,s=0,ans=INT_MAX;
	cin>>n;
	vector<int>v(n);
	for(i=0;i<n;i++)
		cin>>v[i];
	for(i=-100;i<=100;i++)
	{
		for(j=0;j<v.size();j++)
			s+=(abs(v[j]-i)*abs(v[j]-i));
		ans=min(s,ans);
		s=0;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
n, k, c = map(int, input().split())
s = input()
l = [0] * k
r = [0] * k
p = 0
# for i in range(n):
i = 0
while i < n:
    if s[i] == "o":
        l[p] = i
        p += 1
        if (p >= k):
            break
        i += c
    i += 1
p = k-1
# for i in range(n - 1, -1, -1):
i = n - 1
while i >= 0:
    if s[i] == "o":
        r[p] = i
        p -= 1
        if (p < 0):
            break
        i -= c
    i -= 1
#print(l, r)
for i in range(k):
    if l[i] == r[i]:
        print(l[i]+1)


Measured memory_bytes: 20516
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


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

int main(){
    long double a,b,c;
    cin >> a >> b >> c;

    if (a + 2 * sqrt(a) * sqrt(b) + b < c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
	public static void main(String[] args)                                        
	{
		Scanner sc=new Scanner(System.in);
		int t,k;
		
		k=sc.nextInt();
		int sum=0;
		int a[]=new int[200010];
		int arr[]=new int[200010];

		for(int i=2;i<=k;i++)
		a[i]=sc.nextInt();
		for(int i=2;i<=k;i++)
		arr[a[i]]++;
		for(int i=1;i<=k;i++)
		System.out.println(arr[i]+"");
		
	
		
	}
	
	
			
	
		
}



Measured memory_bytes: 59872
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<Pl> a(N);
  rep(i,N){
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(ALL(a));
  reverse(ALL(a));
  vl ans(N);
  int mi = INF;
  rep(i,N){
    mi = min(mi,int(a[i].second));
    if(i<N-1 && a[i].first==a[i+1].first) continue;
    ll diff;
    if(i<N-1) diff = a[i].first - a[i+1].first;
    else diff = a[i].first;
    ans[mi] += diff * ll(i+1); 
  }
  rep(i,N) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main() {
    long long n,k,sum=0,i;
    scanf("%lld%lld",&n,&k);
    long long  a[n];
    for(i=0; i<n; i++) {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    for(i=0; i<n-k; i++)
        sum+=a[i];
    printf("%lld\n",sum);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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 main() {
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> s(A + 2);
  repp(i, 1, A) cin >> s[i];
  vector<ll> t(B + 2);
  repp(i, 1, B) cin >> t[i];
  vector<ll> x(Q + 1);
  repp(i, 1, Q) cin >> x[i];

  s[0] = t[0] = -LINF / 2;
  s[A + 1] = t[B + 1] = LINF / 2;

  repp(i, 1, Q) {
    vector<ll> ss(2);
    auto itr = lower_bound(all(s), x[i]);
    ss[0] = *itr;
    ss[1] = *(itr - 1);

    vector<ll> tt(2);
    itr = lower_bound(all(t), x[i]);
    tt[0] = *itr;
    tt[1] = *(itr - 1);

    ll ans = LINF;
    rep(sss, 2) {
      rep(ttt, 2) {
        ll ds = ss[sss];
        ll dt = tt[ttt];

        ll temp = abs(ds - dt) + min(abs(x[i] - ds), abs(x[i] - dt));
        chmin(ans, temp);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3712