akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	string s,t;
    cin>>s>>t;
    int m = s.length(), n = t.length();
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (s[i-1] == t[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   string ans = "";
   
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          ans += s[i-1];
          i--; j--; 
      }
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
    reverse(ans.begin(),ans.end());
   cout<<ans; 
} 

Measured memory_bytes: 35456
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();

	
	bool[] cs = new bool[8];
	int ncolor = 0;
	int nOver = 0;
	
	for (int i = 0; i < n; i++)
	{
	    int c = a[i] / 400;

	    if (c < 8 && !cs[c])
	    {
		ncolor++;
		cs[c] = true;
	    }
	    else if (c >= 8)
	    {
		nOver++;
	    }
	}
	
	int min = Math.Max(1, ncolor);
	int max = ncolor + nOver;
	WriteLine($"{min} {max}");
    }
}
    


Measured memory_bytes: 11348
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  VI a(n);
  rep(i,n) cin>>a[i];

  ll sum = 0;
  ll cnt1 = 0;
  bool flg = true;
  rep(i,n){
    sum += a[i];
    cerr << sum << ' ';
    if(flg){
      if(sum<=0){
        cnt1+=1-sum; sum=1;
      }
      flg=false;
    }else{
      if(sum>=0){
        cnt1+=1+sum; sum=-1;
      }
      flg=true;
    }
  }
  cerr << endl;
  sum = 0;
  ll cnt2 = 0;
  flg = false;
  rep(i,n){
    sum += a[i];
    cerr << sum << ' ';
    if(flg){
      if(sum<=0){
        cnt2+=1-sum; sum=1;
      }
      flg = false;
    }else{
      if(sum>=0){
        cnt2+=1+sum; sum=-1;
      }
      flg = true;
    }
  }
  cerr << endl;

  cout << min(cnt1,cnt2) << endl;

  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    long long p[1001] = {0};
    int i, j, cpy;
    for(i = 2; i <= n; i++){
        cpy = i;
        j = 2;
        while(cpy != 1){
            if(cpy % j == 0){
                p[j]++;
                cpy /= j;
            }else{
                j++;
            }
        }
    }
    
    long long ans = 1;
    for(i = 2; i <= n; i++){
        ans *= p[i] + 1;
        ans %= 1000000000 + 7;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; i++)
  {
    v[i] = i + 1;
  }
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++)
  {
    cin >> q[i];
  }
  int a, b;
  int cnt = 1;
  do
  {
    int pe = 0;
    int qe = 0;
    for (int i = 0; i < n; i++)
    {
      if (v[i] == p[i])
      {
        pe++;
      }
      if (v[i] == q[i])
      {
        qe++;
      }
    }

    if (pe == n)
    {
      a = cnt;
    }
    if (qe == n)
    {
      b = cnt;
    }
    cnt++;

  } while (next_permutation(v.begin(), v.end()));
  cout << abs(a - b) << endl;
}


Measured memory_bytes: 3604
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	map<string, int>mp;
	rep(i, N) {
		string s;cin >> s;
		mp[s]++;
	}
	vector<pair<int, string>>vec;
	for (auto p : mp) {
		vec.push_back(make_pair(INF - p.second, p.first));
	}
	sort(all(vec));
	int a = vec[0].first;
	rep(i, vec.size()) {
		if (a == vec[i].first)cout << vec[i].second << "\n";
	}

	return 0;
}

Measured memory_bytes: 28400
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;

