akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner

val mod = 1000000007L
fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val h = scanner.nextInt()
	val w = scanner.nextInt()
	val a = scanner.nextInt()
	val b = scanner.nextInt()
	val max = Math.max(h-a+b-1, h+w-b-1)

	val arr = Array(max+1){Pair(1L,1L)}
	for (i in 2..max){
		val fct = (arr[i-1].first * i)%mod
		arr[i] = Pair(fct, powM(fct, mod-2L))
	}

	val fs = LongArray(h-a){ ((arr[it+b-1].first*arr[it].second)%mod * arr[b-1].second)%mod }
	var ans = 0L
	fs.forEachIndexed { i, l ->
		ans = (((arr[h-i+w-b-2].first*arr[h-i-1].second)%mod * arr[w-b-1].second)%mod * l + ans)%mod
	}
	println(ans)
}

fun powM(b: Long, e: Long): Long{
	var ans = 1L
	var mul = b
	var e = e
	while (e!=0L){
		if (e%2L==1L) ans = (ans*mul)%mod
		mul = (mul*mul)%mod
		e /= 2L
	}
	return ans
}

Measured memory_bytes: 63480
if __name__ == '__main__':
    a = int(input())
    s = input()
    ans =0
    for i in range(10):
        if str(i) in s:
            findi= s.find(str(i))+1
            listi=s[findi:]
            for j in range(10):
                if str(j) in listi:
                    findj = listi.find(str(j))+1
                    listj = listi[findj:]
                    sumlist= set(listj)
                    ans=ans+ len(sumlist)

    print(ans)

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

void test() {
    int x,n,tmp,i,l;
    set<int> p;
    cin >> x >> n;
    for (i=0; i<n; ++i) {
        cin >> tmp;
        p.insert(tmp);
    }
    i=0;
    while (1) {
        l=p.size();
        p.insert(x-i);
        if (p.size()>l) {
            cout << x-i << '\n';
            return;
        }
        l=p.size();
        p.insert(x+i);
        if (p.size()>l) {
            cout << x+i << '\n';
            return;
        }
        ++i;
    }
}

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

    // int t;
    // cin >> t;
    // while (t--) {
    //     test();
    // }
    test();

    return 0;
}

Measured memory_bytes: 3616
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
ab.sort(key=lambda x:x[1])
cnt=0
x=-1
for i in range(m):
  if x<ab[i][0]:
    x=ab[i][1]-1
    cnt+=1
print(cnt)

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

struct Card {
    char mark ,number;
};

void BubbleSort(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for (int j = N-1; j >= i+1; j--){
            if(A[j].number < A[j-1].number){
                swap(A[j], A[j-1]);
            }
        }
    }
}

void SelectionSort(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        int minj = i;
        for (int j = i; j < N; j++){
            if (A[j].number < A[minj].number) minj = j;
        }
        swap(A[i], A[minj]);
    }
}

