akhauriyash/Code-Regression huggingface dataset:
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
   
    
    ll n;
    cin >> n;
    vector<string> v(n);
    map<string,ll> ma;
    for(auto &x : v)
    {
        cin >> x;
        ma[x]++;
    }
    set<string> s;
    ll mx = -1;
    for(auto x : ma)
    {
        mx = max(mx, x.sec);  
    }
    for(auto x : ma)
    {
        if(x.sec == mx)
            s.insert(x.fi);
    }
    for(auto x : s)
        cout << x << endl;
    
}

Measured memory_bytes: 34816
import os

import sys
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A, B = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))
if A == B:
    print(0)
    exit()

A = np.array(A, dtype=int)
B = np.array(B, dtype=int)
ans = B.sum() - B[A > B].min()
print(ans)


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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];

  long long ans=0;
  rep(i,n)ans+=a[i];
  cout << ans-n << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
#define min_value(type) numeric_limits<type>::min()
#define max_value(type) numeric_limits<type>::max()
typedef long long ll;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(12); solve(); return 0;}
template<typename T> void prv(vector<T> v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void prm(vector<vector<T>> v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}
template<typename... T> void err(const T&... cod) {pr(cod...); exit(0);}

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int dp[N][15];
string s;

void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}

void solve() {
  rd(string, s);
  int n = sz(s);
  dp[n][0] = 1;
  int mt = 1;
  per(i, n - 1, 0) {
    if (s[i] == '?') {
      rep(d, 0, 10) rep(ps, 0, 13) {
        int cs = (d * mt + ps) % 13;
        add(dp[i][cs], dp[i + 1][ps]);
      }
    } else {
      rep(ps, 0, 13) {
        int cs = ((s[i] - '0') * mt + ps) % 13;
        add(dp[i][cs], dp[i + 1][ps]);
      }
    }
    mt *= 10;
    mt %= 13;
  }
  pr(dp[0][5]);
}

Measured memory_bytes: 6352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<map>
#include<deque>
#include<list>
#include<forward_list>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define ll long long
#define v vector<ll>
const ll w = (1e9 + 7);
using namespace std;
void fireman()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
struct great {
	//descending order
	bool operator()(int x, int y)
	{
		return x < y;
	}
};


struct small {
	//asecending order
	bool operator()(int x, int y)
	{
		return x > y;
	}
};

bool prime(ll x)
{
	bool b = true;
	if (x == 2)
	{
		return true;
	}
	else if (x == 1 || x % 2 == 0)
	{
		return false;
	}
	for (int i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0)
		{
			return false;
		}
	}
	return true;
}
bool great1(int a, int b)
{
	//descending order 
	return a > b;
}
bool small1(int a, int b)
{
	//asecending order 
	return a < b;
}
/*int sum_range(ll i, ll j, ll k, ll l, vector<vector<ll>>& S) {
	return S[k][l] - S[k][j - 1] - S[i - 1][l] + S[i - 1][j - 1];
}*/

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

int lcm(int a, int b)
{
	return a / gcd(a, b) * b;
}
int modpow(ll a, ll b, ll c)//fast_power log(n)
{
	if (b == 0)
		return 1 % c;
	ll u = modpow(a, b / 2, c);
	u = (u * u) % c;
	if (b & 1)
		u = (u * a) % c;
	return u;
}

int main()
{
	fireman();
	ll a, b, c,z=0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++)
	{
		if (i % c == 0)
		{
			z++;
		}
	}
	cout << z << endl;
	
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
main()
{
   long long n,a,b,mx,x;
   mx=0;
   cin>>a>>b>>n;
   long long d=min(b-1,n);
   long long m=((a*d)/b)-a*(d/b);
   cout<<m<<endl;
    
}

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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
int cou[200200];

int main(void) {
	int N;
	scanf("%d", &N);
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int temp;
		scanf("%d", &temp);
		cou[temp]++;
		cou[temp - 1]++;
		cou[temp + 1]++;
		ans = std::max(std::max(cou[temp], cou[temp - 1]), std::max(cou[temp + 1], ans));
	}

	printf("%d", ans);

	return 0;
}

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

