akhauriyash/Code-Regression huggingface dataset:
/*
   TASK: nocows
   LANG: C++14
 */

#include "bits/stdc++.h"

//region Template

typedef long long ll;
typedef long double ld;

using namespace std;
#define finish(x) return cout << x, 0;
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

const string USCAO_TAG = "nocows";
void usaco() { setIn(USCAO_TAG + ".in"); setOut(USCAO_TAG + ".out"); }


template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
//endregion

/* Notes:
 * I didn't wanna do this round :/
 */


int main() {
	#ifdef LOCAL
	setIn("in.txt");
	#endif

	int n;
	cin >> n;

	set<string> v;
	map<string, int> cnt;

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

		sort(s.begin(), s.end());
		v.insert(s);
		cnt[s]++;
	}

	ll ans = 0;
	for(auto x : v){
		ll y = cnt[x];

		ans += (y * (y - 1)) / 2;
	}

	cout << ans;
}


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

int main() {
  int d, t, s, now = 0;

  cin >> d >> t >> s;

  while (d > now) {
    now += s;
    t--;
  }

  if (t < 0) {
    cout << "No";
  } else {
    cout << "Yes";
  }

  return 0;
}

Measured memory_bytes: 3628
using System;
using System.Linq;
class Program {
	public static void Main() {
		int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine((x[0] / x[1]) + " " + (x[0] % x[1]) + " " + (1.0 * x[0] / x[1]).ToString("f12"));
	}
}

Measured memory_bytes: 9584
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=300005;

int a[maxn],flag,ans=1<<30;
char s[maxn];

int main(){
    int n;
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++)
        a[i]=a[i-1]+(s[i]=='E');
    flag=a[n];
    for(int i=1;i<=n;i++)
     ans=min(ans,(i-1-a[i-1])+(flag-a[i]));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1664
items = gets.chomp.split(/\s+/).map { |e| e.to_i }
n = items[0]
m = items[1]

answer = 0
penalty = 0

ac = Array.new(10**5, false)
penalties = Array.new(10**5, 0)

m.times { |i|
  items = gets.chomp.split(/\s+/)
  number = items[0].to_i
  next if ac[number]
  if items[1] == 'WA'
    penalties[number] += 1
  else
    answer += 1
    ac[number] = true
  end
}

penalty = penalties.map.with_index { |v, i| ac[i] ? v : 0 }.inject(:+)
puts "#{answer} #{penalty}"


Measured memory_bytes: 6780
/**
 * ベルマンフォード法
 *  - 概要
 *      - 開始ノードから任意のノードへの最短距離を計算
 *      - へんの重みに負の値がある場合へ対応可能
 *      - 閉路判定可能
 *  - 時間計算量
 *      - O( EV )
 *  - 探索対象
 *      - グラフ (vector)
*/

#include "bits/stdc++.h"
#define REP(i, a, b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;

const ll LLINF = 1e18;
const ll NODE_SIZE = 10101;

ll V;  //グラフのノードの数
ll E;  //グラフの辺の数
vector<pair<ll, ll>> edge[NODE_SIZE];   //<ノード, 距離>
ll d[NODE_SIZE];   //始点ノードからノードiへの最短距離
ll start;  //開始ノード番号

