akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 998244353;
ll fact[5010200];
ll invfact[5010200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a + mod -b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    if(k == 0){
        return 1;
    }
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    ll N, M;
    cin >> N >> M;
    make_fact(5010000);
    make_invfact(5010000);

    ll res = 1;
    res = mul(res, comb(3 * M + N - 1, N-1));

    for(ll i = 2 * M + 1; i <= 3 * M; i++){
        ll remain = 3 * M - i;
        ll tmp = mul(N, comb(N + remain - 2, N-2));
        res = sub(res, tmp);
    }
    for(ll x = M + 1; x <= N; x++){
        if(3 * M - x < 0 || (3 * M - x) % 2 == 1){
            continue;
        }
        if(x > N){
            continue;
        }
        ll ball = (3 * M - x) / 2;

        ll tmp = mul(comb(N, x), comb(ball + N - 1, N-1));
        res = sub(res, tmp);
    }

    cout << res << endl;
}

Measured memory_bytes: 78464
#include <stdio.h>

int main(void) {
    char c;
    int i, n;
    scanf("%d",&n);
    for (i=0;i<n;i++) {
        scanf("%c",&c);
        if (c == 'Y') {
            printf("Four\n");
            return 0;
        }
    }
    printf("Three\n");
    return 0;
}

Measured memory_bytes: 128
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_WATER_MAX		30										// 最大水種類数
#define D_SUGAR_MAX		1500									// 最大砂糖種類数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF

// 内部変数
static int si1W[D_WATER_MAX + 5];								// 水種類
static int siWCnt;												// 水種類数
static int si1S[D_SUGAR_MAX + 5];								// 砂糖種類
static int siSCnt;												// 砂糖種類数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化
	memset(si1W, D_OFF, sizeof(si1W));							// 水種類
	siWCnt = 0;													// 水種類数
	memset(si1S, D_OFF, sizeof(si1S));							// 砂糖種類
	siSCnt = 0;													// 砂糖種類数

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 設定取得
	int liW1, liW2, liS1, liS2, liSL, liAL;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d%d%d%d%d", &liW1, &liW2, &liS1, &liS2, &liSL, &liAL);

	// 限界濃度
	double ldLimit = (double)liSL / (double)(liSL + 100);

	// 水種類作成
	int liCnt1 = liAL / 100 / liW1;						// 追加回数
	for (i = 0; i <= liCnt1; i++) {
		int liCnt2 = (liAL / 100 - liW1 * i) / liW2;		// 追加回数
		for (j = 0; j <= liCnt2; j++) {
			int liW = liW1 * i + liW2 * j;						// 重さ
			if (liW <= liAL / 100) {
				si1W[liW] = D_ON;
			}
		}
	}
	for (i = 0; i <= D_WATER_MAX; i++) {
		if (si1W[i] == D_ON) {
			si1W[siWCnt] = i;
			siWCnt++;
		}
	}

	// 砂糖種類作成
	liCnt1 = liAL / 2 / liS1;							// 追加回数
	for (i = 0; i <= liCnt1; i++) {
		int liCnt2 = (liAL / 2 - liS1 * i) / liS2;			// 追加回数
		for (j = 0; j <= liCnt2; j++) {
			int liS = liS1 * i + liS2 * j;						// 重さ
			if (liS <= liAL / 2) {
				si1S[liS] = D_ON;
			}
		}
	}
	for (i = 0; i <= D_SUGAR_MAX; i++) {
		if (si1S[i] == D_ON) {
			si1S[siSCnt] = i;
			siSCnt++;
		}
	}

	// 水と砂糖を混ぜる
	double ldMax = -1;
	int liSum, liS;
	for (i = 0; i < siWCnt; i++) {
		for (j = 0; j < siSCnt; j++) {

			// 重さチェック
			int liWeight = si1W[i] * 100 + si1S[j];
			if (liWeight > liAL) {
				continue;
			}

			// 濃度チェック
			double ldCon = (double)si1S[j] / (double)liWeight;
			if (ldCon > ldLimit) {
				continue;
			}

			// 最大濃度
			if (ldMax < ldCon) {
				ldMax = ldCon;
				liSum = liWeight;
				liS = si1S[j];
			}
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d %d\n", liSum, liS);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time = 0;
    time += 60 - m1 + (h2 - h1 - 1) * 60 + m2;
    int ans = time - k;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	int n, z, w;
	cin >> n >> z >> w;

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

	if(n == 1){
		cout << abs(a[0] - w) << endl;
	}else{
		cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
	}

	return 0;
}

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


def main():
    """Function."""
    a, b = map(int, input().split())

    if a == 1 or b == 1:
        if a == 1 and b != 1:
            print("Alice")
        elif a != 1 and b == 1:
            print("Bob")
        else:
            print("Draw")
    else:
        if a > b:
            print("Alice")
        elif b > a:
            print("Bob")
        else:
            print("Draw")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#import<cstdio>
int main(){int a,c=3,r=1;for(char d[]="123546",s[9];a=scanf("%s",s),*s>60;r+=*d%8)*s%6-4?a+=*s%5+*s%2*2+c&3,d[a]=*d,*d=d[a=++a%4+1],d[a]=d[5],d[5]=55-*d:c+=*s+3;~-r&&printf("%d\n",r);~a&&main();}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
flag = 0
List = []

for n in range(N):
    if A[n]%2 == 0:
        List.append(A[n])


for n in range(len(List)):
    if List[n] % 3 == 0:
        pass
    elif List[n] % 5 == 0:
        pass
    else:
        flag += 1
        break

if flag != 0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 61868
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 100000+5;
vector<pair<int, int>> G[MX];
bool visited[MX];

void dfs(int node) {
    visited[node] = true;
    for(auto &[a,b]: G[node]) {
        if(!visited[a]) dfs(a);
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n, m; cin >> n >> m;

    FOR(i,0,m-1) {
        int x,y,z; cin >> x >> y >> z;
        G[x].emplace_back(y, z);
        G[y].emplace_back(x, z);
    }

    int ans = 0;
    FOR(i,1,n) {
        if(!visited[i]) {
            ans++;
            dfs(i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13840
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const long long mminus=-1;
const long long one=1;
long long a[maxn],m;
int n;
long long gcd(long long a,long long b)
{
	if(a>b)
		swap(a,b);
	if(a==0)
		return b;
	return gcd(b%a,a);
}
long long get_least()
{
	long long res=a[0];
	for(int i=1;i<n;i++)
	{
		res=(long long)res*a[i]/gcd(res,a[i]);
		if(res>m)
			return mminus;
	}
	return res;
}
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	scanf("%d%lld",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]/=2;
	}
	long long least=get_least();
//	printf("%lld\n",least);
	if(least==mminus)
		puts("0");
	else
	{
		for(int i=0;i<n;i++)
			a[i]*=2;
		for(int i=0;i<n;i++)
			if(least%a[i]==0)
			{
				puts("0");
				return 0;
			}
		long long ans=(m/least+one)/2;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> a,b;
    int u=0;
    rep(i,n){
        if (u<=0 && s[i]=='o'){
            a.push_back(i+1);
            u=c+1;
        }
        u--;
    }
    u=0;
    rep(i,n){
        if (u<=0 && s[n-i-1]=='o'){
            b.push_back(n-i);
            u=c+1;
        }
        u--;
    }
    if (a.size()!=k) return 0;
    reverse(all(b));
    rep(i,a.size()){
        if (a[i]==b[i]) cout << a[i] << endl;
    }
}

Measured memory_bytes: 3448
#include <stdio.h>

int main(void)
{
    char s[3];
    scanf("%s", s);

    int i, ans = 700;
    for (i = 0; i < 3; ++i) {
        if (s[i] == 'o') ans += 100;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC092C solver = new ABC092C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC092C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }
            int sum = 0;
            int prev = 0;
            for (int i = 0; i < N; i++) {
                sum += Math.abs(prev - A[i]);
                prev = A[i];
            }
            sum += Math.abs(prev);
            for (int i = 0; i < N; i++) {
                int ans = sum;
                int p = 0;
                int n = 0;
                if (i != 0) {
                    p = A[i - 1];
                }
                if (i != N - 1) {
                    n = A[i + 1];
                }
                ans -= Math.abs(p - A[i]);
                ans -= Math.abs(n - A[i]);
                ans += Math.abs(p - n);
                out.println(ans);
            }
        }

    }
}



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

const int M = 100001;

int memo[M * 2], sum[M * 2];
int s[M], t[M], c[M];

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

    for(int i = 0; i < N; i++) {
        cin >> s[i] >> t[i] >> c[i];
        s[i] *= 2;
        t[i] *= 2;
    }

    for(int i = 1; i <= C; i++) {
        for(int j = 0; j < M * 2; j++) memo[j] = 0;
        for(int j = 0; j < N; j++) if(c[j] == i) memo[s[j]-1]++, memo[t[j]]--;
        for(int j = 1; j < M * 2; j++) memo[j] += memo[j-1];
        for(int j = 0; j < M * 2; j++) if(memo[j] > 0) sum[j]++;
    }

    int ans = -1e9;
    for(int i = 0; i < M * 2; i++) {
        ans = max(ans, sum[i]);
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>

using namespace std;

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

    float mai = 0;
    mai = ceil(N/1000);
    int result = 1000 * mai - N;
    cout << result << endl;
}


Measured memory_bytes: 3720
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int a[100110];
int ans=0;
int main()
{
	  cin>>n;
	  int maxn=-1;
	  int x=0;
	  for(int i=1;i<=n;i++)
	    {
	    	  cin>>x;
	    	  ans+=x;
	    	  if(maxn<x)
	    	    maxn=x;
		}
	  ans-=maxn/2;
	  cout<<ans;
	  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a,/*b[n],*/c[61];
    //memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++){
        cin>>a;
        for(ll i=0;i<60;i++){
            if((1LL<<i)&a)c[i]++;
            //cout << c[i]<<endl;
        }
    }
    ll ans=0;
    for(ll i=0;i<60;i++){
        ans+=(((1LL<<i)%mod)*((c[i]*(n-c[i]))%mod))%mod;
        ans%=mod;

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

Measured memory_bytes: 384
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    readln;
    readln.split.to!(int[]).reduce!gcd.writeln;
}








void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4348
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    // string temp="";
    ll ans=0;
    string last="",curr="";
    rep(i,0,sz(s)-1){
        curr+=s[i];
        if(curr!=last){
            ans++;
            last=curr;
            curr="";
        }
    }
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define vi vector<int>
#define vd vector<double>
#define ii pair<int,int>
#define vii vector<ii>
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i<(int)b; i++)
#define fi first
#define se second
#define repd(i, a, b) for (int i = a; i>=(int)b; i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define foreach(it, c) for (typeof((c).begin()) it = (c).begin(); it!= (c).end(); ++it)
#define in freopen("test.in","rt",stdin)
#define out freopen("test.out","wt",stdout)
#define tl cout<<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms"

using namespace std;


int main()
{  // in;
long a,b,c,tmpb,tmpc,tmpa;
int i=0;
cin>>a>>b>>c;
while(true)
{
if (a%2==1)break;
if (b%2==1)break;
if (c%2==1)break;

tmpb=a/2+c/2;
tmpc=a/2+b/2;
tmpa=b/2+c/2;
//cout<<a<<" "<<b<<" "<<c<<endl;

if((a==tmpa)&&(b==tmpb)&&(c==tmpc)){i=-1; break;}
if((a==tmpb)&&(b==tmpc)&&(c==tmpa)){i=-1; break;}
if((a==tmpc)&&(b==tmpa)&&(c==tmpb)){i=-1; break;}
if((a==tmpa)&&(b==tmpc)&&(c==tmpb)){i=-1; break;}
if((a==tmpc)&&(b==tmpb)&&(c==tmpa)){i=-1; break;}
if((a==tmpb)&&(b==tmpa)&&(c==tmpc)){i=-1; break;}
i++;
a=tmpa;
b=tmpb;
c=tmpc;
if (a%2==1)break;
if (b%2==1)break;
if (c%2==1)break;
if((a==b)&&(b==c)){i=-1; break;}
}
cout<<i;






return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<int>[201];
            var dic = new HashSet<int>[201];

            var K = int.Parse(Console.ReadLine());

            for (var k = 1; k <= K; k++)
            {
                list[k] = new List<int>();
                dic[k] = new HashSet<int>();

                for (var t = k; t >= 1; t--)
                {
                    if ((k % t) == 0)
                    {
                        list[k].Add(t);
                        dic[k].Add(t);
                    }
                }
            }

            var sum = 0L;

            for (var a = 1; a <= K; a++)
            {
                for (var b = 1; b <= K; b++)
                {
                    for (var c = 1; c <= K; c++)
                    {
                        var min = Math.Min(Math.Min(a, b), c);

                        foreach (var kouho in list[min])
                        {
                            if(dic[a].Contains(kouho) && dic[b].Contains(kouho) && dic[c].Contains(kouho))
                            {
                                sum += kouho;
                                goto fin;
                            }
                        }
                    fin:
                        continue;
                    }
                }
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 19968
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = input()
N = len(A)
ans = N*(N-1)//2

for v in Counter(A).values():
	ans -= v*(v-1)//2
print(ans+1)


Measured memory_bytes: 5712
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
string substrback(string str, size_t pos, size_t len) {
    const size_t strLen = str.length();
    return str.substr(strLen - pos, len);
}
int N,length;


int main(){
    cin >> N;
    string W[N];
    rep(i,N) cin >> W[i];
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            if(W[i]==W[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    rep(i,N-1){
        if(substrback(W[i],1,1)!=W[i+1].substr(0,1)){
            cout << "No" << endl;
                return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N, M;
    cin >> N >> M;
    vector<pl> v(N);
    for (auto &x : v) cin >> x.first >> x.second;
    sort(ALL(v));
    PQ<ll> pque;
    ll ans = 0;
    ll idx = 0;
    FOR(i, 1, M + 1) {
        while (idx < N) {
            if (v[idx].first > i) {
                break;
            }
            pque.push(v[idx].second);
            idx++;
        }
        if (pque.size()) {
            ll tmp = pque.top();
            pque.pop();
            ans += tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2936
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut x: i32 = s.trim().parse().unwrap();

    let mut res = 0;
    while x >= 5 {
        if x >= 500 {
            x -= 500;
            res += 1000;
        } else if x >= 5 {
            x -= 5;
            res += 5;
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class Program
    {   
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] array = new int[n];
            for(int i = 0; i < n; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
            int max = int.MinValue;
            int min = array[0]; 

            for(int i = 1; i < n; i++)
            {
                if (max < array[i] - min)
                {
                    max = array[i] - min;
                }
                if (min > array[i])
                {
                    min = array[i];
                }
            }

            
            Console.WriteLine(max);
        }


    }
}

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

int k(int a) {
	for (int i = 0;; i++) {
		if (a - 26 * i >= 'a'&&a - 26 * i <= 'z')return a-26*i;
	}
}
int main() {
	int a;
	while (cin>>a,a) {
		string b;
		cin >> b;
		int x[100], y[100];
		for (int c = 0; c < a; c++) {
			scanf("%d%d", &x[c], &y[c]); x[c]--; y[c]--;
		}
		for (int i = a - 1; i >= 0; i--) {
			int d = (int)b[x[i]]+abs(x[i]-y[i]), e = (int)b[y[i]] + abs(x[i] - y[i]);
			d = k(d); e = k(e);
			b[x[i]] = e; b[y[i]] = d;
		}
		cout << b << endl;
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;

int main()
{
	int n = 0;
	cin >> n;
	int sum = 0;
	int max_price = 0;
	for (int i = 0; i < n; i++)
	{
		int price = 0;
		cin >> price;
		sum += price;
		max_price = max(price, max_price);
	}


	cout << (sum - max_price + (max_price / 2)) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int L, R, D;
	scanf("%d %d %d", &L, &R, &D);
	int c = 0;
	for (int i = L; i <= R; i++){
		if (i%D==0){
		c++;
		}
	}
	printf("%d", c);
	return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll x;
int main(){
	
	scanf("%lld",&x);
	ll cnt=100;
	int ans=0;
	while(cnt<x){
		cnt=(ll)(cnt*1.01);
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
const int maxi = 100005;
typedef long long ll;

ll h[maxi],dp[maxi];
ll n;

ll inf = 100000000000000L;
ll fun(ll i)
{
	if(dp[i]!=-1)return dp[i];
	if(i==n)return 0;
	if(i>n) return inf;
	return dp[i]=min((abs(h[i]-h[i+1]))+fun(i+1), abs(h[i]-h[i+2])+fun(i+2));
	
}


int main()
{
	memset(dp,-1,sizeof dp);
	cin>>n;
	for(ll i =1;i<=n;i++)cin>>h[i];h[n+1]=inf;
	cout<<fun(1)<<endl;
	
	
}

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

int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.length();
  int ans=0;
  for(int i=0,j=0;i<s.length();i++,j++)
  {
    if(s[i]!=t[j])
      ans++;
  }
  cout<<ans;
}

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

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	int an= a.size()-1,bn= b.size()-1,cn= c.size()-1;
	if(a.at(an) != b.at(0) ){
		cout<< "NO" << endl;
	}
	else if(b.at(bn)!= c.at(0)){
		cout << "NO" << endl;
	}
	else{
		cout << "YES" <<endl;
}
		
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100010];

int main()
{
    int n,m,L=-1;
    cin>>n>>m;
    if(m==0 || n==0) cout<<"Zero";
    else if(m>0 && n<0) cout<<"Zero";
    else if(m>0 && n>0) cout<<"Positive";
    else
    {
        if((m-n)%2==0) cout<<"Negative";
        else cout<<"Positive";
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vll;
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define mod 1000000007
#define pi 3.1415926535
lld a,b,c,d,e,f,g,h,i,j,k=0,l=0,m=1,n=1,o,q=0,r=0,u,v,w,x,y,z,s,t,p=0;
lld temp=0,ans=0;
double f1,f2,f3,f4,f5,f6;
char c2,c3,c4,c5,c6;
vll v11;
pair<lld,lld>p1,p2,p3;
map<lld,lld>mv;bool a12[200005],a13[200005];
bool b11[500006],c11[500006];lld a11[500006];
lld gcd(lld a, lld b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}
void dfs(lld i,vector<lld>vg[])
{
    if(b11[i]==true)    return;
    v11.pb(i);
    p++;
    b11[i]=true;
    for(auto x11:vg[i])
    {
        if(b11[x11]==false)
        {
            dfs(x11,vg);
        }
    }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  t=1;
  //cin>>t;
  while(t--)
  {
    string s3,s1,s2;
    cin>>n;
    //lld p1,q1,a1,b1,c1,d1;
    lld a1[n+1]={0},b1[n],c1[n+1];vector<lld>vg[n+1];
    map<lld,lld>m1,m2;queue<lld>q2;vll v1,v2;
    rep(i,0,n)  cin>>a1[i];
    p=0;
    rep(i,1,n)
    {
        if((a1[i]<=a1[i-1]))
        {
            p=p+a1[i-1]-a1[i];
            a1[i]=a1[i-1];
        }
    }
    cout<<p;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 9860
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
}; 

int main(){
    Stream io;
    
    string S;
    io.read(S);
    string ans = "AC";
    if(S[0] != 'A') ans = "WA";
    int c = 0;
    for(int i = 1; i < S.size(); i++){
        if(!(S[i] <= 'z' && S[i] >= 'a')){
            if(i <= S.size() - 2 && i >= 2){
                c++;
            }
            else ans = "WA";
        }
    }
    if(c != 1) ans = "WA";
    cout << ans;
    return 0;
}

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

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

	int ret = 0;
	for(auto c : S)
		if(c == '+')
			ret++;
		else if(c == '-')
			ret--;

	cout << ret << endl;

	return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;

    if (U == S) {
        cout << A-1 << " " << B << endl;
    } else {
        cout << A << " " << B-1 << endl;
    }
}

signed main() {
    solve();
}


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

int main() {
	long long N, M;
	vector<long long> D;
	vector<pair<long long, long long> > V;
	vector<long long> ANS;
	vector<bool> check;
	vector<long long> C;
	cin >> N >> M;
	D.resize(N), V.resize(M), C.assign(N, 2), ANS.resize(M), check.assign(N, false);
	for (int i = 0; i < N; i++) cin >> D[i];
	for (int i = 0; i < M; i++) {
		cin >> V[i].first >> V[i].second;
		V[i].first--, V[i].second--;
		if (D[V[i].first] == D[V[i].second]) {
			check[V[i].first] = check[V[i].second] = true;
			ANS[i] = D[V[i].first];
			if (C[V[i].first] == 2) {
				if (C[V[i].second] == 2) C[V[i].first] = 0, C[V[i].second] = 1;
				else C[V[i].first] = 1 - C[V[i].second];
			}
			else {
				if (C[V[i].second] == 2) C[V[i].second] = 1 - C[V[i].first];
			}
		}
		else {
			if (D[V[i].first] > D[V[i].second]) check[V[i].first] = true;
			else check[V[i].second] = true;
		}
	}
	for (int i = 0; i < N; i++) {
		if (!check[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		if (C[i] == 2) cout << 'W', C[i] = 0;
		else cout << (C[i] == 0 ? 'W' : 'B');
	}
	cout << endl;
	for (int i = 0; i < M; i++) {
		long long S = V[i].first, T = V[i].second;
		if (C[S] == C[T]) {
			if (D[S] == D[T]) ANS[i] = D[S];
			else ANS[i] = abs(D[S] - D[T]);
		}
		else ANS[i] = max(D[S], D[T]);
	}
	for (int i = 0; i < M; i++) cout << ANS[i] << endl;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0)
	{
		cout << "Even" << endl;
	}else{
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {

	static int[] v1 = {2,0,-2,0};
	static int[] v2 = {0,2,0,-2};
	static int[] v3 = {1,0,-1,0};
	static int[] v4 = {0,1,0,-1};
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			String[] s = str.split(" " );
			int w = Integer.parseInt(s[0]);
			int h = Integer.parseInt(s[1]);
			if(w+h==0){
				break;
			}
			s = new String[h*2-1];
			for(int i = 0; i < h*2-1;i++){
				s[i]=br.readLine();
				if(s[i].length()!=w*2-1){
					s[i]=s[i]+" ";
				}
			}
			char[][] field=new char[h*2-1][];
			for(int i = 0; i < h*2-1;i++){
				field[i]=s[i].toCharArray();
			}


			int[][] saitan=new int[h][w];
			for(int i = 0; i < h;i++){
				for(int j = 0; j < w;j++){
					saitan[i][j]=10000;
				}
			}
			saitan[0][0]=1;
			int tmph=h-1;
			int tmpw=w-1;
			h=h*2-1;
			w=w*2-1;
			Queue<Integer[]> q = new LinkedList<Integer[]>();
			Integer[] pair = {0,0};
			q.add(pair);
			while(!q.isEmpty()){
				Integer[] p = q.poll();
				int x = p[0];
				int y  =p[1];
				//System.out.println(x+"  "+y+" " + saitan[x/2][y/2]);
				for(int i = 0; i < 4;i++){
					int xx = x+v1[i];
					int yy = y+v2[i];
					int xxx = x+v3[i];
					int yyy = y+v4[i];
					if(xx>=0&&xx<h&&yy>=0&&yy<w){
						if(field[xxx][yyy]=='0'){
							if(saitan[(xx)/2][(yy)/2]>saitan[x/2][y/2]+1){
								saitan[(xx)/2][(yy)/2]=saitan[x/2][y/2]+1;
								Integer[] next = {xx,yy};
								q.add(next);
							}
						}
					}
				}
			}
			if(saitan[tmph][tmpw]==10000){
				System.out.println(0);
			}
			else{
				System.out.println(saitan[tmph][tmpw]);
			}
		}
	}

}

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

using ll = long long; using vi = vector<int>; using vll = vector<ll>;
using vvi = vector<vi>; using vvll = vector<vll>;
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll INF_MAX = numeric_limits<ll>::max();

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int min_diff = INF;
  for (int i = 0; i < (n - k + 1); ++i) {
    int diff = arr[i + k - 1] - arr[i];
    min_diff = min(min_diff, diff);
  }
  cout << min_diff << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
// #define inf 1e15
    
const int N=1e5+5;
const int M=1e9+7;
vector<int> primeFactors(int n)  
{  
    // Print the number of 2s that divide n 
    vector<int> v;
    while (n % 2 == 0)  
    {  
        v.pb(2); 
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            v.pb(i); 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        v.pb(n);
        return v;
}  

void solve()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<0;
		return;
	}
	vector<int> v=primeFactors(n);
	map<int,int> mm;
	for(auto X:v)
	{
		mm[X]++;
	}
	int ans=0;
	for(auto X:mm)
	{
		int p=X.ss;
		int j=1;
		while(j<=p)
		{
			ans++;
			p-=j;
			j++;
			
		}
	}
	cout<<ans;

}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,N;
  cin>>H>>W>>N;
  vector<int>A(N);
  REP(i,N)cin>>A[i];
  vector<int>tmp;
  REP(i,N){
    REP(j,A[i]){
      tmp.push_back(i+1);
    }
  }
  vector<vector<int>>ans(H,vector<int>(W,0));
  REP(i,H){
    REP(j,W){
      ans[i][j]=tmp[i*W+j];
    }
    if(i%2){
      reverse(ALL(ans[i]));
    }
  }
  REP(i,H){
    REP(j,W-1){
      cout<<ans[i][j]<<" ";
    }
    cout<<ans[i][W-1]<<endl;
  }
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

#define ARR_SIZE 1000003
#define STR_SIZE 16
#define CMD_SIZE 8
#define H1(k) (k % ARR_SIZE)
#define H2(k) (1 + k % (ARR_SIZE - 1))
#define HASH(k, i) ((H1(k) + i * H2(k)) % ARR_SIZE)

static long long int to_key(char *str) {
  long long int p, sum;

  for (p = 1, sum = 0; *str != '\0'; p *= 5) {
    switch (*str++) {
      case 'T': sum += 1L * p; break;
      case 'G': sum += 2L * p; break;
      case 'A': sum += 3L * p; break;
      case 'C': sum += 4L * p; break;
    }
  }
  return sum;
}

static void insert(char **arr, char *str) {
  long long int k;
  int idx, i;

  k = to_key(str);
  for (i = 0; i < ARR_SIZE; ++i) {
    idx = HASH(k, i);
    if (arr[idx] == NULL) {
      arr[idx] = str;
      break;
    }
    if (strcmp(arr[idx], str) == 0) break;
  }
}

static int find(char **arr, char *str) {
  long long int k;
  int idx, i;

  k = to_key(str);
  for (i = 0; i < ARR_SIZE; ++i) {
    idx = HASH(k, i);
    if (arr[idx] == NULL) return 0;
    if (strcmp(arr[idx], str) == 0) return 1;
  }
  return 0;
}

int main(int argc, char **argv) {
  int n, i, ret;
  char cmd[CMD_SIZE];
  char *str;
  char **arr;

  ret = scanf("%d", &n);
  if (errno != 0) perror("scanf: n");
  if (ret < 1) exit(1);

  arr = (char **) calloc(ARR_SIZE, sizeof(char *));
  if (arr == NULL) exit(1);

  while (n--) {
    str = (char *) calloc(STR_SIZE, sizeof(char));
    if (str == NULL) break;

    ret = scanf("%s %s", cmd, str);
    if (errno != 0) perror("scanf: cmd, str");
    if (ret < 1) break;

    switch (cmd[0]) {
      case 'i':
        insert(arr, str);
        break;
      case 'f':
        if (find(arr, str)) {
          printf("yes\n");
        } else {
          printf("no\n");
        }
        break;
    }
  }

  for (i = 0; i < ARR_SIZE; ++i) free(arr[i]);
  free(arr);
  exit(0);
}


Measured memory_bytes: 40556
S = input()
N = len(S)
S = '0' + S
if S[:2] == '01' and S == S[::-1]:
    before = 1
    for i in range(2, N + 1):
        print(before, i)
        if S[i - 1] == '1' and i < (N + 1) // 2 + 2:
            before = i
else:
    print(-1)


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

int main() {
  int a,b,c,max;
  vector<int> num(3);
  for(int i=0;i<3;i++){
  cin >> num[i];
  }
  
  sort(num.begin(), num.end());
 
  cout << num[2]*10 +num[0] + num[1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[10];
int x[10], y[10];
int main(){
    for(int i=1; i<=9; ++i) a[i]=i;
    int n;
    double s=0;
    scanf("%d", &n);
    for(int i=1; i<=n; ++i) scanf("%d%d", &x[i], &y[i]);
    do{
        for(int i=2; i<=n; ++i){
            s+=sqrt((x[a[i]]-x[a[i-1]])*(x[a[i]]-x[a[i-1]])+(y[a[i]]-y[a[i-1]])*(y[a[i]]-y[a[i-1]]));
        }
    }while(next_permutation(a+1, a+n+1));
    while(n){
        s/=n;
        n--;
    }
    printf("%.6lf", s);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        cout<<3;
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
        cout<<2;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
        cout<<1;
    else
        cout<<0;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int64_t;
using P = pair<i64,i64>;
using D = pair<P, string>;

// t is lower
bool f(D& A, D& B){
    P a = A.first;
    P b = B.first;
    i64 c = a.first * b.second;
    i64 d = b.first * a.second; 
    if(c > d) return true;
    else if(c == d && A.second < B.second ) return true;
    return false;
}

int main(){
    int N;
    while(cin >> N, N != 0){
        vector<D> ans;
        rep(i,N){
            string L;
            i64 P, A, B, C, D, E, F, S, M;
            cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
            i64 time = A + B + C + M*D + M*E;
            i64 val = F*S*M - P;
            ans.push_back({{val,time}, L});
        }
        sort(ans.begin(), ans.end(), f);
        for(auto p : ans) cout << p.second << endl;
        cout << "#" << endl; 
    }
}



Measured memory_bytes: 3048
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] cube = sc.next().toCharArray();
        int zero = 0;
        for(int i = 0; i < cube.length; i++){
            switch(cube[i]){
                case '0':
                zero++;
            }
        }
        System.out.println(Math.min(zero, cube.length-zero)*2);
    }
}

Measured memory_bytes: 28812
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    
    int train = n * a;
    if (train > b) cout << b << endl;
    else cout << train << endl;
}


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

int main(){
  int n = 0;
  cin >> n;
  int i;
  for (i = 0; i < n;i++){
    string s;
    cin >> s;
    if (s =="Y"){
      cout << "Four" << endl;
      break;
    }
  }
  if (i == n) cout << "Three" << endl;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main {
    static Card[] A;

    static int partition(int l, int r){
        int i = l-1;

        for (int j = l; j < r; j++){
            if (A[j].n <= A[r].n){
                i++;
                // swap
                Card temp = A[j];
                A[j] = A[i];
                A[i] = temp;
            }
        }
        i++;
        Card temp = A[r];
        A[r] = A[i];
        A[i] = temp;
        return i;
    }

    static void quickSort(int l, int r){
        if (l < r){
            int q = partition(l,r);
            quickSort(l,q-1);
            quickSort(q+1,r);
        }
    }

    static String stable(Card[] A, Card[] B){
        for (int i = 0; i < A.length; i++) {
            if (!A[i].c.equals(B[i].c)){
                return "Not stable";
            }
        }
        return "Stable";
    }



    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        int n = sc.nextInt();
        A = new Card[n];

        for (int i = 0; i < n; i++)
            A[i] = new Card(sc.next(),sc.nextInt());

        Card[] B = new Card[n];
        for (int i = 0; i < n; i++)
            B[i] = A[i];

        Arrays.sort(B,(Card a, Card b) -> b.n - a.n);

        quickSort(0,n-1);

        System.out.println(stable(A,B));

        for (int i = 0; i < n; i++)
            System.out.println(A[i].c + ' ' + A[i].n);

    }

    static class Card{
        String c;
        int n;
        Card(String c, int n){
            this.c = c;
            this.n = n;
        }
    }

    /**
     * MyScanner is a user-defined fast I/O class.
     * Source: https://algocoding.wordpress.com/2015/04/23/fast-io-methods-for-competitive-programming/
     */

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}



Measured memory_bytes: 79952
#include<bits/stdc++.h>
#define input(arr, s, n) for (int i = s; i < n; i++) cin >> arr[i]
using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    cout << x - k + 1;
    for (int i = x - k + 2; i < k + x; i++) {
        cout << " " << i;
    }
    cout << "\n";
}


Measured memory_bytes: 256