akhauriyash/Code-Regression huggingface dataset:
import numpy as np
n= int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
    
b = np.array(a)
b = np.sort(b)[::-1]

ans = [0]*n

for i in range(n):
    if a[i] == b[0]:
        ans[i] = b[1]
    else:
        ans[i] = b[0]
        
for i in range(n):
  print(ans[i])

Measured memory_bytes: 30888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  ll N, M; cin >> N >> M;
  vector<ll> A(2*N, 0); rep(i, N) cin >> A.at(i);
  vector<pair<ll,ll>> CB(M); rep(i, M) cin >> CB.at(i).second >> CB.at(i).first;
  sort(all(CB));
  ll n = 0;
  ll m = M-1;
  while(n < N && m >= 0){
    rep(i, CB.at(m).second){
      A.at(N+n) = CB.at(m).first;
      n++;
      if(n>=N) break;
    }
    m--;
  }
  sort(all(A));
  reverse(all(A));
  ll ans = 0;
  rep(i, N) ans += A.at(i);
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n,i,c=0;
	cin >> n;
	vector<long long> v(n);
	map<long long, int> m;

	rep(i, n) {
		cin >> v[i];
		m[v[i]]++;
	}
	rep(i, n) {
		if (m[v[i]] % 2 == 1)c++;
		m[v[i]] = 0;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include<string>
using namespace std;
char a;
string s;
int main() {
	while(cin>>a){
	if(a=='B'){if(s.empty()==false)s.pop_back();}else{
	s.push_back(a);}
	}
	cout<<s<<endl;
		return 0;
}

Measured memory_bytes: 256
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};

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


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

    int n; cin >> n;
    vector<int> a(n + 1);
    for(int i : in(n)) cin >> a[i];
    a[n] = a[n - 1];
    int before = a[0], l = 0;
    vector<pair<int, int>> range;
    for(int i : in(1, n + 1)) {
        if(a[i] == before) {
            range.emplace_back(l, i);
            l = i;
        }
        before = a[i];
    }
    int ans = 0;
    int k = range.size();
    for(int i : in(k)) {
        int l = range[i].first, r = range[i].second;
        if(i > 0) l = range[i - 1].first;
        if(i < k - 1) r = range[i + 1].second;
        ans = max(ans, r - l);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int j = 0;
  for (int A=1; A<N; A++){
    for (int B=1; B<N; B++){
      if (A*B >= N){
        break;
      }
      for (int C=N-A*B; C<N; C++){        
        if (A*B+C > N){
          break;
        }
        if (A*B+C!=N){
          continue;
        }
        if (A*B+C==N){
          j += 1;
        }
      }
    }
  }
  cout << j << endl;  
}

     

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