int getNum(int n){
    int ret = 0;
    while(n%2==0){
        ret++;
        n /= 2;
    }
    return ret;
}

int main(){
    int n;
    int temp;
    int ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> temp;
        ans += getNum(temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <string.h>

int main(void){
  int i,n,out,score;
  int x[4],size;
  char op[8];

  scanf("%d",&n);
  while(n--){
    out=size=score=0;
    memset(x,0,sizeof(x));
    while(1){
      scanf("%s",op);
      if(!strcmp(op,"HIT")){
        for(i=3;i>0;i--){
          x[i] = x[i-1];
        }
        x[0] = 1;
        size++;
        if(x[3] == 1){
          score++;
          size--;
        }
      }
      else if(!strcmp(op,"HOMERUN")){
        memset(x,0,sizeof(x));
        score += size+1;
        size = 0;
      }
      else{
        out++;
        if(out==3)break;
      }
    }
    printf("%d\n",score);
  }

  return 0;
}

Measured memory_bytes: 0
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)

n = int(input())
h = list(map(int, input().split()))

@lru_cache(maxsize=2)
def f(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1] - h[0])
    return min(f(n-2) + abs(h[n] - h[n-2]), f(n-1) + abs(h[n] - h[n-1]))

print(f(n-1))

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	int rem = N % 1000;
	if (rem == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	cout << 1000 - rem << endl;
	
	return 0;
}


Measured memory_bytes: 3648
//# define FLAG
///delet....................................
# include   <bits/stdc++.h>
using namespace std;
# define    pb                      push_back
# define    mp                      make_pair
# define    IOS                     ios::sync_with_stdio(false)
# define    mem(a,b)                memset(a,b,sizeof(a))
# define    FO(i,n,a)               for(int i=n; i>=a; --i)
# define    FOR(i,a,n)              for(int i=a; i<=n; ++i)
# define    MAX(a,b)                (a)>(b)?(a):(b)
# define    MIN(a,b)                (a)<(b)?(a):(b)
# define    LINF                    0xfcfcfcfcfcfcfcf
# define    INF                     0x3f3f3f3f
# define    MOD                     1000000007
# define    eps                     0.00000001
# define    pi                      3.141592653
# define    ee                      2.718281828459
# define    hr                      putchar('\n')
# define    kb                      putchar(' ')
# define    bug                     puts("H");
# pragma    comment(linker,"/STACK:1024000000,1024000000")
typedef     vector<int>             VI;
typedef     long long               LL;
typedef     unsigned long long      ULL;
inline char gtc() {
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
# define    Template                int
inline Template read() {
    int flag=1;
    char ch=gtc();
    if(ch==EOF)return EOF;
    Template sum=0;
    while(!((ch>='0'&&ch<='9')||ch=='-'))ch=gtc();
    if(ch=='-')flag=-1,ch=gtc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-'0',ch=gtc();
    return sum*flag;
}
inline void out(Template x) {
    if(x<0)putchar('-'),x=-x;
    if(x>9)out(x/10);
    putchar(x%10+'0');
}
///coding...................................

char ch[105][105];
int a[27];
int b[105][105];

bool cmp(int i,int j) {
    return i>j;
}

int main() {
    IOS;
#ifdef FLAG
    //freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
    int h,w;
    cin>>h>>w;
    FOR(i,1,h)cin>>ch[i]+1;
    FOR(i,1,h)FOR(j,1,w)++a[ch[i][j]-'a'];
    sort(a,a+26,cmp);
    bool flag=1;
    int n4=0,n2=0,n1=0,sum=0;
    FOR(i,1,(h+1)/2)FOR(j,1,(w+1)/2) {
        if(i!=h-i+1&&j!=w-j+1)n4++;
        else if(i!=h-i+1||j!=w-j+1)n2++;
        else n1++;
    }
    //printf("......\n4:%d\n2:%d\n1:%d\n......\n",n4,n2,n1);
    while(n4) {
        if(a[0]>=4)a[0]-=4,--n4;
        else {
            flag=0;
            puts("No");
            return 0;
        }
        sort(a,a+26,cmp);
        //FOR(i,1,3)cout<<a[i]<<endl;
    }
    while(n2) {
        if(a[0]>=2)a[0]-=2,--n2;
        else {
            flag=0;
            puts("No");
            return 0;
        }
        sort(a,a+26,cmp);
    }
    while(n1) {
        if(a[0]>=1)a[0]-=1,--n1;
        else {
            flag=0;
            puts("No");
            return 0;
        }
        sort(a,a+26,cmp);
    }
    if(flag)puts("Yes");
    else puts("No");
//    FOR(i,0,25)if(a[i])printf("%c,%d\n",i+'a',a[i]);

    return 0;
}










///delete FLAG..............................




Measured memory_bytes: 256
a2, b, c, d, e= [int(input()) for i in range(5)]
a=[a2,b,c,d,e]
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (int(a[i]/10) +1)*10-a[i];
    #print(temp)
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
     # print(sum)
    else:
      sum = sum+a[i]+temp
      #print(sum)
print(int(sum))

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

using namespace std;
#define int long long
int n,a[100][100],f[24][2097200],base=1e9+7,pow_[30];
int F(int i,int ok)
{
    if(f[i][ok]!=-1) return f[i][ok];
    else if(i==n+1)
    {
        return 1;
    }
    else
    {
        int res=0;
        for(int j=1;j<=n;j++)
        {
            if(a[i][j]==1)
            {
                if((ok/pow_[j-1])%2==0) res=(res+F(i+1,ok+pow_[j-1]))%base;
            }
        }
        f[i][ok]=res;
        return res;
    }
}
main()
{
    cin>>n;
    pow_[0]=1;
    for(int i=1;i<=n+1;i++) pow_[i]=pow_[i-1]*2;
    memset(f,-1,sizeof(f));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++) cin>>a[i][j];
    }
    cout<<F(1,0);
}


