akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    vector<int> a(3);
    for(int i=0; i<3; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());

    int ans = a[2] * 2 - a[0] - a[1];
    if(ans % 2 != 0)
        ans += 3;
    ans /= 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int n, s, g;
	while (cin >> n >> s >> g, n) {
		int x[300];
		rep(i, n) {
			cin >> x[i];
		}
		sort(x, x + n,greater<int>());
		int ma = 0; int chk;
		Rep1(i,s,g) {
			if (ma <= x[i - 1]-x[i]) {
				ma = x[i - 1] - x[i]; chk = i;
			}
		}
		cout << chk << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
typedef pair<ll,ll>ii;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,m;
    while(sf("%d %d",&n,&m)==2)
    {
        string s;
        cin>>s;
        s.insert(s.begin(),'#');
        int cum[n+5];
        cum[0]=0;
        for(int i=1;i<s.size();i++)
        {
            if(s[i-1]=='A' && s[i]=='C')cum[i]=cum[i-1]+1;
            else cum[i]=cum[i-1];
        }

        for(int i=0;i<m;i++)
        {
            int l,r;
            sf("%d %d",&l,&r);
            if(s[l]!='C')pf("%d\n",cum[r]-cum[l-1]);
            else pf("%d\n",cum[r]-cum[l]);
        }
    }   
    return 0;
}
 









 




























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

ll N,K;
ll dp[55][55][20000];

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;

ll S=N*(N+1)/2;
ll SS=(2*S+K)/2;

dp[0][0][0]=1;
for(int n=0; n<=N; n++){
	for(int m=0; m<=N; m++){
		for(int k=0; k<=SS; k++){
			if(n>=m){
				dp[n+1][m+1][k+n+1]=(dp[n+1][m+1][k+n+1]+(n-m)*dp[n][m][k]%mod)%mod;
				dp[n+1][m+2][k+2*(n+1)]=(dp[n+1][m+2][k+2*(n+1)]+(n-m)*(n-m)*dp[n][m][k]%mod)%mod;
				dp[n+1][m+1][k+n+1]=(dp[n+1][m+1][k+n+1]+(n-m)*dp[n][m][k]%mod)%mod;
			}
			dp[n+1][m+1][k+n+1]=(dp[n+1][m+1][k+n+1]+dp[n][m][k])%mod;
			dp[n+1][m][k]=(dp[n+1][m][k]+dp[n][m][k])%mod;
		}
	}
}

if(K%2){
	cout<<0<<endl;
}else{
	cout<<dp[N][N][SS]<<endl;
}

}



Measured memory_bytes: 438528
n,m=map(int,input().split())
d=[0 for i in range(m)]
for i in range(n):
    x=list(map(int,input().split()))
    for j in range(1,x[0]+1):
        d[x[j]-1]+=1

count=0
for i in range(m):
    if d[i]==n:
        count+=1
print(count)

Measured memory_bytes: 3060
import math

loop = 1
while loop == 1:
    a, op, b = (x for x in input().split())

    if op == "+":
        ans = int(a)+int(b)
    elif op == "-":
        ans = int(a)-int(b)
    elif op == "*":
        ans = int(a)*int(b)
    elif op == "/":
        ans = math.floor(int(a)/int(b))
    else:
        loop = 0
        break

    print(ans)


Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

lint A, B, ans;

int main()
{
    cin >> A >> B;
    if (A == B)
    {
        cout << 1 << endl;
        return 0;
    }
    int now = 60;
    while (true)
    {
        if ((A & (1LL << now)) and (B & (1LL << now)))
        {
            A ^= (1LL << now);
            B ^= (1LL << now);
        }
        else if ((A & (1LL << now)) || (B & (1LL << now))) break;
        now--;
    }

    int btop = now;
    now--;
    while (now >= 0)
    {
        if (B & (1LL << now)) break;
        now--;
    }

    lint ans1 = (1LL << btop) - A;
    if (now < 0)
    {
        cout << ans1 * 2 + (A ? 1 : 0) << endl;
        return 0;
    }
    ans1 += min(1LL << btop, ans1 + (1LL << (now + 1)));
    cout << ans1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int x, y;
    cin >> x >> y;

    int g[13] = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};

    cout << (g[x] == g[y] ? "Yes\n" : "No\n");

    return 0;
}

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