int main() {
	long long N, h, n;
	cin >> N;

	for (long long i = 1; i <= 3500; i++) {
		for (long long j = 1; j <= 3500; j++) {
			long long a = (4 * i * j - N * i - N * j);
			long long b = (N * i * j);
			if (a > 0 && b % a == 0) {
				long long k = b / a;
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
typedef struct Dice
{
  int top;
  int bottom;
  int front;
  int back;
  int right;
  int left;
} dice;
void input(dice*);
void roll(dice*,char);
int getRight(dice*,int,int);
int main(void)
{
  int i;
  int q;
  int top,front;
  dice d;
  input(&d);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d%d",&top,&front);
      printf("%d\n",getRight(&d,top,front));
    }
  return 0;
}
void input(dice *d)
{
  scanf("%d",&d->top);
  scanf("%d",&d->front);
  scanf("%d",&d->right);
  scanf("%d",&d->left);
  scanf("%d",&d->back);
  scanf("%d",&d->bottom);
}
void roll(dice *d,char c)
{
  int temp;
  switch(c)
    {
    case 'E':
      temp=d->right;
      d->right=d->top;
      d->top=d->left;
      d->left=d->bottom;
      d->bottom=temp;
      break;
    case 'N':
      temp=d->back;
      d->back=d->top;
      d->top=d->front;
      d->front=d->bottom;
      d->bottom=temp;
      break;
    case 'S':
      temp=d->front;
      d->front=d->top;
      d->top=d->back;
      d->back=d->bottom;
      d->bottom=temp;
      break;
    case 'W':
      temp=d->left;
      d->left=d->top;
      d->top=d->right;
      d->right=d->bottom;
      d->bottom=temp;
      break;
    }
}
int getRight(dice *d,int top,int front)
{
  int i,j;
  for(i=0;i<6;i++)
    {
      for(j=0;j<4;j++)
        {
          roll(d,'E');
          if(d->top==top&&d->front==front) return d->right;
        }
      if(i%2==0)
        {
          roll(d,'N');
          roll(d,'N');
        }
      else if(i==1)
        {
          roll(d,'N');
        }
      else if(i==3)
        {
          roll(d,'E');
          roll(d,'N');
        }
    }
}


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

static const int MAX_N = 200100;
int a,i, sm,m,ans,s[MAX_N];
int main() {
	cin>>a;
	for(i=0;i<a;++i){
		cin>>s[i];
	}
	m=-2000000000;
	sm=s[0];
	for(i=1;i<a;++i){
		m=max(m,s[i]-sm);
                sm=min(s[i],sm);
			}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3852
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        String s = inp.next();
        if (s.equals("Sunny")) System.out.println("Cloudy");
        if (s.equals("Rainy")) System.out.println("Sunny");
        if (s.equals("Cloudy")) System.out.println("Rainy");
    }
}


Measured memory_bytes: 19540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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



signed main(){
    int n;cin>>n;
    
    rep(i,1,10)rep(j,1,10){
        if(n==i*j){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
num = int(input())
prices = []
 
for i in range(num):
  prices.append(int(input()))

max_i=0
max = prices[0]
for i in range(1,num):
  if prices[i]>max:
    max=prices[i]
    max_i = i
 
sum=0
for i in range(num):
  if i==max_i:
    sum += int(prices[i]/2)
  else:
    sum += prices[i]

print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  if(n >= 30)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;
ll sum=0;

int main(){


    
    cin >> N;
    rep(ni,N){
        int val;
        val = ni + 1;
        if(val % 3 ==0){
        }else if (val % 5==0){

        }else{
            sum+=val;
        }


    }
    cout << sum << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define Tayeb ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;
int main()
{
    Tayeb;
    int A,B;
    cin >> A >> B;
    if(A%2==B%2)
        cout << (A+B)/2 << "\n";
    else
        cout << "IMPOSSIBLE\n";

    return 0;

}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct UnionFind{
    int par[10000000],size[10000000];
    UnionFind(int N){
        for(int i=0;i<N;i++){
            par[i]=i;
            size[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        int y=find(par[x]);
        par[x]=y;
        return y;
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y)return;
        if(size[x]>=size[y])swap(x,y);
        par[x]=y,size[y]+=size[x];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};
signed main(){
  int N,M;
  cin>>N>>M;
  UnionFind U(N);
  while(M--){
    int a,b;
    cin>>a>>b;
    U.unite(a-1,b-1);
  }
  int ans=0;
  for(int i=0;i<N;i++)ans=max(ans,U.size[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 6712
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int>> visited(h, vector<int>(w, -1));
    deque<vector<int>> dq;
    string a;
    for(int i=0; i<h; i++){
        cin >> a;
        for(int j=0; j<w; j++){
            if(a[j] == '#'){
                dq.push_back(vector<int>{i, j, 0});
                visited[i][j] = 0;
            }
        }
    }
    int x, y, cnt;
    int ans = 0;
    vector<vector<int>> diff{{1,0}, {0,1}, {-1,0}, {0,-1}};
    while(!dq.empty()){
        x = dq.front()[0];
        y = dq.front()[1];
        cnt = dq.front()[2];
        for(auto& v:diff){
            if(x+v[0] >= 0 && x+v[0] < h && y+v[1] >= 0 && y+v[1]<w){
                if(visited[x+v[0]][y+v[1]] == -1){
                    dq.push_back(vector<int>{x+v[0], y+v[1], cnt+1});
                    visited[x+v[0]][y+v[1]] = cnt+1;
                    ans = max(ans, cnt+1);
                }
            }
        }
        dq.pop_front();
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 59572
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(j,i,n) for(int i=j;i<n;++i)
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
void solve()
{
	int n;
    cin>>n;
    int f=0;
    for(int i=1;i<=1000000;i++)
    {
        f=(f*10+7)%n;
        if(!f)
        {
            cout<<i;
            break;
        }
    }
    if(f)
    cout<<"-1";
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int sol = 0;
    for (int i = 0; i <= a; ++i)
        for (int j = 0; j <= b; ++j)
            for (int k = 0; k <= c; ++k)
                if (i * 500 + j * 100 + k * 50 == x)
                    sol++;
    cout << sol;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a[300010], q, l, r;
int ac, wa, tle, re;


int32_t main(){
INIT
cin>>n;

for(int i=1; i<=n; i++){
    string s; cin>>s;

    if(s=="TLE"){tle++;}
    if(s=="AC"){ac++;}
    if(s=="WA"){wa++;}
    if(s=="RE"){re++;}

}
cout<<"AC x "<<ac<<"\n";
cout<<"WA x "<<wa<<"\n";
cout<<"TLE x "<<tle<<"\n";
cout<<"RE x "<<re<<"\n";

return 0;
}


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

ll INF = 1e+9 + 7;
ll bamboo[9];
ll n, A, B, C;

int dfs(ll a, ll b, ll c, ll total){ // 竹をtotal本まで使ったとき、aからAを、bからBを…と作っていくときのmpの最小値
    if (total == n){
        if (a == 0 || b == 0 || c == 0) return INF;
        else return abs(A - a) + abs(B - b) + abs(C - c) - 30;
    }
    else { // 合成魔法を優先して使う
        ll mp0 = dfs(a, b, c, total + 1);
        ll mp1 = dfs(a + bamboo[total], b, c, total + 1) + 10;
        ll mp2 = dfs(a, b + bamboo[total], c, total + 1) + 10;
        ll mp3 = dfs(a, b, c + bamboo[total], total + 1) + 10;
        return min(min(mp0, mp1), min(mp2, mp3));
    }
}

int main(){
    cin >> n >> A >> B >> C;
    rep(i,n) cin >> bamboo[i];
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
#define LL long long
LL H,W,N;
LL ans[10];
LL dx[]={-2,-2,-2,-1,-1,-1,0,0,0};
LL dy[]={-2,-1,0,-2,-1,0,-2,-1,0};
map<LL,LL> m;
void slove(LL x,LL y)
{
    LL a,b;
    LL id;
    for(int i=0;i<9;i++){
        a=x+dx[i];
        b=y+dy[i];
        if(a<1 || b<1 || a>H-2 || b>W-2)   continue;
        id=(H-2)*(b-1)+a;//对每个小矩形进行编号
		//左上角的位置就只能在(h-2)*(w-2)的矩形区域内
		//每一行有w-2个元素 a-1
        m[id]++;
    }
}
int main(){
    LL x,y;
    cin>>H>>W>>N;
    for(int i=1;i<=N;i++)
	{
        cin>>x>>y;
        slove(x,y);
    }
    ans[0]=(H-2)*(W-2);//总数
    LL temp;
	map<LL,LL>::iterator it=m.begin();
    for(it=m.begin();it!=m.end();it++){
        temp=it->second;
        ans[temp]++;
        ans[0]--;
    }
    for(int i=0;i<=9;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 56448
using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Console = System.Console;

    namespace Atcoder
    {
        class Program
        {
            static void Main(string[] args)
            {
                var s = Read();
                var rep = s.Replace("hi", "");
                if (rep.Any())
                {
                    Console.WriteLine("No");
                }
                else
                {
                    Console.WriteLine("Yes");
                }
            }
            private static readonly Func<string> Read = () => Console.ReadLine();
            private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
            private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
            private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
            private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
            private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
            private static readonly Action<string> Cw = str => Console.WriteLine(str);
        }
    }

Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    vs64 a(n); rep (i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<s64>());

    s64 ans = 0;
    rep (i, n - 1)
    {
        ans += a[(i + 1)/ 2];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4780
function main(input) {
  const S = input.split('');
  const ary = ['A', 'C', 'G', 'T'];
  let words = [];
  let word = [];
  
  for (let i = 0; i < S.length; i++) {
    if (ary.includes(S[i])) {
      word.push(S[i]);
      
      //最後のループ時に残っている文字があるのなら回収
      if (i === S.length - 1) {
        if (word.length > 0) {
          s = word.join('');
          words.push(s);
          word = [];
        }
      }
    } else {
      if (word.length > 0) {
        s = word.join('');
        words.push(s);
        word = [];
      }
    }
  }
  
  words = words.sort((a, b) => { return b.length - a.length; });
  
  if (words.length > 0) {
    console.log(words[0].length);
  } else {
    console.log(0);
  }
  
}

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

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

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

void hoge() {
	VV<int> win(10, vi(10, -1));
	win[0][0] = 0;  // lose
	repr(i,1,9) win[i][0] = win[0][i] = i % 2;  // win iff i is odd
	repr(i,1,9) repr(k,1,9) {
		if (win[i - 1][k - 1] == 0 || win[i - 1][k] == 0 || win[i][k - 1] == 0) win[i][k] = 1;
		else win[i][k] = 0;
	}
	rep(i, 10) cout << win[i] << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	rep(i,N) {
		int a; cin >> a;
		if (a % 2 == 1) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

struct edge {
    lli from;
    lli to;
    lli cost;
};
vector<edge> edges;


lli d[1001]; // 各頂点の始点からの距離
bool is_negative[1001]; // 各頂点の始点からの距離
lli V;       // 頂点の数
lli E;       // 辺の数
lli r;       // 始点の番号

bool calc_shortest_path(lli start) {
    REPE(i, 0, V) {
        d[i] = LLONG_MAX;
    }
    d[start] = 0;

    lli loop_count = 0;
    bool updated;
    // O(V*E)
    while (true) {
        // V-1 回に収まっていなかったら、負の閉路がある
        // なぜなら、1 ループごとに少なくとも 1 つの最短経路が求まるから
        // V 個の頂点のうち、1 つは始点なので、V-1 個の最短経路が求まれば良い。
        updated = false;
        REP(i, 0, (lli)edges.size()) {
            edge e = edges[i];
            if (d[e.from] == LLONG_MAX)
                continue;
            if (d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
                updated = true;
                if (loop_count >= V)
                    is_negative[e.to] = true;
            }
        }

        if (loop_count == 2*V) {
            if (is_negative[V])
                return false;
            else
                return true;
        }

        loop_count++;
        if (!updated)
            break;
    }
    return true;
}
int main() {
    cin2(V, E);
    r = 1;
    REP(i, 0, E) {
        lli a, b, c;
        cin3(a, b, c);
        edge e = {a, b, -c};
        edges.push_back(e);
    }

    if (calc_shortest_path(1)) {
        cout << -d[V] << endl;
    }
    else {
        cout << "inf" << endl;
    }

}


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

#define ll long long

#define f first
#define s second

#define pb push_back

using namespace std;

const int N = 3e4 + 10;
const int md = 1e9 + 9;

string s;

int n;

int gox[N][2];
int goy[N][2];

int x, y;

int cnt[N];

int sz;

int add = 8000;

int main() {
 cin >> s;
 cin >> x >> y;
 for (auto smb : s) {
  if (smb == 'F') {
   ++cnt[sz];
   continue;
  }
  ++sz;
 }
 gox[add + cnt[0]][0] = 1;
 for (int i = 2; i <= sz; i += 2) {
  for (int j = 0; j <= add + add; j++) {
   gox[j][1] = (gox[j - cnt[i]][0] | gox[j + cnt[i]][0]);
  }
  for (int j = 0; j <= add + add; j++) {
   gox[j][0] = gox[j][1];
  }
 }
 goy[add][0] = 1;
 for (int i = 1; i <= sz; i += 2) {
  for (int j = 0; j <= add + add; j++) {
   goy[j][1] = (goy[j - cnt[i]][0] | goy[j + cnt[i]][0]);
  }
  for (int j = 0; j <= add + add; j++) {
   goy[j][0] = goy[j][1];
  }
 }
 if (gox[add + x][0] & goy[add + y][0])
  cout << "Yes";
 else
  cout << "No";
 return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <assert.h>

using namespace std;

typedef long long ll;

const int MAXN = 5005;
const int MOD = 1000000007;

int n,A,B,ans;
int pw[MAXN];
int f[MAXN][MAXN];
int g[MAXN][MAXN];
int lazg[MAXN][MAXN];
int lazf[MAXN][MAXN];
int sumg[MAXN];
int sumf[MAXN];
int spec[MAXN];

int main()
{
	scanf("%d%d%d",&n,&A,&B);
	if (A > B)
		swap(A,B);
	pw[0] = 1;
	for (int i = 1;i <= n;i++)
		pw[i] = pw[i - 1] * 2 % MOD;
	f[0][0] = g[0][0] = 1;
	int all = 0;
	for (int i = 0;i <= n;i++)
		for (int j = 0;j <= i;j++)
		{
			if (i || j)
			{
				(sumf[j] += lazf[i][j]) %= MOD;
				f[i][j] = sumf[j];
			}
			if (f[i][j])
			{
				(spec[i + 1] += f[i][j]) %= MOD;
				(spec[min(n + 1,i + A)] -= f[i][j]) %= MOD;
			//	for (int k = i + 1;k < i + A;k++)
			//		(g[k][k] += f[i][j]) %= MOD;
				(lazg[min(i + A,n + 1)][j] += f[i][j]) %= MOD;
			//	for (int k = i + A;k <= n;k++)
			//		(g[k][j] += f[i][j]) %= MOD;
			}
			if (i || j)
			{
				if (i == j)
				{
					(all += spec[i]) %= MOD;
					g[i][j] = all;
				}
				(sumg[j] += lazg[i][j]) %= MOD;
				(g[i][j] += sumg[j]) %= MOD;
			}
			if (g[i][j])
			{
				if (j + B <= n)
					(ans += (ll)g[i][j] * pw[n - max(j + B,i) - (i < n ? max(j + B,i) == i : 0)] % MOD) %= MOD;
				(lazf[min(i + 1,min(j + B - 1,n) + 1)][j] += g[i][j]) %= MOD;
				(lazf[min(j + B - 1,n) + 1][j] -= g[i][j]) %= MOD;
			//	for (int k = i + 1;k <= min(j + B - 1,n);k++)
			//		(f[k][j] += g[i][j]) %= MOD;
			}
		}
	printf("%d\n",(ans + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 271096
fun main(arr:Array<String>) {
    val (a,b,c,x,y) = readLine()!!.split(" ").map { it.toInt() }
    var ans = Int.MAX_VALUE
    for(i in (0..Math.max(x,y)*2 step 2)) {
        var cost = c*i
        cost += Math.max(x - (i/2), 0)*a
        cost += Math.max(y - (i/2), 0)*b
        ans = Math.min(ans, cost)
    }
    println(ans)
}


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


int n;
char sq[1000][1000];
int dp[1000][1000];


int solve(){
	int ans = 0;

	for(int i = 0;i < n;i++){
		dp[0][i] = (sq[0][i] == '*' ? 0 : 1);
		dp[i][0] = (sq[i][0] == '*' ? 0 : 1);
	}
	for(int y = 1;y < n;y++){
		for(int x = 1;x < n;x++){
			if(sq[y][x] == '*') dp[y][x] = 0;
			else {
				dp[y][x] = min({ dp[y-1][x], dp[y][x-1], dp[y-1][x-1] }) + 1;
				ans = max(ans, dp[y][x]);
			}
		}
	}

	return ans;
}


int main(){
	while(cin >> n, n != 0){
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				cin >> sq[i][j];
			}
		}

		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 7872
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define fi first
#define so second
#define ps push_back
#define pii pair<int,int>
#define mod 1000000007
#define TT int t;cin>>t;while(t--)

vector<string> v;

void make(int n,char c,string s)
{
    s=s+c;
    if(s.size()==n) {v.ps(s);}
    else
    {
        int vis[26]={0},i;
        for(i=0;i<s.size();i++) vis[s[i]-'a']=1;
        for(i=0;i<26;i++)
        {
            if(vis[i]==1) {make(n,char('a'+i),s);}
            else break;
        }
        if(i!=26) make(n,char('a'+i),s);
    }
}

signed main()
{
    int n;
    cin>>n;
    string s="";
    int vis[26]={0};
    make(n,'a',s);
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++) cout<<v[i]<<endl;
}


Measured memory_bytes: 9588
a,b,h,m = map(int,input().split())
import math
pi = math.pi
a1 = 2*pi*(h*60 + m)/(12*60)
a2 = 2*pi*m/60
print((a**2 + b**2 - 2*a*b*math.cos(a1-a2))**0.5)


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

signed main(){
  
  int M, K;
  cin>>M>>K;
  
  if( K == 0 ){
    
    int N = 1;
    
    for(int i=0;i<M;i++) N *= 2;
    
    for(int i=0;i<N*2;i++){
      if( i ) cout<<' ';
      cout<<i/2;
    }
    cout<<endl;
    
  }
  else{
    
    int N = 1;
    
    for(int i=0;i<M;i++) N *= 2;
    
    if( 1 <= K && K < N ){
      
      int XO = 0;
      
      for(int i=0;i<N;i++){
	XO ^= i;
      }

      XO ^= K;
      
      if( XO == K ){
	
	vector<int> ans;
	
	for(int i=0;i<N;i++){
	  if( i != K ) ans.push_back( i );
	}

	ans.push_back(K);
		
	for(int i=N-1;i>=0;i--){
	  if( i != K ) ans.push_back( i );
	}
	
	ans.push_back(K);
	
	for(int i=0;i<ans.size();i++){
	  if(i) cout<<' ';
	  cout<<ans[i];
	}
	
	cout<<endl;
	
      }
      else cout<<-1<<endl;
      
    }
    else cout<<-1<<endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#include<vector>
#include<set>
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t; cin>>t; while(t-->0)
#define pb push_back
#define pp pop_back
#define mk make_pair
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define debug(i,x) cout<<"Case #"<<i<<": "<<x<<"\n"
#define debug1(i,x,y) cout<<"Case #"<<i<<": "<<x<<" "<<y<<"\n"
#define mx 10000000
#define pi pair<int,int>
#define pl pair<long long,long long>
#define fi first
#define se second
using namespace std;

int main(){
    boost
    
  ll n,W;
  cin>>n>>W;
  ll w[n],v[n];
  fo(i,n) cin>>w[i]>>v[i];
  ll dp[n+1][W+1];
  
  fo(i,n+1){
    fo(j,W+1){
      if(i==0||j==0) dp[i][j]=0;
      else if(w[i-1]>j) dp[i][j]=dp[i-1][j];
      else dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
      
    }  
  }
  
  
  cout<< dp[n][W];
  
  
  
}

Measured memory_bytes: 82508
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
priority_queue<int>q;
struct node
{
	int a,b;
}x[100010];
bool cmp(node a,node b)
{
	return a.a<b.a;
}
int ans,t;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>x[i].a>>x[i].b;
	sort(x+1,x+n+1,cmp);
	int t=1,d=0;
	for(int i=m;i>=0;--i)
	{
		while(x[t].a<=m-i&&t<=n)
			q.push(x[t].b),++t;
		if(!q.empty())
			ans+=q.top(),q.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
map <string,bool>  mp;
int main()
{
	int n;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		mp[s]=true;
	}
	cout<<mp.size()<<endl;
	return 0;
}

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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	for (int i = 1; i <= 10; i++) {
		if (n < pow(2, i)) {
			cout << pow(2, i - 1);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, L = map(int, input().split())
tastes = [None] * N
abs_tastes = [None] * N

for i in range(1, N + 1):
  tastes[i - 1] = L + i - 1
  abs_tastes[i - 1] = abs(tastes[i - 1])

print(sum(tastes) - tastes[abs_tastes.index(min(abs_tastes))])

Measured memory_bytes: 38460
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
  
        FastIO
        int n,i;
        cin>>n;
        set<string> s;
        string t;

        for(i=0;i<n;i++)
        {
        	cin>>t;
        	s.insert(t);

        }
        cout<<s.size();
        return 0;
    }

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

int main() {
  int d,g,p[11],c[11];
  cin>>d>>g;
  for(int i=0;i<d;i++) cin>>p[i]>>c[i];
  int ans=1e9;
  for(int temp=0;temp<(1<<d);temp++){
    int rest_max=-1,sum=0,num=0;
    for(int i=0;i<d;i++){
      if(temp>>i&1){
        sum+=(i+1)*100*p[i]+c[i];
        num+=p[i];
      }
      else rest_max=i;
    }
    if(sum<g){
      int s1=100*(rest_max+1);
      int need=(g-sum+s1-1)/s1;
      if(need>=p[rest_max]) continue;
      num+=need;
    }
    ans=min(num,ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    vector<ll>a(A);
    rep(i,A){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
      vector<ll>b(B);
    rep(i,B){
        cin>>b[i];
    }
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
      vector<ll>c(C);
    rep(i,C){
        cin>>c[i];
    }
   /* sort(c.begin(),c.end());
    reverse(c.begin(),c.end());*/
    ll ans=0;
    vector<ll>s(X+Y+C);
    for(int i=0;i<X;i++){
        s[i]=a[i];
    }
    for(int i=X;i<X+Y;i++){
        s[i]=b[i-X];
    }
    for(int i=X+Y;i<X+Y+C;i++){
        s[i]=c[i-X-Y];
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    for(int i=0;i<X+Y;i++){
        ans+=s[i];
    }
    cout<<ans<<endl;

}
 



Measured memory_bytes: 4864
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
f=gets.split.map(&:to_i).sort.reverse
l=-1
r=a[-1]*f[0]
while l+1<r
  m=(l+r)/2
  c=0
  n.times do |i|
    if a[i]*f[i]>m
      c+=a[i]-m/f[i]
    end
  end
  if c>k
    l=m
  else
    r=m
  end
end
puts r

Measured memory_bytes: 44864
#include <stdio.h>
#include <string.h>

int main(void)

{
  char *a = "YAKI";
  
  char b[10];
  
  scanf("%s",b);
  
  char *count;
  
  int c;

  count = strstr( b, a );
  c = count - b;
  
  if( c == 0 )
  printf("Yes\n");
  else
  printf("No\n");

  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N; cin>>N;
  vector<string>A(N);
  rep(i,N)cin>>A[i];
  sort(A.begin(),A.end());
  int ans=1;
  vector<int>B(N+1);
  REP(i,N){
    if(A[i]==A[i-1])ans++;
    else{
      B[i]=ans;
      ans=1;
    }
  }
  if(ans!=1)B[N-1]=ans;
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  ans=1;
  REP(i,N){
    if(A[i]==A[i-1])ans++;
    else{
      if(ans==B[0])cout<<A[i-1]<<endl;
      ans=1;
    }
  }
  if(ans==B[0])cout<<A[N-1]<<endl;
}


Measured memory_bytes: 11104
#include <iostream>

using namespace std;

bool getdigit(int num){
    bool result = false;

    if(num <= 9){
        result = true;
    }
    if(num >= 100 && num <= 999){
        result = true;
    }
    if(num >= 10000 && num <= 99999){
        result = true;
    }
    if(num >= 1000000 && num <= 9999999){
        result = true;
    }

    return result;
}


int main(){
    // 入力
    int n;
    cin >> n;

    int count; // 桁数が奇数の数

    // 判定
    for(int i = 1; i <= n; i++){
        if(getdigit(i)){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

long long num_patty(int n){
    long long t=pow(2, n+1);
    return t-1;
}

long long num_total(int n){
    long long t=pow(2, n+2);
    return t-3;
}

long long f(int n, long long x){
    if(x==0) return 0;
    if(x==num_total(n)) return num_patty(n);
    long long t=num_total(n-1);
    if(x<t+2) return f(n-1, x-1);
    if(x>t+2) return f(n-1, x-t-2)+num_patty(n-1)+1;
    else return num_patty(n-1)+1;
}

int main(){
    int n; cin >> n;
    long long x; cin >> x;
    cout << f(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int digits(int n)
{
    int r = 0;
    while(n) n = n/10, r++;
    return r;
}

int main(void)
{
    int n, m;
    while(scanf("%d %d", &n, &m) != EOF)printf("%d\n", digits(n+m));
    return 0;
}

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

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n; cin >> n;
  Vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  int ans = 0;
  rep(i,n) {
    int A = a[i];
    for (int j = i+1; j < n; ++j) {
      int B = a[j];
      for (int k = j+1; k < n; ++k) {
        int C = a[k];
        if (A != B && B != C) if (abs(A-B) < C && C < A + B) ++ans;
      }
    }
  }
  pl(ans)
  return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int N=1e5+5;
  
int n,m,f[N],ans,a[N],mid,b[N],c[N],ky;
ll num;
  
inline void update(int x,int y){ for(;x<=ky;x+=x&-x) f[x]+=y;}
inline int query(int x){ int an=0; for(;x;x-=x&-x) an+=f[x]; return an;}
  
inline ll calc(){
    ll an=0;
    b[0]=0,memset(f,0,sizeof(f));
    for(int i=1;i<=n;i++) b[i]=b[i-1]+(a[i]<=mid?1:-1),c[i]=b[i];
    c[ky=n+1]=0,sort(c+1,c+ky+1),ky=unique(c+1,c+ky+1)-c-1;
    for(int i=0;i<=n;i++) b[i]=lower_bound(c+1,c+ky+1,b[i])-c;
     
    update(b[0],1);
    for(int i=1;i<=n;i++) an+=(ll)query(b[i]-1),update(b[i],1);
     
    return an;
}
  
inline void solve(){
    int L=1,R=1e9;
    while(L<=R){
        mid=L+R>>1;
        if(calc()>=num) ans=mid,R=mid-1;
        else L=mid+1;
    }
}
  
int main(){
    scanf("%d",&n),num=n*(ll)(n+1)>>1,num=(num>>1)+1;
    for(int i=1;i<=n;i++) scanf("%d",a+i);
     
    solve();
     
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

u32 N, M;
u32* light;

#define bit1(x) ((((x) >> 9) & 0x1) + (((x) >> 8) & 0x1) + (((x) >> 7) & 0x1) + (((x) >> 6) & 0x1) + (((x) >> 5) & 0x1) + (((x) >> 4) & 0x1) + (((x) >> 3) & 0x1) + (((x) >> 2) & 0x1) + (((x) >> 1) & 0x1) + ((x) & 0x1))

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

    scanf("%d%d", &N, &M);
    light = new u32[N]();

    int k;
    u32 s;
    u32* p = new u32[M];
    rep(i, M)
    {
        scanf("%d", &k);
        rep(j, k)
        {
            scanf("%d", &s);
            light[i] |= ((u32)1 << (s - 1));
        }
    }

    u32 bitsum[1 << 10];
    rep(i, 1 << 10)
    {
        bitsum[i] = bit1(i);
    }

    rep(i, M)
    {
        scanf("%d", p + i);
    }

    u32 num = ((u32)1 << N);
    u32 ret = 0;
    for (u32 i = 0; i < num; ++i)
    {
        bool flag = true;
        rep(j, M)
        {
            flag &= ((bitsum[i & light[j]] & 0x1) == p[j]);
        }
        if (flag) ++ret;
    }

    printf("%d\n", ret);

    return 0;
}



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

int main()
{
  int a;
  int x;
  
  cin >> a;
  x = a % 10;
  a = a / 10;
  x = x + a % 10;
  a = a / 10;
  x = x + a % 10;
  cout << x << endl;
}

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

int main(void){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > d(n, vector<int>(n,1));
    for(int i=0;i<n;i++){
        d[i][i] = 0;
    }
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        d[a][b] = 0;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    for(int i=0;i<n;i++){
        bool f = false;
        for(int j=0;j<n;j++){
            if(d[i][j] || d[j][i]) continue;
            if(f) cout << " ";
            f = true;
            cout << j+1;
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
	string s,t;
	cin>>s>>t;
	
	int cnt=0;
	for(int i=0;i<s.size();i++)
		if(s[i]!=t[i])
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3816
#-*- coding:utf-8 -*-
"""
1以上3以下の整数A,Bが与えられます。
A×B×Cが奇数となるような1以上3以下の整数Cが存在するか判定してください。
"""
def judge(a, b):
    if(a%2 == 0 or b%2 == 0):
        print("No")
    else:
        print("Yes")


def main(input):
    str = input.split()
    A = int(str[0])
    B = int(str[1])
    judge(A, B)

if __name__ == "__main__":
    main(input())

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

int main() {
	int x,n,k;
	cin >> x >> n;
	k=x;
	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin >> p.at(i);
	}
	for(int i=0;i<102;i++)
	{
		int t = 0;
		for(int j=0;j<n;j++)
		{
			if(x-i==p.at(j))
			{
				t = 1;
			}
		}
		if(t == 0)
		{
			k = x - i;
			break;
		}
		t=0;
		for(int j=0;j<n;j++)
		{
			if(x+i==p.at(j))
			{
				t = 1;
			}
		}
		if(t == 0)
		{
			k = x + i;
			break;
		}
	}
	cout << k << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library

//
int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; string S;
    cin >> N >> S;

    string mae = S.substr(0, N);
    string ushi = S.substr(N, N);

    map<pair<string,string>, ll > mp;
    for (int bit = 0; bit < (1<<N); ++bit) {
        string a, b;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)){
                a += ushi[i];
            }
            else{
                b += ushi[i];
            }
        }
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
        ++mp[{a, b}];
    }

    ll res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        string a, b;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)){
                a += mae[i];
            }
            else{
                b += mae[i];
            }
        }
        res += mp[{b, a}];
    }

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



Measured memory_bytes: 87040
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    if(a[i] == x):
      a[i] = 0
    elif(b[i] == x):
      b[i] = 0
    elif(c[i] == x):
      c[i] = 0

if(a[0] == 0 and a[1] == 0 and a[2] == 0):
  print('Yes')
elif(b[0] == 0 and b[1] == 0 and b[2] == 0):
  print('Yes')
elif(c[0] == 0 and c[1] == 0 and c[2] == 0):
  print('Yes')
elif(a[0] == 0 and b[0] == 0 and c[0] == 0):
  print('Yes')
elif(a[1] == 0 and b[1] == 0 and c[1] == 0):
  print('Yes')
elif(a[2] == 0 and b[2] == 0 and c[2] == 0):
  print('Yes')
elif(a[0] == 0 and b[1] == 0 and c[2] == 0):
  print('Yes')
elif(a[2] == 0 and b[1] == 0 and c[0] == 0):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064