akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <ctime>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 200010

int n;
int l[N], r[N];
char s[N];

int main() {
	in(n);
    scanf("%s", s+1);
    for(int i = 1; i <= n; ++i) {
    	l[i] = l[i - 1];
    	if(s[i] == '#') ++l[i];
    }
    for(int i = n; i; --i) {
    	r[i] = r[i + 1];
    	if(s[i] == '.') ++r[i];
    }
    int ans = inf;
    for(int i = 0; i <= n; ++i) {
    	ans = min(ans, l[i] + r[i + 1]);
    }
    outn(ans);
}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;



    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scaner sc = new Scaner();
        write wr = new write();
        Math2 mmath = new Math2();
        //ここから

        var x=sc.IntArr;
        var N=x[0];
        var A=sc.IntArr;

        double ans=0;
        for(int i=0;i<N;++i){
            ans+=1.0/(double)A[i];

        }

        wr.wri(1.0/ans);
        //ここまで
       
    }


    
}


 class Math2
{
    public long[] Fact;  //Nまでの階乗
    public long[] invFact;  //階乗の逆元
    public void FactoricalModSet(long N,long MOD=1000000007)
    {
        Fact = new long[N + 1];
        invFact = new long[N + 1];

        Fact[0] = 1;
        for(long i = 1; i <= N; ++i)
        {
            Fact[i] = Fact[i - 1] * i%MOD;
        }
        invFact[N] = powMOD(Fact[N], MOD - 2);

        for (long i = N; i > 0; --i)
        {
            invFact[i - 1] = invFact[i] * i%MOD;
        }

    }

    public long nCrMod(long n,long r,long MOD=1000000007)
    {
        return (Fact[n] * invFact[r] % MOD * invFact[n-r]%MOD);
    }

    public long powMOD(long x,long n,long MOD = 1000000007)
    {
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * x % MOD;
            x = x * x % MOD;
            n >>= 1;
        }
        return res;
    }

    static long GCD(long x, long y)
    {
        if (y == 0) return x;
        return GCD(y, x % y);
    }

    static long LCM(long x, long y)
    {
        return x * y / GCD(x, y);
    }
}


class Scaner
{
    public string Str => Console.ReadLine();

    public string[] StrArr => Str.Split(' ');

    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public char[] CharArr => Str.ToArray();
    public long Long1 => LongArr[0];
    public int Int1 => IntArr[0];
    
}



class write
{
    public  void wri<T>(T x)
    {
        Console.WriteLine(x);
    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x=0,y=0;
		cin>>n;
		vector<int> v(n,0);
		vector<int> c(n,0);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		for(int i=0;i<n;i++){
			cin>>c[i];
		}
		for(int i=0;i<n;i++){
			if(v[i]>=c[i]){
				x = x+v[i];
				y = y+c[i];
			}
		}
		cout<<x-y<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
ll MOD=1e9+7;
ll MAX=1e17;

int main(){
	int n;
	cin>>n;
	int a[n+1],ans=0,c=0;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 1; i <= n; ++i)
	{
		if(a[i]==i){
			c++;
			if(i!=n and a[i+1]!=i+1) {
				ans+=(c+1)/2;
				c=0;
			}
		}
	}
	ans+=(c+1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N; cin >> N;
    deque<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));

    ll ans = N;

    vector<bool> B(A[N - 1] + 1, false);

    rep(i, N) {
        if (i != N - 1 && A[i] == A[i + 1]) {
            --ans;
        }
        else if (B[A[i]] == true) {
            --ans;
        }
        for (ll j = A[i]; j <= A[N - 1]; j += A[i]) {
            B[j] = true;
        }
    }

    cout << ans << endl;

}

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

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;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


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






Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc055/tasks/arc069_a
// math
import std.algorithm;
import std.stdio;

void main() {
    long n, m;
    readf("%s %s\n", &n, &m);

    if(m < 2*n) {
        min(n, m/2).writeln;
        return;
    }

    ((2*n + m)/4).writeln;
}



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