Measured memory_bytes: 393472
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    string s;
    string a, b;
    cin >> s;
    for (auto itr = s.rbegin(); itr != s.rend();)
    {
        itr = string::reverse_iterator(s.erase((++itr).base()));
        if (s.size() % 2 != 0)
        {
            continue;
        }
        a.resize(s.size() / 2);
        b.resize(s.size() / 2);
        for (size_t i = 0; i < s.size(); i++)
        {
            if (i < s.size() / 2)
            {
                a[i] = s[i];
            }
            else
            {
                b[i - s.size() / 2] = s[i];
            }
        }
        if (a == b)
        {
            cout << s.size() << endl;
            return 0;
        }
    }

}

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

int main()
{
	int n;
	cin>>n;
   int m=n/1000;
   if(m*1000==n)
   	cout<<'0'<<endl;
   else{
   	m++;
   cout<<((m*1000)-n)<<endl;
}
   return 0;
}

Measured memory_bytes: 3560
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long H, W;
    scan(H, W);
    auto C = new string[](H);
    foreach (i; 0 .. H)
        scan(C[i]);
    foreach (i; 0 .. H * 2)
    {
        writeln(C[(i / 2)]);
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;
class Program
{
    public static int Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();
        int[] a2 = new int[n + 2];
        for (int i = 1; i <= n; i++)
            a2[i] = a[i - 1];

        long cost = 0;
        for (int i = 0; i < n + 1; i++)
            cost += Math.Abs(a2[i] - a2[i + 1]);

        for (int i = 1; i <= n; i++)
        {
            long ans = cost - Math.Abs(a2[i - 1] - a2[i]) - Math.Abs(a2[i + 1] - a2[i]) + Math.Abs(a2[i - 1] - a2[i + 1]);
            Console.WriteLine(ans);
        }

        return 0;
    }
}

Measured memory_bytes: 28124
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
 int n;
 cin>>n;
 for(int i=1;;i++){
      if(i*(i+1)>=2*n){
           for(int j=1;j<=i;j++){
                if(j!=i*(i+1)/2 - n){
                     cout<<j<<endl;
                }
           }
           return 0;
      }
 }






    }





      

        


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())

print("U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)+"L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U")

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


int main() {
    string s, t;
    cin >> s >> t;
    int r = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]){
            r++;
        }
    }
    cout << r; 
    cout << endl;
}


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

using namespace std;