void print(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        if (i > 0)  cout << " ";
        cout << A[i].mark << A[i].number;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for (int i = 0; i < N-1; i++){
        if (C1[i].mark != C2[i].mark)   return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> C1[i].mark >> C1[i].number;
    }
    
    for (int i = 0; i < N; i++) C2[i] = C1[i];
    
    BubbleSort(C1, N);
    SelectionSort(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int A,B,C,ops=0;
	cin >> A >> B >> C;
	vector<int> v(3);
	v[0] = A;
	v[1] = B;
	v[2] = C;
	while (true){
		sort(v.begin(),v.end());
		if ((v[0] == v[1]) and (v[1] == v[2])){
			cout << ops;
			break;
		}
		if (v[0] == v[1]){
			++v[0];
			++v[1];
			++ops;
		}
		else{
			v[0] += 2;
			++ops;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int gcd(int a, int b) {
		if(a == 0) return b;
		return gcd(b%a, a);
}

int main() {
	ll k, sum = 0;
	cin >> k;
	
	for(int a = 1; a <= k; a++) {
		for(int b = 1; b <= k; b++) {
			for(int c = 1; c <= k; c++) sum += gcd(gcd(a,b),gcd(b,c));
		}
	}
	
	cout << sum << endl;
  
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int w,h;
int n;
int mp[105][105];

int main(){
  cin>>h>>w;
  cin>>n;
  bool dir = true;
  int cnth = 0;
  int cntw = 0;
  for(int i=1;i<=n;i++){
    int tmp;
    cin>>tmp;
    for(int j=0;j<tmp;j++){
      if(dir){
        mp[cnth][cntw] = i;
      } else {
        mp[cnth][w-cntw-1] = i;
      }

      cntw++;

      if(cntw == w){
        dir ^= true;
        cnth++;
        cntw = 0;
      }
    }

  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cout<<mp[i][j]<<" ";cout<<endl;
  }

  return 0;
}

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

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    x1 -= x2;
    y1 -= y2;
    if (x1 < 0) x1 = -x1;
    if (y1 < 0) y1 = -y1;
    
    double ans = sqrt(pow(x1, 2) + pow(y1, 2));
    
    cout << fixed << setprecision(8) << ans << endl;
}


Measured memory_bytes: 3288
n=int(input())
a=[]
for i in range(n):
    s,t=input().split()
    a.append([s,int(t)])
x=input()
sum1=0
for j in range(n):
    if a[j][0]!=x:
        sum1+=a[j][1]
    else:
        sum1+=a[j][1]
        break
sum2=0
for i in range(n):
    sum2+=a[i][1]
print(sum2-sum1)


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

int main()
{
	char s[11];
	int i;
	int len;
	char strnum[4];
	int num;
	int min = 753;
	int dif;
	
	scanf("%s",s);
	len = strlen(s);
	
	for(i=0;i<len-2;i++){
		strncpy(strnum, s+i, 3);
		num = atoi(strnum);
		dif = abs(num - 753);
			if(dif<min){
				min=dif;
			}
	}
	
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
h, w = map(int,input().split())
s = []
for i in range(h):
    s.append(list(input()))

ans = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == '#' and s[max(0,i - 1)][j] == '.' and s[min(h - 1, i + 1)][j] == '.' and s[i][min(w - 1, j + 1)] == '.' and s[i][max(0, j - 1)] == '.':
            ans = "No"
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include<cstdio>
#include <math.h>
using namespace std;
int main(void){

    

    int m1,d1,m2,d2;


    cin>>m1>>d1;
    cin>>m2>>d2;
   if(d2==1){
       cout<<1<<endl;
   }
   else{
       cout<<0<<endl;
   }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if(A==B&&A==C){
			System.out.println("Yes");
        }else{
			System.out.println("No");
        }
    }
}


Measured memory_bytes: 35684
main(i,n,a,b,x,y){
  for(;scanf("%d",&n),n;printf("%d %d\n",a,b)){
    for(a=b=i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      if(x>y)a+=x+y;
      else if(x<y)b+=x+y;
      else a+=x,b+=x;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0
#define LIM 1000000007

lli isPrime(lli n){
	if(n==0 || n==1)return 0;
	else if(n==2) return 1;
	else if(n%2==0)return 0;
	else{
		for(lli i=3;i*i<=n;i+=2){
			if(n%i == 0){
				return 0;
			}
		}
		return 1;
	}
}

lli calc(lli n,lli prime){
	lli cnt=0;
	while(1){
		if(n%prime==0){
			cnt++;
			n/=prime;
		}
		else break;
	}
	return cnt;
}

int main(){

	/*素数リストを作る*/
	set<lli> prime;
	lli num;
	cin>>num;
	for(lli i=1;i<=1000;i++){
		if(isPrime(i)){
			prime.insert(i);
		}
	}

	map<lli,lli> ans;

	for(lli n = 1; n<= num;n++){
		for(auto &e:prime){
			ans[e]+=calc(n,e);
		}
	}

	lli ansSum=1;

	for(auto e:ans){
		ansSum *= (e.second+1)%LIM;
		ansSum %= LIM;
	}

	cout<<ansSum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll  N[300005],ans[300005],sumN[300005];
int n,m;

int search(int b){
  int L=0,M,R=n+1;
  while(L<R){
    M=(R+L)/2;
    if(N[M]>b) R=M;
    else L=M+1;
  }
  return L-1;
}

int main(){

  cin>>n;
  for(int i=1;i<=n;i++) scanf("%d",&N[i]);
  sort(N,N+n+1);
  for(int i=1;i<=n;i++) sumN[i]+=sumN[i-1]+N[i];
  cin>>m;
  for(int i=0;i<m;i++){
    int b;
    scanf("%d",&b);
    ans[i]=sumN[search(b)];
  }

  for(int i=0;i<m;i++){
    ll c;
    cin>>c;
    if(c<=ans[i]) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 8288
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define int long long
#define MOD 1000000007
using namespace std;

int32_t main()
{
    int n;	
    cin >> n;
    string s;
    cin >> s;
    int v[26] = {};
    for(int i = 0;i < n;i++)
    {
    	++v[s[i] - 'a'];
    }
    vector<int> p;
    for(int i = 0 ;i < 26;i++)
    {
    	if(v[i] != 0)
    		p.push_back(v[i]);
    }
    int ans = 0,prev = 0;
    for(auto i : p)
    {
    	ans = (ans + (i*((1 + prev)%MOD))%MOD) % MOD;
    	prev = ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512
def solve():
  N=int(input())
  a=list(map(int,input().split()))
  dp=[float('inf') for i in range(N)]
  dp[0]=0
  for i in range(N):
  	for j in range(i+1,min(i+3,N)):
  		dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]))
  print(dp[N-1])
solve()
      
# your code goes here

Measured memory_bytes: 13976
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = list(STR())
t = list(STR())
s.sort()
t.sort(reverse=True)
if ''.join(s) < ''.join(t):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 59500
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
int main()
{
    gbtb;
    cin>>n;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    dp[2]=abs(a[2]-a[1]);
    repd(i,3,n)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));

    }
    cout<<dp[n];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}


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

int main() {
  int A, B;
  double H, M, h, m, C, pi=3.141592653589793, Ans;
  cin >> A >> B >> H >> M;
  h=H*30+M*0.5;
  m=M*6;
  if(abs(h-m)>180) C=360-abs(h-m);
  else C=abs(h-m);
  Ans=sqrt(A*A+B*B-2*A*B*cos(C/180*pi));
  cout << setprecision(20) << Ans << endl;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    string a,b;cin>>a>>b;bool chk=1;int as=a.size(),bs=b.size();
    for(int i=0;i<as;i++){
        chk=1;
        for(int j=0;j<bs;j++){
            if(a[(i+j)%as]!=b[j]){
                chk=0;
                break;
            }
        }
        if(chk) break;
    }
    if(chk) printf("%s\n","Yes");
    else printf("%s\n","No");
}


Measured memory_bytes: 3232
#include <stdio.h>
#define min(a, b) a > b ? b : a
#define max(a, b) a > b ? a : b

typedef long long ll;

int main(void) {
  ll n, i, j, k, a, b, u = 0;
  scanf("%lld%lld%lld", &n, &a, &b);
  if(a + b > n + 1 || (a == 1 && b != n) || (b == 1 && a != n) || a * b < n) {
    printf("-1");
    return 0;
  }
  while( 1 ) {
    if(u >= n) break;
    for(i = max(n - a + 1, u + 1); i <= n; ++i) printf("%lld ", i);
    n = n - a;
    if(!u) --a;
    ll t = min(b - 1, n);
    for(i = t; i > u; i--) printf("%lld ", i);
    u = t;
  }
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,we;
ll w[101],v[101];
ll memo[3001][3001];
string s,t;
ll findans(ll i,ll j)
{
    if(i==s.length()||j==t.length())
    {
        return 0;
    }
    /*if(i==n-1)
    {
       
        if(sum+w[i]<=we)
        {
            return v[i];
        }
        else
        {
            return 0;
        }
    }*/
   if(memo[i][j]!=-1)
    {
        return memo[i][j];
    }
    ll ans1=0;
    ll ans2=0;
    ll ans3=0;
    if(s[i]==t[j])
    {
        //cout<<i<<" "<<j<<'\n';
        ans1=1+findans(i+1,j+1);
    }
     ans2=findans(i+1,j);
     ans3=findans(i,j+1); 
    return memo[i][j]=max(ans1,max(ans3,ans2));//memo[i][sum]=
}
int main(){
    // Your code here!
    
    cin>>s;
    cin>>t;
    for(ll i=0;i<s.length();i++)
    {
        for(ll j=0;j<t.length();j++)
        {
            memo[i][j]=-1;
        }
    }
    findans(0,0);
    string ans="";
    ll i=0,j=0;
    while(i<s.length()&&j<t.length())
    {
        //cout<<i<<" "<<j<<'\n';
        if(memo[i][j]==memo[i+1][j])
        {
           /* if(i==3&&j==3)
            {
                cout<<"h1"<<'\n';
            }*/
            i++;
        }
        else if(memo[i][j]==memo[i][j+1])
        {
            /*if(i==3&&j==3)
            {
                cout<<"h2"<<'\n';
            }*/
            j++;
        }
        else if(memo[i][j]==(memo[i+1][j+1]+1))
        {
            /*if(i==3&&j==3)
            {
                cout<<"h3"<<'\n';
            }*/
            
            ans+=s[i];
            i++;
            j++;
            
        }
    }
   /* for(ll i=0;i<=s.length()+1;i++)
    {
        for(ll j=0;j<=t.length()+1;j++)
        {
            cout<<memo[i][j]<<" ";
        }
        cout<<'\n';
    }*/
    cout<<ans;
    return 0;
}


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

const int N = 5;
char a[N];

int main() {
    ss(a + 1);
    int cnt = 0;
    repi(i, 1, 3)if (a[i] == 'R')cnt++;
    if (cnt == 2) {
        if (a[1] == 'S' || a[3] == 'S')puts("2");
        else puts("1");
    } else
        pi(cnt);
    return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>

int main(void)
{
	int num, i, a, b, c;
	scanf( "%d\n", &num );
	
	for( i = 0; i < num; i++ )
	{
		scanf( "%d %d %d\n", &a, &b, &c );
		printf( "%s\n",
			(0
				|| a*a + b*b == c*c
				|| a*a + c*c == b*b
				|| b*b + c*c == a*a
			)? "YES":"NO"
		);
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N,M;
    ll a,sum=0,b;
    scanf("%lld%lld",&N,&M);
    for(ll i=0;i<M;i++){
        scanf("%lld",&a);
        sum += a;
    }
    b= -1;
    if(sum > N) printf("-1\n");
    else printf("%lld\n",N-sum);
    return 0;

}

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

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

    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if (p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        else if (p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }

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


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

#define forn(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) begin(x),end(x)
#define ll long long
#define vi vector<int>

using namespace std;


int main(){
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        ll a,b,c,k;
        cin>>a>>b>>k;
        c=a;
        a=max(0ll,a-k);
        k-=(c-a);
        b=max(0ll,b-k);
        cout<<a <<" "<<b;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e5+10;
const int mod=1e9+7;




int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    ll sum=7;
    for(int i=1;i<1e7;i++)
    {
        if(sum%k==0)
        {
            cout<<i<<'\n';
            return 0;
        }
        sum*=10;
        sum+=7;
        sum%=k;
    }
    cout<<-1<<'\n';





}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

ll n, a[200005];

int main() {
    cin >> n;
    REP(i,n){
        int t;
        cin >> t;
        a[t-1] = i;
    }
    ll ans = 0;
    set<ll> used;
    used.insert(-1);
    used.insert(n);
    REP(i,n){
        ll l, r;
        l = a[i] - *--used.lower_bound(a[i]);
        r = *used.lower_bound(a[i]) - a[i];
        ans += (i+1)*l*r;
        used.insert(a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
def ABC149D():
	N, K = map(int,input().split())
	RSP = list(map(int,input().split()))
	T = [0] + list(input())
	hand_dic ={'r' : 0, 's' : 1, 'p' : 2}
	ans=0
	mod_l = [ [] for _ in range(K)]
	for i in range(1,N+1):
		mod_l[i%K].append(T[i])
	for a in range(K):
		dp = [ [0 for i in range(3)] for j in range(len(mod_l[a])+5)]
		for b in range(len(mod_l[a])):
			for c in range(3):
				if hand_dic[mod_l[a][b]] == c:
					dp[b+1][c] = max(dp[b][(c+1)%3], dp[b][(c+2)%3])
					dp[b+1][(c+1)%3] = max(dp[b][c], dp[b][(c+2)%3])
					dp[b+1][(c+2)%3] = max(dp[b][c] + RSP[(c+2)%3], dp[b][(c+1)%3] + RSP[(c+2)%3])
		ans += max(dp[len(mod_l[a])])

	print(ans)

if __name__ == '__main__':
	ABC149D()

Measured memory_bytes: 19744
#include<stdio.h>
int main(void) {
	char i, s[100];
	for (i = 0; i < 4; i++)
		scanf("%c", &s[i]);
	for (i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}

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

int main()
{
	std::string correct = "CODEFESTIVAL2016";

	std::string S;
	std::cin >> S;

	int result = 0;

	for (int i = 0; i < S.size(); ++i)
	{
		if (correct[i] != S[i]) {
			result++;
		}
	}

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N+1);
    for (int i = 0; i < N+1; i++) {
        cin >> A[i];
    }
    vector<ll> B(N);
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    ll ans = 0;
    REP(i, N){
        if(A[i] <= B[i]) {
            ans += A[i];
            B[i] -= A[i];
        }
        else{
            ans += B[i];
            B[i] = 0;
        } 
        if(A[i+1] <= B[i]){
            ans += A[i+1];
            A[i+1] = 0;
        }else{
            A[i+1] -= B[i];
            ans += B[i];
        }
    }
    pr(ans);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <vector>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

vector<ll> vec[200000];
ll n, a[200000], ans[200000];
multiset< pair<ll, ll> > s;
multiset< pair<ll, ll> >::iterator it;

void dfs(ll t, ll b) {
  ll i;
  pair<ll, ll> p = make_pair(a[t], 1);
  it = s.lower_bound(p);
  if(it != s.begin()) p.second = (*(--it)).second + 1;
  s.insert(p);
  it = s.upper_bound(p);
  multiset< pair<ll, ll> > st;
  while(it != s.end() && (*it).second <= p.second) st.insert(*it), it = s.erase(it);
  it = s.end();
  ans[t] = (*(--it)).second;
  for(i = 0; i < vec[t].size(); ++i) if(vec[t][i] != b) dfs(vec[t][i], t);
  s.erase(s.find(p));
  for(it = st.begin(); it != st.end(); ++it) s.insert(*it);
}

int main(void) {
  ll i, u, v;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 1; i < n; ++i) {
    scanf("%lld%lld", &u, &v);
    vec[--u].push_back(--v);
    vec[v].push_back(u);
  }
  dfs(0, 0);
  for(i = 0; i < n; ++i) printf("%lld\n", ans[i]);
  return 0;
}

Measured memory_bytes: 57660
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define int long long int
#define vec vector<int>
#define mp map<int,int>
#define inf 1e18
using namespace std;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt=1;
  //cin>>tt;
  while(tt--)
  {
    string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
        s+="es";
    else
        s+="s";
    cout<<s<<"\n";
  }
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

struct ModInt {
    static int MOD;
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

int ModInt::MOD;
using mint = ModInt;

void solve() {
    int n;
    std::cin >> n >> ModInt::MOD;

    auto comb = vec(n + 1, vec(n + 1, mint(0)));
    comb[0][0] = 1;
    for (int x = 0; x < n; ++x) {
        for (int y = 0; y <= x; ++y) {
            comb[x + 1][y] += comb[x][y];
            comb[x + 1][y + 1] += comb[x][y];
        }
    }

    auto dp = vec(n + 1, vec(n + 1, mint(0)));
    for (int k = 0; k <= n; ++k) {
        for (int l = 0; l <= k; ++l) {
            if (l == 0) {
                dp[k][l] = 1;
            } else if (k == 0) {
                dp[k][l] = 0;
            } else {
                dp[k][l] = dp[k - 1][l - 1] + dp[k - 1][l] * (l + 1);
            }
        }
    }

    mint ans = 0;
    for (int k = 0; k <= n; ++k) {
        mint c = 0;
        for (int l = 0; l <= k; ++l) {
            c += dp[k][l] * mint(2).pow((n - k) * l);
        }

        int e = 1;
        for (int i = 0; i < n - k; ++i) {
            (e *= 2) %= (ModInt::MOD - 1);
        }
        c *= mint(2).pow(e);

        ans += comb[n][k] * c * mint(k % 2 == 0 ? 1 : -1);
    }

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

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

    solve();

    return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <cmath>
#include <bitset>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int sum = 0;
    string s = "";
    int rest;
    while (n != 0){
        if (n % 2 != 0){
            s = '1' + s;
            n--;
        } else {
            s = '0' + s;
        }
        n /= -2;
    }
    if (s == ""){
        s = "0";
    }
   
    cout << s << endl;
}

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

#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define all(v) (v.begin(),v.end())
#define ll long long

const int N=205;
const int inf=2e9;
vector<int>f;
map<int,int>p;

int main(){
    //ios::sync_with_stdio(0);
    //freopen("in.txt","r",stdin);
    int n,t;
    ll a,b;
    a=b=0;
    cin>>n;
    rep(i,0,n){
        cin>>t;
        f.pb(t);
        p[t]++;
    }
    sort(f.begin(),f.end());
    per(i,0,sz(f)){
        if(p[f[i]]>=4){
            if(a==0) a=b=f[i];
            else b=f[i];
            break;
        }
        else if(p[f[i]]>=2){
            if(a==0){
                a=f[i];
                p[f[i]]=0;
            }
            else{
                b=f[i];
                break;
            }
        }
    }
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 5368
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N;
    cin >> N;
    for(ll h = 1; h <= 3500; h++) for(ll n = 1; n <= 3500; n++){
        ll lhs = N * h * n;
        ll rhs = 4 * h * n - N * n - N * h;
        if(rhs > 0){
            if(lhs % rhs == 0 && lhs / rhs > 0) {
                cout << h << " " << n << " " << lhs / rhs << endl;
                return 0;
                
            }
        }
        
    }

    
    return 0;
}

Measured memory_bytes: 256
#lang racket

(define (count-rgb N S)
  (let ([r 0] [g 0] [b 0])
    (define (iter s)
      (if (null? s)
          (* r g b)
          (begin
            (let ([item (car s)])
              (cond [(char=? item #\R) (set! r (+ r 1))]
                    [(char=? item #\G) (set! g (+ g 1))]
                    [(char=? item #\B) (set! b (+ b 1))])
            (iter (cdr s))))))
    (iter S)))

(define (solve N S)
  (let ([total (count-rgb N S)]
        [colors (list->vector S)])
    (define (nonnon i j)
      (let ([k (+ j (- j i))])
        (and (not (char=? (vector-ref colors i) (vector-ref colors j)))
             (not (char=? (vector-ref colors i) (vector-ref colors k)))
             (not (char=? (vector-ref colors j) (vector-ref colors k))))))
    (define (j-iter i j)
      (if (>= (+ j (- j i)) N)
          0
          (+ (if (nonnon i j) 1 0) (j-iter i (+ j 1)))))
    (define (i-iter i)
      (if (>= (+ i 2) N)
          0
          (+ (j-iter i (+ i 1)) (i-iter (+ i 1)))))
    (- total (i-iter 0))))

(let ([N (read)]
      [S (string->list (symbol->string (read)))])
  (display (solve N S)))


Measured memory_bytes: 85464
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  long a[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }

  int flag = 1;
  int operation = 0;
  while (1) {
    for (int i = 0; i < n; i++) {
      if (a[i]%2 == 0) {
        a[i] /= 2;
      } else {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      operation++;
    } else {
      break;
    }
  }
  printf("%d\n", operation);

  return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <string>

int main(int argc, const char *argv[]) {
  int a, b, c, d, e, k;
  std::string no = ":(";
  std::string yes = "Yay!";
  std::cin >> a >> b >> c >> d >> e >> k;
  if (std::abs(a - b) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(a - c) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(a - d) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(a - e) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(b - c) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(b - d) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(b - e) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(c - d) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(c - e) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  if (std::abs(d - e) > k) {
    std::cout << no << std::endl;
    return 0;
  }
  std::cout << yes << std::endl;
  return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }

    return 0;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, M, start, stop, ans=0, tmp=0;
vector<vector<ll>> G;

void bfs(){
    ll DP[N][3];
    for(int i=0;i<N;i++) {
        for(int j=0;j<3;j++) {
            DP[i][j] = INF;
        }
    }
    queue<pair<ll,ll>> Q;
    Q.push(make_pair(start,0));
    DP[start][0]=0;
    while(!Q.empty()) {
        pair<ll,ll> p = Q.front();
        Q.pop();
        for(int i=0;i<G[p.first].size();i++) {
            if(DP[G[p.first][i]][(p.second+1)%3]!=INF) continue;
            else {
                DP[G[p.first][i]][(p.second+1)%3] = p.second+1;
                Q.push(make_pair(G[p.first][i], p.second+1));
            }
        }
    }
    if(DP[stop][0]==INF) ans = -1;
    else ans = DP[stop][0]/3;
}

signed main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0;i<M;i++) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
    }
    cin >> start >> stop;
    start--;
    stop--;
    bfs();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long W,H,x,y;
    cin >> W >> H >> x >> y;
    double ans;
    ans = W*H/2.0;
    cout << setprecision(16) << ans << " ";
    if(2*x == W && 2*y == H) cout << 1 << endl;
    else cout << 0 << endl;
}

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

using namespace std;

const int MOD = 1000000007;

int n, m, ans = 1;

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

    cin >> n >> m;

    if (abs(n - m) > 1) {
        ans = 0;
    }

    for (int i = 1; i <= n; i++) {
        ans = ((long long)(ans) * (long long)(i)) % MOD;
    }

    for (int i = 1; i <= m; i++) {
        ans = ((long long)(ans) * (long long)(i)) % MOD;
    }

    if (n == m) {
        ans *= 2;

        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	char c[6];
	for (int i = 0; i < 6; i++) {
		cin >> c[i];
	}
	if (c[0] == c[5] && c[1] == c[4] && c[2] == c[3]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout << a*b/2 << endl;
  return 0;
}

Measured memory_bytes: 256
// Problem : 
// 			B - Making Triangle
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n; cin >> n;
    vi v(n);
    rep(i,0,n) cin >> v[i];
    int cnt = 0;
    vi temp;
    
    rep(i,0,n-2){
    	rep(j,i+1,n-1){
    		rep(k,j+1,n){
    			temp.clear();
    			temp = {v[i] , v[j] , v[k]};
    			sort(all(temp));
    			// deb(temp);
    			if(temp[0] != temp[1] && temp[0] != temp[2] && temp[1] != temp[2]){
    				if(temp[0]+temp[1] > temp[2]) cnt++;    				
    			}
    		}
    	}
    }
    
    cout << cnt;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int min = sc.nextInt();
        sc.nextInt();
        sc.nextInt();
        sc.nextInt();
        int max = sc.nextInt();
        int k = sc.nextInt();
        if((max - min) > k) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}

Measured memory_bytes: 23124
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:u32 = read();
    let m:usize = read();
    let x:u32 = read();
    let mut c:usize = 0;
    let mut l:Vec<u32> = (0..m).map(|_| read()).collect();
    l.sort();
    for i in &l {
        if i > &x {
            break
        }
        c += 1;
    }
    println!("{}", min(c, m-c));
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int> > g(n);
  for(int i=0;i<n-1;i++){
  	int a,b;
  	cin>>a>>b;
  	a--;
  	b--;
  	g[a].PB(b);
  	g[b].PB(a);
  }
  vector<int> d(n,-1);
  priority_queue<PII,vector<PII>,greater<PII> > pq;
  int k;
  cin>>k;
  while(k--){
  	int v,p;
  	cin>>v>>p;
  	v--;
  	d[v]=p;
  	pq.push(PII(p,v));
  }
  while(!pq.empty()){
  	PII p=pq.top();
  	pq.pop();
  	int u=p.S;
  	for(int i=0;i<g[u].size();i++){
	  int v=g[u][i];
  	  if(d[v]==-1){
  	    d[v]=d[u]+1;
  	    pq.push(PII(d[v],v));
	  }
    }
  }
  for(int u=0;u<n;u++)
    for(int i=0;i<g[u].size();i++){
      int v=g[u][i];
      if(abs(d[u]-d[v])!=1){
      	cout<<"No";
      	return 0;
	  }
    }
  cout<<"Yes\n";
  for(int u=0;u<n;u++)
    cout<<d[u]<<"\n";
  return 0;
}

Measured memory_bytes: 7924
#include<iostream>	// 入出力
#include<stdio.h>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか


using namespace std;

using ll = long long;

string S;

int main()
{
	cin >> S;

	if (S == "zyxwvutsrqponmlkjihgfedcba")
	{
		cout << -1 << endl;
		return 0;
	}

	if (S.length() == 26)
	{

		for (int i = 24; i >= 0; --i)
		{
			int min = 1000;
			int index = -1;

			for (int j = i + 1; j < 26; ++j)
			{
				if(S[i]<S[j]&&(int)S[j]<min)
				{
					min = (int)S[j];
					index = i;
				}
			}

			if (index != -1)
			{
				cout << S.substr(0, i) << (char)min << endl;

				return 0;
			}
		}

		return 0;
	}

	int used[26] = { 0 };

	for (char & a : S)
	{
		used[a - 'a'] = 1;
		
	}

	for(int i=0;i<26;++i)
	{
		
		if (used[i] == 0)
		{
			cout << S << (char)('a' + i) << endl;

			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
/* #define MOD 1000000007 */
#define MOD 998244353
#define INF LLONG_MAX
#define PI 3.14159265359
#define MAX 100000
using namespace std;

ll power(ll x, ll n)
{
  ll ans = 1;
  while(n)
  {
    if(n&1) ans = (ans*x)%MOD;
    x = (x*x)%MOD;
    n>>=1;
  }
  return ans;
}


int main()
{
  fastio
  /* int t; cin >> t; */
  /* while(t--) */
  /* { */
  /* } */
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool t = true;
  while(a>0 && c>0)
  {
    if(t) c -= b;
    else a -= d;
    t = !t;
  }
  if(a>0) cout << "Yes";
  else cout << "No";
  return 0;
}




Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const long long llinf=9223372036854775807ll;
int c[100005][11],clr[100005],n,m,q;
vector<int> e[100005];
int main(){ 
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);  
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int v,d;
		cin>>v>>d>>clr[i+1];
		v--;
		c[v][d]=i+1;
	}
	for(int i=9;i>=0;i--)
		for(int v=0;v<n;v++)
			for(int u=0;u<e[v].size();u++)
				if(c[e[v][u]][i]<c[v][i+1])
					c[e[v][u]][i]=c[v][i+1];
	for(int v=0;v<n;v++)
	{
		int ans=0;
		for(int d=0;d<11;d++)
			if(ans<c[v][d])
				ans=c[v][d];
		cout<<clr[ans]<<'\n';
	}
	return 0;
}

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

#define SAFE_DELETE( x ){ if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : count( 0 ), prev( NULL ), next( NULL ){}

	int count;
	string s;
	tCell *prev, *next;
};

class Database{
public:
	Database() : size( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~Database(){
		init();
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void init(){
		for ( int i = size; i > 0; --i ){
			--size;
			tCell* cell = tail->prev;
			cell->prev->next = cell->next;
			cell->next->prev = cell->prev;
			SAFE_DELETE( cell );
		}
	}
	void store( string& s ){
		bool stored = false;
		tCell* cell = head;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( cell->s == s ){
				++cell->count;
				stored = true;
				break;
			}
		}
		if ( !stored ){
			pushBack( s );
		}
	}
	string getMaxCount(){
		if ( !size ) return "";
		int c = 0;
		tCell* cell = head;
		tCell* maxc = NULL;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( c < cell->count ){
				c = cell->count;
				maxc = cell;
			}
		}
		return maxc->s;
	}
	string getMaxCharSize(){
		if ( !size ) return "";
		unsigned c = 0;
		tCell* cell = head;
		tCell* maxc = NULL;
		for ( int i = 0; i < size; ++i ){
			cell = cell->next;
			if ( c < cell->s.size() ){
				c = cell->s.size();
				maxc = cell;
			}
		}
		return maxc->s;
	}

private:
	void pushBack( string& s ){
		++size;
		tCell* cell = new tCell;
		cell->s = s;
		++cell->count;
		cell->prev = tail->prev;
		cell->next = tail;
		cell->prev->next = cell;
		cell->next->prev = cell;
	}

	int size;
	tCell *head, *tail;
};

int main(){
	string s;
	Database db;

	getline( cin, s );

	istringstream iss( s );
	while ( !iss.eof() ){
		iss >> s;
		db.store( s );
	}

	cout << db.getMaxCount() << " " << db.getMaxCharSize() << endl;

	return 0;
}

Measured memory_bytes: 0