string s;
vector<int > consti;
vector<int> ans_consti;
int depth;
int n;
void depth_count(){
	int i = 0;
	depth = -1;
	while(s[i] == '['){
		depth++;i++;
	}
}
void solve(int index,int now_depth){
	while(index < s.size()){
		if(s[index] == '[' || s[index] == ']'){
			index++;
			continue;
		}else{
			int first_index = index;
			while(s[index] != ']'&&index < s.size()){
				if(s[index] == '['){index++;continue;}
				string tmp_s;
				for(int i=0;s[index+i] != ']';i++)tmp_s = tmp_s + s[index+i];
				index += tmp_s.size() + 1;//]
				stringstream ss;
				ss << tmp_s;
				int a;
				ss >> a;
				consti.push_back(a);
			}
			sort(consti.begin(),consti.end());
			int min_consti = 0;
			if(now_depth == 0)for(int i=0;i<consti.size()/2+1;i++)min_consti += consti[i]/2 + 1;
			else for(int i=0;i<consti.size()/2+1;i++)min_consti += consti[i];
			stringstream ss2;
			ss2 << min_consti;
			string min_s = ss2.str();
			s.erase(s.begin() + first_index-1,s.begin() + index);
			for(int i=0;i<min_s.size();i++)
				s.insert(s.begin() + first_index - 1 + i,min_s[i]);
			index = first_index + min_s.size();
			if(now_depth == depth-1)ans_consti = consti;
			consti.clear();
		}
	}
}
		
int main(){
	cin >> n;
	while(n--){
		cin >> s;
		depth_count();
		for(int i=0;i<depth;i++)solve(0,i);
		if(depth == 1){
		s.erase(remove(s.begin(),s.end(),'['),s.end());
		s.erase(remove(s.begin(),s.end(),']'),s.end());
		cout << s << endl;
		}else{
		int ans = 0;
		for(int i = 0;i<ans_consti.size()/2 + 1;i++)
			ans += ans_consti[i];
		cout << ans << endl;
		}
		consti.clear();
	}
}

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

typedef struct{
	double x;
	double y;
}Point;

void koch(int n, Point a, Point b){
	if(n==0) return;
	
	Point s,t,u;
	double th=M_PI*60.0/180.0;
	
	s.x=(2.0*a.x+1.0*b.x)/3.0;
	s.y=(2.0*a.y+1.0*b.y)/3.0;
	
	u.x=(1.0*a.x+2.0*b.x)/3.0;
	u.y=(1.0*a.y+2.0*b.y)/3.0;
	
	t.x=(u.x-s.x)*cos(th)-(u.y-s.y)*sin(th)+s.x;
	t.y=(u.x-s.x)*sin(th)+(u.y-s.y)*cos(th)+s.y;
	
	
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,b);
	
}

int main(void){
	Point a,b;
	int n;
	
	scanf("%d",&n);
	
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	
	return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int n, k;
	cin >> n >> k;

	vector< int >v(202020);
	vector< pair<int, int> >a;
	rep(i,0,n){
		int x;
		cin >> x;
		v[x]++;
	}

	rep(i,0,202020) {
		if (v[i]>0) {
			a.push_back({v[i],i});
		}
	}
	
	sort(a.begin(),a.end());

	int sz = a.size();
	int ans = 0;
	if (sz <= k) {
		cout << ans << endl;
	}
	else {
		int c = 0;
		while (sz > k) {
			ans += a[c].first;
			sz--;
			c++;
		}
		cout << ans << endl;
	}


	return 0;

}

Measured memory_bytes: 3188
from math import factorial

S = int(input())
MOD = 1000000007

max_num_part = S // 3

