akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int ans[20],k,len;

inline void wk()
{
	int f=0;
	for(int i=len;i>=2;i--)
	{
		if(ans[i]-ans[i-1]!=1&&ans[i]!=9)
		{
			f=i;
			break;
		}
	}
	if(f==0)
	{
		ans[1]++;
		if(ans[1]==10)
		{
			len++;
			ans[1]=1;
		}
		for(int i=2;i<=len;i++) ans[i]=max(0,ans[i-1]-1);
	}
	else
	{
		ans[f]++;
		if(ans[f]==10)
		{
			while(ans[f-1]==9&&f!=0) f--;
			if(f==0)
			{
				len++;
				ans[1]=1;
			}
			else
			{
				ans[f-1]++;
				for(int i=f;i<=len;i++) ans[i]=max(0,ans[i-1]-1);
			}
		}
		else for(int i=f+1;i<=len;i++) ans[i]=max(0,ans[i-1]-1);
	}
	//for(int i=1;i<=len;i++) printf("%d",ans[i]); puts("");
}

int main()
{
	cin>>k;
	if(k==1) {puts("1"); return 0;}
	len=1; ans[1]=1;
	for(int i=2;i<=k;i++) wk();
	for(int i=1;i<=len;i++) printf("%d",ans[i]);
	return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
for i in range(l-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        exit()
for i in range(l-2):
    if s[i] == s[i+2]:
        print(i+1, i+3)
        exit()
print(-1,-1)

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

int main() {
/*	int a[3];
	cin >> a[0] ;
	a[1] = 3;
	a[2] = a[0] * 10;

	cout << a[0] <<" " << a[1] <<" "<< a[2] << endl;
	
	for (int i = 0; i < 3; i++) {
		cout << a[i] << endl;
	}


	sort(a,a+5);
*//*
	int a[10];
	for (int i = 0; i < 10; i++) {
		cin >> a[i];
	}
	
	sort(a,a+10,greater<int>());

	for (int i = 0; i < 3; i++) {
		cout << a[i]<<endl;
	}
*/
	int ans = 0;
	int a, b,c;
	while(cin>>a>>b) {
		ans = 0;
		c = a + b;

		if ( c==0   ) {
			ans = 1;
		}
		else{
			while (c > 0) {
				c /= 10;
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;;
}

Measured memory_bytes: 3000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
vector<int>ans0,ans1;
int digit(int n) {
	int res = 0;
	while (n) {
		res += n % 10;
		n /= 10;
	}
	return res;
}
int ipow(int a, int n) {
	int res = 1;
	rep(i, n)res *= a;
	return res;
}
double snk(int a) {
	double A = a, B = digit(a);
	return A / B;
}

signed main() {
	int k; cin >> k;
	rep(i, 9)ans0.push_back(i + 1);
	for(int i=0;i<=15;i++){//末尾の9の数
		int num = ipow(10, i) - 1;
		rep(j, 1000) {
			int n = j*ipow(10, i) + num;
			if(n)ans0.push_back(n);
		}
	}
	sort(ans0.begin(), ans0.end());
	ans0.erase(unique(ans0.begin(), ans0.end()), ans0.end());
	sort(ans0.begin(), ans0.end());
	rep(i, ans0.size()) {
		for (int j = i + 1; j < ans0.size(); j++) {
			if (snk(ans0[i]) > snk(ans0[j]))goto A;
		}
		ans1.push_back(ans0[i]);
	A:;
	}
	rep(i, k)cout << ans1[i] << endl;
	//cout << ans1.size() << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    int A,B,C,D,X,Y,N,L,M,P,Q;
    cin>>A;
    char f[100];

    cin>>f;

    if(A>=3200){
        cout<<f<<endl;
    }else{
        cout<<"red"<<endl;
    }
}

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

typedef pair<string, int> PAIR;

void fnInput(int &rnMaxProc, int &rnQtm, queue<PAIR> &rqPPrc)
{
  cin >> rnMaxProc >> rnQtm;
  
  for (int i = 0; i < rnMaxProc; i++)
  {
    string sPrcNam;
    int nPrcTim;
    cin >> sPrcNam >> nPrcTim;
    rqPPrc.push(PAIR(sPrcNam, nPrcTim));
  }
}

void fnSchedule(int nQtm, queue<PAIR> &rqPPrc)
{
  int nTtlTim = 0;
  while (rqPPrc.size())
  {
    PAIR PProcess = rqPPrc.front(); rqPPrc.pop(); 
    if (PProcess.second > nQtm)
    {
      PProcess.second -= nQtm;
      rqPPrc.push(PProcess);
      nTtlTim += nQtm;
    }
    else
    {
      nTtlTim += PProcess.second;
      cout << PProcess.first << " " << nTtlTim << endl;
    }
  }
}

int main()
{
  int nMaxPrc, nQtm;
  queue<PAIR> qPPrc;
  
  fnInput(nMaxPrc, nQtm, qPPrc);
  fnSchedule(nQtm, qPPrc);

  return 0;
}

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

int an(int m){
	if(m==1) return 1;
	else{
		return 3*an(m-1) + 1;
	}
}


int main(){
	const int MAX=1000000;
	int arr[MAX], G[MAX];
	int N, cnt = 0;
	cin >> N;
	
	int m = (int)(log(2*N+1)/log(3.0));
	
	for(int i=0; i<m; i++){
		G[m-1-i] = an(i+1);
	}
	
	for(int i=0; i<N; i++){
		cin >> arr[i];
	}
	
	for(int k=0; k<m; k++){
		int g = G[k];
		
		for(int i=g; i<N; i++){
			int v = arr[i];
			int j = i - g;
			while(j >= 0 && arr[j] > v){
				arr[j+g] = arr[j];
				j = j - g;
				cnt++;
			}
			arr[j+g] = v;
		}
	}
	
	cout << m << endl;
	for(int i=0; i<m; i++){
		if(i==0){
			cout << G[i];
		}
		else{
			cout << " " << G[i];
		}
	}
	cout << endl;
	
	cout << cnt << endl;
	
	for(int i=0; i<N; i++){
		cout << arr[i] << endl;
	}
	
}

Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {//言語変えろ言語変えろ言語変えろ言語変えろ言語変えろ

int sh,sm,fh,fm,k; cin>>sh>>sm>>fh>>fm>>k;
  int s=sh*60+sm;
  int f=fh*60+fm;
  
  if(f-s<k){cout<<0<<endl;}
  else{int ans;
       ans=f-s-k;
      cout<<ans<<endl;}
  
  
return 0; }


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

int main(void)
{
  int mf,m,f,r,k,i;
  char g[101]={};

  k=0;
  do{
    cin >> m >> f >> r;
    k = k + 1;
    mf = m + f;
    if(mf>=80) g[k]='A';
    if(mf>=65 && mf<80) g[k]='B';
    if(mf>=50 && mf<65) g[k]='C';
    if(mf>=30 && mf<50) {
      g[k]='D';
      if(r>=50) g[k]='C';
    }
    if(mf<30) g[k]='F';
    if(m==-1 ||f==-1) g[k]='F';
  }while(m!=-1||f!=-1||r!=-1);

  for(i=1;i<=k-1;i++)
    cout << g[i] << endl;

  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h.at(i);
  
  vector<bool> x(n, true);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h[a] == h[b]) {
      x.at(a) = false;
      x.at(b) = false;
    }
    else if (h[a] < h[b]) x.at(a) = false;
    else x.at(b) = false;
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x.at(i)) ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

string s;
bool check(int cnt){
  DUMP(s[cnt]);
  if(s[cnt] - '0' < 0 ||  s[cnt] - '0' > 9)return false;
  return true;
}

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b >> s){
    int cnt = 0;
    bool ans = true;
    while(cnt < a){
      ans = ans & check(cnt);
      cnt ++;
    }
    if(s[cnt] != '-') ans = false;
    cnt ++;
    while(cnt < a + b + 1){
      ans = ans & check(cnt);
      cnt ++;
    }
    if(s.size() != a + b + 1) ans = false;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC108C
int main(void) {
  long long n, k, i, cou=0, tmp;
  scanf("%lld %lld", &n, &k);
  if(k%2==0) cou=pow(n/k, 3)+pow((n+k/2)/k, 3);
  else cou=pow(n/k, 3);
  printf("%lld", cou);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    //入力
    long n = long.Parse(Console.ReadLine());
    
    //処理
    long a = 0 , b = 0;
    //nの平方根を求める
	long m = (long)Sqrt(n);
    //mから割り切れる数を探して、F(a,b)が最小となる組み合わせを探す
    for(long i=m; i>0; i--){
      if(n % i == 0){
        a = i;
        b = n / a;
        break;
      }
    }
    
    //桁数を求める
    int ans = 0;
    while(b>0){
      b /= 10;
      ans++;
    }
    
    Console.WriteLine(ans);
  }
}


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

int main()
{
    string s;
    long long int k;
    cin >> s >> k;
    long long int ans = 0, b = 0, c = 1;

    long long int size = s.size();
    for(long long int i = 0;i < size - 1;i++){
        if(s[i] == s[i + 1]){
            c++;
        }
        else{
            b += c / 2;
            c = 1;
        }
    }
    b += c / 2;
    ans = b * k;
    long long int g = 1, o = 1;
    for(long long int i = 0;i < size - 1;i++){
        if(s[i] == s[i + 1]){
            g++;
        }
        else{
            break;
        }
    }
    for(long long int i = size - 1;i > 0;i--){
        if(s[i] == s[i - 1]){
            o++;
        }
        else{
            break;
        }
    }
    
    if(s[0] == s[size - 1]){
        ans = ans - (((g / 2) + (o / 2) - ((g + o) / 2)) * (k - 1));
    }
    
    if(size == g){
        ans = ((size) * k) / 2;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int a, b; cin >> a >> b;
  if(a+b>=10) cout << "error" << endl;
  else cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;




int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    vector <pair <int, int>> v;
    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        v.emplace_back(x, i);
    }
    sort(v.begin(), v.end());

    int ans = 0;
    for (int i = 0; i < n; i++)
        if (i % 2 != v[i].second % 2)
            ans++;

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




	return 0;
}




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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int n, w;
vi u, v;
int dp[101][100001] = {};  // dp[i][j] i番目まで見たときの重さj以下の最大値

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

  cin >> n >> w;
  u.pb(0);
  v.pb(0);
  rep(i, 0, n) {
    int U, V;
    cin >> U >> V;
    u.pb(U);
    v.pb(V);
  }

  rep(i, 1, n + 1) {
    rep(j, 0, w + 1) {
      if (j - u[i] >= 0) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - u[i]] + v[i]);
      } else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  cout << dp[n][w]<<endl;
  return 0;
}


Measured memory_bytes: 78336
# 【考察】
# 原点から、移動距離が C ～ D で移動していくと、到達できる区間は…
# [0]
# [-D, -C], [C, D]
# [-2D, -2C], [-D+C, D-C], [2C, 2D]
# [-3D, -3C], [-2D+C, D-2C], [-D+2C, 2D-C], [3C, 3D]
# [-4D, -4C], [-3D+C, D-3C], [-2D+2C, 2D-2C], [-D+3C, 3D-C], [4C, 4D]
# ...


def main():
    N, A, B, C, D = map(int, input().split())
    lower, upper = - (N - 1) * D, - (N - 1) * C
    target = B - A
    for _ in range(N):
        if lower <= target <= upper:
            print('YES')
            return
        lower += C + D
        upper += C + D
    print('NO')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <stdio.h>
  
int main(void) {
  
    int a,b;
    int c,i,div;
  
    scanf("%d %d",&a,&b);
    if(a < b){
        c = a;
        a = b;
        b = c;
    }else if(a == b){
        printf("%d\n",a);
        return 0;
    }
    else {}
  
    for(div=a%b;div>0;){
        div=a%b;
        a = b;
        b = div;
    }
    printf("%d\n",a);
      
    return 0;
}

Measured memory_bytes: 592
N = int(input())
A = [int(i) for i in input().split()]

I = [x>y for x,y in zip([0]+A,A+[10**10])]          
D = [x<y for x,y in zip([10**10]+A,A+[0])]          

ci = False
cd = False
ans = 1
for i in range(N+1): 
    ci += I[i]
    cd += D[i]
    if ci and cd:
        ans += 1
        ci = False
        cd = False
print(ans)


Measured memory_bytes: 14252
m = 10**9+7
n,a,b = map(int,input().split())
def c(k):
  v = 1
  w = 1
  for i in range(k):
    v = v*(n-i)%m
    w = w*(i+1)%m
  return (v*pow(w,m-2,m)%m)
print((pow(2,n,m)-1-c(a)-c(b))%m)

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[25]; 
int main(){
	int n;
	cin>>n;
	for(int i = 0; i < n;i++){
		cin>>a[i];
	}
	int f = 0;
	for(int i = 1; i < n-1;i++){
		if( (a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]) )
			f++;
	}
	cout<<f<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set tree<TEMP, null_type, less<TEMP>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}