// cl /EHsc xxx.cpp
int main(int argc, char *argv[])
{
	int bfrv[4][3][10] = {0};
	
	int n;
	cin >> n;
	int t = n;
	
	int b, f, r, v;
	while (t)
	{
		cin >> b >> f >> r >> v;
		//printf("%d %d %d %d t=%d\n", b, f , r, v, t);
		bfrv[b-1][f-1][r-1] += v;
		
		t--;
	}
	
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << bfrv[i][j][k];
			}
			cout << endl;
		}
		if (i < (4-1))
			cout << "####################" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll X;
	cin >> X;
	if (X >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}


Measured memory_bytes: 3556
import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = [v >> 1 for v in list(map(int, readline().split()))]
    lcm = a[0]
    for v in a[1:]:
        gcd = fractions.gcd(lcm, v)
        if lcm // gcd % 2 == 0 or v // gcd % 2 == 0:
            print(0)
            exit()
        else:
            lcm = lcm * v // gcd
        if lcm > m:
            print(0)
            exit()
    print(m // lcm - m // (lcm * 2))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 83820
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto h = readln.chomp.to!size_t;
  auto hi = readln.split.to!(int[]);
  hi = 0 ~ hi;

  foreach (i; 1..h+1) {
    writef("node %d: key = %d, ", i, hi[i]);
    if (i / 2 > 0)
      writef("parent key = %d, ", hi[i / 2]);
    if (i * 2 <= h)
      writef("left key = %d, ", hi[i * 2]);
    if (i * 2 + 1 <= h)
      writef("right key = %d, ", hi[i * 2 + 1]);
    writeln;
  }
}

Measured memory_bytes: 2516
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a;
    long long int i,j,k=0;
    for(i=0;i<m;i++) {
        cin>>a;
        k+=a;
    }
    if(k>n) cout<<-1<<endl;
    else cout<<n-k<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
    char c[300];
    int m,h,i,j,k,num=0,temp;
    while(1){
        scanf("%s",c);
        if(c[0]=='-')break;
        for(num=0; num<300; num++)if(c[num]=='\0')break;
        scanf("%d",&m);
        for(i=0; i<m; i++){
            scanf("%d",&h);
            for(j=0; j<h; j++){
                temp=c[0];
                for(k=0; k<num; k++){
                    c[k]=c[k+1];
                }
                c[num-1]=temp;
            }
        }
        printf("%s\n",c);
    }
    return 0;
}

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

signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	int res=0;
	if(c<b){
		cout<<c+b<<endl;
	}
	else if(c==b){
		if(a)cout<<c*2<<endl;
		else cout<<c*2<<endl;
	}
	else if(c>b){
		int d=c-b;
		if(a<d)cout<<b*2+a+1<<endl;
		else if(a==d)cout<<b*2+a<<endl;
		else cout<<b*2+d<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int Q = scan.nextInt();
			int []l = new int[Q];//奇数
			int []r= new int[Q];//奇数
			for(int i = 0;i<Q;i++) {
				l[i] = scan.nextInt();
				r[i] = scan.nextInt();
			}
			
			long[]s = new long[100002];
			
			for(int i = 0;i<100001;i++) {
				if(isprime(i)&&isprime((i+1)/2)) {
					s[i+1] = s[i]+1;
				}else {
					s[i+1] = s[i];
				}
				
			}
			
			for(int i = 0;i<Q;i++) {
				
				System.out.println(s[r[i]+1]-s[l[i]]);
				
			}
			
			
			
		}
		
		
	}
		private static boolean isprime(long x) {//素数判定、入力xが素数かtrue,falseで返す
		long i;
		if(x<2)return false;//まず２より小さいのは素数じゃない
		if(x==2)return true;//２は素数
		if(x%2==0)return false;//２で割り切れたら素数じゃない
		for(i =3;i*i<=x;i = i+2) {//それ以降iで割り切れたら素数じゃない
			if(x%i==0)
				return false;
		}
		return true;//for文回しても割り切れなかったらそれは素数
	}

}

Measured memory_bytes: 71940
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