ans = 0
for p in range(1, max_num_part + 1):
    rem_ball = S - 3 * p
    v = (factorial(rem_ball + p - 1) // (factorial(rem_ball) * factorial(p - 1))) % MOD
    v %= MOD
    ans += v

print(ans % MOD)

Measured memory_bytes: 9224
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
divlist =  [0] + make_divisors(n)
print(len(str(divlist[divlist.index(divlist[-1])//2 + 1])))


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

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

	int N, M; cin >> N >> M;
	if(N == M) Yes
	else No
}

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

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

    int w,h,x,y,r;
    while(cin >> w >> h >> x >> y >> r){
        string result = (r <= x && x <= (w - r)) && (r <= y && y <= (h - r)) ? "Yes" : "No";
        cout << result << endl;
        return 0;
    }
}

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

double dp[3141][3141];

int main(){
	int N;
	cin >> N;
	double p[N];
	for(int i=0;i<N;i++)cin >> p[i];
	
	for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)dp[i][j]=0.0;
	dp[0][0]=1.0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=N;j++){
			dp[i+1][j]+=dp[i][j]*(1-p[i]);
			if(j<N){
				dp[i+1][j+1]+=dp[i][j]*p[i];
			}
		}
	}
	
	double ans=0.0;
	for(int i=(N/2)+1;i<=N;i++)ans+=dp[N][i];
	
	printf("%.10f\n",ans);
	
	/*for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++)printf("%.10f ",dp[i][j]);
		cout << endl;
	}*/
	
	return 0;
}

Measured memory_bytes: 73984
#C
N = int(input())
S = list(str(input()))
look_east = [0]
E = 0
W = 0
for s in S:
    if s == "E":
        look_east.append(look_east[-1]+1)
        E+=1
    else:
        look_east.append(look_east[-1])
        W+=1

ans = N
for i in range(N):
    we = look_east[i]
    if S[i] == "E":
        change = i-we + E-(we+1)
    else:
        change = i-we + E-(we)
        
    ans = min(ans,change)
        
print(ans)


Measured memory_bytes: 17528
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
typedef long long ll;
int a[MAXN];
int sv[MAXN],mi[MAXN],Cnt[MAXN];
ll ans[MAXN];
int n,cnt;
int getpos(int now)
{
	int pos=lower_bound(sv+1,sv+1+cnt,now)-sv;
	return pos;
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	memset(mi,0x3f,sizeof(mi));
	memset(Cnt,0,sizeof(Cnt));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sv[i]=a[i];
	}
	sort(sv+1,sv+1+n);
	cnt=unique(sv+1,sv+1+n)-sv-1;
	sv[0]=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=getpos(a[i]);
		mi[a[i]]=min(mi[a[i]],i);
		Cnt[a[i]]++;
	}
	for(int i=cnt;i>=1;i--)
	{
		ll det=sv[i]-sv[i-1];
		ans[mi[i]]+=det*Cnt[i];
		mi[i-1]=min(mi[i],mi[i-1]);
		Cnt[i-1]+=Cnt[i];
	}
	for(int i=1;i<=n;i++)
	{
		printf("%lld\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 3456
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split()))for _ in range(n)]
ans=0
for i in range(n):
    sum=0
    for j in range(m):
        sum+=b[j]*a[i][j]
    if sum+c>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
    int i, n;
    long r, r_1, tmp, benefit;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%ld", &r);
        if (i==0) {
            tmp=r;
            r_1=r;
            continue;
        }
        if (i==1) {
            benefit=r-r_1;
            r_1=r;
            if ((r-tmp)<0) tmp=r;
            continue;
        }
        if ((r-r_1)<0) {
            if (tmp>r) tmp=r;
            r_1=r;
        } else if ((r-r_1)>=0) {
            if (benefit<=(r-tmp)) benefit=r-tmp;
            r_1=r;
        }
        // printf("%ld %ld\n", tmp, benefit);
    }
    printf("%ld\n", benefit);
    return 0;
}



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