int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  
    string s;
    cin >> s;
    if((s[2] == s[3]) && (s[4] == s[5])){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 200200;

int n;
char s[N];
int nxt[N][28];
int dp[N], who[N];

int main() {
	scanf("%s", s);
	for (n=0; s[n]; n++) ;
	FOR(i,26) nxt[n][i] = n;
	for (int i = n-1; i>=0; i--) {
		FOR(j,26) nxt[i][j] = nxt[i+1][j];
		nxt[i][s[i]-'a'] = i;
	}
	dp[n]=1;
	for (int i=n-1; i>=0; i--) {
		dp[i] = n+1;
		FOR(j,26) {
			//printf("%d %d -> %d\n", i, j, nxt[i][j]);
			if (dp[nxt[i][j]+1]+1 < dp[i]) {
				who[i] = j;
				dp[i] = dp[nxt[i][j]+1]+1;
			}
		}
		//printf("dp[%d] = %d (%d)\n", i, dp[i], who[i]);
	}
	int pos = 0;
	while (pos < n) {
		putchar('a'+who[pos]);
		pos = nxt[pos][who[pos]]+1;
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 23936
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int cnt = 0;
	FOR (i, 1, n - 1)
	    for (int j = i; j < n; j += i)
	        cnt++;
	 
	cout << cnt;
}



















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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t ans = n / (a + b) * a;
    cout << ans + min(a, n % (a + b)) << endl;
    
    return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = a; i <= b; i++){
		if(i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100) / 10) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int n, m;
priority_queue<int, vector<int>, greater<int>> a;
pair<int, int> p[100000];
ll ans = 0;
int main(){
  cin >> n >> m;
  rep(i,n){
    int k;
    cin >> k;
    a.push(k);
  }
  rep(i, m){
    int u,t;
    cin >> u >> t;
    p[i] = make_pair(t, u);
  }
  sort(p, p+m);
  reverse(p, p+m);
  rep(i, m){
    bool update;
    rep(j, p[i].second){
      if(a.top() < p[i].first){
        update = true;
        a.pop();
        a.push(p[i].first);
      }else{
        break;
      }
    }
    if(!update) break;
  }
  rep(i, n){
    ans += a.top();
    a.pop();
  }
  cout << ans <<endl;
}
    
    

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

const int SIZE = 1e5 + 4;
int n, ans;
int Max_1, Max_2, Max_3, Max_4;
int a[SIZE], v1[SIZE], v2[SIZE];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i += 2)
	{
		++v1[a[i]]; ++v2[a[i+1]];
	}
	Max_1 = Max_2 = Max_3 = Max_4 = 0;
	for (int i = 1; i <= SIZE; ++i)
	{
		if (v1[i] > v1[Max_1]) Max_2 = Max_1, Max_1 = i;
		else if (v1[i] > v1[Max_2]) Max_2 = i;
		if (v2[i] > v2[Max_3]) Max_4 = Max_3, Max_3 = i;
		else if (v2[i] > v2[Max_4]) Max_4 = i;
	}
	if (Max_1 != Max_3) ans = n - v1[Max_1] - v2[Max_3];
	else ans = n - max(v1[Max_1] + v2[Max_4], v1[Max_2] + v2[Max_3]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4908
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>

#include <unordered_map>
#include <unordered_set>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define DFOR(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define rep(i,n) FOR(i,0,n)
#define repn(i,n) FORN(i,1,n)
#define drep(i,n) DFOR(i,n-1,0)
#define drepn(i,n) DFOR(i,n,1)
#define MAX(a,b) a = Max(a,b)
#define MIN(a,b) a = Min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define Reset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(all(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define forever for(;;)
#define PINF 1000000000000
#define newline '\n'

#define test if(1)if(0)cerr
using namespace std;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double pi = acos(-1.0);



int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (ans = 0; ans < 1e7; ++ans)
    {
        if (a%2 || b %2 || c%2) break;
        int na = b/2+c/2+a%2, nb = a/2+c/2+b%2, nc = a/2+b/2+c%2;
        a = na, b = nb, c = nc;

    }
    if (ans == 1e7)
    {
        ans = -1;
    }
    cout << ans << newline;
}