template<class T> struct Counting {
    Counting(int64_t n) {
        _fact.assign(n+1, 1);
        for(int64_t i = 1; i <= n; i++)  _fact[i] = T(i) * _fact[i-1];
    }

    T fact(int64_t n) {
        assert(0 <= n && n < (int)_fact.size());
        return _fact[n];
    }

    T perm(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / fact(n-k);
    }

    T comb(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / (fact(k) * fact(n-k));
    }

    private:
        vector<T> _fact;
};

int main() {
  Counting<mint> cnt(2123456);
  lint K;
  cin >> K;

  string S;
  cin >> S;
  lint N = S.size();

  mint sum = 0;
  for(lint i=N; i<=N+K; i++) {
    sum += cnt.comb(i-1, N-1) * mint::pow(25, i-N) * mint::pow(26, N+K-i);
  }

  cout << sum << endl;
}

Measured memory_bytes: 21940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int h[100005];
  int dp[100005] = {};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=1;i<n;i++){
    if(i==1){
      dp[i] = abs(h[i]-h[i-1]);
    }
    else{
      dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);           
    }
  }
  cout<<dp[n-1]<<'\n';
}
		  
  



Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,ans=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
     cin>>A[i];
     if(i%2==1&&A[i]%2==1)
     {
          ans++;
     }
 }
 cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin>>n;
double d[n];
rep(i,0,n)
cin>>d[i];
sort(d,d+n);
double x=d[0];
rep(i,1,n)
{
	x+=d[i];
	x=1.0*(x/2);
}
cout<<setprecision(15)<<x<<endl;

}

Measured memory_bytes: 256
<?php
list($n, $m) = ints();
for($i = 0; $i < $m; $i++){
    list($x[], $y[]) = ints();
}
foreach(r($n) as $i){
    $map[$i] = [];
    $goals[$i] = true;
}

for($i = 0; $i < $m; $i++){
    $map[$y[$i]-1][] = $x[$i]-1;
    $goals[$x[$i]-1] = false;
}
$max = 0; 
foreach($goals as $g => $flag){
    if($flag){
        chmax($max, dfs($g));
    }
}
echo $max;

function dfs($f){
    global $d, $map;
    if(!isset($d[$f])){
        $max = 0;
        foreach($map[$f] as $from){
            chmax($max, dfs($from)+1);
        }
        $d[$f] = $max;
    }
    return $d[$f];
}