int main(void){
    // Your code here!
    string s;
    cin >> s;
    int length = s.size();
    s.pop_back();
    s.pop_back();
    int counter =2;
    bool res = false;
    while(!res){
        bool cur =true;
        for (int i = 0;i<=s.size()/2-1;i++){
            if (s[i] !=  s[i+s.size()/2]){
                cur = false;
            }
        }
        if (cur) res = true; 
        else if (cur ==false){
            counter +=2;
            s.pop_back();
            s.pop_back();
        }
    }
   cout << length-counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll r=0,g=0,b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
    }
    ll ans=r*g*b;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int k=j+(j-i);
            if(k>=n) continue;
            if(s[i]==s[j]) continue;
            if(s[j]==s[k]) continue;
            if(s[k]==s[i]) continue;
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.*; 
import java.io.*;

public class Main{
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        
        long N = nextLong();
        long K = nextLong();

        // if N < K
        // 1st will be K-N
        // 2nd will be N again

        N = N % K;
        System.out.println(Math.min(N, K-N));
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

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

int n = 2e5;
int newnode() { return -- n; }

struct node {
    char op;
    int x, y, z;

    node() { }
    node(char o, int a, int b, int c): op(o), x(a), y(b), z(c) { }
};

vector<node> ans;

void add(int a, int b, int c) { ans.push_back(node('+', a, b, c)); }
void cmp(int a, int b, int c) { ans.push_back(node('<', a, b, c)); }

int zero, temp;
int pw[35], x[35], y[35], z[65];

int main() {
#ifdef Wearry 
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    zero = newnode();
    temp = newnode();
    for (int i = 0; i <= 30; ++i) pw[i] = newnode();
    for (int i = 0; i <= 30; ++i) x[i] = newnode();
    for (int i = 0; i <= 30; ++i) y[i] = newnode();
    for (int i = 0; i <= 60; ++i) z[i] = newnode();

    add(0, 1, temp); 
    cmp(zero, temp, pw[0]);
    for (int i = 1; i <= 30; ++i) add(pw[i-1], pw[i-1], pw[i]);

    for (int i = 30; i >= 0; --i) {
        add(zero, zero, temp);
        for (int j = 30; j > i; --j) add(temp, temp, temp), add(temp, x[j], temp);
        add(temp, temp, temp), add(temp, pw[0], temp);
        for (int j = i-1; j >= 0; --j) add(temp, temp, temp);

        cmp(0, temp, temp);
        cmp(temp, pw[0], x[i]);
    }

    for (int i = 30; i >= 0; --i) {
        add(zero, zero, temp);
        for (int j = 30; j > i; --j) add(temp, temp, temp), add(temp, y[j], temp);
        add(temp, temp, temp), add(temp, pw[0], temp);
        for (int j = i-1; j >= 0; --j) add(temp, temp, temp);

        cmp(1, temp, temp);
        cmp(temp, pw[0], y[i]);
    }

    for (int i = 0; i <= 30; ++i) 
        for (int j = 0; j <= 30; ++j) {
            add(x[i], y[j], temp);
            cmp(pw[0], temp, temp);
            add(temp, z[i + j], z[i + j]);
        }

    add(zero, zero, temp);
    for (int i = 60; i >= 0; --i) add(temp, temp, temp), add(temp, z[i], temp);

    add(temp, 2, 2);

    //cerr << (int) ans.size() << endl;

    printf("%d\n", (int) ans.size());
    for (auto x : ans) {
        printf("%c %d %d %d\n", x.op, x.x, x.y, x.z);
    }

    return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n,x,pos[N];
int main() {
	scanf("%d",&n);
	rep(i,1,n+1) scanf("%d",&x),pos[x]=i;
	int cnt=0,ans=0;
	rep(i,1,n+1) {
		if (i==1||pos[i-1]>pos[i]) cnt=0;
		++cnt;
		ans=max(ans,cnt);
	}
	printf("%d\n",n-ans);
}


Measured memory_bytes: 1024
#include <stdio.h>

#define MAX_INPUT 50

void dataset(int*);

int
main()
{
  int kumiawasenokazu[MAX_INPUT + 1] = {};
  dataset(kumiawasenokazu);

  int n;
  while(-1 != scanf("%d\n", &n))
    {
      printf("%d\n", kumiawasenokazu[n]);
    }
  
  return 0;
}

void dataset(int *kumiawase)
{
  int a, b, c, d;
  for(a = 0; a <= 9; a++)
    {
      for(b = 0; b <= 9; b++)
	{
	  for(c = 0; c <= 9; c++)
	    {
	      for(d = 0; d <= 9; d++)
		{
		  kumiawase[a + b + c + d]++;
		}
	    }
	}
    }
}



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

string chng(string t){
  string work = t;
  int n = t.size();
  work.at(0) = t.at(n-1);
  for(int i = 1;i < n;i++){
      work.at(i) = t.at(i-1);
  }
  return work;
}

int main(){
  string s,t,r,ans;
  cin >> s >> t;
  r = s; ans = "No";
  for(int i = 0;i < s.size();i++){
    if(r == t){
      ans = "Yes";
      break;
    }else{
      r = chng(r);
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> L[i];
    }

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

    int ans = 0;

    for (int i = 0; i < N - 2; ++i)
    {
        for (int j = i + 1; j < N - 1; ++j)
        {
            if (L[i] == L[j])
                continue;
            for (int k = j + 1; k < N; ++k)
            {
                if (L[j] == L[k])
                    continue;
                if (L[k] < L[j] + L[i])
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Control.Monad

solve :: VU.Vector Int -> Int -> IO ()
solve xs n = forM_ [0..n-1] $ \i -> print $ max (l VU.! i) (r VU.! (i+1))
    where
        l = VU.scanl max 0 xs
        r = VU.scanr max 0 xs

main = do
    n <- readLn :: IO Int
    xs <- VU.replicateM n (fst . fromJust . B.readInt <$> B.getLine)
    solve xs n

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

int main(int argc, char const *argv[])
{
    long long int n, a; cin >> n;
    long long int sum = 0, sq_sum = 0;
    int mod = 1000000007;
    rep(i,n){
        cin >> a; sum += a; sq_sum += a*a;
        sum %= mod; sq_sum %= mod;
    }
  	long long int ans = sum * sum % mod - sq_sum + mod;
    ans *= (mod+1)/2;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3512
use proconio::{input, fastout};
extern crate itertools;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n-1],
    }

    let mut sn = vec![0; n];

    for &sub in a.iter() {
        sn[sub-1] += 1;
    }

    for &v in sn.iter() {
        println!("{}", v);
    }
}


Measured memory_bytes: 5528
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
	int n,t,a[111][111],cnt=0,b;double s;
	cin>>n>>t;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<t;j++)
		{
			cin>>a[i][j]; 
		}
	}
	for(int i=0;i<n-1;i++)
	{
	
		for(int z=i+1;z<n;z++)
		{
			s=0;
		for(int j=0;j<t;j++)
		{
			s+=(a[i][j]-a[z][j])*(a[i][j]-a[z][j]);
		}
		s=sqrt(s);
		if(s==int (s))cnt++;
}
	}
	cout<<cnt<<endl;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

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

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

    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] != b[i]) cnt++;
    }

    if(cnt <= 2) {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(void){
    int s;
    map<int,int> u;
    cin>>s;
    u[s]++;
    for(int i=2;i<=10000000;i++){
        if(s%2==0){
            s/=2;
        }else{
            s=s*3+1;
        }
        u[s]++;
        if(u[s]>=2){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int[] list = new int[5];
    for (int i=0; i<list.length; i++) {
      list[i] = sc.nextInt();
    }
    int k = sc.nextInt();
    
    int max = 0;
    for (int i=0; i<list.length; i++) {
      for (int j=i+1; j<list.length; j++) {
        max = Math.max(max, list[j]-list[i]);
      }
    }
    
    if (max > k) {
      System.out.println(":(");
    }
    else {
      System.out.println("Yay!");
    }
  }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int X = scanner.nextInt();
    int[] L = new int[N];
    for (int i = 0; i < N; i++) {
      L[i] = scanner.nextInt();
    }
    int count = 1;
    int x = 0;
    for (int i = 0; i < N; i++) {
      x += L[i];
      if (x <= X) count++;
    }
    System.out.println(count);
  }
}


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

int hgt[100005];

int n, l;
vector<vector<int>> adj;

int timer;
vector<int> tin, tout;
vector<vector<int>> up;

void dfs(int v, int p,int x)
{
    tin[v] = ++timer;
    up[v][0] = p;
    hgt[v]=x;
    for (int i = 1; i <= l; ++i)
        up[v][i] = up[up[v][i-1]][i-1];

    for (int u : adj[v]) {
        if (u != p)
            dfs(u, v,x+1);
    }

    tout[v] = ++timer;
}

bool is_ancestor(int u, int v)
{
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v)
{
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

void preprocess(int root) {
    tin.resize(n+1);
    tout.resize(n+1);
    timer = 0;
    l = ceil(log2(n+1));
    up.assign(n+1, vector<int>(l + 1));
    dfs(root, root,0);
}



signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    int u,v;
    cin>>n;
    cin>>u>>v;
    int x,y;
    adj.resize(n+1);
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    preprocess(v);
    
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        int z=lca(i,u);
        int dis1=hgt[z];
        int dis2=hgt[u]-hgt[z];
        if(dis1>dis2)
        {
            mx=max(mx,hgt[i]-1);
        }
    }
    cout<<mx;

}