using namespace std;

int main(void){
    int d,n;
    cin >> d >> n;
    if(n<100){
        cout << n*pow(100,d) << endl;
    }else if(d < 2){
        cout << dec << (n+1)*pow(100,d) << endl;
    }else{
        cout << 1010000 << endl;
    }
    return 0;
}


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

int main(void)
{
    int n, l;
    cin >> n >> l;
    int a, s;
    a = 101;
    s = 0;
    for (int i = 1; i <= n; i++) {
        if (abs(a) > abs(l+i-1)) a = l+i-1;
        s += l+i-1;
    }
    cout << s-a << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;


int main() {
	int N;
	cin >> N;
    vector<vector<int>> a(101010, vector<int>(3));
    rep(i, N) rep(j, 3) cin >> a[i][j];

    vector<vector<int>> dp(100010, vector<int>(3));
    rep(j, 3) dp[0][j] = 0;

    rep(i, N) rep(j, 3) rep(k, 3) {
        if (j == k) continue;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
    }

    int ans = 0;
    rep(j, 3) ans = max(ans, dp[N][j]);
	cout << ans << endl;
	return 0;
}


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

using ll = long long int;

const ll MOD = (ll)(1e9 + 7);

ll n, m;

map<ll, ll> cnt;

ll ans = 1;

/////////////////////////////////////////////////////////////
class CombinationModula {
public:
  const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModula(ll n) {
    vector<ll> tmp_fact(n + 5);
    vector<ll> tmp_inv(n + 5);
    vector<ll> tmp_fact_inv(n + 5);

    fact = tmp_fact;
    inv = tmp_inv;
    fact_inv = tmp_fact_inv;

    init(n);
  }

  void init(ll n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
  	for (int i = 2; i <= n; i++) inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
  	for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MOD;
  	for (int i = 1; i <= n; i++) fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }

  ll comb(ll n, ll r) {
    if (r > n) return 0;
  	return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res[i] += 1;
      n /= i;
    }
  }

  if (n != 1) res[n] = 1;
  return res;
}

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &m);

  cnt = prime_factorization(m);

  CombinationModula comb_mod(n + 100);

  for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
    ans *= comb_mod.comb(n - 1 + itr->second, n - 1);
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;
}

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

const int N = 2005;

pair<int, int> a[N];

int n;
long long dp[N][N];
long long f(int x, int l) {
  if (x == n) return 0LL;
  if (~dp[x][l]) return dp[x][l];

  int r = n - (x-l) - 1;
  return dp[x][l] = max(
    1LL * a[x].first * abs(a[x].second - l) + f(x+1, l+1),
    1LL * a[x].first * abs(a[x].second - r) + f(x+1, l)
  );
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }

  sort(a, a + n, greater<pair<int, int>>());
  memset(dp, -1, sizeof dp);

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


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

static const int INF = (1<<30)-1;