bool bellmanford(){
    REP(i,0,V) d[i]=LLINF;
    d[start]=0;

    REP(cnt,0,V){
        REP(from,0,V){
            for(auto e : edge[from]){
                if (d[from]!=LLINF && d[e.first] > d[from] + e.second) {  //移動した後のコストが小さいと、頂点のコストを更新
                    d[e.first] = d[from] + e.second;
                    if (cnt == V-1 && e.first==V-1) {   //頂点の数と同じ回数ループすると、負の閉路があるのでループをぬける
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

int main(){
    cin >> V >> E;
    ll A,B,cost;
    REP(i,0,E) {
        cin >> A >> B >> cost;
        A--;B--;
        edge[A].emplace_back(B, -cost);
    }

    start = 0;

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

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int[] d = new int[4];
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'N')
                d[0]++;
            if (s[i] == 'W')
                d[1]++;
            if (s[i] == 'S')
                d[2]++;
            if (s[i] == 'E')
                d[3]++;
        }
        if ((d[0] == 0 && d[2] != 0) || (d[0] != 0 && d[2] == 0) || (d[1] == 0 && d[3] != 0)
                || (d[1] != 0 && d[3] == 0)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

}


Measured memory_bytes: 23764
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


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

  int d_min = 1001001001;
  for(int d=1;d<=100;d++){
    int dis = 0;
    rep(i, n) dis += pow(x[i] - d, 2);
    d_min = min(dis, d_min);
  }
  cout << d_min << endl;
  return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Sep  7 21:07:22 2019
//
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	bs := make([]int, n)
	for i := range bs {
		fmt.Scan(&bs[i])
	}

	cs := make([]int, n-1)
	for i := range cs {
		fmt.Scan(&cs[i])
	}

	ans := 0
	for i, a := range as {
		ans += bs[a-1]
		if i > 0 && as[i] == as[i-1]+1 {
			ans += cs[as[i-1]-1]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX  = 100001;

int main(){
    int n, t;
    cin >> n;
    int v0[MAX], v1[MAX];
    int M0 = 0, M1 = 0, maxi0, maxi1;
    for(int i = 0; i < MAX; i++ ){
        v0[i] = 0;
        v1[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> t;
        if(i % 2 == 0) v0[t]++;
        else v1[t]++;
    }
    for(int i = 0; i < MAX; i++){
        if(M0 < v0[i] ){
            M0 = v0[i];
            maxi0 = i;
        }
    }
    for(int i = 0; i < MAX; i++){
        if(M1 < v1[i] && maxi0 != i){
            M1 = v1[i];
        }
    }
    int k0 = n - M0 - M1;
    M0 = M1 = 0;
    for(int i = 0; i < MAX; i++){
        if(M1 < v1[i] ){
            M1 = v1[i];
            maxi1 = i;
        }
    }
    for(int i = 0; i < MAX; i++){
        if(M0 < v0[i] && maxi1 != i){
            M0 = v0[i];
        }
    }
    int k1 = n - M0 - M1;
    cout << min(k1, k0) << endl;

    return 0;
}

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

int main()
{
  int p;
  double a,b,x,y;
  double ans;
  cin>>a>>b>>x>>y;
  ans=a*b/2;
  if((a/2==x)&&(b/2==y))
    p=1;
  else
    p=0;
  cout<<fixed<<setprecision(10);
  cout<<ans<<' '<<p<<endl;
}

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

typedef complex<double> P;
typedef pair<P,P> L;

double dot(P a,P b ){ return a.real()*a.imag() + b.real()*b.imag(); }
double cross(P a,P b){ return a.real()*b.imag() - a.imag()*b.real(); }

const double eps = 1e-10;
int ccw( P p, P a, P b ){
  a -= p;
  b -= p;
  if( cross( a, b ) > eps ) return 1; //ue
  if( cross( a, b ) < -eps ) return -1; //shita
  if( dot( a, b ) < -eps ) return 2;
  if( norm(b) - norm(a) > eps ) return -2;
  return 0;
}


int N,M,W,H,S;


int get(P p,const vector<L> &vec){
  int st = 0, ed = vec.size()-1; // [st,ed]
  int res=1e9;
  //  cout << p << endl;
  while( st<ed  ){
    int h = (st+ed)/2;
    //    cout << st << " " << ed <<" "<< h << " " << ccw( vec[h].first, vec[h].second, p ) << endl;

    if( ccw( vec[h].first, vec[h].second, p ) == 1 ){
      st = h+1;

    } else {
      ed = h;
    }
  }

  res=st;
  /*
  cout<<p<<endl;

  for(int i=0;i<vec.size();i++){
    cout<<vec[i].first<<' '<<vec[i].second<<endl;
  }
  cout<<res<<endl;
  cout<<endl;
  */
  return res;
}

int main(){
  while( cin >> N >> M>> W >> H >> S && (N|M|W|H|S) ){
    vector<L> vec; 

    vector<double> area;
    double pl = 0, pr = 0;
    for(int i=0;i<M;i++){
      int l,r; cin >> l >> r;
      area.push_back( ( l - pl + r - pr ) * W / 2.0 );
      vec.push_back( L(P(0,l),P(W,r)) );
      pl = l; pr = r;
    }
    
    vector<int> A;
    A.resize(M,0);
    for(int i=0;i<N;i++){
      double x,y; cin >> x >> y;
      //      cout << P(x,y) << " " << get(P(x,y),vec) << endl;
      A[get(P(x,y),vec)]++;
    }
 
    double L = W*H - S;
    int mt = 0;
    double sum = 0.0;
    int anum = 0;
    int res = N;
    for(int i=0;i<M;i++){
      sum += area[i];
      anum += A[i];
      while( sum > L+eps ){
        anum -= A[mt];
        sum -= area[mt++];
      }
      //cout << area[i] << " "<<A[i] << " " << sum << " "<< anum << endl;
      res = min( res, N-anum );
    }
    cout  << res << endl;
  }
}

Measured memory_bytes: 4776
// increment.cpp
#include<iostream>
using namespace std;

int main(){    
    // 変数の定義
    int a;
    int b;
    int ans;
        
    cin >> a;
    cin >> b;

    ans = a*b;
    if (ans % 2 != 0){
        cout << "Odd" <<endl;
    } else{
        cout << "Even" <<endl;
    }
        
}

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

using namespace std;

/*int bin_search_pred(vector <int> &l, int left, int right, int num, int ans) {
    if (left == right) {
        if (l[left] < num)
            return left;
        return ans;
    }
    int mid = left + (right - left) / 2;
    if (l[mid] < num) {
        ans = mid;
        return bin_search_pred(l, mid + 1, right, num, ans);
    }
    return bin_search_pred(l, left, mid - 1, num, ans);
}*/

int main() {
    int n;
    cin >> n;
    int sol = 0;
    vector <int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

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

    int sum;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum = l[i] + l[j];
            int left = j + 1, right = n - 1, mid, ans = j;
            while (left <= right) {
                mid = left + (right - left) / 2;
                if (l[mid] < sum) {
                    ans = mid;
                    left = mid + 1;
                }
                else
                    right = mid - 1;
            }
            sol += ans - j;
            /*int ans = j;
            ans = bin_search_pred(l, j + 1, n - 1, sum, ans);
            sol += ans - j;*/
        }
    }

    cout << sol << '\n';
    return 0;
}

/* while (left <= right) {
    mid = (left + right) / 2;
    if ()...)
        left = mid + 1;
    else
        right = mid - 1;
}
*/

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
using ld=long double;
int32_t main()
{
	int n,k;
	cin>>n>>k;
	ld ans=0;
	int cur;int tm;
	for(int i=1;i<=n;i++)
	{
		cur=i;tm=0;
		while(cur<k)
		{
			cur*=2;
			tm++;
		}
		ans+=(1/(ld)(1LL<<tm));
		
	}
	
	ans*=(1/(ld)n);
	
	cout<<fixed<<setprecision(12)<<ans;
	
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	string winner = "";
	if ((s.size() % 2 == 1) && (s.at(0) == s.at(s.size() - 1))) {
		winner = "Second";
	}
	else if ((s.size() % 2 == 0) && (s.at(0) != s.at(s.size() - 1))) {
		winner = "Second";
	}
	else {
		winner = "First";
	}

	cout << winner << endl;
}

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

#define fi first
#define se second

const int N = 550;
const int mod = 1e9 + 7;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        long long a[7];
        long long res = 0;
        for(int i = 0; i < 7; i++){
                cin >> a[i];
        }
        res += a[1];
        for(int i: {0, 3, 4}){
                long long g = min(2ll, a[i]);
                long long shit = (a[i] - g) / 2;
                res += shit * 2;
                a[i] -= shit * 2;
        }
        long long best = 0;
        for(int i = 0; i * 2 <= a[0]; i++){
                for(int j = 0; j * 2 <= a[3]; j++){
                        for(int h = 0; h * 2 <= a[4]; h++){
                                long long cur = (i + j + h) * 2;
                                if((a[0] - i * 2) && (a[3] - j * 2) && (a[4] - h * 2)){
                                        cur += 3;
                                }
                                best = max(best, cur);
                        }
                }
        }

        cout << res + best << "\n";
}


Measured memory_bytes: 256
N,K=map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x = str(Base_10_to_n(N, K))
print( len(x) )

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	for (int u = 0; u < 5; u++)
	{
		long n,a[9];

		cin >> n;
		if (n == 0)
		{
			break;
		}

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

		int o = 0;

		for (int i = 0; i < 9; i++)
		{
			o += a[i];
		}

		cout << n - o << endl;
	}
}



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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
   cout << "vowel" <<endl;
  }else{
   cout << "consonant" <<endl;
   }
  return 0;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;

import javax.lang.model.util.ElementScanner6;

 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int A=sc.nextInt();
      int B=sc.nextInt();
      int H=sc.nextInt();
      int M=sc.nextInt();
      int sec=3600*H+60*M;

      double hang=sec*2.0*Math.PI/(12*3600.0);
      double mang=sec*2.0*Math.PI/3600;
      double ang=Math.abs(hang-mang);
      double ans=Math.sqrt(A*A+B*B-2.0*A*B*Math.cos(ang));

      out.println(String.format("%.12f", ans));

      out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

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

typedef long long ll;

int main(){
	string s;
	int n,cnt;
	cin>>n>>s;
	for(int i=0;i<1000;i++){
		int c[3]={i/100,(i/10)%10,i%10};
		int f=0;
		for(int j=0;j<n;j++){
			if(s[j]==('0'+c[f]))f++;
			if(f==3)break;
		}
		if(f==3)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    try {
        val x = Integer.parseInt(scanner.next())
        val a = Integer.parseInt(scanner.next())
        if (x < a) println(0) else println(10)
    } catch (e: Exception) { 
        println(e)
    }
}

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

using namespace std;

int main() {
  string s;

  cin >> s;

  int len = s.length();

  for(int i = 0; i < len; i++) {


    vector< set<char> > v(len - i);

    for(int j = 0; j < len - i; j++) {
      for(int k = 0; k <= i; k++) {
        v[j].insert(s[j + k]);
      }
    }

    set<char> lapped = v[0];

    for(set<char> st: v) {
      for(char j: lapped) {
        if(st.find(j) == st.end()) {
          lapped.erase(j);
        }
      }
    }

    if(lapped.empty()) {
      continue;
    }else{
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 
 
int main(){
 
	int n;
	cin>>n;
 
	vector<int> a(n);
	set<int> b[100000];
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
 
	int res=0;
	for(int i=0;i<n;i++){
		res+=(i==a[a[i]]);
	}
	cout<<res/2<<endl;
 
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> st;

    rep(i,n){
        st[(a[i])]++;
    }


    vec p(1000000+10);

    int ans=0;

   for(auto x:st){
                if(p[x.fs]==0){
                    if(x.sc==1) ans++;
                for(int i=x.fs;i<=1000000;i+=x.fs){
                    p[i]++;
                }
            }
        
    }

    cout<<ans<<endl;
    
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 100*1000+10;
vector<int> vec[maxn];
int h[maxn], n, ans, m, u, v;
bool mark[maxn];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;
        u--;
        v--;
        vec[u].pb(v);
        vec[v].pb(u);
    }
    for (int i = 0; i < n; i++)
    {
        for (auto &w : vec[i])
        {
            if (h[w] >= h[i])
            {
                mark[i] = 1;
                break;
            }
        }
        if (!mark[i])
            ans++;
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200000 + 10;
const LL MOD = 1e9 + 7;
int b,w;
LL fac[N],inv[N];
LL mpow(LL a, LL x) {
	if(x==0)return 1;
	LL t=mpow(a,x>>1);
	if(x%2==0)return t*t%MOD;
	return t*t%MOD*a%MOD;
}
LL c(int n,int m){
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
LL sum[N];
int main() {
	fac[0]=1; inv[0]=1;
	for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%MOD,inv[i]=mpow(i,MOD-2);
	for(int i=1;i<N;i++)inv[i]=inv[i-1]*inv[i]%MOD;
	scanf("%d%d",&b,&w);

	for(int i=w;i<b+w;i++){
		LL p = c(i-1,w-1) * mpow(mpow(2,i),MOD-2) % MOD;
		sum[b+w] += p; sum[b+w] %= MOD;
		sum[i] -= p; sum[i] %= MOD;
		if(i-1>0) {
			sum[i-1] += p * (1 - 1LL * (w-1) * mpow(i-1, MOD-2) % MOD);
			sum[i-1] %= MOD;
		}	
	}
	for(int i=b;i<b+w;i++) {
		LL p = c(i-1,b-1) * mpow(mpow(2,i),MOD-2) % MOD;
		if (i - 1 > 0){
			sum[i-1] += p * (b-1) % MOD * mpow(i-1,MOD-2) % MOD;;
			//printf("add [%d, %d] %.5f\n", 1,i-1, p * (b-1) / (i-1));
		}
		//printf("add [%d, %d] %.5f\n", i,i,p);
		sum[i] += p;
		sum[i-1] -= p;
		sum[i] %= MOD, sum[i-1] %=MOD;
	}


	for(int i=b+w;i>=1;i--) sum[i]=(sum[i]+sum[i+1])%MOD;
	for(int i=1;i<=b+w;i++){
		sum[i] = (sum[i] % MOD + MOD) % MOD;
		printf("%lld\n", sum[i]);
	}
}

Measured memory_bytes: 6912
#include<cstdio>
using namespace std;

#define ll long long

int i,t,j;
int n,nt,a[200005],ans[200005],cnt;

bool check(int x1, int x2){
	while(x1>0){
		if (x1%10==x2) return 1;
		x1/=10;
	}
	return 0;
}

int main(){
	scanf("%d",&n);
	
	for (i=1; i<=n; ++i){
		scanf("%d",&a[i]);
	}
	
	for (i=1; i<=n; ++i){
//		if (check(a[i],cnt+1)){
//			++cnt;
//		}

		if (a[i]==cnt+1) ++cnt;
	}
	
	if (cnt==0) printf("-1\n");
	else printf("%d\n",n-cnt);
	
	return 0;
}
/*
1
12345
*/

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  map<string, int> mp;
  rep(i, n) {
    mp[s[i]]++;
  }
  int res = mp.size();
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 24936
n, a, b = map(int, input().split())

mod = 10**9+7

def comb(n, r):
    ans = 1
    for i in range(r):
        ans = ans * (n-i) * pow(i+1, mod-2, mod) % mod
    return ans

print((pow(2, n, mod)-1-comb(n,a)-comb(n,b)) % mod)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	string w;
	cin >> w;
	vector<int> a(26, 0);
	rep(i, w.size())
	{
		a[w[i] - 'a']++;
	}
	rep(i, 26)
	{
		if (a[i] % 2 == 1)
		{
			co("No");
			return 0;
		}
	}
	co("Yes");
	return 0;
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,c,k;
    ll t[100010];
    std::cin >> n>>c>>k;
    for (int i = 0; i < n; i++) {
        std::cin >> t[i];
    }
    sort(t,t+n);
    ll result = 0;

    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>,greater<pair<ll,ll>> > cap;
    
    for (int i = 0; i < n; i++) {
        while(!cap.empty()){
            pair<ll,ll> tmp = cap.top();
            if(tmp.second != 0 && tmp.first >= t[i] ){
                break;
            }else{
                cap.pop();
            }
        }
        
        if( cap.empty() ){
            result++;
            cap.push({t[i]+k,c-1});
        }else{
            pair<ll,ll> tmp = cap.top();
            cap.pop();
            tmp.second = tmp.second-1;
            cap.push(tmp);
        }
    }
    
    std::cout << result << std::endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();
        int ok = 0;
        for(int i = 0; i < s.length(); i++){
            if(ok == 0 && s.charAt(i) == 'C')ok = 1;
            if(ok == 1 && s.charAt(i) == 'F')ok = 2;

        }
        if(ok == 2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }


}


Measured memory_bytes: 9680
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

int func(){
	int n;
	cin >> n;
	return 3 * n * n;
}
int main(){
	cout << func() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#define llint long long
#define mod 1000000007

using namespace std;

llint sx, sy, tx, ty;
const int FACT_MAX = 3000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> sx >> sy >> tx >> ty;
	
	llint ans = 0;
	for(int i = sx; i <= tx; i++){
		ans += comb(i+ty+1, ty), ans %= mod;
		ans += mod - comb(i+(sy-1)+1, sy-1), ans %= mod;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 47740
package main

import(
	"fmt"
	"os"
)

func nextValue(i int) int {
	if i%2 == 0 {
		return i/2
	} else {
		return 3*i + 1
	}
}

func main() {
	var s int
	var pro []int
	fmt.Scan(&s)
	pro = append(pro, s)
	top := 0

	for true {
		nv := nextValue(pro[top])
		pro = append(pro, nv)
		for i:=0; i<=top; i++ {
			if nv == pro[i] {
				fmt.Println(len(pro))
				os.Exit(0)
			}
		}
		top++
	}
}

Measured memory_bytes: 512
from sys import stdin

def main():
    input = lambda: stdin.readline()[:-1]
    H, W, A, B = map(int, input().split())

    grid = [[1] * A + [0] * (W - A) for _ in range(B)]
    grid += [[0] * A + [1] * (W - A) for _ in range(H - B)]
    for n in grid:
        print(*n, sep='')

main()


Measured memory_bytes: 13300
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input().rstrip()
td = [list(input().rstrip().split()) for i in range(q)]
def judge(x,direction):
  if direction == "L":
    if x == n:
      return True
    if x == -1:
      return False
    jpos = lambda w: True if w>=0 else False
  else:
    if x == -1:
      return True
    if x == n:
      return False
    jpos = lambda w: True if w<n else False
  for i in range(q):
    if td[i][0] == s[x]:
      if td[i][1] == "R":
        x += 1
      else:
        x -= 1
    if jpos(x) == False:
      return False
    if not 0<=x<n:
      return True
  return True
l = -1
r = n
while l+1<r:
  m = (l+r)//2
  if judge(m,"L"):
    r = m
  else:
    l = m
ansl = r
l = -1
r = n
while l+1<r:
  m = (l+r)//2
  if judge(m,"R"):
    l = m
  else:
    r = m
ansr = l
print(max(0,ansr-ansl+1))


Measured memory_bytes: 82752
def inpl(): return list(map(int, input().split()))
S = input()
C = set("ACGT")

tmp = 0
ans = 0

for s in S:
    if s in C:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3060
n, k = map(int, input().split())
p_list = [i+1 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for p in a:
        if p in p_list:
            p_list.remove(p)

print(len(p_list))

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    while(true){
        int n, m;
        cin >> n >> m;
        if(!n && !m){
            return 0;
        }
        int items[n];
        for(int i = 0; i < n; i++){
            cin >> items[i];
        }
        int ans = -1;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                if(items[i] + items[j] <= m){
                    ans = max(ans, items[i] + items[j]);
                }
            }
        }
        if(ans == -1){
            cout << "NONE" << endl;
        }else{
            cout << ans << endl;
        }
    }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d, e, f;
    cin >> a>> b >> c >> d >> e >> f;

    vll vec;

    for(ll i=0;c*i<=f;i++){
        for(ll j=0;j*d<=f;j++){
            ll tmp = c*i + d*j;
            if(tmp<=f){
                vec.PB(tmp);
            }
        }
    }
    sort(ALL(vec));


    double na = 0;
    ll nw = 0;
    ll ns = 0;

    for(ll i=0;i<30;i++){
        for(ll j=0;j<30;j++){
            ll wat = 100*a*i + 100*b*j;
            ll maxi = wat/100*e;
            ll lb, ub;
            lb = -1;
            ub = SZ(vec);
            while(ub-lb>1){
                ll mid = (ub+lb) / 2;
                if(vec[mid]+wat<=f && vec[mid]<=maxi){
                    lb = mid;
                }
                else{
                    ub = mid;
                }
            }
            if(lb==-1){
                continue;
            }
            lb = vec[lb];
            double tmpa = (double)(lb)/(double)(wat+lb);
            if(tmpa>=na){
                na = tmpa; 
                nw = wat;
                ns = lb;
            }
        }
    }

    cout << nw+ns <<" "<<ns <<endl;


    
    return 0;
}



Measured memory_bytes: 5152
import java.util.*

fun main(args:Array<String>?): Unit {
    val (m, n) = readLine()!!.trim().split(' ').map(String::toInt)
    val lessCount = IntArray(m){0}
    val greaterNode = Array(m){ Stack<Int>() }
    val lowerLimit = Array(m){IntArray(n){0}}
    val upperLimit = Array(m){IntArray(n){100}}
    repeat(m){special ->
        val k = readLine()!!.trim().toInt()
        repeat(k){
            val (s, cond, t) = readLine()!!.trim().split(' ')
            if (cond == "<="){
                if (upperLimit[special][s.toInt() - 1] > t.toInt()) upperLimit[special][s.toInt() - 1] = t.toInt()
            }else {
                if (lowerLimit[special][s.toInt() - 1] < t.toInt()) lowerLimit[special][s.toInt() - 1] = t.toInt()
            }
        }
    }
    if ((0 until m).any{s -> (0 until n).any{lowerLimit[s][it] > upperLimit[s][it]}}) {
        println("No")
        return
    }
    for (i in 1 until m) for (j in 0 until i){
        for (k in 0 until n){
            if (lowerLimit[i][k] > upperLimit[j][k]) {
                if (greaterNode[j].isEmpty() || greaterNode[j].peek() != i){
                    greaterNode[j].add(i)
                    ++lessCount[i]
                }
            }
            if (lowerLimit[j][k] > upperLimit[i][k]) {
                if (greaterNode[i].isEmpty() || greaterNode[i].peek() != j){
                    greaterNode[i].add(j)
                    ++lessCount[j]
                }
            }
        }
    }
    val queue: Queue<Int> = LinkedList<Int>()
    for (i in 0 until m) if (lessCount[i] == 0) queue.add(i)
    while(queue.isNotEmpty()){
        val top = queue.poll()
        for (i in greaterNode[top]) {
            --lessCount[i]
            if (lessCount[i] == 0) queue.add(i)
        }
    }
    println(if (lessCount.all{it == 0}) "Yes" else "No")
}


Measured memory_bytes: 51828
#include<cstdio>
#include<cstring> 
#define N 200010
 
using namespace std;

int n;
int a[27], f[N], g[N], dp[N];
char s[N];

int main(){
	int t, i, j;
    scanf("%s", s + 1);
    n = strlen(s + 1);
    f[n+1] = n + 2; g[n+1] = 1;
    dp[n+1]=1;
    for(i = 1; i <= 26; ++i) a[i]=n+1;
    for(i = n; i >= 1; --i){
        a[s[i]-'a'+1] = i;
        t = 1;
        for(j = 2; j <= 26; ++j)
        if (dp[a[j]+1] < dp[a[t]+1]) t = j;
        dp[i] = dp[a[t]+1] + 1;
        f[i] = a[t]; g[i] = t;
    }
    for(i = 1; i <= n+1; i = f[i] + 1)
		putchar(g[i]+'a'-1);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

vector<vector<int>> to;
vector<int> dp;

int dfs(int v) {
    if (dp[v] != -1) return dp[v];
    dp[v] = 0;
    for (int nv : to[v]) {
        chmax(dp[v], dfs(nv) + 1);
    }
    return dp[v];
}

int main() {
    int N, M;
    cin >> N >> M;
    to.resize(N);
    dp.resize(N, -1);

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        to[x].push_back(y);
    }

    int ans = 0;
    rep(i, N) {
        chmax(ans, dfs(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void){

while(true){
  int n, input; cin >> n;
  if(n == 0)     break;
  
  int max_point = 0, min_point = 1000, sum = 0;
  for(int i = 0 ; i < n ; i++){
    cin >> input;
    min_point = min(min_point , input);
    max_point = max(max_point , input);
    sum += input;
  }
  sum -= min_point + max_point;

  cout << sum / (n - 2) << endl;

}

  return 0;
}


Measured memory_bytes: 3100
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s = list(input()[:-1])
    Q = int(input())
    reverse = False
    before = []
    after = []
    for _ in range(Q):
        q = list(map(str, input().split()))
        t = q[0]
        if t == '1':
            reverse = not (reverse)
        else:
            if reverse ^ (q[1] == '1'):
                before.append(q[2])
            else:
                after.append(q[2])
    if reverse:
        after.reverse()
        s.reverse()
        print(''.join(after + s + before))
    else:
        before.reverse()
        print(''.join(before + s + after))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 73736
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;

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

	if (N < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#coding:utf-8


mo =""
moji_m =""

while True:
    try:
        mo = input().rstrip().lower()
        moji_m += mo
    except:
        break


moji = list(moji_m.lower())
moji_l = list("abcdefghijklmnopqrstuvwxyz")
moji_c = [0 for i in range(26)]

for i in moji:
    #??¢??????????????????????????????
    if i.isalpha() == False:
        pass
    else:
        moji_c[moji_l.index(i)] += 1

for i in range(26):
    print(str(moji_l[i]) + " : " +str(moji_c[i]))

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

int main()
{
    int h, w, n;
    cin >> h >> w >> n;

    //各行列に何個爆弾があるかカウントする配列
    vector<int> hs(h), ws(w);
    //爆弾を補完するための配列
    //被らないようにsetを使う
    set<P> s;
    rep(i, n)
    {
        int r, c;
        cin >> r >> c;
        --r;
        --c;
        hs[r]++;
        ws[c]++;
        s.emplace(r, c);
    }

    //各行列での爆弾の最大個数を求める
    int mh = 0, mw = 0;
    rep(i, h) mh = max(mh, hs[i]);
    rep(i, w) mw = max(mw, ws[i]);

    //最大個数を含んでいる行列を求めて配列に突っ込む
    vector<int> is, js;
    rep(i, h) if (mh == hs[i]) is.push_back(i);
    rep(i, w) if (mw == ws[i]) js.push_back(i);
    int ans = mh + mw;
    for (auto &&i : is)
    {
        for (auto &&j : js)
        {
            if (s.count(P(i, j)))
                continue;
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans - 1 << endl;
}


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

using namespace std;
typedef long long ll;

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

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  a.push_back(a[n - 1]);

  vector<ll> cum = a;
  for (int i = 1; i < n; i++) {
    cum[i] += cum[i - 1];
  }

  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i + 1] > cum[i] * 2) break;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

//pii(値,インデックス)を返す
//datのサイズ変更
struct RMQi {
    int N;
    pii dat[256 * 1024];

    RMQi(int n, int *x) {
        N = 1;
        while (N < n)N *= 2;
        for (int i = N - 1; i < 2 * N - 1; ++i)dat[i] = pii(x[i + 1 - N], i + 1 - N);
        for (int i = N - 2; i >= 0; --i)dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
    }

    RMQi(int n) {
        N = 1;
        while (N < n)N *= 2;
        fill(dat, dat + 2 * N - 1, pii(INF, INF));
    }

    void update(int k, int a) {
        dat[k + N - 1] = pii(a, k);
        k += N - 1;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    pii query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    pii query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return pii(INF, INF);
        if (a <= l && r <= b) return dat[k];
        int m = (l + r) / 2;
        pii chl = query(a, b, 2 * k + 1, l, m);
        pii chr = query(a, b, 2 * k + 2, m, r);
        return min(chl, chr);
    }
};

int N;
int P[256 * 1024];
RMQi ki(128 * 1024);
RMQi gu(128 * 1024);

struct Sub {
    int l, r;
    bool k;
    int xi, yi;

    //[l,r)
    //k true xは奇数番目から false xは偶数番目から
    Sub(int l, int r, bool k) : l(l), r(r), k(k) {
        if (k) {
            xi = ki.query(l / 2, r / 2).SE * 2 + 1;
            yi = gu.query((xi + 1) / 2, (r + 1) / 2).SE * 2;
        } else {
            xi = gu.query(l / 2, r / 2).SE * 2;
            yi = ki.query((xi + 1) / 2, (r + 1) / 2).SE * 2 + 1;
        }
    }

    bool operator>(const Sub &o) const {
        return P[xi] > P[o.xi];
    }
};

priority_queue<Sub, vector<Sub>, greater<Sub>> que;

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> P[i];
        if (i % 2 == 0) {
            gu.update(i / 2, P[i]);
        } else {
            ki.update(i / 2, P[i]);
        }
    }
    que.push(Sub(0, N, false));
    vector<int> ans;
    while (!que.empty()) {
        Sub sub = que.top();
        que.pop();
        ans.push_back(P[sub.xi]);
        ans.push_back(P[sub.yi]);
        if (sub.xi != sub.l) {
            que.push(Sub(sub.l, sub.xi, sub.k));
        }
        if (sub.yi != sub.xi + 1) {
            que.push(Sub(sub.xi + 1, sub.yi, !sub.k));
        }
        if (sub.yi != sub.r - 1) {
            que.push(Sub(sub.yi + 1, sub.r, sub.k));
        }
    }
    rep(i, ans.size()) {
        cout << (i ? " " : "") << ans[i];
    }
}

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

///for ordered set///
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
///for ordered set///

using namespace std;

///for ordered set///
//using namespace __gnu_pbds;
//typedef tree< long long int , null_type, less_equal<long long int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
///for ordered set///

///Compiler Optimizer///
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
///Compiler Optimizer///

typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define PF                  first
#define PS                  second
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define CLR(arr,val)        memset(arr,val,sizeof arr);
#define vout(v)             for(int ind=0;ind<v.size();ind++){ cout<<v[ind]; if(ind<v.size()-1) cout<<' '; else cout<<endl;}
#define TCL(test,t)         for(test=1;test<=t;test++)
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define fastIO()            {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define MAXN                1000006
#define MAXP                1000006
#define MOD                 1000000007
#define PI                  acos(-1)

int main(){
    #ifdef ELDUIVEL
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll n,ans=0;
    cin>>n;
    ans=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans<<endl;
    #ifdef ELDUIVEL
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
N = int(input())
S = [list(input()) for i in range(N)]

for l in range(N):
  S[l].sort()
  S[l] = ''.join(S[l]) 

S.sort()

X = []
p = 1

for j in range(N-1):
  if S[j] == S[j+1]:
    p +=1
  else:
    X.append(p)
    p = 1
X.append(p)


def comb(n):
  if n == 2: return 1
  else:
    return int(n*(n-1)/2)

ans = 0

for k in range(len(X)):
  ans += comb(X[k])

print(ans)


Measured memory_bytes: 24208