Measured memory_bytes: 33200
n, k = map(int, input().split())

ans = 0
a = n//k
ans += a*(a-1)*(a-2) + 3*a*(a-1) + a

if k % 2 == 0:
  a = (n-k//2)//k + 1
  ans += a*(a-1)*(a-2) + 3*a*(a-1) + a
  
print(ans)

Measured memory_bytes: 38384
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    string N = to_string(n);
    string M = to_string(m);
    string x;
    string y;
    rep(i, n)
    {
        y+=M;
    }
    rep(i,m){
        x+=N;
    }
    if(x<y){
        cout << x << endl;
    }else{
        cout << y << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int A[] = new int[M];
    
    for(int i=0; i<M; i++){
      A[i] = sc.nextInt();
      if(X<A[i]){
        if(i <= (double)M/2){
          System.out.println(i);
          break;
        } else {
          System.out.println(M-i);
          break;
        }
      }
    }
  }
}

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int deg[5];

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

	for(int i=0; i<3; i++){
		int a, b; cin>>a>>b;
		deg[a]++, deg[b]++;
	}
	for(int i=1; i<=4; i++) if(deg[i]>=3){
		cout<<"NO\n";
		return 0;
	}
	cout<<"YES\n";

	return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

struct UFTree {
    static const int MAX_N = 1e6;
    int p[MAX_N], r[MAX_N], s[MAX_N];

