akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws NumberFormatException, IOException {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    int[] numCount = new int[101];
    ArrayList<Integer> ansSet = new ArrayList<>();
    Arrays.fill(numCount, 0);
    while (input.ready()) {
      int data = Integer.parseInt(input.readLine());
      numCount[data]++;
    }
    int tmp = 0;
    for (int i = 0; i < numCount.length; i++) {
      if (numCount[i] == 0)
        continue;
      if (tmp > numCount[i]) {
        continue;
      }
      if (tmp < numCount[i]) {
        tmp = numCount[i];
        ansSet.clear();
        ansSet.add(i);
        continue;
      }
      if (tmp == numCount[i]) {
        ansSet.add(i);
      }
    }

    for (int i : ansSet) {
      System.out.println(i);
    }
  }

}

Measured memory_bytes: 24032
A,B,C,X,Y = map(int,input().split())
ans = 0
if (A+B)/2 > C:
    ans += C*2*min(X,Y)
else:
    ans += A*min(X,Y)+B*min(X,Y)
if X>Y:
    ans += (X-Y)*min(A,2*C)
elif X<Y:
    ans += (Y-X)*min(B,2*C)

print(ans)

Measured memory_bytes: 3064
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

A, B, C = list(map(int, sys.stdin.readline().split()))

print(B + min(A + B +1, C))


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

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

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    double a,b,h,m,d,ans;cin>>a>>b>>h>>m;
    m=360*m/60;
    h=360*h/12+m/12;
    d=min(abs(m-h),360-abs(m-h));
    ans=sqrt(a*a+b*b-2*a*b*cos(d*PI/180));
    cout<<fixed<<setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 4076
N = int(input())

lst = []
for i in range(N):
  N, K = map(int, input().split())
  lst.append((K-N, N, K))

lst.sort()
lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")


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

int main(){
  int m[10000];
  int i,j,cnt=0,n,a;
  
  while(1){
    scanf("%d",&n);
    if(n>=1 && n<= 10000){
      break;
    }
  }
  
  for(i = 0;i < n ; i++){
    scanf("%d",&m[i]);
    if(m[i]<2 && m[i]>100000000){
      break;
    }
  }
  for(i = 0;i < n ; i++){
    a = sqrt(m[i]);
    for(j = a;j > 2; j--){
      if( m[i]%j == 0){
	break;
      }
    }
    if(m[i]%j != 0 || m[i] == 2 || m[i] ==3){
      cnt++;
    }
  }  
  printf("%d\n",cnt);
  return 0;
}



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

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long ans = -1e18;

    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << endl;
}