Measured memory_bytes: 896
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int N, M;
int A[112345], sum[112345]; // sum[1-indexed]

int main() {
	cin >> N >> M;
	REP(i, N) scanf("%d", A + i);
	REP(i, N) sum[i + 1] = (sum[i] + A[i]) % M;
	
	map<int, int> m;
	m[0]++;
	
	ll ans = 0;
	REP(i, N) {
		ans += m[sum[i + 1]];
		m[sum[i + 1]]++;
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 450555;
const int M = 1155;

int a[N], cnt[N];
void solve() {
    int n,k;
    cin >> n >> k;

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

    while (k--){
        for (int i = 1; i <= n; i++){
            cnt[i] = 0;
        }
        for (int i = 1; i <= n; i++){
            int l = max(1, i - a[i]), r = min(n, i + a[i]);
            cnt[l]++;
            cnt[r+1]--;
        }
        int z = 0;
        for (int i = 1; i <= n; i++){
            cnt[i] += cnt[i-1];
            a[i] = cnt[i];
            if (a[i] == n) z++;
        }
        if (z == n) break;
    }

    for (int i = 1; i <= n; i++){
        cout << a[i] << ' ';
    }

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5180
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn solve() {
    let mut scan = Scanner::default();
    let s: String = scan.next();
    let mut cont = 0;
    let mut res = 0;
    for c in s.chars() {
        if c == 'R' {
            cont += 1;
        } else {
            cont = 0;
        }
        res = max(res, cont);
    }
    println!( "{}", res);
}

fn main() {
    let mut scan = Scanner::default();
    // let t = scan.next::<u64>();
    let t = 1;
    for _ in 0..t {
        solve();
    }
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<string.h>
#include<map>
char s1[300000][15];
int main()
{
    ll test,i,j=0,k,m;
    map<string,ll>mp;
    cin>>k;
    for(i=0; i<k; i++)
    {
        cin>>s1[i];
        mp[s1[i]]++;
    }
    ll mx=0;
    for(i=0;i<k;i++)
    {
        mx=max(mx,mp[s1[i]]);
    }
    set<string>st;
    ll cnt=0;
    for(i=0;i<k;i++)
    {
        if(mp[s1[i]]==mx)
        {
            st.insert(s1[i]);
        }
    }
    set<string>::iterator it;
    string c;
    for(it=st.begin();it!=st.end();it++)
    {
        c=*it;
        cout<<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 46720
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
    ll test_case, h = 0;
    cin >> test_case;
    vector<int> numbers(test_case);
    for(auto &i: numbers) cin >> i;
    for(int i = 0; i < test_case - 1; i++) {
        for(int j = i + 1; j < test_case; j++) {
            h += (numbers[i]*numbers[j]);
        }
    }
    if(test_case==1) h = numbers[0];
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Saiki();
        }

        static void Saiki()
        {
            var N = ReadInt();
            var h = ReadSplitInt();
            var dp = new int[N];
            for (var i = 0; i < N; i++) dp[i] = int.MaxValue;

            Func<int, int> func = null;

            func = i =>
            {
                if (dp[i] < int.MaxValue) return dp[i];
                if (i == 0) return 0;
                if (i == 1) return func(i - 1) + Abs(h[i] - h[i - 1]);

                dp[i] = Min(func(i - 1) + Abs(h[i] - h[i - 1]), func(i - 2) + Abs(h[i] - h[i - 2]));
                return dp[i];
            };

            Println(func(N - 1));
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 28768
#include <iostream>
using namespace std;
int main() {
  string s1,s2;
  cin>>s1>>s2;
  int c = 0;
  for(int i=0;i<s1.size();i++)
  {
    if(s1[i]!=s2[i]) c++;
  }
  cout<<c<<endl;
  return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 51;
const int   M   = N * N * N;

int nCh[N];
ll  sum[N];
int p[N];
int a[N];

ll  f[N][M];

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

    int n;  cin >> n;
    int S;  cin >> S;
    int D;  cin >> D;

    for(int i = 1 ; i <= n ; ++i)   {
        nCh[i] = 1;
        cin >> sum[i];
        
        if (i > 1)  cin >> p[i];
    }
    for(int i = n ; i >= 2 ; --i)
        nCh[p[i]] += nCh[i],
        sum[p[i]] += sum[i];
    
    a[1] = 1e9; fill(a + 2,a + 1 + n,D);

    for(int i = 0 ; i <= n ; ++i)
    for(int w = 1 ; w <  M ; ++w)   f[i][w] = 1e18;

    for(int i = 0 ; i < n ; ++i)
    for(int w = 0 ; w < M ; ++w)    if (f[i][w] < 1e18) {
        int c = min(a[i + 1],50);

        for(int j = 0 ; j <= c ; ++j)   {
            int nv = nCh[i + 1] * j + w;
            ll  nw = sum[i + 1] * j + f[i][w]; 

            if (nv >= M)    break;
            if (f[i + 1][nv] > nw)
                f[i + 1][nv] = nw;
        }
    }
    int ans = 0;

    vector<int> order(n);

    iota(all(order),1);
    sort(all(order),[&](int x,int y)    {
        return  1ll * nCh[x] * sum[y] > 1ll * nCh[y] * sum[x]; 
    });

    for(int i = 1 ; i <= n ; ++i)   a[i] -= min(a[i],50);
    for(int w = 0 ; w <  M ; ++w)   if (f[n][w] <= S)   {
        int val = S - f[n][w];
        int nxt = w;

        for(int x : order)  {
            int c = min(a[x],(int)(val / sum[x]));

            val -= c * sum[x];
            nxt += c * nCh[x];
        }
        if (ans < nxt)
            ans = nxt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 53120
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a < b){
    printf("a < b\n");
  }else if (a > b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
    return 0;
}

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



int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    int sum = 0;
    rep(i,n) {
        sum += a[i];
    }
    
    int cnt = 0;
    sum = (sum + 4*m-1) / (4 * m);
    rep(i,n) {
        if(a[i] >= sum)
            cnt++;
    }
    
    if(cnt >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3516
import sys
n=int(input())
A = [int(x) for x in input().split()]
bar = 10**18
ans =A[0]
if 0 in A:
    print(0)
    sys.exit()
    
for i in A[1:]:
    ans = ans * i
    if ans > bar:
        print(-1)
        sys.exit()
        
print(ans)

Measured memory_bytes: 21584
#include <iostream>
using namespace std;
 
int main(void){
    int n;
     
    while(cin >> n && n) {
        char a[201] = {};
        for (int i = 0; i < n; i++) cin >> a[i];
        int max1 = 0;
        int max2 = 0;
        int r = 0;
        int b[201] = {};
        for (int i = 0; i < n; i++) {
            if (b[(int)a[i]] == max1) max1++;
            else if (b[(int)a[i]] == max2) max2++;
            b[(int)a[i]]++;
             
            if ((n-i-1)+max2 < max1) {
                //cout << "break at " << i << endl;
                r = i + 1;
                break;
            }
        }
        if (max1 == max2) {
            cout << "TIE" << endl;
            continue;
        }
        else {
            for (int i = 65; i < 100; i++) {
                if (b[i] == max1) {
                    cout << (char)i << " " << r << endl;
                    break;
                }
            }
        }
    }
}


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

int cont(float y)
{
    int cont = 1;
    while(y>0){	
	y -= 5;
	cont++;
    }
    return cont;
}

int main()
{
    float y, nv;
    while(cin >> nv)
    {
	y = (nv * nv) / 19.6;
	
	cout << cont(y) << endl;
    }
}

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

int main(void) {
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%f\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
    return 0;
}

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

long long n, k;
vector<long long> a;

long long solve();

int main() {
  cin >> k >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = k + 1;
  for(int i = 0; i < n - 1; ++i) {
    res = min(res, k - a[i + 1] + a[i]);
  }
  res = min(res, k - (k + a[0] - a[n - 1]));
  return res;
}

Measured memory_bytes: 1792
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    cin >> n;
    ll ans = 1;
    ll di = pow(10,9) + 7;
    for (int i = 1; i <= n; i++){
        ans = (ans * i) % di;
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
// C++ 14
#include <math.h>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <string>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.000000001
#define fequals(a,b) (fabs((a) - (b)) < EPS)

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (const Vector2 v) const { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (const Vector2 v) const { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (const double k) const { return Vector2(x * k, y * k); }
  Vector2 operator / (const double k) const { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 const v) { return x * v.x + y * v.y; }
  double cross (Vector2 const v) { return x * v.y - y * v.x; }
  
  bool parallel(Vector2 &other) {
    return fequals(fabs(dot(other)), length() * other.length());
  }
  
  bool orthogonal(Vector2 &other) {
    return fequals(0, dot(other));
  }
  
  bool operator < (const Vector2 &v) {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N;
Vector2 p0, p1, p2, p3;


Vector2 crossPoint() {
  Vector2 baseSeg = p1 - p0;
  Vector2 crossSeg = p3 - p2;
  double h1 = fabs(baseSeg.cross(p2 - p0)) / (baseSeg.length() * 2);
  double h2 = fabs(baseSeg.cross(p3 - p0)) / (baseSeg.length() * 2);
  return p2 + crossSeg * h1 / (h1 + h2);
}

void solve() {
  Vector2 p = crossPoint();
  if (fabs(p.x) < EPS) cout << 0;
  else cout << p.x;
  cout << ' ';
  if (fabs(p.y) < EPS) cout << 0;
  else cout << p.y;
  cout << endl;
}

void input() {
  cin >> N;
  while (cin >> p0 >> p1 >> p2 >> p3) {
    solve();
  }
}

int main() {
  cout.precision(15);
  input();
}


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

using namespace std;


int main(){
    string S;
    long long ans=0;
    cin>>S;
    while(1){ 
        if(S[0]=='W')S.erase(S.begin());
        else break;
    
    }
    string tm(S.rbegin(),S.rend());
    while(1){ 
        if(tm[0]=='B')tm.erase(tm.begin());
        else break;
    
    }
    
    for(int k=0;k<tm.size();++k){
        if(tm[k]=='B'){
            ans+=k;
            tm.erase(tm.begin()+k);
            --k;
        }
    }

    cout<<ans<<endl;

}

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

typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define F first
#define S second
#define endl '\n'
#define LEN(x) int((x).size())
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(a, b) for(int a = 0; (a) < (b); (a)++)
#define debug(x) cerr << #x << " = " << x << '\n'

int main() {
	ios_base::sync_with_stdio(0), cin.tie(NULL);
	
	int n;
	cin >> n;
	
	vi a(n);
	
	REP(i, n) {
		cin >> a[i];
	}
	
	sort(ALL(a));
	
	int ans = 0;
	
	for(int i = 0; i < LEN(a); i++) {
		for(int j = i+1; j < LEN(a); j++) {
			for(int k = j+1; k < LEN(a); k++) {
				if(a[k] < a[i]+a[j] and a[i] != a[j] and a[k] != a[i] and a[j] != a[k])
					ans++;
			}
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int x, y;
    cin >> x >> y;
    int g1[7] = {1, 3, 5, 7, 8, 10, 12};
    int g2[4] = {4, 6, 9, 11};
    int g3[1] = {2};
    int xg, yg;
    for ( auto g : g1 ) {
        if ( x == g ) xg = 1;
        if ( y == g ) yg = 1;
    }
    for ( auto g : g2 ) {
        if ( x == g ) xg = 2;
        if ( y == g ) yg = 2;
    }
    for ( auto g : g3 ) {
        if ( x == g ) xg = 3;
        if ( y == g ) yg = 3;
    }
    if ( xg == yg ) cout << "Yes" << endl;
    else            cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map( int, input().split())
N, M = min(N,M), max(N,M)
if N == 1:
    if M == 1:
        ans = 1
    elif M == 2:
        ans = 0
    else:
        ans = M-2
elif N == 2:
    if M == 2:
        ans = 0
    else:
        ans = 0
else:
    ans = (N-2)*(M-2)
print(ans)

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

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;++i)

int main()
{
	//freopen("1.in","r",stdin);
	int n,a,b;
	cin>>n>>a>>b;
	if(!(a+b-1<=n&&(ll)a*b>=n))
	{
		puts("-1");
		return 0;
	}
	int top=0;
	rep(i,1,a)
	{
		int mj=min(b,n-top-(a-i));
		top+=mj;
		rep(j,1,mj)printf("%d ",top-j+1);
	}
}

Measured memory_bytes: 2176
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Sun Jan  7 21:18:56 2018
//

#include <cstdint>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

int32_t main()
{
  uint32_t N, Y;
  cin >> N >> Y;

  for (uint32_t a = 0; a <= N; a++) {
    for (uint32_t b = 0; b <= N - a; b++) {
      uint32_t c = N - a - b;
      if (Y == 10000 * a + b * 5000 + c * 1000) {
        cout << a << " " << b << " " << c << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
//ヘッダファイル
#include<stdio.h>

//マクロ定義
#define MAX 1000
#define FALSE 1
#define compile 1

//関数のプロトタイプ宣言
void func_init(int array[], int n);

main()
{
	int dead_end[MAX];
	int exit[MAX];
	func_init(dead_end, MAX);
	func_init(exit, MAX);
	int input = 0, i = 0, j = 0, k = 0, flag = 0;
	
	while(scanf("%d", &input) != EOF)
	{
		if(input != 0)
		{
			dead_end[i] = input; //現在のiを要素番号としてinputを入力
			i++;
		}
		else if(input == 0)
		{
			exit[j] = dead_end[--i];
			dead_end[i] = 0;
			j++;
		}
	}
	
	for(i = 0; exit[i] != 0; i++)
	{
		printf("%d\n", exit[i]);
	}
	return 0;
}
void func_init(int array[], int n)
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		array[i] = 0;
	}
}

Measured memory_bytes: 608
import java.util.Scanner;
public class Main{

	public static void main (String [] args) {

		Main main = new Main ();
		main.solve();
	}

	private void solve() {

		Scanner scanner = new Scanner(System.in);

		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();

		if (A==B&&B==C) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int exit = n % 500;
		if(exit > a){
		System.out.println("No");	
		}else{
		System.out.println("Yes");
		}
	}
}

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

int main()
{
  int A, B, d[5], ans = 0;
  cin >> A >> B;

  for (int i = A; i <= B; i++)
  {
    int temp = i;
    for (int j = 0; j < 5; j++)
    {
      d[j] = temp % 10;
      temp /= 10;
    }

    if (d[0] == d[4] && d[1] == d[3])
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	String S;
	public void solve() {
		S = next();
		String s = "CODEFESTIVAL2016";
		int ans = 0;
		for(int i = 0;i < S.length();i++){
			if(s.charAt(i) != S.charAt(i)){
				ans++;
			}
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int main()
{
    int n;
    cin>>n;
    long long ans=0;
    memset(b,0,sizeof b);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        b[a[i]]++;
        ans+=a[i];
    }
    int q;
    cin>>q;
    for(int i=0; i<q; i++)
    {
        int x,y;
        cin>>x>>y;
        ans+=b[x]*(y-x);
        b[y]+=b[x];
        b[x]=0;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4576
# coding: utf-8

import collections

# 1行目は破棄
input()

# 2行目を読み込み、リストに変換
a = map(int, input().split())

# 結果保持用の変数を宣言
count_res = 0

# それぞれの個数をカウント
count = collections.Counter(a)

#カウンタの要素ごとに繰り返し
for k, v in count.items():

## 数値>個数の数値→すべて削除なので一時変数にすべて加算
    if (k>v) :
        count_res += v

## 数値=個数の数値→変化なし

## 数値<個数の数値→超過分だけ削除するので個数-数値を一時変数に加算
    elif (k<v) :
        count_res += (v-k)
        
#結果表示
print(count_res)

Measured memory_bytes: 23668
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	long long n;
	cin >> n;
	long long l1 = 1;
	long long l2 = 1;
	long long a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		long long p1 = (l1 + a - 1) / a;
		long long p2 = (l2 + b - 1) / b;
		long long p3 = max(p1, p2);
		l1 = p3 * a;
		l2 = p3 * b;
	}
	cout << l1 + l2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    cin.tie(0);ios::sync_with_stdio(false);
    
    int N; cin >> N;
    string S; cin >> S;

    vector<int> R(N), G(N), B(N);    
    rep(i, N) {
        R[i] = (i == 0 ? 0 : R[i-1]) + (S[i] == 'R' ? 1 : 0);
        G[i] = (i == 0 ? 0 : G[i-1]) + (S[i] == 'G' ? 1 : 0);
        B[i] = (i == 0 ? 0 : B[i-1]) + (S[i] == 'B' ? 1 : 0);
    }

    ll ans = 0;

    for (int i = 1; i < N - 1; i++) {
        if (S[i] == 'R') {
            ans += G[i-1] * (B[N-1] - B[i]);
            ans += B[i-1] * (G[N-1] - G[i]);
        } else if (S[i] == 'G') {
            ans += R[i-1] * (B[N-1] - B[i]);
            ans += B[i-1] * (R[N-1] - R[i]);
        } else {
            ans += G[i-1] * (R[N-1] - R[i]);
            ans += R[i-1] * (G[N-1] - G[i]);
        } 
    }

    for (int i = 1; i < N - 1; i++) {
        int j_lim = min(i, N-i-1);
        for (int j = 1; j <= j_lim; j++) {
            if (S[i] != S[i-j] && S[i] != S[i+j] && S[i-j] != S[i+j]) {
                ans--;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3704
#include <iostream>


using ll=long long int;

ll k,a,b;

int main() {

    std::cin>>k>>a>>b;

    if(a+2>=b||k<=a){
        std::cout<<k+1<<std::endl;
        return 0;
    }

    ll ans=1;

    k-=a+1;

    ans=b;

    ans+=(b-a)*(k/2);

    ans+=k%2;

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 256