    UFTree(int n) : p(), r(), s() {
        for(int i = 0; i < n; ++i) {
            p[i] = i;
            r[i] = 0;
            s[i] = 1;
        }
    }

    int root(int x) {
        return p[x] == x ? x : (p[x] = root(p[x]));
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(r[x] < r[y]) {
            p[x] = y;
            s[y] = s[x] + s[y];
        } else {
            p[y] = x;
            s[x] = s[x] + s[y];
            if(r[x] == r[y]) r[x]++;
        }
    }

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


ll n, m;
string s;

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

    V<Pii> edges(m);
    REP(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        edges[i] = {a, b};
    }
    UFTree t = UFTree(n);

    Vl res(m+1, 0LL);
    RREP(i, m-1, 0) {
        int a = edges[i].first, b = edges[i].second;
        if (t.same(a, b)) {
            res[i] = res[i+1];
            continue;
        }
        ll sa = t.size(a), sb = t.size(b);
        res[i] = res[i+1] + sa*sb;
        t.unite(a, b);
    }
    REP(i, m) {
        std::cout << n*(n-1)/2 - res[i+1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 14592
n,h=gets.split.map(&:to_i)
a=0
b=[]
n.times do
  aa,bb=gets.split.map(&:to_i)
  a=aa if aa>a
  b << bb
end
b.sort!.reverse!
c=0
b.each do |bb|
  if bb>a
    h-=bb
    c+=1
    if h<=0
      puts c
      exit
    end
  else
    break
  end
end
puts c+(h-1)/a+1


Measured memory_bytes: 3704
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<string>
typedef long long ll;
using namespace std;

char a[100000];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a == b && a == c && b == c)
	printf("1\n");
	if(a == b && a != c)
	printf("2\n");
	if(a == c && a != b)
	printf("2\n");
	if(b == c && b != a)
	printf("2\n");
	if(a != b && a != c && b != c)
	printf("3\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl a(3),b(3),c={3600,60,1};
	while(cin>>a>>b){
		auto v=inner_product(all(c),b.begin(),-inner_product(all(c),a.begin(),0));
		vl d(3);
		rep(i,3)if(v>=c[i]){
			d[i]++;
			v-=c[i--];
		}
		puta(d);
	}
	return 0;
}


Measured memory_bytes: 3156
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    int coins;

    cin >> A >> B;
    coins = 0;

    for (int i = 0; i < 2; i++) {
        if (A > B) 
            coins += A--;
        else 
            coins += B--;
    }

    cout << coins << endl;

    return 0;    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0;i < n; i++) 

int main(void)
{
  int  rem = 0;
  int K;
  cin >> K;
  vector<bool> isRemainded(K);
  
  int cnt = 0;
  while(1)
  {
    cnt++;
    rem = (rem * 10 + 7) % K;
    
    if(rem == 0)
    {
      break;
    }
    else if(isRemainded[rem -1])
    {
      cnt = -1;
      break;
    }
    else
    {
      isRemainded[rem -1] = true;
    }
  }
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 3308
use std::io;

fn main() {
    let s = {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        iter.next().unwrap();
        let s: String = iter.next().unwrap().parse().unwrap();
        s
    };
    print!("A{}C", &s[0..1]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
int main()
{
    int M;
    cin >> M;
    cout << 48 - M << endl;
    return 0;
}

Measured memory_bytes: 256
//                                                   ¯\_(ツ)_/¯
  //#pragma GCC optimize("Ofast")
 //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pi pair<int,int>
const int N=100005,MOD=1e9+7;

using namespace std;

int n,k;
ll dp[105][N];
ll last[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	scanf("%d %d",&n,&k);

	for(int i=0,x;i<n;i++){

		scanf("%d",&x);

		if(i==0){
			for(int j=0;j<=x;j++)dp[i][j]=1;
		}
		else{
			for(int j=0;j<=k;j++){
				if(j<=x)
					dp[i][j]=(last[j])%MOD;
				else 
					dp[i][j]=(last[j]-last[j-x-1]+MOD)%MOD;
			}
		}

		memset(last,0,sizeof(last));

		for(int j=0;j<=k;j++){
			if(j)last[j]=last[j-1];
			(last[j]+=dp[i][j])%=MOD;
		}
	}

	printf("%lld\n",dp[n-1][k]);

}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    ll s1=0,s2=0;
    if(n%2==0){
        rep(i,(n-1)/2) s2+=2ll*(a[n-i-1]-a[i]);
        s2+=a[(n-1)/2+1]-a[(n-1)/2];
    }
    else{
        rep(i,(n-2)/2){
            s1+=2ll*(a[n-i-1]-a[i]);
            s2+=2ll*(a[n-i-1]-a[i]);
        }
        s1+=a[(n-2)/2+2]+a[(n-2)/2+1]-a[(n-2)/2]*2;
        s2+=a[(n-2)/2+2]*2-a[(n-2)/2+1]-a[(n-2)/2];
    }
    cout<<max(s1,s2)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int func1(int a){
  if (a<0) {
    a *=-1;
    return a;
  }
  else {
    return a;
  }
}
 
 
int main(){
  int N;
  cin >>N;
  vector<int> vec;
  for (int i=0;i<N;i++){
    int a;
    cin >>a;
    vec.push_back(a);
  }
  vector<int64_t> dp(N);
  dp[0]=0;
  dp[1]=func1(vec[0]-vec[1]);
  if(N==2){
    cout << dp[1] << endl;
  }
  else{
    for (int i=2;i<N;i++){
      int64_t a =dp[i-2]+func1(vec[i]-vec[i-2]);
      int64_t b =dp[i-1]+func1(vec[i]-vec[i-1]);
      
      if (a<b){dp[i]=a;}
      else{dp[i]=b;}
    }
    cout << dp[N-1] <<endl;
    
  }
}

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

int main(void){
    char s[5];
    scanf("%s",&s);
    int ans=0;

    for(int i=1;i<4;i++){
        if(s[i-1]==s[i]){
            ans++;
        }
    }

    if(ans==0){
        puts("Good");
    }else{
        puts("Bad");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 100005
ll mod=1e9+7;

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

int bit[MAX_N];
void add(int i,int x){
  i++;

  while(i<MAX_N){
    bit[i]+=x;
    i+=(i&-i);
  }
}

int sum(int i){
  i++;

  int res=0;
  while(i){
    res+=bit[i];
    i-=(i&-i);
  }
  return res;
}

ll N,R,a,b;
ll fact[MAX_N];
int t[MAX_N];

int main(){
  fact[0]=1;
  for(int i=1;i<MAX_N;i++)
    fact[i]=mul(fact[i-1],i);

  while(1){
    scanf("%lld",&N);
    if(N==0)break;
    scanf("%lld",&R);
    memset(bit,0,sizeof(bit));
    for(int i=0;i<N;i++)t[i]=i;

    for(int i=0;i<R;i++){
      scanf("%lld %lld",&a,&b);
      a--,b--;
      swap(t[a],t[b]);
    }

    ll ans=0;
    for(int i=0;i<N;i++){
      ll num=t[i];
      ll cnt=num-sum(num);
      ans+= mul(fact[N-1-i],cnt);
      ans%=mod;
      add(t[i],1);
    }

    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 4736
io = STDIN
int=Array.new(10**6){0}
n=io.gets.to_i
max=0
ar=io.gets.split.map do |a|
  i=a.to_i
  max=i if i>max
  i
end.sort.tally
  # 3  6  9  12  15  18  21  24
  #      8         16        24
  #         11             22
  #                16
  #                          24
int=Array.new(max+1)
cnt=0
ar.each do |k,v|
  i=k
  cnt+=1 if v==1 && !int[i]
  while(i<=max)
    int[i]=true
    i+=k
  end
end
puts cnt


Measured memory_bytes: 53216
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;

#define sorted(vector) sort(vector.begin(),vector.end())
#define vmin(vector) *min_element(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())

//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n,m,tmp;
    long long mod= 1000000007;
    cin>>n>>m;
    
    L dp(100010,0);
    M x;
    dp[0]=1;
    for(int i=0  ;i<m  ;i++){
        cin>>tmp;
        x[tmp]=1;
    }
    for(int i=0  ;i<n  ;i++){
        if (not x[i+1]){
            dp[i+1]+=dp[i]%mod;
        }
        if (not x[i+2]){
            dp[i+2]+=dp[i]%mod;
        }
    }
    cout<<dp[n]%mod<<endl;
}


Measured memory_bytes: 7296
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

R = int(input())
print(2*R*math.pi)




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

using namespace std;

bool kaibun(const string &s) {
    for (int i = 0; i < s.length() / 2; ++i) {
        if (s.at(i) != s.at(s.length() - i - 1)) {
            return false;
        }
    }
    return true;
}

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

    int N = s.length();

    if (N == 1 || kaibun(s) && kaibun(s.substr(0, (N - 1) / 2)) && kaibun(s.substr((N + 3) / 2 - 1, (N - 1) / 2))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;
    if(b == 1){
        cout<<0;
        return 0;
    }
    int have = a,ans = 1;
    while(have < b){
        ans++;
        have += a - 1;
    }
    
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256