function r($n){
  return range(0, $n-1);
}
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  ll k = -1;
  rep1(i, N + 1) {
    ll temp = i * (i - 1) / 2;
    if (temp > N) break;
    if (temp == N) k = i;
  }
  if (k < 0) {
    cout << "No" << BR;
    return 0;
  }

  vector<vector<ll>> ans(k);
  int a = 0;
  rep0(i, k - 1) {
    rep0(j, k - i - 1) {
      a++;
      ans[i].push_back(a);
    }
  }

  a = 0;
  rep1(i, k) {
    rep(j, i, k) {
      a++;
      ans[j].push_back(a);
    }
  }

  cout << "Yes" << BR << k << BR;

  rep0(i, ans.size()) {
    cout << (k - 1);
    rep0(j, ans[i].size()) {
      cout << SP << ans[i][j];
    }
    cout << BR;
  }

  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> TP;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    bool iszero = false;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) == 0) {
            iszero = true;
        }
    }
    if(iszero == true) {
        cout << 0 << endl;
        return 0;
    }
    ll cnt = 1000000000000000000;
    for(int i = 0;i < N;i++) {
        cnt /= vec.at(i);
        if(cnt == 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ret = 1;
    for(int i = 0;i < N;i++) {
        ret *= vec.at(i);
    }
    cout << ret << endl;
}

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

int main(){
  
  int n;
  int sum=0;
  vector<vector<int>> data(2, vector<int>(n));
  
  cin >> n;
  
  for (int i=0; i<2; i++){
    for (int j=0; j<n; j++){
      cin >> data[i][j];
    }
  }
  
  for (int j=0; j<n; j++){
    int d=data[0][j]-data[1][j];
    if (d>0)
      sum += d;
  }
  
  cout << sum << endl;
 
  return 0;
}

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

int main(){
  ll n,c;
  cin>>n>>c;
  ll x[100005],v[100005];
  rep(i,n){
    cin>>x[i]>>v[i];
  }
  ll sum_l[100005],sum_r[100005];
  sum_l[0]=0; sum_r[0]=0;
  rep(i,n){
    sum_l[i+1]=sum_l[i]+v[i];
  }
  rep(i,n){
    sum_r[i+1]=sum_r[i]+v[n-1-i];
  }
  ll max_l[100005],max_r[100005];
  max_l[0]=0; max_r[0]=0;
  rep(i,n){
    max_l[i+1]=max(max_l[i],sum_l[i+1]-x[i]*2);
  }
  rep(i,n){
    max_r[i+1]=max(max_r[i],sum_r[i+1]-(c-x[n-1-i])*2);
  }
  ll ans=0;
  rep(i,n){
    ans=max(ans,sum_l[i+1]-x[i]+max_r[n-i-1]);
  }
  rep(i,n){
    ans=max(ans,sum_r[i+1]-(c-x[n-1-i])+max_l[n-i-1]);
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 4992
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

const INF: usize = 1001001001001001;

#[fastout]
fn main() {
   input! {
      h: usize,
      w: usize,
      mut s: [Bytes; h]
   }

   for i in 0..h {
      s[i].insert(0, b'#');
      s[i].push(b'#');
   }
   s.insert(0, vec![b'#'; w + 2]);
   s.push(vec![b'#'; w + 2]);

   let mut q = std::collections::VecDeque::new();
   let mut d = vec![vec![INF; w + 2]; h + 2];
   d[1][1] = 0;
   q.push_back((1, 1));
   while let Some((x, y)) = q.pop_front() {
      for &(dx, dy) in [(1, 0), (0, 1), (!0, 0), (0, !0)].iter() {
         let xn = x + dx;
         let yn = y + dy;
         if s[xn][yn] == b'#' {
            continue;
         }
         if d[xn][yn] > d[x][y] + 1 {
            d[xn][yn] = d[x][y] + 1;
            q.push_back((xn, yn));
         }
      }
   }
   if d[h][w] == INF {
      println!("-1");
      return;
   }

   let mut x = h;
   let mut y = w;
   while x != 1 || y != 1 {
      s[x][y] = b'#';
      for &(dx, dy) in [(1, 0), (0, 1), (!0, 0), (0, !0)].iter() {
         let xn = x + dx;
         let yn = y + dy;
         if s[xn][yn] == b'#' {
            continue;
         }
         if d[xn][yn] + 1 == d[x][y] {
            x = xn;
            y = yn;
            break;
         }
      }
   }
   s[1][1] = b'#';
   let mut ans = 0;
   for i in 1..=h {
      for j in 1..=w {
         if s[i][j] == b'.' {
            ans += 1;
         }
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2192
A, B = map(int, input().split())
a = set()
b = set()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
"""
i = 2
temp = A + 0
while i * i <= temp:
  if A <= 1:
    break
  while A % i == 0:
    a.add(i)
    A //= i
  i += 1
i = 2
temp = B + 0
while i * i <= temp:
  if B <= 1:
    break
  while B % i == 0:
    b.add(i)
    B //= i
  i += 1
"""
a = set([i[0] for i in factorization(A)])
b = set([i[0] for i in factorization(B)])
inter = a.intersection(b)
if A == 1 and B == 1:
  print(1)
else:
  print(len(inter) + 1)

Measured memory_bytes: 38896
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#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
using namespace std;

int main() {
	int N;
	cin >> N;
	int ans = N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9592
#include<stdio.h>
int main()
{
    int k;
    int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d", &k);
    printf("%d", arr[k-1]);
}


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

/*
int vistd[10004];
vector<int>a[10004];
vector<int>dis(10004,0);
void dfs(int k){
   if(vistd[k]==0){
    vistd[k]=1;
    for(int i=0;i<a[k].size();i++){
        if(!vistd[a[k][i]]){
/// to find the distance between each node and their children dis[a[k][i]]=dis[k]+1;
            dfs(a[k][i]);
        }
    }
   }

}
int freq[2004];
*/
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 double d,t,s;
 cin>>d>>t>>s;
 if(d/s <=t)
    cout << "Yes" << endl;
 else 
    cout << "No" << endl;




}


Measured memory_bytes: 3712
import sys
input = sys.stdin.readline
import collections

N, X, Y = map(int, input().split())

def bfs(i):
    dist = [-1]*N
    dist[i] = 0
    que = collections.deque([])
    que.append(i)
    
    while len(que) != 0:
        v = que.popleft()
        for nv in graph[v]:
            if dist[nv] != -1:continue
            dist[nv] = dist[v]+1
            que.append(nv)
    return dist[i+1:]

graph = {}
for i in range(N):
    graph[i] = set()

for i in range(N-1):
    graph[i].add(i+1)
    graph[i+1].add(i)
graph[X-1].add(Y-1)
graph[Y-1].add(X-1)

d = collections.Counter([])
for i in range(N):
    d += collections.Counter(bfs(i))
for i in range(1,N):
    if i == N-1:
        print(0)
    else:
        print(d[i])

Measured memory_bytes: 93404
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;

void print_table(int A[],int n){
  for(int i=0;i<n;i++){
    cout << (i==0 ? "" : " ") << A[i];
  }
  cout << endl;
}

int SelectionSort(int A[],int N){
  int minj,sw;
  sw = 0;
  for(int i=0;i<N;i++){
    minj = i;
    for(int j=i;j<N;j++){
      if(A[minj]>A[j]){
        minj = j;
      }
    }
    swap(A[minj],A[i]);
    if(i != minj){
      sw++;
    }
  }
  return sw;
}


int main(){
  int N,sw,A[100];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sw = SelectionSort(A,N);

  print_table(A,N);
  cout << sw << endl;
  return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n,greater<int>());
	int ans=0;
	for(int i=0;i<n-1;i++)
	{
		ans+=a[(i+1)/2];
	}
	cout << ans;
	
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;cin >>s;
   ll k;cin >>k;
   ll n=s.size();
   vector<ll>num(n);
//   vector<bool>ch(n,true);
    for (int i = 0; i < n; ++i) {
        num[i]=(('a'-s[i])+26)%26;
    }
//    for (int i = 0; i < n; ++i) {
//        cout <<num[i]<<" ";
//    }
    for (int i = 0; i < n; ++i) {
        if (num[i] <= k) {
            k -=num[i];
            s[i]='a';
        }
        if(i==n-1){
            k%=26;
            s.back()+=k;
        }
    }
    cout <<s<<endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

    string s;
    vector<string> data;
    for(int i = 0; i < N; i++){
        cin >> s;
        sort(&s[0], &s[10]);
        data.push_back(s);
    }
    sort(data.begin(), data.end());

    long long ans = 0;
    string active_s = "";
    int active_cnt = 0;
    for(int i = 0; i < N; i++){
        if(data[i]==active_s){
            active_cnt++;
            ans += active_cnt;
        }else{
            active_s = data[i];
            active_cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
    }

    vector<int> ans;

    while (b.size() > 0)
    {
        for (int i = b.size() - 1; i >= 0; i--)
        {
            if (b[i] == i + 1)
            {
                ans.push_back(b[i]);
                b.erase(b.begin() + i);
                break;
            }
            else if (i == 0)
            {
                ans.push_back(-1);
                goto END;
            }
        }
    }

END:
    for (int i = ans.size() - 1; i >= 0; i--)
    {
        printf("%d\n", ans[i]);
        if (ans[i] == -1)
            break;
    }

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0;i<N;i++) cin >> S[i];
  sort(S.begin(),S.end());
  
  map<string,int> M;
  int maxs=1;
  M[S[0]] = 1;
  for(int i=1;i<N;i++){
    M[S[i]]++;
    maxs = max(maxs,M[S[i]]);
  }
  
  for(int i=0;i<N;i++){
    if(i!=0) if(S[i]==S[i-1]) continue;
    if(M[S[i]] == maxs) cout << S[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 27136
def main():
    N = int(input())
    R = tuple(int(input()) for _ in range(N))

    min_ = float('inf')
    max_ = -float('inf')
    for i in range(N):
        max_ = max(max_, R[i] - min_)
        min_ = min(min_, R[i])

    print(max_)

main()

Measured memory_bytes: 15736
#include<stdio.h>

int n,A[2000000],B[2000000],C[10001],i;

int main(void){
  for(i=0;i<10001;i++)C[i]=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]),C[A[i]]++;
  for(i=1;i<10001;i++)C[i]+=C[i-1];
  for(i=n-1;i>=0;i--)B[C[A[i]]-1]=A[i],C[A[i]]--;
  for(i=0;i<n;i++)printf("%d%c",B[i],(i<n-1?' ':'\n'));

  return 0;
}

Measured memory_bytes: 16264
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (N,K) = rd.readListInt()
    val A = rd.readListLong()

    val nums = ArrayList<Long>()
    for (i in 0 until N-1) {
        var sum = A[i]
        nums.add(sum)
        for (j in i+1 until N) {
            sum += A[j]
            nums.add(sum)
        }
    }
    
    val BitLn = 40
    var mask = 0L
    for (d in BitLn downTo 0) {
        val nmask = mask + (1L shl d)
        if (nums.count{ (it and nmask) ==  nmask } >= K) {
            mask = nmask
        }
    }

    val ans = mask
    println(ans)

    return
}


//val rd = debug.Reader("etc", "dwacon5th-prelims", "b", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 62580
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n,m,v,p,vv;
    cin >> n >> m >> v >> p;
    vector<ll> a(n),b(n);
    rep(i,0,n-1)cin >> a[i];

    sort(a.begin(),a.end(),greater<ll>());
    rep(i,0,n-1)b[i] = -a[i];


    ll border = a[p-1];
    ll l = p-1;
    ll r = n-1;
    ll bstart = lower_bound(b.begin(),b.end(),-border) - b.begin();
    // ll bend = upper_bound(b.begin(),b.end(),border) - b.begin() -1;
    if(bstart> 0)vv = max(v - bstart -1,(ll)0);
    else vv = v-1;
    ll ball = m*vv;

    ll tmp = a[r] + m;
    if(tmp >= border){
        rep(j,bstart,n-1)ball -= min(tmp - a[j],m);
        if(ball <= 0){
            cout << n << endl;
            return 0;
        }
    }
    // cout << bstart << endl;

    while(r-l > 1){
        ball = m*vv;
        // cout << l << " " << r << endl;;
        ll mid = (r+l)/2;
        ll tmp = a[mid] + m;
        if(tmp < border){
            r = mid;
            continue;
        }
        rep(j,bstart,n-1)if (j != mid)ball -= min(tmp - a[j],m);
        if(ball <= 0){
            l = mid;
            continue;
        }else{
            r = mid;
            continue;
        }
        
    }
    ll ans = l + 1;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1792
def solve():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    num_dict = {}
    for i, num in enumerate(A):
        if not num in num_dict:
            num_dict[num] = 1
        else:
            num_dict[num] = num_dict[num] + 1
    cnt, ans = 0, 0
    num_dict_size = len(num_dict)
    for k, v in sorted(num_dict.items(), key =lambda x: x[1]):
        if cnt >= num_dict_size - K:
            print(ans)
            return
        else:
            ans += v
            cnt += 1
        
solve()


Measured memory_bytes: 38964
def answer(in0):
    nums = [int(n) for n in in0.split(" ")]
    x1 = int(nums[0])
    y1 = int(nums[1])
    x2 = int(nums[2])
    y2 = int(nums[3])

    width = (x2 - x1)
    height = (y2 - y1)

    x3 = x2 - height
    y3 = y2 + width
    x4 = x1 - height
    y4 = y1 + width

    print(x3, y3, x4, y4)

answer(input())

Measured memory_bytes: 3064
s = '01234567'
memo = {s => 0}
q = [s]

mv = [-4, 4, 1, -1]
while p = q.shift
  i = p.index('0')
  mv.each do |m|
    j = i + m
    next if j < 0 || j > 7 || (i == 3 && j == 4) || (i == 4 && j == 3)
    pn = p.dup
    pn[i], pn[j] = pn[j], pn[i]
    next if memo[pn]
    memo[pn] = memo[p] + 1
    q.push pn
  end
end

while s = gets
  puts memo[s.chomp.delete(' ')]
end

Measured memory_bytes: 10848