int main() {
	int n;
	int k;
	cin >> n >> k;
	set<char> s;
	REP(i,k){
		char a;
		cin >> a;
		s.insert(a);
	}
	while(1){
		string tmp=to_string(n);
		bool flag=true;
		REP(i,tmp.size()){
			if(s.find(tmp[i])!=s.end()){
				i=tmp.size();
				n++;
				flag=false;
			}
			else{
				continue;
			}
		}
		if(flag){
			cout << n << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    var t;
    var input = input.split("\n");
    t = input[0];
    var min_try_count = -1;



    for (var i = "a".charCodeAt(0); i < "z".charCodeAt(0) + 1; i++) {
        //t_primeが単一の文字のみになっていればbreak
        if (/^([a-z])\1*$/.test(t)) {
            min_try_count = 0;
            break;
        }

        var tmp = t;
        var t_prime = "";
        var c = String.fromCharCode(i);
        var try_count = 0;

        while (true) {

            //文字数-1回分ループをまわす。
            //t'のi文字目について、tのi文字目またはi+1文字目を見る。
            //cと一致する文字があれば、その文字をt'のi文字目とする。
            //一致しなければ、tのi文字目をt'のi文字目とする。
            for (var j = 0; j < tmp.length-1; j++) {
                if (c === tmp.charAt(j)) {
                    t_prime += c;
                }
                else if (c === tmp.charAt(j + 1)) {
                    t_prime += c;
                }
                else {
                    t_prime += tmp.charAt(j);
                }
            }

            try_count++;

            //console.log(t_prime);
            //t_primeが単一の文字のみになっていればbreak
            if (/^([a-z])\1*$/.test(t_prime)) {
                break;
            }
            tmp = t_prime;
            t_prime = "";

        }

        if (min_try_count == -1 || min_try_count > try_count) {
            min_try_count = try_count;
        }

    }
    console.log(min_try_count);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 10164
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int MAXN = 1e3+5,MAXM = 2e5+5,MOD = 20130427,INF = 0x3f3f3f3f,N=100050;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const db eps = 1e-9;
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define mid l + ((r-l)>>1)
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define vii vector<pair<int,int>>
#define vi vector<int>
using namespace std;
struct node{
    int x,y,step;
}cur,nxt;
int n,m;
char mp[MAXN][MAXN];
bool vis[MAXN][MAXN];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
inline bool bound(int x,int y){
    return x>=1&&x<=n&&y>=1&&y<=m;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    //freopen("../A.in","r",stdin);
    //freopen("../A.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>(mp[i]+1);
    }
    int ans=0;
    queue<node> q;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(mp[i][j]=='#'){
                q.push({i,j,0});
                vis[i][j]=1;
            }
        }
    }
    while(q.size()){
        cur =q.front();q.pop();
        ans=max(ans,cur.step);
        for(int i=0;i<4;i++){
            nxt.x=cur.x+dx[i];
            nxt.y=cur.y+dy[i];
            nxt.step=cur.step+1;
            if(bound(nxt.x,nxt.y)&&!vis[nxt.x][nxt.y]&&mp[nxt.x][nxt.y]=='.'){
                vis[nxt.x][nxt.y]=1;
                q.push(nxt);
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 14352
from math import floor, sqrt


def func(x):
    return floor((sqrt(1 + 8 * x) - 1) / 2)


N = int(input())
limit = floor(sqrt(N))

primes = [2]

count = 0
flag = True
p = 2
while 1:
    #print(p,N)
    isprime = True
    if N == 1:
        break
    if p > sqrt(N):
        count += 1
        break
    
    a = 0
    while N % p == 0:
        #print("while",p, a)
        a += 1
        N = N // p
    count += func(a)
    if p == 2:
        p = 3
    else:
        p += 2
print(count)





Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MD = 1e9+7;
int la, ra;
ll l, r, ans;
int main(){
	scanf("%lld%lld", &l, &r);
	for(; l>>la; la++); la--;
	for(; r>>ra; ra++); ra--;
	for(int i = la; i <= ra; i++){
		ll dp1 = 1, dp2 = 0, dp3 = 0, dp4 = 0, lc = la==i?l:0, rc = ra==i?r:~0;
		for(int j = i-1; j >= 0; j--){
			int lb = lc>>j&1, rb = rc>>j&1; lb ^= 1;
			dp4 = (dp4*3 + rb * dp2 + lb * dp3) % MD;
			if(rb) dp2 = (dp2*2 + lb * dp1) % MD;
			if(lb) dp3 = (dp3*2 + rb * dp1) % MD;
			dp1 &= lb | rb;
		}
		(ans += (dp1 + dp2 + dp3 + dp4) % MD) %= MD;
	}
	printf("%lld\n", ans);
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll cnt(ll A, ll B){
  ll cnta = 0, cntb = 0;
  while (A > 0){
    cnta++; A /= 10;
  }
  while (B > 0){
    cntb++; B /= 10;
  }
  return max(cnta, cntb);
}

int main(){
  ll N; cin >> N;
  ll ans = 1e9;
  for (ll i = 1; i * i <= N; i++){
    if (N % i != 0) continue;
    ans = min(ans, cnt(i, N / i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())

lis=[a1,a2,a3,b1,b2,b3]
n1=lis.count(1)
n2=lis.count(2)
n3=lis.count(3)
n4=lis.count(4)
lis2=(n1,n2,n3,n4)
if 3 in lis2:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3060
n , m = map(int, input().split())
ipy = []
 
for i in range(m):
    p, y = map(int, input().split())
    ipy.append([i, p, y])

ipy.sort(key=lambda x:(x[1], x[2]))

num = None
count = 1

for i in range(len(ipy)):
    if num == None:
        num = ipy[i][1]

    if num != ipy[i][1]:
        count = 1
        num = ipy[i][1]

    bangou = str(ipy[i][1]).zfill(6) + str(count).zfill(6)

    ipy[i].append(bangou)

    count += 1

ipy.sort(key=lambda x:x[0])

for i in range(len(ipy)):
    print(ipy[i][3])

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a!=c)
	{
		cout<<"Yes";
	}
	else if(b==c && b!=a){
		cout<<"Yes";
	}
	else if(a==c && b!=c)
	{
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
#define maxn 100005
using namespace std;
ll sum[maxn];
int n;
struct node
{
    int id;
    ll val;
}a[maxn];
bool cmp(node a,node b)
{
    if(a.val==b.val)
return a.id<b.id;
return a.val>b.val;
}
int main()
{
 
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        {scanf("%lld",&a[i].val);
        a[i].id=i;
        }
    sort(a+1,a+n+1,cmp);
    int pos=a[1].id;
   ll num=1;
    a[n+1].val=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i+1].val==a[i].val)
            num++;
            else
            {
              sum[pos]+=(a[i].val-a[i+1].val)*num;
              num++;
             if(a[i+1].id<pos)
                pos=a[i+1].id;
            }
 
    }
    for(int i=1;i<=n;i++)
        printf("%lld\n",sum[i]);
    return 0;
 
 
}

Measured memory_bytes: 3456
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------

int main(void){
    int a, b;

    cin >> a >> b;

    cout << max({a + b, a - b, a * b}) << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<P> q;
    rep(i,n) {
      int a;
      cin >> a;
      q.push(P(a,1));
    }
    rep(i,m) {
      int b, c;
      cin >> b >> c;
      q.push(P(c,b));
    }
    ll ans = 0;
    rep(i,n) {
      auto p = q.top();
      q.pop();
      ans += p.first;
      if (p.second > 1) {
        p.second--;
        q.push(p);
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5356
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "";
        for(int i = 0; i < s.length(); i++){
            ans += "x";
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <numeric>
#define ll long long
using namespace std;
int main() {
  ll A,B,C,K,ans;
  cin>>A>>B>>C>>K;
  if(K%2==0) ans=A-B;
  else ans=B-A;
  if(abs(ans)>pow(10,18)) cout<<"Unfair"<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int T1,T2,R1,R2;

	scanf("%d %d %d %d",&T1,&T2,&R1,&R2);

	if(R1 == -1 || R2 == -1){

		if(T1 == T2){

			printf("Draw\n");

		}else if(T1 < T2){

			printf("Alice\n");
		}else{

			printf("Bob\n");
		}

	}else{

		if(R1 == R2){

			printf("Draw\n");

		}else if(R1 > R2){

			printf("Alice\n");

		}else{ //R1 < R2

			printf("Bob\n");
		}
	}

	return 0;
}



Measured memory_bytes: 3164
a, b, c = map(int, input().split())

if a == b:
    if b != c:
        print("Yes")      
    elif b == c:
        print("No")        
elif a != b:
    if b != c:
        if c == a:
            print("Yes")
        elif c != a:
            print("No")      
    elif b == c:
        print("Yes")  

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

//10度目の正直
//さっきの提出7度目とか書いておきながら9回目だったし……

long long oc_bit(long long x,long long y,long long z,int i){
  int X,Y,Z;
  X=i%2;i/=2;
  Y=i%2;i/=2;
  Z=i%2;
  return x*(2*X-1)+y*(2*Y-1)+z*(2*Z-1);
}
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<long long> wa(N);
  vector<long long> hikaku(8,0);
  long long x,y,z;
  vector<long long> X(N);
  vector<long long> Y(N);
  vector<long long> Z(N);
  for(int i=0;i<N;i++){
    cin >> x >> y >> z;
    X.at(i)=x;Y.at(i)=y;Z.at(i)=z;
  }
  for(int j=0;j<8;j++){
    for(int i=0;i<N;i++){
      long long xx=X.at(i);
      long long yy=Y.at(i);
      long long zz=Z.at(i);
      wa.at(i)=oc_bit(xx,yy,zz,j);
    }
    sort(wa.begin(),wa.end());
    reverse(wa.begin(),wa.end());
    for(int i=0;i<M;i++)
      hikaku.at(j) += wa.at(i);
  }
  sort(hikaku.begin(),hikaku.end());
  cout << hikaku.at(7);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  int N[n] =  {0};
  
  for (int i = 0; i < k; i++) {
  	int d;
    cin >> d;
    for(int j = 0; j < d; j++) {
    	int a;
      	cin >> a;
      	N[a-1] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
  	if (N[i] == 0) {
    	ans ++;
    }
  }
  
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;

const int MAXN = 100005;

int N, M;
vector <int> E[MAXN];
int color[MAXN];

void load() {
	scanf("%d%d", &N, &M);
	while (M--) {
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
}

bool dfs(int x, int c) {
	if (color[x] != -1)
		return color[x] == c;
	color[x] = c;
	bool ans = true;
	for (auto it : E[x])
		ans &= dfs(it, c ^ 1);
	return ans;
}

ll square(int x) {
	return (ll)x * x;
}

ll solve() {
	memset(color, -1, sizeof color);	
	int cnt[2] = {0}, iso = 0;
	for (int i = 1; i <= N; i++)
		if (E[i].empty())
			iso++;
		else if (color[i] == -1)
			cnt[dfs(i, 0)]++;
	
	return (ll)iso * (2 * N - iso) + square(cnt[0] + cnt[1]) + square(cnt[1]);
}

int main() {
	load();
	printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 9984
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	int n;
	cin >> n;
	vector <int> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if ((arr[i] + arr[j] > arr[k]) && (arr[i] + arr[k] > arr[j]) && (arr[j] + arr[k] > arr[i]) && arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
					//cout << i << " " << j << " " << k << endl;
					count++;
				}
			}
		}
	}
	cout << count << endl;
}
signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a; cin >> b;
  if(a - b == 0){
    cout << a << endl;
    return 0;
  }
  for(;;){
    if(a > b)
      a = a % b;
    else if (a < b)
      b = b % a;
    if (a * b == 0)
      break;
  }
  cout << a + b << endl;
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main() 
{   
    int N,K,X,Y,m=0;
    cin>>N>>K>>X>>Y;
    if(N>=K)
    m=K*X+(N-K)*Y;
    else 
    m=N*X;
    cout<<m<<endl;
	return 0; 
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
N = int(input())
C = [0] * (N + 1)
for i in range(2, N+1):
    k = i
    for j in range(2, i+1):
        while k % j == 0:
            k //= j
            C[j] += 1
        if k == 1:
            break
ans = 1
for c in C:
    ans *= (c + 1)
    ans %= MOD
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int main() {
    int n, p; cin >> n >> p;
    string s; cin >> s;

    if (p == 2 || p == 5) {
        int64_t res = 0;
        rep(i, n) {
            if ((s[n - i - 1] - '0') % p == 0) {
                res += n - i;
            }
        }
        cout << res << endl;
        return 0;
    }

    vector<int64_t> arr(p, 0);
    int64_t position = 1;
    int64_t cur = 0;
    arr[cur]++;
    rep(i, n) {
        cur = (cur + (s[n - i - 1] - '0') * position) % p;
        position = (position * 10) % p;
        arr[cur]++;
    }
    int64_t res = 0;
    rep(i, p) {
        res += arr[i] * (arr[i] - 1) / 2;
    }
    cout << res << endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A;
    ll b = -1;
    REP(i,0,N) {
        ll a;
        cin >> a;
        if(a != b) A.pb(a);
        b = A.back();
    }

    ll cnt = 1;
    REP(i,1,SZ(A)-1) {
        if((A[i-1] > A[i] && A[i] < A[i+1]) || (A[i-1] < A[i] && A[i] > A[i+1])) {
            ++cnt;
            ++i;
        }
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 4284
import Data.Functor( (<$>))
import Data.List( group, sort)
import Data.Char( isLetter, toLower)

main = do
    str <- (toLower <$>) . filter isLetter <$> getContents
    let
	normalized = group . sort $ str++['a'..'z']

	count list@(x:_) = (x, length list	-1)

	answer = count <$> normalized

    printCount `mapM_` answer	
      where
	printCount (c,n) = putStrLn $ [c]++" : "++show n




Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define FIN freopen("entrada.txt", "r", stdin);
#define FOUT freopen("saida.sol", "w", stdout);

#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define MAX int(55)

const int INF = 0x3f3f3f3f;
using namespace std;

int main() {

   IO

   int a, b; cin >> a >> b;
   cout << a*b;
   return 0;
}


Measured memory_bytes: 3640
//#define _CRT_SECURE_NO_WARNINGS
//             بسم الثالوث الاقدس

#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<fstream>
#include<bitset>
#include <cstring>
using namespace std;
const double EPS = 1e-8;
//jesus help me.......
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
///////////////////////////////////////////////////////////////		
///////////////////////////////////////////////////////////
bool sortby(const pair<int, int>&a, const pair<int, int>&b)
{
	if (a.first >= b.first&&a.second >= b.second)
		return true;
	return false;
}
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
int w[20002];
int main()
{
	fast();
	//freopen("keys.in", "r", stdin);
	int x, y;
	cin >> x >> y;
	if ((x*y) >= (x + y) && (x*y) >= (x - y))
		cout << x*y << endl;
	else if ((x + y) >= (x * y) && (x + y) >= (x - y))
		cout << x + y << endl;
	else
		cout << x - y << endl;




	//system("pause");
	return 0;
}

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

int main(){
	int n,m=1,ans=0, an=0;
	cin >> n;
	int a[n];
	int b[n];
	for(int i=1;i<=n;i++){
		cin >> a[i];
		if(a[i]%2==0){
			if(a[i]%3==0 || a[i]%5==0){
				an++;
			}
		}
		else{
			ans++;
		}
	}
	if(an==n-ans)
	cout << "APPROVED";
	else
	cout << "DENIED";
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	vector<pii> td(n);
	for(auto& x: td){ cin >>x.second >>x.first; x.second--; }
	sort(td.rbegin(), td.rend());
	ll sm = 0, psu =0;
	VI cnt(n);
	rep(i, k){
		sm += td[i].first;
		cnt[td[i].second]++;
	}
	rep(i, n) if(cnt[i]>0) psu++;
	sm += psu * psu;
	ll ans = sm;
	int p=k-1, j=k;
	repr(i, p, 0) if(cnt[td[i].second]>=2) {
		for( ;j<n; j++) if(cnt[td[j].second]==0){
			sm -= td[i].first + psu*psu;
			cnt[td[i].second]--;
			psu++;
			sm += td[j].first + psu*psu;;
			cnt[td[j].second]++;
			ans = max(ans, sm);
			break;
		}
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#define fir first
#define sec second
using namespace std;

int n;
double l;
int main() {
    cin>>l;
    double k = l/3;
    printf("%.6f\n",k*k*k);
    return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    int ans = max(a+b,max(a-b,a*b));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a,b,c,d;
signed main(){
    cin >> a >> b >> c >> d;
    long long int p1 = a*d;
    long long int p2 = a*c;
    long long int p3 = b*c;
    long long int p4 = b*d;
    cout << max({p1,p2,p3,p4});
}

Measured memory_bytes: 3636
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
 
sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

dp = [{} for _ in range(N + 1)]
dp[0] = {0: 0}
dp[1] = {0: 0, 1: A[0]}

for i in range(2, N + 1):
    for j in range(max(0, i // 2 - 2), min(N, i // 2 + 2) + 1):
        candidates = []
        if j - 1 in dp[i - 2]:
            candidates.append(dp[i - 2][j - 1] + A[i - 1])
        if j in dp[i - 1]:
            candidates.append(dp[i - 1][j])
        if len(candidates) > 0:
            dp[i][j] = max(candidates)

print(dp[N][N // 2])

Measured memory_bytes: 153824
import sys
input=sys.stdin.readline

def BellmanFord(Edges,num_v,source):
    inf=float('inf')
    dist=[inf for _ in range(num_v)]
    dist[source]=0
    for i in range(num_v):
        for edge in Edges:
            if edge[0]!=inf and dist[edge[1]]>dist[edge[0]]+edge[2]:
                dist[edge[1]]=dist[edge[0]]+edge[2]
                if i==num_v-1:
                    before_dist=dist[num_v-1]
                    for i in range(num_v):
                        for edge in Edges:
                            if edge[0]!=inf and dist[edge[1]] > dist[edge[0]]+edge[2]:
                                dist[edge[1]]=dist[edge[0]]+edge[2]
                    if before_dist!=dist[num_v-1]:
                        return -1
    return dist

n,m,p=map(int,input().split())
Edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    Edges.append((a,b,-(c-p)))
d=BellmanFord(Edges,n,0)
print(-1 if d==-1 else max(0,-d[-1]))

Measured memory_bytes: 44584
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#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 <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;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

  string s; cin >> s;
  int dest_x, dest_y; cin >> dest_x >> dest_y;

  vi x, y;
  int f_count = 0;
  int direction = 1;
  bool is_first_x_moved = true;

  REP(i, s.size()){
    if ( s[i] == 'F' ){
      f_count++;
    } else if ( s[i] == 'T' ){
      if( x.size() == 0 and direction == -1 ) is_first_x_moved = false;
      if( f_count > 0 ){
        if( direction > 0 ){
          x.push_back(f_count);
        } else {
          y.push_back(f_count);
        }
      }
      direction *= -1;
      f_count = 0;
    }
  }
 
  if( f_count > 0 ){
    if( direction > 0 ){
      x.push_back(f_count);
    } else {
      y.push_back(f_count);
    }
  }

  set<int> dpx, dpy;
  dpx.insert(0);
  dpy.insert(0);
  if( x.size()>0 and is_first_x_moved ) {dpx.clear(); dpx.insert(x[0]); }

  for(int i=0; i<x.size(); ++i){
    if( is_first_x_moved ) {is_first_x_moved=false; continue;}
    auto buf = dpx;
    dpx.clear();
    for(auto e : buf){
      dpx.insert(e+x[i]);
      dpx.insert(e-x[i]);
    }
  }

  for(int i=0; i<y.size(); ++i){
    auto buf = dpy;
    dpy.clear();
    for(auto e : buf){
      dpy.insert(e+y[i]);
      dpy.insert(e-y[i]);
    }
  }

  if( dpx.count(dest_x)>0 and dpy.count(dest_y)>0 ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;

}



Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string s,t; cin >> s >> t;
    int len = s.length();
    int ans = 0;
    REP(i,len){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;

}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 1000000007
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back

using namespace std;

ll dp[1001][1<<12];

ll helper(vi &a,vi &b,ll st,ll mask,ll reqmask)
{
    if(mask==reqmask)
        return 0;
    if(st>=a.size())
        return inf;
    if(dp[st][mask]!=-1)
        return dp[st][mask];
    ll ans;
    ans=helper(a,b,st+1,mask,reqmask);
    ans=min(ans,a[st]+helper(a,b,st+1,mask|b[st],reqmask));
    return dp[st][mask]=ans;
}

void solve()
{
    ll n,m;
    cin>>n>>m;
    vi a,b;
    rep(i,0,m)
    {
        vector <bool> v(n,false);
        ll x,y;
        cin>>x>>y;
        rep(i,0,y)
        {
            ll p;
            cin>>p;
            v[p-1]=true;
        }
        ll num=0;
        rep(i,0,n)
        {
            num=num*2;
            num+=v[i];
        }
        a.pb(x);
        b.pb(num);
    }
    ll reqmask=(1<<n)-1;
    memset(dp,-1,sizeof dp);
    ll ans=helper(a,b,0,0,reqmask);
    if(ans==inf)
        ans=-1;
    cout<<ans;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
#define N 101
int s[N], f[N], tt = 0, n;
int graph[N][N];

void dfs(int node){
    if(s[node] == 0){
        s[node] = ++tt;
    }else return;
    for(int i = 0; i < n; i++){
        if(graph[node][i]) dfs(i);
    }
    f[node] = ++tt;
}

int main(){
    int u, k, val;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++)graph[i][j] = 0;
    }
    for(int i = 0; i < n; i++){
        scanf("%d %d", &u, &k);
        u--;
        for(int j = 0; j < k; j++){
            scanf("%d", &val);
            val--;
            graph[u][val] = 1;
        }
    }
    
    for(int i = 0; i < n; i++)dfs(i);
    for(int i = 0; i < n; i++)printf("%d %d %d\n", i + 1, s[i], f[i]);
}


Measured memory_bytes: 3216
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    if(a == b)
        cout << "Draw" << endl;
    else if(a == 1 || (b != 1 && a > b))
        cout << "Alice" << endl;
    else
        cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int n;
  while(cin>>n){
    if(n==0){break;}
    int x,m;
    int a[10000];
    for(int i =0;i<1000;i++){
      a[i]=0;
    }
  for(int i =0;i<n;i++){
    cin >> m;
    a[m] += 1;
  }
  for(int j =0;j<10;j++){
    if(a[j]==0){
      cout << "-";
    }else{
      for(int k =0;k<a[j];k++){
	cout << "*";
      }
    }
    cout << endl;
  }
  }
	return 0;
}



Measured memory_bytes: 3084
x, k, d = (int(entry) for entry in input().split())
r = x
moves = k
if x < 0:
    r = -x

steps = r // d
if steps >= moves:
    print(r - moves * d)
    exit(0)

r -= steps * d
if abs(r - d) <= abs(r):
    steps += 1
    r -= d

moves -= steps
if moves % 2 != 0:
    moves -= 1
    if abs(r - d) < abs(r + d):
        r -= d
    else:
        r += d

print(abs(r))


Measured memory_bytes: 9216
//import java.lang.Math;
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();

        int R;
        if(n>10){
            R = r;
        }else{
            R = r+100*(10-n);
        }
        System.out.print(R);
    }
}

Measured memory_bytes: 22740
#include<iostream>

using namespace std;

int main() {
	int a, b;

	cin >> a >> b;

	bool p = false, k = false;

	if (a + b == 15) {
		p = true;
	}
	if (a*b == 15) {
		k = true;
	}

	if (p) {
		cout << "+";
	}
	else if (k) {
		cout << "*";
	}
	else {
		cout << "x";
	}

	return 0;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,X = map(int,input().split())
M = [int(input()) for _ in range(N)]

r = X - sum(M)
print(N + r//min(M))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e5+4;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int N;
pii P[10];

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    fori(i,N) cin >> P[i].fi >> P[i].se;
    sort(P,P+N);

    double total = 0;
    do {
        fori(i,N-1) {
            int xi = P[i].fi;
            int xj = P[i+1].fi;

            int yi = P[i].se;
            int yj = P[i+1].se;

            double d = sqrt((double)((xi-xj)*(xi-xj) + (yi-yj)*(yi-yj)));
            total += d;
        }
    } while(next_permutation(P,P+N));

    fori(i,N) total /= i+1;
    cout << fixed << setprecision(8) << total << endl;
    return 0;
}



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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int M = 1000000007;
string s;
int d;
int dp[105][10005][2];
void add_self(int &a, int b){
    a+=b;
    if(a>=M)
        a-=M;
}
int go(int idx, int less, int m){
    if(dp[m][idx][less]!=-1)
        return dp[m][idx][less];
    if(idx==s.size())
        return m==0;
    dp[m][idx][less]=0;
    int ds = s[idx]-'0';
    for(int i = 0; i<=9; ++i){
        if(i>ds&&(!less))
            break;
        int ii = i%d;
        int nxt_m = (m+ii)%d;
        add_self(dp[m][idx][less],go(idx+1,i<ds||less,nxt_m));
    }
    //error(idx,m,less,dp[m][idx][less]);
    return dp[m][idx][less];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s>>d;
    memset(dp,-1, sizeof(dp));
    int ans = go(0,0,0);
    ans-=1;
    if(ans==-1)
        ans = M-1;
    cout<<ans<<"\n";
    //error(dp[0][1]);    
}

Measured memory_bytes: 9472
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int a[];

		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			a = new int[5];
			a[0] = n + m;
			for (int i = 1; i < 5; i++) {
				n = sc.nextInt();
				m = sc.nextInt();
				a[i] = n + m;
			}
			int maxIndex = 0;
			for (int i = 0; i < 5; i++) {
				if (a[maxIndex] < a[i]) {
					maxIndex = i;
				}
			}
			System.out.println((char)('A' + maxIndex) + " " + a[maxIndex]);
		}
	}
}

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

int h,w,k;
int ans=0;
char a[6][6];
void dfs(int s,int r){
	s=~s;
	r=~r;
	int res=0;
	for(int x=0;x<h;x++){
		for(int y=0;y<w;y++){
			if((s>>x&1==1)&&(r>>y&1==1)){
				if(a[x][y]=='#') res++;
			}
		}
	}
	if(res==k) ans++;
}

int main(){
	cin>>h>>w>>k;
	for(int p=0;p<h;p++){
		getchar();
		for(int q=0;q<w;q++){
			a[p][q]=getchar();
		}
	} 
	for(int m=0;m<1<<h;m++)
	    for(int n=0;n<1<<w;n++){
	    	dfs(m,n);
		}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int n;
  ll ans=0;
  std::cin >> n;
  vector<ll> a(n),b(n),c(n);
  for(int i=0; i<n; i++) std::cin >> a[i];
  for(int i=0; i<n; i++) std::cin >> b[i];
  for(int i=0; i<n; i++) std::cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  for(int i=0; i<n; i++){
    ll p=b[i];
    auto Ia=lower_bound(a.begin(),a.end(),p);
    auto Ic=upper_bound(c.begin(),c.end(),p);
    ans+=(Ia-a.begin())*(c.end()-Ic);
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int n, a;
    cin >> n >> a;
    cout << n*n - a << endl;
    
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main{
	public static void main(String[] a){
		Scanner scanner = new Scanner(System.in);
		int first = 0 ,second = 0 , third = 0;
		int[] hills = new int[10];
		for(int i = 0 ; i < 10 ; i ++ ){
			hills[i] = scanner.nextInt();
			if(hills[i]>first){
				third = second;
				second = first;
				first=hills[i];
			}
			else if(hills[i]>second){
				third = second;
				second=hills[i];
				}
			else if(hills[i]>third){
				third=hills[i];
				}
		}
		System.out.print(first+"\n"+second+"\n"+third+"\n");
		
    	}
}

Measured memory_bytes: 25984
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	h := float64(nextInt())
	a := float64(nextInt())
	fmt.Println(int(math.Ceil(h / a)))
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

void maxUpdate(lint& a, lint b) { a = max(a, b); }

int N;
lint A[200005];
lint dp[200005][10];

int main() {
    cin >> N;
    for_(i,0,N) cin >> A[i];
    A[N] = A[N+1] = 0;

    lint MIN_VAL = -1 * (1LL << 60);
    for_(i,0,N+4) for_(j,0,3) dp[i][j] = MIN_VAL;

    dp[0][0] = 0;
    for_(i,0,N) for_(j,0,3) {
        if (dp[i][j] == MIN_VAL) continue;
        maxUpdate(dp[i+2][j], dp[i][j] + A[i]);
        maxUpdate(dp[i+3][j+1], dp[i][j] + A[i+1]);
        maxUpdate(dp[i+4][j+2], dp[i][j] + A[i+2]);
    }

    lint ans = MIN_VAL;
    for_(i,N,N+4) {
        if (N & 1) maxUpdate(ans, max(dp[i][1], dp[i][2]));
        else maxUpdate(ans, max(dp[i][0], dp[i][1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 20800
def LI():return map(int,input().split())
def I(): return input().split()

while(True):
    a,b=LI()
    if a==b==0:
        break
    else:
        for i in range(a):
            lst_a=[]
            for j in range(b):
                if (i+j) %2==0:
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


Measured memory_bytes: 7008
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	int A, B, C, X, Y;
	int sum;
	cin >> A >> B >> C >> X >> Y;
	if (A + B < C * 2) {
		sum = A*X + B*Y;
	}
	else {
		if (X < Y) {
			if (B < 2 * C) {
				sum = 2 * C*X + B*(Y - X);
			}
			else {
				sum = 2 * C*Y;
			}
		}
		else {
			if (A < 2 * C) {
				sum = 2 * C*Y + A*(X - Y);
			}
			else {
				sum = 2 * C*X;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
//g++ -std==c++14
//setprecision(10)
int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++)
        cin >> p[i];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(i == p[i] - 1){
            cnt ++;
            swap(p[i], p[i + 1]);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
# AGC003A - Wanna go back home
def main():
    S = input().rstrip()
    flg = (("N" in S) ^ ("S" in S) ^ 1) & (("E" in S) ^ ("W" in S) ^ 1)
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
L = []
for i in range(5):
    L.append(int(input()))

ans = 0
tmp = []

for i in range(len(L)):
    if(L[i]%10 == 0):
        ans += L[i]
    else:
        ans += L[i] + (10 - L[i]%10)
        tmp.append(L[i]%10)

if(len(tmp) > 0):
    ans -= 10 - min(tmp)

print(ans)


Measured memory_bytes: 38256