Measured memory_bytes: 3596
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING
    EXPLAINATION BELOW->
    Pure implementation
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
char X[400005];
void solve()
{
   memset(X,'0',sizeof(X));
   ll head,tail,pivot,i;
   head=200004;
   tail=head+1;
   pivot=tail;
   string s;cin>>s;
   for(i=0;i<sz(s);i++)
   {
       X[tail]=s[i];
       tail++;
   }
   tail++;
   ll q,t,f,T=0;cin>>q;
   char c;
   while(q--)
   {
       cin>>t;
       if(t==1)T++,swap(head,tail);
       else
       {
           cin>>f>>c;
           if(f==1)
           {
               X[head]=c;
               if(head<pivot)head--;
               else head++;
           }
           else
           {
               X[tail]=c;
               if(tail<pivot)tail--;
               else tail++;
           }
       }
   }
   
   if(T%2==1)
   reverse(X,X+400005);
   
   fo(i,0,400005)
   {
       if(X[i]!='0')cout<<X[i];
   }
   cout<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;

int n, q;
char s[N];
int bit[N][26];

void update(int pos, int id, int val) {
	for (int i = pos; i <= N; i += i & (-i))
		bit[i][id] += val;
}

int query(int pos, int id) {
	int res = 0;
	for (int i = pos; i >= 1; i -= i & (-i))
		res += bit[i][id];
	return res;
}

int main() {
	cin >> n >> (s + 1);
	for (int i = 1; i <= n; i++) {
		update(i, s[i] - 'a', 1);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int op; cin >> op;
		if (op == 1) {
			int j; char c; cin >> j >> c;
			update(j, s[j] - 'a', -1);
			update(j, c - 'a', 1);
			s[j] = c;
		} else {
			int l, r; cin >> l >> r;
			int ans = 0;
			for (int j = 0; j < 26; j++) 
				if (query(r, j) - query(l - 1, j))
					++ans;
			cout << ans << "\n";		
		}
	}
}

Measured memory_bytes: 51584
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;

int main(){

    int n,x;
    cin >> n >> x;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    vector<int> b;

    rep(i,n-1){
        b.pback(a[i] + a[i+1]);
    }

    ll ans = 0;

    for(int i = 0; i < n - 1; i++){
        int dig = max(b[i] - x, 0);

        if(a[i + 1] >= dig){
            a[i + 1] = a[i + 1] - dig;
            b[i] = b[i] - dig;
            if(i + 1 <= n - 2) b[i + 1] = b[i + 1] - dig;
            ans = ans + dig;
        }else{
            b[i] = b[i] - a[i + 1];
            if(i + 1 <= n - 2) b[i + 1] = b[i + 1] - a[i + 1];
            ans = ans + a[i + 1];
            a[i + 1] = 0;
        }
    }

    if(b[0] > x){
        int dig = b[0] - x;
        ans = ans + dig;
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void solve()
{
    int N, K;
    cin >> N >> K;

    int ans = floor(log(N) / log(K)) + 1;

    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>	
#include<vector>
#include<queue>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;


int ans[200010];
int x[502][502];
int c[502][502];

int main() {
	int n, m, Q;
	cin >> n >> m >> Q;
	int l, r;
	for (int i = 0; i < 502; i++) {
		for (int j = 0; j < 502; j++) {
			x[i][j] = 0;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		x[l][r]++;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			x[i][j] += x[i][j-1];
		}
	}
	int p, q;
	int ans = 0;
	vector<int>answer;
	for (int i = 0; i < Q; i++) {
		cin >> p >> q;
		ans = 0;
		for (int j = p; j <= q; j++) {
			ans += x[j][q] - x[j][p - 1];
		}
		answer.push_back(ans);
	}
	for (int i = 0; i < Q; i++) {
		cout << answer[i] << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int A, B, K;
  scanf("%d %d %d", &A, &B, &K);
  int len = min(K, B - A + 1);
  set<int> st;
  for (int i = 0; i < len; ++i) {
    st.insert(A + i);
  }
  for (int i = 0; i < len; ++i) {
    st.insert(B - i);
  }
  vector<int> v(st.begin(), st.end());
  sort(v.begin(), v.end());
  for (int i = 0; i < (int)v.size(); ++i) {
    printf("%d\n", v[i]);
  }

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxw=30+5;
int w,n,rank[maxw];
int main(){
    scanf("%d%d",&w,&n);
    for(int i=1;i<=w;i++)
        rank[i]=i;
    for(int i=1,x,y;i<=n;i++){
        scanf("%d,%d",&x,&y);
        swap(rank[x],rank[y]);
    }
    for(int i=1;i<=w;i++)
        cout<<rank[i]<<endl;
    return 0;
}

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

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int razon = B / A;
        if(razon > C){
            System.out.println(C);
        }else{
            System.out.println(razon);
        }

    }
}


Measured memory_bytes: 21844
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Thursday August 13, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof arr)
#define ll    int64_t

const int oo  = (int)(1e9);
const ll lloo  = (ll)(1e18);

const int N = 1e5 + 10;

class Task {
public:
    
    int n, k;
    vector<int> A;

    ll dp[N];

    ll go(int index) {
        if(index > n) return 0LL;
        if(index == n) {
            return 0LL;
        }

        ll &ans = dp[index];
        if(ans != -1) return ans;

        ll x = oo;
        
        for(int i = 1; i <= k; ++i){            
            if(index+i <= n) {
                x = min(x, abs(A[index]-A[index+i]) + go(index + i));
            }
        }
        if(x == oo) {
            x = 0;
        }
        ans = x;
        return ans;
    }


    ll solveOne(istream &in, ostream &out) {
        in >> n >> k;
        A.resize(n+1);
        for(int i = 1; i <= n; ++i){
            in >> A[i];
        }
        memset(dp, -1, sizeof dp);
        ll ans = go(1);
        return ans;  
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) {
            out << solveOne(in, out) << endl;
        }
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 12204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag,                    //if  using ll change ll to ll
        tree_order_statistics_node_update> pbset;
#define fob(x) find_by_order(x)

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.size() <= k)
		cout << s;
	else
	{
		string a;
		for (int i = 0; i < k; i++)
			a += s[i];
		a += '.'; a += '.'; a += '.';
		cout << a;
	}
	return 0;
}

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

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}
int main(){
	int n, m;
	cin >> n;
	vi d(n);
	rep(i,n){
		cin >> d[i];
	}
	cin >> m;
	vi t(m);
	rep(i,m) cin >> t[i];
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	bool f = true;
	int id = 0;
	rep(i,n){
		if(id >= m) continue;
		if(d[i]>t[id]){
			f=false;break;
		}
		if(d[i] == t[id]) id++;
	}
	cout << (f ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef int64_t i64;
typedef uint64_t ui64;
typedef pair<int, int> pi;

template <class T, class U>
inline ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <class T, class U>
inline istream& operator>>(istream& os, pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
    if (v.empty())
        return os;
    if (v.begin() != v.end())
        os << v.front();
    for (auto it = ++v.begin(); it != v.end(); ++it)
        os << ' ' << *it;
    return os;
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
    for (auto& i : v)
        is >> i;
    return is;
}

void Solve(istream& is, ostream& os) {
    int a, b, h;
    is >> a >> b >> h;
    os << (h >> 1)*(a + b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15) << fixed;
    Solve(cin, cout);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 100 * 1000 + 20;
int a[N];
int main() {
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	if (n == 2) {
		cout << 1 << "\n" << 2 << "\n" << 3;
		return 0;
	}
	if (x == n) {
		for (int i = 1; i <= 2 * n - 1; i++)
			cout << i << endl;
		return 0;
	}
	if (x <= n) {
		a[x] = a[x + 1] = a[x + 2] = a[x - 1] = 1; 
		int tmp = 0;
		for (int i = 1; i <= 2 * n - 2; i++) {
			if (tmp >= n - 2) {
				break;
			}
			else {
				if (a[i] == 0) {
					cout << i << endl;
					tmp++, a[i] = 1;
				}
			}
		}
		cout << x + 2 << endl << x << endl << x - 1 << endl << x + 1 << endl;
		for (int i = 1; i <= 2 * n - 1; i++) {
			if (a[i] == 0)
				cout << i << endl;	
		}
	}
	else {
		a[x] = a[x - 1] = a[x - 2] = a[x + 1] = 1;
		int tmp = 0;
		for (int i = 1; i <= 2 * n - 1; i++) {
			if (tmp >= n - 2)
				break;
			else {
				if (a[i] == 0) {
					cout << i << endl;
					tmp++, a[i]++;
				}
			}
		}
		cout << x - 2 << endl << x << endl << x + 1 << endl << x - 1 << endl;
		for (int i = 1; i <= 2 * n - 1; i++) {
			if (a[i] == 0)
				cout << i << endl;	
		}
	}
	
	return 0;
}

Measured memory_bytes: 1920
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int V, E, A, B;

vector<vector<int> > G;

vector<int> T;

vector<bool> used;

void rec(int u)
{
	used[u] = true;

	for (int i = 0; i < G[u].size(); i++)
	{
		int v = G[u][i];

		if (!used[v]) { rec(v); }
	}

	T.push_back(u);
}

int main()
{
	scanf("%d", &V);
	scanf("%d", &E);

	G = vector<vector<int> >(V);

	for (int i = 0; i < E; i++)
	{
		scanf("%d", &A);
		scanf("%d", &B);

		G[A - 1].push_back(B - 1);
	}

	used = vector<bool>(V, false);

	for (int i = 0; i < V; i++)
	{
		if (!used[i])
		{
			rec(i);
		}
	}

	reverse(T.begin(), T.end());

	for (int i = 0; i < T.size(); i++)
	{
		printf("%d\n", T[i] + 1);
	}

	bool ok = false;

	for (int i = 1; i < V; i++)
	{
		bool c = false;

		for (int j = 0; j < G[T[i - 1]].size(); j++)
		{
			if (G[T[i - 1]][j] == T[i])
			{
				c = true;
			}
		}

		if (c == false)
		{
			ok = true;
		}
	}

	printf("%d\n", ok ? 1 : 0);

	return 0;
}

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


int main() {
  ll a,n,m,ans;
  cin >> a >> n >> m;
  for (ll i=1;i<=100;i++){
    ll p=i+a,u=1;
    rep(j,n){
      u*=p;
      if (u>m) break;
    }
    if (u<m){
      int y=0;
      while(true){
        y+=u%10;
        u/=10;
        if (u==0) break;
      }
      if (y==i) ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}


const int N = 1e5 + 100;

vector<int> G[N];
int dp[N];
int res = 0;
int first = -1;
bool DP(int u, int fa) {
    dp[u] = u;
    int all = 0, sel = 0;
    int book = 0;
    for(int v : G[u]) {
        if(v == fa) continue;
        all ++;
        int c = DP(v, u);
        sel += c;
        if(c == 0) book = v; 
    }
    if(book) dp[u] = dp[book];
    

    if(all > sel + 1) {
        res += all - (sel + 1);
        if(first == -1) first = dp[u];
        return true;
    } else {
        if(sel) return true;
        else return false;
    }
}

int main() {
    int n;
    cin >> n;
    for(int i = 1; i < n; i ++) {
        int u, v;
        scanf("%d %d", &u, &v);
        u ++, v ++;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    DP(1, 1);
    int ans = res;
    res = 0;
    if(first != -1) {
        DP(first, first);
        ans = min(ans, res);
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 13952
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    a = list(map(int, input().split()))
    set_a = set(a)
    if len(set_a) == len(a):
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 25176
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
char a[10][10];
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());
    map<int,int>s;
    for(int i=0;i<N;i++){
      s[a[i]]++;
    }
    int ans=0;int XX=0;
    for(int X=a[0];X<=a[N-1];X++){
     int sum=0;
     if(X>a[0]){sum+=s[X-1];}
     if(X<a[N-1]){sum+=s[X+1];}
     sum+=s[X];
     if(sum>=ans){XX=X;}
     ans=max(ans,sum);
    }
    cout<<ans<<endl;
return 0;}

Measured memory_bytes: 5376
def main():
  _n, k, c = map(int, input().split())
  s = input()

  l = []
  r = []

  for i, char in enumerate(s):
    if len(l) >= k:
      break

    if char == 'o' and (not len(l) or i - l[-1] > c):
      l.append(i)

  for i, char in reversed(tuple(enumerate(s))):
    if len(r) >= k:
      break

    if char == 'o' and (not len(r) or r[-1] - i > c):
      r.append(i)

  r.reverse()

  for i in range(k):
    if l[i] == r[i]:
      print(l[i] + 1)


main()


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

int main(){
	int m, d, ans, t, o;
	cin >> m >> d;
	ans=0;
	for(int i=1; i<=m; i++){
		for(int j=1; j<=d; j++){
			t = j/10;
			o = j%10;
			if(t>=2 && o>=2 && t*o==i){
				//cout << i << ' ' << j << endl;
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

[N] = [int(x) for x in sys.stdin.readline().split(" ")]

As = [int(x) - 1 for x in sys.stdin.readline().split(" ")]
Bs = [int(x) for x in sys.stdin.readline().split(" ")]
Cs = [int(x) for x in sys.stdin.readline().split(" ")]

prev = -999
result = 0
for i in range(N):
    a = As[i]
    result += Bs[a]
    if a == prev+1:
        result += Cs[prev]
    prev = a

print(result)


Measured memory_bytes: 3064
n = gets.chomp.to_i
a = []
n.times do
  a.push(gets.chomp.to_i)
end

max = a.max
count = a.count(max)
if count > 1
  n.times do
    p max
  end
else
  n.times do |i|
    if a[i] == max
      b = a.dup
      b.delete_at(i)
      p b.max
    else
      p max
    end
  end
end


Measured memory_bytes: 7292
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int w,h,n,x[200],y[200],a[200];
  cin >> w >> h >> n;
  for(int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> a[i];
  
  int s = 0, t = 0;
  int u = w, v = h;
  for(int i = 0; i < n; i++) {
    if(a[i] == 1) {
      if(u <= x[i]) {
        cout << "0" << endl;
        return 0;
      }
      if(s < x[i]) s = x[i];
    }
    if(a[i] == 2) {
      if(s >= x[i]) {
        cout << "0" << endl;
        return 0;
      }
      if(u > x[i]) u = x[i];
    }
    if(a[i] == 3) {
      if(v <= y[i]) {
        cout << "0" << endl;
        return 0;
      }
      if(t < y[i]) t = y[i];
    }
    if(a[i] == 4) {
      if(t >= y[i]) {
        cout << "0" << endl;
        return 0;
      }
      if(v > y[i]) v = y[i];    
    }
  }
  cout << (u-s)*(v-t) << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

int main(void)
{
	long long int a,b,c,k;
	cin >> a >> b >> c >> k ;
	long long int an;
	
	if((k % 2) == 0){
		an = 1;
	}else{
		an = -1;
	}
	
	long long int v = 1000000000000000000;
	if(a - b > v || a - b < -v){
		cout << "Unfair";
	}else{
		cout << (a - b) * an;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int read();
int n;
long long k;
int a[200005], r[200005];
int t[200005];
long long vis[200005];
int main() {
    n = read();
    scanf("%lld", &k);
    for (int i = 1; i <= n; ++i) a[i] = read();
    for (int i = 1; i <= 200000; ++i) t[i] = n + 1;
    for (int i = n; i >= 1; --i) r[i] = t[a[i]], t[a[i]] = i;
    long long cnt = 1;
    int p = 1;
    while (cnt <= k) {
        if (r[p] == n + 1) {
            if (cnt == k) {
                printf("%d ", a[p]), ++p;
                if (p == n + 1) break;
            } else {
                cnt++, p = t[a[p]] + 1;
                if (p == n + 1) {
                    if (cnt == k)
                        break;
                    else
                        p = 1, cnt++;
                }
            }
        } else {
            if (r[p] == n) {
                if (cnt == k)
                    break;
                else
                    p = 1, cnt++;
            } else
                p = r[p] + 1;
        }
        if (vis[p]) {
            long long t = cnt - vis[p];
            cnt += (k - cnt) / t * t;
        }
        vis[p] = cnt;
    }
    return 0;
}
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Measured memory_bytes: 5376
a, b, c, k = list(map(int,input().strip().split()))
ans = int(0)
if k >= a:
    ans += a
    k -= a
else:
    ans += k
    k = 0
if k >= b:
    k -= b
if k >= c:
    ans -= c
else:
    ans -= k
print(ans)

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

using namespace std;

typedef vector<set<uint64_t>> EdgeMap;

struct QueueItem
{
  uint64_t src, dst, hop;
  QueueItem(uint64_t src, uint64_t dst, uint64_t hop)
    : src(src), dst(dst), hop(hop) {}
  bool operator>(const QueueItem &rhs) const {
    return hop > rhs.hop;
  }
};

const uint64_t Undefined = static_cast<uint64_t>(-1);

int64_t solve(uint64_t N, uint64_t S, uint64_t T, EdgeMap &edges)
{
  vector<uint64_t> dist((N + 2) << 2, Undefined);
  
  priority_queue<QueueItem, vector<QueueItem>, greater<QueueItem>> q;
  dist[S] = 0;
  q.emplace(S, S, 0);
  
  while (!q.empty()) {
    QueueItem item = q.top(); q.pop();
    
    for (uint64_t next : edges[item.dst]) {
      if (item.hop + 1 < dist[next]) {
        dist[next] = item.hop + 1;
        q.emplace(item.src, next, item.hop + 1);
      }
    }
  }
  
  return (dist[T] == Undefined) ? -1 : static_cast<int64_t>(dist[T] / 3);
}

int main()
{
  ios::sync_with_stdio(false);
  
  uint64_t N, M;
  cin >> N >> M;
  
  EdgeMap edges((N + 2) << 2, set<uint64_t>());
  for (uint64_t m = 0; m < M; ++m) {
    uint64_t u, v;
    cin >> u >> v;
    
    edges[(u << 2) + 0].insert((v << 2) + 1);
    edges[(u << 2) + 1].insert((v << 2) + 2);
    edges[(u << 2) + 2].insert((v << 2) + 0);
  }
  
  uint64_t S, T;
  cin >> S >> T;
  
  cout << solve(N, (S << 2) + 0, (T << 2) + 0, edges) << endl;
  
  return 0;
}

Measured memory_bytes: 36224
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){
  
  int n;
  cin >> n;
  
  // n個の2bit表記
  int a[n][20] = {};
  REP(i,n){
    int num;
    cin >> num;
    int bit = 0;
    while(num != 0){
      a[i][bit] = (num % 2);
      num /= 2;
      bit++;
    }
  }
  
/*  REP(i,n){
    REP(j,20){
      cout << a[i][19-j];
    }
    cout << endl;
  }
*/

  ll ans = 0; int s[20] = {}; int count = 1; int index = 0;
 REP(i,n){
   int flag = 1;
   REP(j,20){
   s[j] += a[i][j];
   if(s[j] > 1) flag = 0;
   }
   if(flag == 1) {
     ans += count;
     count++;
   }
   else{
     int Flag = 0;
     while(Flag == 0){
     Flag = 1;
     REP(j,20){
       s[j] -= a[index][j];
       if(s[j] > 1) Flag = 0;
       }
       index++;
       count--;
     }
     ans += count;
     count++;
   }
 }

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

Measured memory_bytes: 15872
#include <iostream>
int main(){
    using namespace std;
    int a,x,y,z,ans;
    cin >> x >> y >> z;
    a = x/(y+z);
    if(x>=a*(y+z)+z){
        ans = (x-(x%(y+z)))/(y+z);
    }else{
        ans = x/(y+z) - 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans=0;
    ll x=max((ll)0, m-n*2);
    ans+=min(m/2, n);

    ans+=x/4;
    cout << ans << endl;
    return 0;
}

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

int main () {
  int N, X;
  cin >> N >> X;
  int cnt = 0;
  int minDonut = 10000;
  vector<int> gram(N);
  for (int i = 0; i < N; i++) {
    cin >> gram.at(i);
    X -= gram.at(i);
    cnt++;
    if (gram.at(i) <= minDonut) minDonut = gram.at(i);
  }
  cnt += X / minDonut;
  cout << cnt << endl;  
}

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

using namespace std;

int money(int x) {
  switch (x) {
    case 1:
      return 300000;
    case 2:
      return 200000;
    case 3:
      return 100000;
  }
  return 0;
}

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

  int X, Y;
  cin >> X >> Y;

  int m = 0;
  m += money(X);
  m += money(Y);

  if (X == 1 && Y == 1) m += 400000;

  cout << m << endl;
}


Measured memory_bytes: 256
n = int(input())

arr = list(map(int,input().split()))
flg = True

for i in range(n-1,0,-1):
    if arr[i] == n:
        n -= 1
    elif flg == True:
        j = arr[i]
        arr[i] = n
        arr[j-1] = j
        n -= 1
        flg = False
    else:
        print('NO')
        exit()
print('YES')


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

int n,ji;
long long ans,a[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
	{
		if(a[i]%2&&ji==0)
		{
			ans+=a[i]/2;
			ji=1;
		}
		else if(a[i]%2&&ji==1)
		{
			ans+=(a[i]+1)/2;
			ji=0;
		}
		else if(a[i]%2==0&&a[i])
		ans+=a[i]/2;
		else 
		ji=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, m;
    cin>>n>>m;
    int ans = (n * (n - 1)) / 2;
    ans += (m * (m - 1)) / 2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

ll const MAX = 510000;
ll const MOD = 1000000007;

// 二分累乗法 O(logn)
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector<ll> fact_inv, inv, Com;

/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(ll n) {
    fact_inv.resize(MAX + 5);
    inv.resize(MAX + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < MAX + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }

    Com.resize(MAX + 5);
    Com[0] = 1;

    for (int i = 1; i < MAX + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}

/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int k) { return Com[k]; }

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    init_nCk(n);

    ll ans = modpow(2, n, MOD) - 1;
    ll ac = nCk(a) % MOD;
    ll bc = nCk(b) % MOD;

    cout << ((ans - ac - bc) + 10 * MOD) % MOD << endl;

    return 0;
}

Measured memory_bytes: 12160
#include<iostream>
#include<cmath>
using namespace std;
typedef unsigned long long ull;
ull power(ull a, ull b, ull n) {
	ull tmp = 1;
	if (b > 0) {
		tmp = power(a, b / 2, n);
		if (b % 2 == 0) {
			tmp = (tmp*tmp) % n;
		}
		else {
			tmp = (((tmp*tmp) % n)*a) % n;
		}

	}
	return tmp;
}
int main() {
	ull m, N;
	cin >> m >> N;
	cout << power(m, N, 1000000007) << endl;
	return 0;
}

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

Measured memory_bytes: 596
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    println(problem115a(d))
}

fun problem115a(d: Int): String {
    var result = "Christmas"
    if (d <= 24) result += " Eve"
    if (d <= 23) result += " Eve"
    if (d <= 22) result += " Eve"
    return result
}

Measured memory_bytes: 29476
#ifdef ONLINE_JUDGE

#include "bits/stdc++.h"
using namespace std;

#define ui unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double

#define all(v) v.begin(), v.end()

#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld PI = 3.1415926535897932384626;
ll MOD = 1000000007;
const ld EPS = 1e-9;
const int N = 3e5 + 7;

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ui setBits(ui v) { ui c; for(c = 0 ; v; ++c) v &= (v - 1); return c; }
inline bool isPowerOfTwo(ui v) { return (v && !(v & (v - 1))); }
ll power(ll base, ull exp, ll mod = MOD) { 
	ll res = 1; base %= mod; 
	while(exp) { 
		if(exp & 1) res = (res * base)%mod; 
		exp >>= 1; base = (base * base)%mod; 
	} 
	return res; 
}
ll modInv(ll a, ll mod = MOD) { 
	if(mod == 1) return 0; 
	ll x = 1, y = 0, m = mod; 
	while(a > 1) { 
		ll q = a/m, t = m; m = a%m; a = t; t = y; y = x - q * y; x = t; 
	} 
	if(x < 0) x += mod; 
	return x; 
}
inline ui iabs(int x) { ui y = x; return (y > 0) ? y : -y; }
inline ll add(ll a, ll b, ll mod = MOD) { ll res = (a%mod + b%mod)%mod; return res; }
inline ll sub(ll a, ll b, ll mod = MOD) { ll res = (a%mod - b%mod + mod)%mod; return res; }
inline ll mult(ll a, ll b, ll mod = MOD) { ll res = (a%mod * b%mod)%mod; return res; }
inline ll div(ll a, ll b, ll mod = MOD) { ll res = (a%mod * modInv(b, mod))%mod; return res; }

#else

#include "custom.h"
using namespace std;

#endif

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

string solve(ll n) {
	string res;
	while(n > 0) {
		n -= 1;
		res += ('a' + n%26);
		n /= 26;	
	}
	reverse(all(res));
	return res;
}

int main() {
	speed;
	openf();
	ll n;
	cin >> n;
	cout << solve(n) << endl;
	return 0;
}  

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

#define mp make_pair

bool dfs(int u, int v, const vector<vector<int>>& tree, vector<bool>& visited, vector<pair<int, int>>& edges) {
    if (u == v) { return true; }
    if (visited[u]) {return false; }
    debug(u);
    debug(v);
    visited[u] = true;
    for (const auto& next : tree[u]) {
        if (visited[next]) { continue; }
        if (dfs(next, v, tree, visited, edges)) {
            debug(next);
            edges.push_back(make_pair(min(u, next), max(u, next)));
            return true;
        }
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> tree(N, vector<int>());
    map<pair<int, int>, int> idxs;
    int cnt = 0;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
        idxs[make_pair(min(a, b), max(a, b))] = cnt++;
    }
    assert(cnt == N - 1);
    int M;
    cin >> M;
    vector<set<pair<int, int>>> edges;
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        vector<bool> visited(N, false);
        vector<pair<int, int>> es;
        assert(dfs(u, v, tree, visited, es));
        edges.push_back(set<pair<int, int>>(es.begin(), es.end()));
    }
    // for (int i = 0; i < edges.size(); ++i) {
    //     for (const auto e : edges[i]) {
    //         cout << e.first << "->" << e.second << " ";
    //     }
    //     cout << endl;
    // }
    vector<uint64_t> edges_bits;
    for (const auto es : edges) {
        uint64_t eset = 0;
        for (const auto& e : es) {
            eset |= 1ll << idxs.at(e);
        }
        edges_bits.push_back(eset);
    }

    int64_t res = 0;
    for (int i = 1; i < (1 << M); ++i) {
        int num = 0;
        for (int j = i; j != 0; j >>= 1) num += j & 1;
        uint64_t es = 0;
        for (int c = 0; c < M; ++c) {
            if ((i >> c) & 1) {
                es |= edges_bits[c];
            }
        }
        if (num % 2 == 0) {
            res -= 1ll << (N - 1 - __builtin_popcountll(es));
        } else {
            res += 1ll << (N - 1 - __builtin_popcountll(es));
        }
    }
    debug(res);
    cout << (1ll << (N - 1)) - res << endl;
}

Measured memory_bytes: 256
/**
* Copyright(c)
* Author : tiketiskte
**/
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long
#define PLL pair<ll, ll>
#define SZ(X) (int)X.size()
#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 100 + 5;
int n;
ll a[maxn], ans;
int main(void)
{
    IOS
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    for(int i = 1;  i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(a[i] == a[j]) {
                continue;
            }
            for(int k = j + 1; k <= n; k++) {
                if(a[k] == a[j] || a[k] == a[i]) {
                    continue;
                }
                if(a[i] + a[j] > a[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}


Measured memory_bytes: 3656
N =int(input())
#横文字数、縦N行の行列を作成
s = [list(input()) for i in range(N)]

#文字列をアルファベット順に並び替える
for i in range(len(s)):
    s[i].sort()
s.sort()   
ans = 0 
cnt = 1
for i in range(1,N):
    for j in range(10):
        #1文とその次の文の文字を比較
        #異なっていた場合はbreak
        if(s[i][j] != s[i-1][j]):
            break
    else:
        cnt +=1
        continue
    ans += cnt*(cnt-1)//2
    cnt =1
ans +=cnt*(cnt-1)//2
print(ans)

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

int main(){
    ll a, b;
    cin >> a >> b;

    ll ans;
    if (a % 2 == 0)
    {
        if (b % 2 == 0)
        {
            if (((b - a) / 2) % 2 == 0)
            {
                ans = b;
            }
            else
            {
                ans = (1 ^ b);
            }
        }
        else
        {
            if (((b - a) / 2) % 2 == 0)
            {
                ans = 1;
            }
            else
            {
                ans = 0;
            }
        }
    }
    else
    {
        if (b % 2 == 1)
        {
            if (((b - a) / 2) % 2 == 0)
            {
                ans = a;
            }
            else
            {
                ans = (1 ^ a);
            }
        }
        else
        {
            if (((b - a) / 2) % 2 == 0)
            {
                ans = (a ^ b);
            }
            else
            {
                ans = (a ^ b ^ 1);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

constexpr int MOD = 1000 * 1000 * 1000 + 7;

class arcC {
private:
    long long fac(long long a) {
        long long res = 1;
        for (long long i = 1; i <= a; ++i) {
            res *= i;
            res %= MOD;
        }
        return res;
    }
public:
    void solve(istream& in, ostream& out) {
        int N, M;
        in >> N >> M;
        
        if (N == M) {
            out << 2 * fac(N) * fac(M) % MOD << "\n";
        } else if (abs(N - M) == 1) {
            out << fac(N) * fac(M) % MOD << "\n";
        } else {
            out << 0 << "\n";
        }
    }
};


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

	arcC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  string s;
  ll m;
  cin >> s;
  cin >> m;

  ll dp[105][2][m + 2];
  REP(i, 105) REP(j, 2) REP(k, m + 2) { dp[i][j][k] = 0; }
  dp[0][0][0] = 1;

  REP(i, s.length()) {
    REP(k, m + 1) {
      dp[i + 1][1][k + 1] += dp[i][1][k] * 9;
      dp[i + 1][1][k] += dp[i][1][k];

      if (s[i] != '0') {
        dp[i + 1][1][k + 1] += dp[i][0][k] * (s[i] - '0' - 1);
        dp[i + 1][1][k] += dp[i][0][k];
      }

      if (s[i] != '0') {
        dp[i + 1][0][k + 1] += dp[i][0][k];

      } else {
        dp[i + 1][0][k] += dp[i][0][k];
      }
    }
  }

  ll ans = 0;
  REP(j, 2) ans += dp[s.length()][j][m];

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

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_cnt = Counter(A)
B_cnt = Counter(B)
for i in range(1,N+1):
    if N < A_cnt[i]+B_cnt[i]:
        print("No")
        break
else:
    print("Yes")
    cnt = 0
    indexes = {}
    alreadychecked = set()
    for i in range(N):
        if A[i] not in alreadychecked:
            indexes[A[i]] = i
            alreadychecked.add(A[i])
    zure = 0
    alreadychecked = set()
    for i in range(N-1,-1,-1):
        if B[i] not in alreadychecked:
            if B[i] in indexes and indexes[B[i]] <= i:
                zure = max(zure,i-indexes[B[i]]+1)
                alreadychecked.add(B[i])

    print(*B[zure:],*B[:zure])


Measured memory_bytes: 172956
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	if(n == 1){
		cout << k/2 << endl;
		return 0;
	}
	if(k < 4){
		string s2 = "";
		rep(i,k){
			s2 += s;
		}
		ll ans = 0;
		for(int i = 1; i < s2.size(); ){
			if(s2[i-1] != s2[i]) ++i;
			else{
				++ans;
				i += 2;
			}
		}
		cout << ans << endl;
		return 0;
	}
	int src = 1;
	vector<ll> dp(2, -1);
	vector<int> memo;
	rep(loop,4){
		int lst = 0;
		bool f = false;
		if(dp[src] == -1){
			dp[src] = 0;
			f = true;
		}
		for(int i = src; i < n; ){
			if(s[(i+n-1)%n] != s[i]) ++i;
			else{
				if(f) dp[src]++;
				lst = i;
				i += 2;
			}
		}
		memo.push_back(src);
		src = (lst == n-1);
	}
	if(memo[2] == 0){
		cout << dp[1] + dp[0] * (k-1) << endl;
	}
	else{
		ll ans = 0, sum = 0;
		rep(i,4){
			sum += dp[memo[i]];
		}
		ans += sum * (k/4);
		rep(i,k%4){
			ans += dp[memo[i]];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll s = 0;
    rep(i,n){
        s = s^a[i];
    }
    rep(i,n){
        ll ans = s^a[i];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4800
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int count = 0;
		ArrayList<Unit> list = new ArrayList<>();
		char prev = '1';
		for (int i = 0; i < n; i++) {
			if (prev != arr[i]) {
				list.add(new Unit(prev, count, i));
				count = 1;
			} else {
				count++;
			}
			prev = arr[i];
			if (i == n - 1) {
				list.add(new Unit(prev, count, n));
				if (prev == '0') {
					list.add(new Unit(1, 0, n));
				}
			}
		}
		int max = 0;
		for (int i = 0; i < list.size(); i += 2) {
			Unit start = list.get(i);
			Unit end = list.get(Math.min(i + k * 2, list.size() - 1));
			int amount = end.total - (start.total - start.size);
          
			if (max < amount) {
				max = amount;
			}
		}
		System.out.println(max);
	}
	
	static class Unit {
		int type;
		int size;
		int total;
		
		public Unit(int type, int size, int total) {
			this.type = type;
			this.size = size;
			this.total = total;
		}
		
		public Unit(char c, int size, int total) {
			this(c - '0', size, total);
		}
      
      public String toString() {
        return type + ":" + size + ":" + total;
      }
	}
}


Measured memory_bytes: 29392