int main()
{
	string s;
	cin >> s;
	string now;
	int ans = INF;
	for (int i = 0; i < s.size() - 2; ++i)
	{
		now = s.substr(i, 3);
		ans = min(ans, abs(stoi(now)-753));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>
#include <set>
#include <string>
#include <queue>
using namespace std;
typedef long long int ll;
#define INF 1LL << 50
int main() {
	int N;
	cin >> N;
	set<int> cards;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		cards.insert(A);
	}
	int s = N - cards.size();
	int ans = N;
	if (s % 2 == 0) ans -= s;
	else ans -= s + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
dataNum=int(input())
wordList=[]
for n in range(dataNum):
    wordList.append(input().strip())

if len(wordList) != len(set(wordList)):
    print("No")
    exit()

char = wordList[0][-1:]
for n in range(1, len(wordList)):
    if(char != wordList[n][:1]):
        print("No")
        exit()
    char = wordList[n][-1:]

print("Yes")

Measured memory_bytes: 3064
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
count_matw = [[0 for w in range(W)]for h in range(H)]
count_math = [[0 for w in range(W)]for h in range(H)]

for h in range(H):
    count = 0
    for w in range(W):
        if '#' == S[h][w]:
            count = 0
        else:
            count += 1
        count_matw[h][w] = count
    for w in range(W-1, 0, -1):
        if count_matw[h][w-1] == 0:
            continue
        count_matw[h][w-1] = max(count_matw[h][w], count_matw[h][w-1])

for w in range(W):
    count = 0
    for h in range(H):
        if '#' == S[h][w]:
            count = 0
        else:
            count += 1
        count_math[h][w] = count
    for h in range(H-1, 0, -1):
        if count_math[h-1][w] == 0:
            continue
        count_math[h-1][w] = max(count_math[h][w], count_math[h-1][w])
ans = 1
for h in range(H):
    for w in range(W):
        ans = max(ans, count_math[h][w] + count_matw[h][w])
# ans = max([count_math[h][w] + count_matw[h][w] for h in range(H) for w in range(W)])
# print(count_math)
# print(count_matw)
print(ans-1)


Measured memory_bytes: 249608
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
int n;
ll mn=-10000000000000;
ll dp[100002][2]={0};
ll w[101],v[101];
ll solve(int weight){
    for(int i=1;i<=n;i++){
        int prev=i%2;
        int now=(i+1)%2;
        for(int j=1;j<=weight;j++){
            if(w[i]>j) dp[j][now]=dp[j][prev];
            else dp[j][now]=max(dp[j-w[i]][prev]+v[i],dp[j][prev]);
        }
    }
    return dp[weight][(n+1)%2];
}
int main(){
    scn(n);
    int wt;scn(wt);
    for(int i=1;i<=n;i++){
        scnll(w[i]);
        scnll(v[i]);
    }
    ll ans=solve(wt);
    printf("%lld\n",ans);
}



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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 200010;
const double eps = 1e-6;

int n;
LL a[N];

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

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    LL res = 1;
    for(int i = 0; i < n; i++)
    {
        LL t = gcd(res, a[i]);
        res /= t;
        res *= a[i];
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int sum,n;
  cin>>sum>>n;
  int temp;
  for(int i=0;i<n;i++)
  {
    cin>>temp;
    sum-=temp;
  }
  if(sum<0) sum=-1;
  cout << sum;
}


Measured memory_bytes: 3632
#include<stdio.h>
int ball[10];

int func(int i,int a,int b);
int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    
    for(j=0;j<10;j++){
      scanf("%d",&ball[j]);
    }
    
    if(func(0,0,0)){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

int func(int i,int a,int b){
  int ans=0;
  if(i==10){
    return 1;
  }
  else if(a<ball[i]){
    ans += func(i+1,ball[i],b);
  }
  else if(b<ball[i]){
    ans += func(i+1,a,ball[i]);
  }

  return ans;
}

Measured memory_bytes: 580
'use strict'
function main(input) {
  input = input.split('\n');
  const length = Number(input[0])
  input = input[1].split(' ')
  let min = 10000000000
  let minusCount = 0
  input = input
    .map(val => {
      val = Number(val)
      let abs = Math.abs(val)
      if (val < 0) minusCount++
      if (abs < min) min = abs
      return abs
    })
    .reduce((prev, current) => prev + current)

  if (minusCount % 2) input -= min * 2
  
  console.log(input)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 32084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int n,m,c,res;
int a[205][205],b[205];
int main() {
	cin>>n>>m>>c;
	for( int i=1;i<=m;i++ )cin>>b[i];
	for( int i=1;i<=n;i++ ) 
		for( int j=1;j<=m;j++ ) cin>>a[i][j];
	for( int i=1;i<=n;i++ ) {
		int sum=c;
		for( int j=1;j<=m;j++ ) 
			sum+=a[i][j]*b[j];
		if(sum>0) res++;
	} 
	cout<<res;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (x == 0) a[y]++;
		if (y == n - 1) b[x]++;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] && b[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int q=sc.nextInt();
        StringBuilder sb=new StringBuilder(s);
        StringBuilder pre=new StringBuilder();
        int count=0;
        boolean flag=false;
        for(int i=0;i<q;i++)
        {
            int t=sc.nextInt();
            if(t==1)
            {
                count++;
                flag=!flag;
                continue;
            }
            else
            {
                int f=sc.nextInt();
                char c=sc.next().charAt(0);
                if(f==1) {
                    if (flag) {
                        sb.append(c);
                    } else {
                        pre.append(c);
                    }
                }
                else
                {
                    if (flag) {
                        pre.append(c);
                    } else {
                        sb.append(c);
                    }
                }
            }
        }
        pre.reverse().append(sb);
        if(count%2==1) {
            pre.reverse();
        }
        System.out.println(pre.toString());
    }
}

Measured memory_bytes: 127056
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
score_a = 0
score_b = 0

for i in range(N):
  if i % 2 == 0:
    score_a += A[i]
  else:
    score_b += A[i]
    
print(abs(score_a - score_b))

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

using pii = pair<int, int>;

int main()
{
    int h, w;
    vector<pair<pii, int>> vec;
    for (int i = 1; i <= 200; i++)
    {
        for (int j = i + 1; j <= 200; j++)
        {
            vec.push_back(make_pair(make_pair(i * i + j * j, i), j));
        }
    }

    sort(vec.begin(), vec.end());
    while (cin >> h >> w, h | w)
    {
        int len = h * h + w * w;
        for (int i = 0; i < vec.size(); i++)
        {
            if (len == vec[i].first.first && h == vec[i].first.second && w == vec[i].second)
            {
                cout << vec[i + 1].first.second << ' ' << vec[i + 1].second << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    map<int, ll> counts;
    for (ll l : numbers) counts[l]++;

    ll all = 0;
    for (auto e : counts) all += (e.second * (e.second - 1) / 2);

    for (ll l : numbers) {
        ll sub = counts[l] * (counts[l] - 1) / 2;
        ll add = (counts[l] - 1) * (counts[l] - 2) / 2;
        ll now = all - sub + add;
        cout << now << endl;
    }

}


Measured memory_bytes: 11008
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) { cout << N * 800 - (N / 15) * 200 << endl; }

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  vector<ll> a(n);
  ll asum = 0;
  rep(i, n) {
    cin >> a[i];
    asum += a[i];
  }
  vector<ll> b(n);
  ll bsum = 0;
  rep(i, n) {
    cin >> b[i];
    bsum += b[i];
  }

  if (asum < bsum) {
    cout << -1 << endl;
    return 0;
  }
  
  vector<ll> c(n);
  int ans = 0;
  ll msum = 0;
  rep(i, n) {
    c[i] = a[i] - b[i];
    if (c[i] < 0) {
      msum += c[i];
      ans++;
    }
  }

  sort(c.rbegin(), c.rend());

  rep(i, n) {
    if (msum >= 0) {
      break;
    }
    msum += c[i];
    ans++;
  }

  cout << ans << endl;
}

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

int main(void){
    long long n,ans=1e18 ;
    cin >> n ;
    for (long long i=1; i<=1000000; i++){
        if (n%i==0){
            ans=min(ans,(i-1)+(n/i-1)) ;
        }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String t[],s;
			double a[] = new double[6];
			while((s = br.readLine()) != null){
				t = s.split(" ");
				for(int i = 0;i < a.length;i++){
					a[i] = Double.parseDouble(t[i]);
				}
				double z = a[0]*a[4]-a[1]*a[3];
				double x = (a[4]*a[2]-a[1]*a[5])/z;
				double y = (-a[3]*a[2]+a[0]*a[5])/z;
				
				if(x == -0.0){
					x = 0.0;
				}
				if(y == -0.0){
					y = 0.0;
				}
					System.out.printf("%4.3f %4.3f\n",x,y);
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 24808
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 1e5 + 5, base = 31, mod = 1e5 + 7;
using namespace std;

vi H;

ll dp[ms], K, N;

int solve(int i){

	if (i == H.size()-1) return 0;
	
	if (dp[i] != -1) return dp[i];
	
	ll best = 1e13;
	
	for (int k = 1; k <= K; k++){
	
		if (i+k > N+1) break;
	
		ll temp = abs(H[i] - H[i+k]) + solve(i+k);
		best = min(best, temp);
	}
	
	return dp[i] = best;
	
}

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	memset(dp, -1, sizeof(dp));
	cin >> N >> K;
	for (int i = 0; i < N; i++){
		int a; cin >> a;
		H.pb(a);
	}
	cout << solve(0) << endl;
	
	//for (auto x : H) cout << x << " "; cout << endl;
	
	
	return 0;
}


Measured memory_bytes: 9716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

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

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

	set<int> st;
	for (int i = 0; i < 2; i++)
	{
		for(int v = 1; v * v <= A[i]; v++)
		{
			if (A[i] % v == 0)
			{
				st.insert(v);

				if (v != 1 && v * v != A[i])
				{
					st.insert(A[i] / v);
				}
			}
		}

		st.insert(A[i]);
	}

	int ans = 1;
	for(int v : st)
	{
		int count = 0;
		for (int i = 0; i < N; i++)
		{
			if (A[i] % v != 0)
			{
				count++;
			}
		}

		if (count <= 1)
		{
			ans = v;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
//ProblemC

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemC

class Solve {
private:

	void solve() {
		int n;
		cin >> n;
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];
		auto b = a;
		sort(b.begin(), b.end());

		for (int i = 0; i < n; i++) {
			if (a[i] < b[n/2]) {
				cout << b[n / 2] << endl;
			}
			else {
				cout << b[n / 2 - 1] << endl;
			}
		}

	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 3712
function solve(input) {
  let n = parseInt(input);
  if (n < 2) {
    return 0;
  }
  let count = 0;
  for (let p = 2; p * p <= n; p++) {
    if (n % p === 0) {
      let z = p;
      while (n % z === 0) {
        n /= z;
        z *= p;
        count++;
      }
      while (n % p === 0) {
        n /= p;
      }
    }
  }
  if (n > 1) {
    count++;
  }
  return count;
}

function main(input) {
  console.log(solve(input));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 33000
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
 int n,f=0,s=0;
 for(int i=0;i<3;i++){
  cin >> n;
  if(n==5){
    f=f+1;
  }else if(n==7){
    s=s+1;
  }
 }
 if(f==2&&s==1){
   cout << "YES" << endl;
 }else{
   cout << "NO" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a,b;
    getline(cin,a);
    getline(cin,b);
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int alice = 0, bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      alice += a[i];
    else
      bob += a[i];
  }
  cout << alice - bob << endl;
  return 0;
}

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

int main()
{
  while(true)
  {
    int m,f,r;
    cin>>m>>f>>r;
    if(m+f+r==-3) return 0;
    if(m*f<0) cout<<"F"<<endl;
    else if (m+f>=80) cout<<"A"<<endl;
    else if (m+f>=65) cout<<"B"<<endl;
    else if (m+f>=50) cout<<"C"<<endl;
    else if (m+f>=30 && r>=50) cout<<"C"<<endl;
    else if (m+f>=30) cout<<"D"<<endl;
    else cout<<"F"<<endl;
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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

  for (int i = 1;; ++i) {
    if (i * i > n) {
      cout << (i - 1) * (i - 1) << endl;
      break;
    }
  }

  return 0;
}


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

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

    long long ans;
    if(2 * n <= m){
        ans = n;
        m -= n * 2;
        ans += m / 4;
    }else ans = m / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define w 200001
i;p;main(n,m,j){
  long int k,a[w],A[w],b[w],B[w];
  scanf("%d%d%ld",&n,&m,&k);
  for(;i<n;i++){
    scanf("%ld",&a[i]);
    A[i+1]=A[i]+a[i];
  }
    
  for(i=0;i<m;i++){
    scanf("%ld",&b[i]);
    B[i+1]=B[i]+b[i];
  }
  int mo=m;
        
  for(i=0;i<=n;i++){
    if(A[i]>k)break;
            
    for(j=mo;j>=0;j--){
      if(A[i]+B[j]<=k){
        if(i+j>p)p=i+j;
        mo=j;
        break;
      }
    }
  }
  printf("%d",p);
}

Measured memory_bytes: 7908
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int m, f, r, n = 0;
		String data[] = new String[50];
		
		while(true) {
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			
			if( m == -1 && f == -1 && r == -1)break;
			
			if( m == -1 || f == -1) {
				data[n] = "F";
			}else if( m + f >= 80){
				data[n] = "A";
			}else if( m + f >= 65) {
				data[n] = "B";
			}else if( m + f >= 50){
				data[n] = "C";
			}else if( m + f >= 30) {
				if( r >= 50) {
					data[n] = "C";
				}else {
					data[n] = "D";
				}
			}else {
				data[n] = "F";
			}
			
			n++;
		}
		
		for(int i = 0; i < n; i++) {
			System.out.println(data[i]);
		}
	}
}



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

int main() {
  unsigned int input;
  unsigned int count;

  while(cin >> input) {
    count = 0;
    for(int a0=0; a0<10; a0++) {
      for(int a1=0; a1<10; a1++) {
        for(int a2=0; a2<10; a2++ ) {
          for(int a3=0; a3<10; a3++) {
            if(a0+a1+a2+a3==input) {
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

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

int main(int argc, char **argv) {
  int N;
  cin >> N;
  vector<double> v(N);

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

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

  double ans = v[0];
  for (int i = 1; i < N; i++) {
    ans = (ans + v[i]) / 2;
  }

  cout << std::setprecision(10) << std::fixed << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int area=a*b;
  int length=2*(a+b);
  System.out.println(area+" "+length);
  }
}

Measured memory_bytes: 26000
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

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

	return 0;
}

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

int n;

vector<int>E[200000];
bool used[200000];
int sz[200000];
ll ans[200000];
int c[300000];

int N,s;

#define map unordered_map

void szdfs(int v,int p){
	sz[v]=1;
	for(auto u:E[v]){
		if(u==p||used[u])continue;
		szdfs(u,v);
		sz[v]+=sz[u];
	}
}

void search_centroid(int v,int p){
	bool centroid=true;
	for(auto u:E[v]){
		if(u==p||used[u])continue;
		search_centroid(u,v);
		if(sz[u]>N/2)centroid=false;
	}
	if(N-sz[v]>N/2)centroid=false;
	if(centroid)s=v;
}

int S[200000];
int M[200000];
void pathdfs(int v,int p,map<int,ll>&mp,ll&X){
	S[v]=1;
	X++;
	bool b=(M[c[v]]==0);
	M[c[v]]++;
	for(auto u:E[v]){
		if(u==p||used[u])continue;
		pathdfs(u,v,mp,X);
		S[v]+=S[u];
	}
	if(b)mp[c[v]]+=S[v];
	M[c[v]]--;
}

void count_pairs(map<int,ll>&mp,ll X,ll x){
	for(auto p:mp){
		ans[p.first]+=p.second*(X-p.second)*x+p.second*(p.second-1)/2*x;
		if(x>0)ans[p.first]+=p.second;
	}
}

void solve(int v){
	szdfs(v,-1);N=sz[v];search_centroid(v,-1);
	used[s]=true;
	map<int,ll>mp_all;
	ll X_all=0;
	for(auto u:E[s]){
		if(used[u])continue;
		map<int,ll>mp;ll X=0;
		mp[c[s]]=0;
		M[c[s]]++;
		pathdfs(u,s,mp,X);
		M[c[s]]--;
		mp[c[s]]+=S[u];
		count_pairs(mp,X,-1);
		X_all+=X;
		if(mp_all.size()<mp.size())swap(mp,mp_all);
		for(auto p:mp)mp_all[p.first]+=p.second;
	}
	ans[c[s]]++;
	count_pairs(mp_all,X_all,1);
	for(auto u:E[s]){
		if(!used[u])solve(u);
	}
}

int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&c[i]),c[i]--;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);E[b].push_back(a);
	}
	solve(0);
	rep(i,n){
		printf("%lld\n",ans[i]);
	}
}
/*
6
5 3 3 1 6 6 
1 4
2 4
2 5
2 6
3 4
*/

Measured memory_bytes: 51172
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;
int main(){
  int a=0,b=0,c=0;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    if(tmp%4==0)a++;
    else if(tmp%2==0)b++;
    else c++;
  }
  if( (a==c-1 and b==0) or (a+b)==n or (a>c-1))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>v(n), dp(k + 5, 0);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        dp[v[i]] = 1;
    }
    for(int i = v[0] + 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i - v[j] >= 0 && dp[i - v[j]] == 0){
                dp[i] = 1;
            }
        }
    }
    if(dp[k] == 1){
        cout << "First";
    }
    else{
        cout << "Second";
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define min(a,b) ((a)<(b))?(a):(b)
int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  printf("%d",min(min(a+b,b+c),a+c));
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String str = sc.next();
   int count = 0;
   int countmem = 0;
 for (int i = 0; i < str.length(); i++) {
	if(str.charAt(i) == 'A' || str.charAt(i) == 'T' ||
       str.charAt(i) == 'C' || str.charAt(i) == 'G'){
       count++;
    }else{
      if(countmem < count){
      countmem = count;
      }
      count = 0;
    }
   if(i == str.length()-1 && countmem < count){
      countmem = count;      
   }
  }
    System.out.print(countmem);
 }
}

Measured memory_bytes: 23252
<?php
# C - Anti-Division

fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $D);

$A = $A - 1;

#1からA
$ADividedC = intdiv($A, $C);
$ADividedD = intdiv($A, $D);
$ADividedCD = intdiv($A, lcm($C, $D));    
$AA = ($A - $ADividedC - $ADividedD + $ADividedCD);

#1からB
$BDividedC = intdiv($B, $C);
$BDividedD = intdiv($B, $D);
$BDividedCD = intdiv($B, lcm($C, $D));
$BB = ($B - $BDividedC - $BDividedD + $BDividedCD);

echo ($BB - $AA) . PHP_EOL;

//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
//最小公倍数
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

Measured memory_bytes: 4856
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#ifndef M_PI
const double M_PI=acos(-1);
#endif
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int dp[20][1200];
bool pr[1121];
int npr[1121],pos;

main(){
  pr[0]=pr[1]=true;
  for(int i=2;i<1121;i++){
    if(pr[i])continue;
    for(int j=i*2;j<1121;j+=i)pr[j]=true;
  }
  rep(i,1121)if(!pr[i])npr[pos++]=i;

  dp[0][0]=1;
  rep(p,pos){
    for(int k=14;k;k--)
      for(int i=npr[p];i<1121;i++)dp[k][i]+=dp[k-1][i-npr[p]];
  }
  int n,k;
  while(cin>>n>>k,n|k)cout<<dp[k][n]<<endl;
}

Measured memory_bytes: 0
N = int(input())
H = list(map(int,input().split()))
H.append(float('inf'))
count = 0
ans = 0
for i in range(N):
  if H[i] >= H[i+1]:
    count += 1
  else:
    ans = max(ans,count)
    count = 0
print(ans)

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) { cin >> L[i]; }
  sort(RALL(L));

  PRINT(L[0])
  int ans = 0;
  rep(i, N) {
    rep(j, N - i - 1) {
      rep(k, N - i - j - 2) {
        if (L[i] < L[j + i + 1] + L[k + j + i + 2]) {
          if (L[j + i + 1] == L[k + j + i + 2]) continue;
          if (L[i] == L[k + j + i + 2]) continue;
          if (L[j + i + 1] == L[i]) continue;
          ans++;
          PRINT(L[i])
          PRINT(L[j + i + 1])
          PRINT(L[k + j + i + 2])
        } else {
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3660
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", max({a + b, a - b, a * b}));
	
	Please AC;
}


Measured memory_bytes: 632
n,m,s,t=map(int,input().split())

import heapq
def dijkstra_heap(s,graph):
  #始点sから各頂点への最短距離と直前の点
  dist=[float("inf")]*size_v
  prev=[-1]*size_v
  used=[False]*size_v
  #used=set()
  dist[s]=0
  used[s]=True
  #used.add(s)

  hq_edge=[]
  for v,w in graph[s]:
    heapq.heappush(hq_edge,(w,v,s))

  while hq_edge:
    min_w,min_v,u=heapq.heappop(hq_edge)
    #まだ使われてない頂点の中から最小の距離のものを探す
    if used[min_v]:
    #if min_v in used:
      continue

    dist[min_v]=min_w
    prev[min_v]=u
    used[min_v]=True
    #used.add(min_v)
    for v,w in graph[min_v]:
      if not used[v]: 
      #if not v in used:
        heapq.heappush(hq_edge,(min_w+w,v,min_v))

  return dist,prev

graph_yen=[[] for _ in range(n+1)]
graph_snu=[[] for _ in range(n+1)]
for _ in range(m):
  u,v,a,b=map(int,input().split())
  graph_yen[u].append((v,a))
  graph_yen[v].append((u,a))
  graph_snu[u].append((v,b))
  graph_snu[v].append((u,b))
  
size_v=n+1
dist_yen,prev_yen=dijkstra_heap(s,graph_yen)
dist_snu,prev_snu=dijkstra_heap(t,graph_snu)
#print(dist_yen)
#print(dist_snu)

cost_list=[0]*(n+1)
cost_list[n]=dist_yen[n]+dist_snu[n]
for i in reversed(range(1,n)):
  cost_list[i]=min(cost_list[i+1],dist_yen[i]+dist_snu[i])
#print(cost_list)

for i in range(1,n+1):
  print(10**15-cost_list[i])

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    double A, B, H, M; cin >> A >> B >> H >> M;

    double PI = acos(-1);
    double angle = abs(2 * PI * (60 * H + M) / (12 * 60) - 2 * PI * M / 60);

    double ans = sqrt(A*A + B*B - 2*A*B*cos(angle));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
const int MOD = 1e9+7;
const ll INF =1e18;

int main(){
  int n;cin>>n;
  vector<pair<pair<string,int>,int>> sp(n);
  fr(i,n){
      string s;cin>>s;
      int p;cin>>p;
      sp[i]=mp(mp(s,-p),i+1);
  }
  sort(sp);
  fr(i,n)cout<<sp[i].sd<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		print();
	}

	private static void print() throws IOException {
		int a;
		int b;
		int c;

		Scanner scn = new Scanner(System.in);
		a = scn.nextInt();
		b = scn.nextInt();
		c = scn.nextInt();
		sort(a, b, c);
	}

	private static void sort(int a, int b, int c) {
		// TODO ?????????????????????????????????????????????
		List<Integer> list = new ArrayList<>();
		list.add(a);
		list.add(b);
		list.add(c);

		Collections.sort(list);
		System.out.println(list.get(0) + " " + list.get(1) + " " + list.get(2));
	}

}

Measured memory_bytes: 26364