akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
    class Main
    {
      public static void main(String args[])throws IOException
      {
        String s,s1="",s2="",s3="",s4="",s5=""; 
        int i,k=0,j=0,l,l1,l2;
        BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
        s=input.readLine();
        l=s.length();
        l1=(l-1)/2;
        l2=(l+3)/2;
        s2=s.substring(0,l1);
        s3=s.substring(l2-1,l);
        for(i=0;i<l;i++)
        {
            s1=s.charAt(i)+s1;
        }
        for(i=0;i<l2;i++)
        {
          if(j<l1)
          {
            s4=s2.charAt(j)+s4;
          }
          if(k<l2-2)
          {
            s5=s3.charAt(k)+s5;
          }
        //  System.out.println(s4+" "+s5);
          j++;
          k++;
        }
        if(s.equals(s1) && s2.equals(s4) && s3.equals(s5))
          System.out.println("Yes");
        else
          System.out.println("No");
      }
    }

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {

	ll n; cin >> n;
	ll add = 0;
	ll tmp = 10000000000;
	ll minIndex;
	for (ll i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		if (chmin(tmp, b)) {
			minIndex = a;
		}
	}
	cout << minIndex + tmp << endl;
    return 0;
}

Measured memory_bytes: 3596
n = input()
op_cnt = len(n) - 1

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
            
    formula = ""
    
    for p_n, p_op in zip(n, op + [""]):
        formula += (p_n + p_op)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3060
N, M = map(int, input().split())

l = -float("inf")
r = float("inf")

for i in range(M):
    l_i, r_i = map(int, input().split())
    if l_i > l:
        l = l_i
    if r_i < r:
        r = r_i

if (l <= r):
    print(r-l+1)
else:
    print(0)

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] == a[1] && a[1] != a[2]){
        cout << "Yes";
    }else if(a[0] != a[1] && a[1] == a[2]){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
p = (A1 - B1) * T1
q = (A2 - B2) * T2
if p < 0:
    p *= -1
    q *= -1

if p + q > 0:
    print(0)
elif p + q == 0:
    print('infinity')
else:
    s = -p // (p + q)
    t = -p % (p + q)
    if t != 0:
        print(s*2+1)
    else:
        print(s*2)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

UL bin(vector<UL> &L, UL v) {
	UL l = 0, r = L.size();
	while (l < r - 1) {
		UL m = (l + r) / 2;
		if (L[m] < v) l = m;
		else r = m;
	}
	return l;
}

struct Problem {

	void Solve() {
		const double pi = 3.1415926535897932;
		UL x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		UL N; cin >> N;
		vector<pair<UL, UL>> P(N);
		rep(i, N) cin >> P[i].first >> P[i].second;
		if (x1 == x2) {
			if (y1 > y2) swap(y1, y2);
			double ans = (y2 - y1) * 100.0;
			rep(i, N) { if (P[i].first == x1) if (y1 < P[i].second && P[i].second < y2) ans += (pi * 10.0 - 20.0); }
			cout << ans << endl; return;
		}
		else if (y1 == y2) {
			if (x1 > x2) swap(x1, x2);
			double ans = (x2 - x1) * 100.0;
			rep(i, N) { if (P[i].second == y1) if (x1 < P[i].first && P[i].first < x2) ans += (pi * 10.0 - 20.0); }
			cout << ans << endl; return;
		}
		if (x1 > x2) { swap(x1, x2); swap(y1, y2); }
		if (y1 > y2) {
			for (UL i = 0; i < N; i++) {
				P[i].second = 100000000 - P[i].second;
			}
			y1 = 100000000 - y1;
			y2 = 100000000 - y2;
		}
		for (UL i = 0; i < N; i++) {
			if (y1 <= P[i].second && P[i].second <= y2)
				if (x1 <= P[i].first && P[i].first <= x2) continue;
			swap(P.back(), P[i]);
			P.pop_back(); N--; i--;
		}
		sort(P.begin(), P.end());
		bool special = true;
		for (UL i = 1; i < N; i++)
			if (!(P[i - 1].second < P[i].second)) special = false;
		if (P.size() != (x2 - x1 + 1) && P.size() != (y2 - y1 + 1)) special = false;
		if (special) {
			double ans = 0;
			ans += ((x2 - x1) + (y2 - y1)) * 100.0;
			ans += (pi * 5.0 - 20.0) * (P.size() - 1);
			ans += (pi * 10.0 - 20.0);
			cout << ans << endl; return;
		}
		vector<UL> LIS; LIS.assign(N + 1, 1000000000);
		LIS[0] = 0;
		rep(i, N) {
			UL p = bin(LIS, P[i].second);
			LIS[p + 1] = P[i].second;
		}
		UL ans1 = bin(LIS, 999999999);
		double ans = 0;
		ans += ((x2 - x1) + (y2 - y1)) * 100.0;
		ans += (pi * 5.0 - 20.0) * ans1;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  int num[3] = {}; // 奇数、２ｎ、４ｎ
  
  REP(i,n){
    int a;
    cin >> a;
    if(a % 2 == 1) num[0]++;
    else if(a % 4 == 0) num[2]++;
    else num[1]++;
  }
  
  if(n-num[2]*2 <= num[1] || n - num[2]*2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  


 return 0;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
a=[0]*(10**5)
b=[0]*(10**5)
s,t=0,0
o,e,oi,ei=0,0,0,0
for i in range(1,n+1):
    if i%2==1:
        a[v[i-1]-1]+=1
        s+=1
    else:
        b[v[i-1]-1]+=1
        t+=1
o=max(a)
oi=[]
e=max(b)
ei=[]
for i in range(10**5):
    if a[i]==o:
        oi.append(i)
    if b[i]==e:
        ei.append(i)
if len(oi)==1 and len(ei)==1 and oi[0]==ei[0]:
    a.sort(reverse=True)
    b.sort(reverse=True)
    print(min(t-e+s-a[1],t-b[1]+s-o))
else:
    print(s+t-e-o)

Measured memory_bytes: 90500
/*
 KMP
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;


#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e15;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=3005;

int dp[N][N],pre[N][N];

void solve()
{
    
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    dp[1][1]=1;
    pre[1][0]=0;
    pre[1][1]=1;
    for(int i=2;i<=n;i++)
        pre[1][i]=1;
    for(int i=2;i<=n;i++)
    {
        
        if(s[i-2]=='<')
        {
            for(int j=2;j<=i;j++)
            {
                dp[i][j]=(pre[i-1][j-1]-pre[i-1][0]+hell)%hell;
            }
        }
        else
        {
            for(int j=1;j<i;j++)
            {
                dp[i][j]=(pre[i-1][i-1]-pre[i-1][j-1]+hell)%hell;
            }
        }
        for(int j=1;j<=n;j++)
            pre[i][j]=dp[i][j]+pre[i][j-1];
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=(ans+dp[n][i])%hell;
    cout<<ans<<endl;
    
}


int32_t main()
{
    
    IOS;
   
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



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

N = int(input())
A = list(map(int, input().split()))
low = [0]*(N+1)
high = [0]*(N+1)
low[N] = A[N]
high[N] = A[N]

for i in range(N-1, -1, -1):
    low[i] = (low[i+1]+1)//2+A[i]
    high[i] = high[i+1]+A[i]

if not low[0]<=1<=high[0]:
    print(-1)
    exit()

ans = 1
now = 1

for i in range(N):
    now = min(2*(now-A[i]), high[i+1])
    ans += now

print(ans)

Measured memory_bytes: 82892
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

// int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << 0 << endl;
	else
		cout << 10 << endl;

	return 0;
}

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

int main() {
  
  int N, M; cin >> N >> M;
  
  if (M <= N) { cout << 0 << endl; return 0; }
  
  vector<int> vec(M); priority_queue<int> memo;
  
  for (int i = 0; i < M; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  int ans = vec.back() - vec.front();
  
  for (int i = 0; i < M - 1; i++) {
    
    int tmp = vec[i + 1] - vec[i];
    
    memo.push(tmp);
    
  }
  
  for (int i = 0; i < N - 1; i++) {
    
    ans -= memo.top();
    
    memo.pop();
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long n;

	int max = 0;

	std::cin >> n;

	for (long long i = 0; i * i <= n; i++)
	{
		max = i;
	}

	std::cout << max * max << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N; cin >> N;
	vector<int64> A(N + 1), S(N + 2);
	for (int i = 0; i <= N; ++i) {
		cin >> A[i];
		S[i + 1] = A[i] + S[i];
	}
	//頂点数は1からスタート
	int64 ans = 0, now = 1;
	for (int i = 0; i <= N; ++i) {
		//現在の頂点数は加算
		ans += now;
		//葉ではない頂点数が葉である頂点数より小さくなると、葉が存在できなくなるので-1を出力する
		if (now < A[i]) {
			cout << -1 << endl;
			return;
		}
		//現在の頂点数から葉である頂点数を引く
		now -= A[i];
		//次の階層に降りた際の葉である頂点数の残数を求める
		int64 s = S[N + 1] - S[i + 1];
		//現在の頂点数 * 2と葉である頂点数の残数のminを次の階層の頂点数とする
		//葉である頂点数の方が小さくなる場合は葉の残数分を頂点を置き、直接連結
		//そうでない場合は葉ではない頂点 * 2個の頂点を置いて、処理を継続
		now = min(now * 2, s);
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4856
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
string s;
ll k;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s;
    cin>>k;
    ll cnt=0;
    ll ans=0;
    char PREV=s[0];
    bool udh=false;
    int x;
    for(auto isi:s){
        if(isi==PREV){
            cnt++;
        }
        else{
            if(udh==false){
                x=cnt;
                udh=1;
            }
            ans+=cnt/2;
            cnt=1;
        }
        PREV=isi;
    }  
    if(udh==false){
        cout<<cnt*k/2<<endl;
        return 0;
    }
    bool u=false;
    ans+=cnt/2;
    if(s.back()==s[0] && x&1 && cnt&1){
        u=true;
    }
    ans=ans*k;
    if(u) ans+=(k-1);
    cout<<ans<<endl;
}
/*
aaaaaaaabbbbbbaaaaa
100
*/

Measured memory_bytes: 3596
from bisect import bisect_right
import sys
input = sys.stdin.buffer.readline

N = int(input())
A = [int(input()) for _ in range(N)]

dp = [10**10] * N

for a in A:
    a = -a
    dp[bisect_right(dp, a)] = a

ans = N - dp.count(10**10)
print(ans)


Measured memory_bytes: 11108
#include <stdio.h>
#define MAX 100

int main(){
  int i,j,n,a,b,c;
  int C[MAX][MAX];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      C[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      C[a-1][c-1]=1;
    }
  }

    
		   
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j){
	printf(" ");
      }
      printf("%d",C[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N, K;
	cin >> N>>K;

	// 解法
	// cout << (N+1)/2 << endl;
	if ((N+1)/2>=K) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	int p,n;
	int c=0,pr=0,num=0;
	while( scanf("%d,%d",&p,&n) != EOF){
		c++;
		pr += p*n;
		num += n;
	}
	printf("%d\n%d\n",pr,(num*10/c+5)/10);

	return 0;
}

Measured memory_bytes: 2604
package main

import (
  "fmt"
  "bufio"
  "strings"
  "strconv"
  "os"
  "unsafe"
)

func main() {
  rd := bufio.NewReaderSize(os.Stdin, 100000)
  num_string := make([]byte, 0, 100000)

  for {
    l, p, _ := rd.ReadLine()
    num_string = append(num_string, l...)
    if !p {
      break
    }
  }

  nums := strings.Split(*(*string)(unsafe.Pointer(&num_string)), " ")
  n, _ := strconv.Atoi(nums[0])
  k, _ := strconv.Atoi(nums[1])

  s := make([]byte, 0, 100000)

  for {
    l, p, _ := rd.ReadLine()
    s = append(s, l...)
    if !p {
      break
    }
  }

  var count [100002]int

  cnt := 0
  var prev_value byte = '1'
  arr_num := 0
  for i := 0; i < n; i++ {
    if s[i] == prev_value {
      cnt++;
    } else {
      count[arr_num] = cnt
      arr_num++
      prev_value = s[i]
      cnt = 1
    }
  }

  count[arr_num] = cnt
  arr_num++
  if prev_value == '0' {
    arr_num++
  }

  num := 2 * k + 1
  max := 0
  for i := 0;; i += 2 {
    sum := 0
    for j := i; j < num + i && j < arr_num; j++ {
      sum += count[j]
    }
    if sum > max {
      max = sum
    }
    if num + i >= arr_num - 1 {
      break
    }
  }

  fmt.Println(max)

}


Measured memory_bytes: 1664
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int A[1000000], n;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    int q, k, sum = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        scanf("%d", &k);
        if(*lower_bound(A, A + n, k) == k) sum++;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool t = true;
    while (a > 0 && c > 0)
    {
        if (t)
        {
            c -= b;
        }
        else
        {
            a -= d;
        }
        t = !t;
    }

    string ans = a > 0 ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
H = list(map(int, input().split()))

max_H = [1 for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        max_H[B-1] = 0
    elif H[B-1] > H[A-1]:
        max_H[A-1] = 0
    else:
        max_H[B-1] = 0
        max_H[A-1] = 0

count = 0
for i in range(N):
    if max_H[i] == 1:
        count += 1
        
print(count)

Measured memory_bytes: 20128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi a(n); rep(i, n) cin >> a[i];
	ll ans = 1e18;
	rep(it, 2){
		ll res = 0, sum = 0;
		rep(i, n){
			sum += a[i];
			ll d = i % 2 ? max(0ll, sum + 1) : max(0ll, -sum + 1);
			sum += i % 2 ? -d : d;
			res += d;
		}
		ans = min(ans, res);
		rep(i, n) a[i] *= -1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n,p;
  unsigned int dis[101][101];
  int r,k,t;
  int s,d,v;

  cin >> n;

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      dis[i][j] = (1<<30);
      if(i==j)dis[i][j] = 0;
    }
  }

  for(int i=0;i<n;i++){
    cin >> r >> k;
    for(int j=0;j<k;j++){
      cin >> t;
      dis[r][t] = 1;
    }
  }

  for(int x=1;x<=n;x++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++)dis[i][j] = min(dis[i][j],dis[i][x] + dis[x][j]);
    }
  }

  cin >> p;
  for(int i=0;i<p;i++){
    cin >> s >> d >> v;
    if(dis[s][d]+1>v)cout << "NA" << endl;
    else cout << dis[s][d]+1 << endl;
  }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, X, D;
    cin >> N >> X >> D;

    if (D == 0) {
        if (X == 0) write(1);
        else write(N + 1);
        return 0;
    }
    else if (D < 0) {
        X *= -1;
        D *= -1;
    }

    map<int, vector<pair<ll, ll>>> mst;
    for (ll n = 0; n <= N; ++n) {
        ll s = n * X / D + (n - 1) * n / 2;
        ll t = n * X / D + ((N - 1) * n - (n - 1) * n / 2 + 1);
        mst[(n * X % D + D) % D].emplace_back(s, t);
    }

    ll ans = 0;
    for (auto&& p : mst) {
        auto& vec = p.second;
        if (vec.size() == 0) continue;

        sort(all(vec));
        ll t = -LINF;
        for (auto&& st : vec) {
            ans += min(st.second - st.first, max(st.second - t, 0LL));
            t = max(t, st.second);
        }
    }

    write(ans);
}

Measured memory_bytes: 22144
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    unsigned int D, T, S;
    cin >> D >> T >> S;
    T *S >= D ? cout << "Yes " : cout << "No ";
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct S {
    LL x,h;
};

void solve() {
    LL n,d,a;
    cin >> n >> d >> a;
    vector<S> s(n);
    REP(i,0,n) cin >> s[i].x >> s[i].h;
    sort(all(s), [](auto &l, auto &r) {
        return l.x < r.x;
    });
    VLL x(n), h(n);
    REP(i,0,n) {
        x[i] = s[i].x;
        h[i] = s[i].h;
    }
    LL ans = 0;
    VLL imos(n+1);
    //LL cnt = 0;
    REP(i,0,n) {
        if (i > 0) imos[i] += imos[i-1];
        LL dec = imos[i];
        h[i] -= dec * a; 
        dump(h[i]);
        if (h[i] <= 0) {
            continue;
        }
        LL cnt = (h[i] + a - 1) / a;
        h[i] = 0;
        ans += cnt;
        LL r =  x[i] + 2 * d;
        //dump(r - d);
        auto it = upper_bound(all(x), r);
        int dis = distance(x.begin(), it);
        //dump(d);
        imos[i+1] += cnt;
        imos[dis] -= cnt;
    }
    cout << ans << endl;
    //dump(ans);
}

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

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

bool is_equal(string &a,string &b,int start)
{
	int len = a.size();
	for(int i = 0; i < len; ++i){
		if( a[i] != b[(start+i)%len])
			return false;	
	}
	return true;
}


int main()
{
//	freopen("D:\\patin.txt","r",stdin);
	string a,b;
	cin >> a >> b;
	bool is_ok = false;
	for(int j = 0;j < a.size();++j){
		if(is_equal(a,b,j)){
			is_ok = true;
			break;
		}
	}
	if(is_ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    cout << (N % 2 == 0 ? N : N*2) << "\n";
}

Measured memory_bytes: 256
//It is made by M_sea
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,m;

struct Edge { int v,nxt; } e[N<<1];
int head[N],cnt=0;

inline void addEdge(int u,int v) {
    e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
}

namespace task1 {
    int s,c[N],sum[N];
    inline void dfs(int u,int fa) {
        sum[u]=c[u],s+=c[u];
        for (re int i=head[u];i;i=e[i].nxt) {
            int v=e[i].v; if (v==fa) continue;
            c[v]=-c[u],dfs(v,u),sum[u]+=sum[v];
        }
    }
    
    inline void work() {
        c[1]=1,dfs(1,0);
        if (s) { puts("-1"); return; }
        int ans=0;
        for (re int i=1;i<=n;++i) ans+=abs(sum[i]);
        printf("%d\n",ans);
    }
}

namespace task2 {
    int c[N],sum[N],fa[N];
    int s,isodd,st,ed;
    
    namespace odd {
        inline void work() {
            if (s&1) { puts("-1"); return; }
            int dlt=s/2,ans=abs(dlt);
            for (re int i=st;i;i=fa[i]) sum[i]-=dlt;
            for (re int i=ed;i;i=fa[i]) sum[i]-=dlt;
            for (re int i=1;i<=n;++i) ans+=abs(sum[i]);
            printf("%d\n",ans);
        }
    }

    namespace even {
        int tmp[N],mark[N],w;
        inline void work() {
            if (s) { puts("-1"); return; }
            int top=0;
            for (re int i=ed;i!=st&&i;i=fa[i])
                tmp[++top]=sum[i],mark[i]=1;
            sort(tmp+1,tmp+top+1);
            if (top&1) w=tmp[(top+1)/2];
            else w=(tmp[top/2]+tmp[top/2+1])/2;
            int ans=abs(w);
            for (re int i=1;i<=n;++i) {
                if (mark[i]) ans+=abs(sum[i]-w);
                else ans+=abs(sum[i]);
            }
            printf("%d\n",ans);
        }
    }

    inline void dfs(int u,int f) {
        sum[u]=c[u],s+=c[u],fa[u]=f;
        for (re int i=head[u];i;i=e[i].nxt) {
            int v=e[i].v; if (v==f) continue;
            if (c[v]) {
                if (c[u]==c[v]) isodd=1;
                st=u,ed=v;
            }
            else c[v]=-c[u],dfs(v,u),sum[u]+=sum[v];
        }
    }
    
    inline void work() {
        c[1]=1,dfs(1,0);
        if (isodd) odd::work();
        else even::work();
    }
}

int main() {
    n=read(),m=read();
    for (re int i=1;i<=m;++i) {
        int u=read(),v=read();
        addEdge(u,v),addEdge(v,u);
    }
    if (m==n-1) task1::work();
    else task2::work();
    return 0;
}


Measured memory_bytes: 7296
import numpy as np

N = input()
T,A = input().split()
H = input().split()

hoge = np.ndarray(int(N))
for piyo in range(int(N)):
  hoge[piyo] = int(H[piyo])

hoge = abs(int(T) - (0.006*hoge) - int(A))
print(np.argmin(hoge - int(A)) + 1)

Measured memory_bytes: 27176
N = int(input())
S = list(input())
count = 0
for i in range(1, N):
    pre_S = set(S[:i])
    post_S = set(S[i:])
    kyoutu_S = pre_S & post_S
    if count < len(kyoutu_S):
        count = len(kyoutu_S)

print(count)

Measured memory_bytes: 3060
def main():
    N=int(input())
    strvar = input()
    # num =[]
    
    # for i in range(strvar.length()):
    #     num+=[int(strvar[i])]

    possible = 0
    for i in range(10):
        iind = strvar.find(str(i))
        if iind == -1:
            continue
        for j in range(10):
            jind =strvar[iind+1:].find(str(j))
            if jind==-1:
                continue
            for k in range(10):
                if str(k) in strvar[iind+1+jind+1:]:
                    possible += 1

    print(possible)


if __name__=="__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> s(m);
    vector<char> c(m);
    for(int i=0;i<m;i++) cin >> s[i] >> c[i];
    for(int i=0;i<m;i++) s[i]--;
    int num=pow(10,n-1);
    int lim=pow(10,n);
    if(n==1) num=0;
    for(num;num<lim;num++){
        string st=to_string(num);
        bool check=true;
        for(int i=0;i<m;i++){
            if(st[s[i]]!=c[i]) check=false;
        }
        if(check){
            cout << st << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#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)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
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;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int h,w;char a[10][10];
signed main(){
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>a[i][j];
  int m = 0;bool b = true;
  rep(i,h){
    rep(j,w){ 
      if(a[i][j] == '#'){
        if(m > j)b = false;
        else m = j;
      }
    }
  }
  cout << (b ? "Possible" : "Impossible") << endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	int n;
	cin >> n;
	int arr[n];
	rep(i, 0, n){
		cin >> arr[i];
	}

	int dp[n+1];
	rep(i, 0, n+1) dp[i] = INF;
	dp[0] = 0;
	rep(i, 0, n-1){
		rep(j, 1, 3){
			if(i+j<n)
				dp[i+j] = min(dp[i+j], dp[i] + abs(arr[i+j] - arr[i]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 4420
# D
N = int(input())
X_list = [0]*N
Y_list = [0]*N

res_flag = 1

r = -1
for i in range(N):
    X, Y = map(int, input().split())
    if r >= 0:
        if r != (X+Y)%2:
            res_flag = -1
    else:
        r = (X+Y)%2
    X_list[i] = X
    Y_list[i] = Y
    
if res_flag == -1:
    print(-1)
else:
    if r == 0:
        print(32)
        print(" ".join([str(2**i) for i in range(30, -1, -1)]+["1"]))
        X_add = 1
        m_list_add = ["L"]
    else:
        print(31)
        print(" ".join([str(2**i) for i in range(30, -1, -1)]))
        X_add = 0
        m_list_add = []
    for n in range(N):
        X = X_list[n] + X_add
        Y = Y_list[n]
        
        S = X + Y
        T = X - Y
        m_list = []
        for i in range(30, -1, -1):
            if S < 0 and T < 0:
                m_list.append("L")
                S += 2**i
                T += 2**i
            elif S < 0 and T > 0:
                m_list.append("D")
                S += 2**i
                T -= 2**i
            elif S > 0 and T > 0:
                m_list.append("R")
                S -= 2**i
                T -= 2**i
            elif S > 0 and T < 0:
                m_list.append("U")
                S -= 2**i
                T += 2**i
            else:
                print("?")
        if S != 0 or T != 0:
            print("?")
        
        print("".join(m_list + m_list_add))

Measured memory_bytes: 3188
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

puts ((sqrt gif).to_i)**2


Measured memory_bytes: 2300
import sys
from collections import deque
from functools import lru_cache

sys.setrecursionlimit(1000000)

N, D, A = map(int, input().split())
XH = []
for i in range(N):
  X, H = map(int, input().split())
  XH.append((X, H))


XH.sort()

window = deque()
windowSum = 0
total = 0
for x, h in XH:
    while window and x - window[0][0] > 2 * D:
        oldX, oldBombs = window.popleft()
        windowSum -= A * oldBombs

    h = max(0, h - windowSum)
    bombs = h // A + (1 if h % A else 0)
    total += bombs

    window.append((x, bombs))
    windowSum += A * bombs
    #print(x, bombs, window, windowSum)


print(total)


Measured memory_bytes: 48028
<?php
fscanf(STDIN, "%d%d", $N, $Q);
for($i = 0; $i < $N; $i++){
    fscanf(STDIN, "%d%d%d", $s, $t, $x);
    $s-=$x;
    $t-=$x;
    $S[]=$s;
    $T[]=$t;
    $X[]=$x;
}
for($i = 0; $i < $Q; $i++){
    fscanf(STDIN, "%d", $D[]);
}
$R = array_fill(0, $Q, -1);
$N = array_fill(0, $Q, -1);//
 
array_multisort($X,SORT_ASC,$S,$T);
foreach($X as $i => $x){
    $f = bsl($D, $S[$i]-0.5);
    $t = bsl($D, $T[$i]-0.5);
    for($i = MAX($f+1,0); $i <= $t; $i++){
        if($N[$i] != -1){
            $i = $N[$i];
        }
        if($R[$i] == -1){
            $R[$i] = $x;
            $N[$i] = $t;
        }
    }
}
echo implode("\n", $R);
 
function bsl($nums, $target) {
    $size = count($nums);
    $min = 0; 
    $max = $size - 1;
    while(true){
        $center = floor(($min + $max) / 2);
        $centerValue = $nums[$center];
        if($target == $centerValue){
            return $center;
        }elseif($target > $centerValue){
            $min = $center + 1;
        }else{
            $max = $center;
        }
        if($min == $max){
            $center = floor(($min + $max) / 2);
            $centerValue = $nums[$center];
            if($centerValue == $target){
                return $center;
            }elseif($centerValue < $target){
                return $center;
            }else{
                return $center-1;
            }
        }
    }
}

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

using namespace std;
typedef long long ll;

int ac_map[100001] = {0};

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    for(int i = n; i > 0; i--)
    {
        if (s[i] == 'C' && s[i-1] == 'A'){
            ac_map[i] = ac_map[i+1] + 1;
        } else {
            ac_map[i] = ac_map[i+1];
        }
        
    }

    // for(int i = 0; i <= n; i++)
    // {
    //     printf("%d ", ac_map[i]);
    // }
    
    for(int i = 0; i < q; i++)
    {
        int tmpl, tmpr;
        cin >> tmpl >> tmpr;
        cout << ac_map[tmpl] - ac_map[tmpr] << endl;
    }


}

Measured memory_bytes: 1408
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;
template<class T>
void read_1d(std::vector<T>& a,int64_t num){
	a.reserve(num);
	for(int64_t i1=0;i1<a;i1++){
		T temp;
		cin>>temp;
		a.push_back(temp);
	}
}
template<class T>
void read_2d(std::vector<std::vector<T> >&a,int64_t x,int64_t y ){
	a.resize(x);
	for(int64_t i1=0;i1<x;i1++){
		a[i1].reserve(y);
		for(int64_t i2=0;i2<y;i2++){
			T temp;
			cin>>temp;
			a[i1].push_back(temp);
		}
	}
}

int main(){
	int64_t n,m;
	cin>>n>>m;
	vector<vector<int64_t> > a;
	read_2d (a,n,m);
	vector<bool> held;
	held.resize(m);
	fill(held.begin(),held.end(),true);
	int64_t ans=INF;
	vector<int64_t> count;
	count.resize(m);
	while(true){
		if(find(held.begin(),held.end(),true)==held.end()){
			break;
		}

		fill(count.begin(),count.end(),0);
		for(auto i1=a.begin();i1!=a.end();i1++){
			for(auto i2=i1->begin();i2!=i1->end();i2++){
				if(held.at((*i2)-1)){
					count[(*i2)-1]++;
					break;
				}
			}
		}
		int64_t c_ans=*max_element(count.begin(),count.end());
		if(c_ans<ans){
			ans=c_ans;
		}
		int64_t max_index=max_element(count.begin(),count.end())-count.begin();
		held[max_index]=false;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  char s[9];
  for(int i = 0; i < 9; i++){
    cin>>s[i];
  }
  cout<<s[0]<<s[4]<<s[8]<<endl;
  return 0;
}




Measured memory_bytes: 256
def isok(x,b):
    if x>b:
        return True
    else:
        return False
def bisect(ls,val): ##bの関数isok(val)がTrueとなる一番右のindexを返す
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,val):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2

    return ok


n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
cnt = [0]*(n+1) ##cnt[i] ==　B[i]以上の(b,c)の組の数
for i in range(n):
    b = B[i]
    cnt[i] = bisect(C,b)+1  ##okの数
    if i!=0:
        cnt[i]+=cnt[i-1]
ans = 0
for a in A:
    idx = bisect(B,a) #使える最小のbのインデックス
    ans += cnt[idx]
print(ans)


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

int main() {
  
    int n;
    int m;
 
   cin >> n >> m;
  
   int nm = n + m;
  
   if (n%3 == 0 || m%3 == 0 || nm%3 == 0){
     
      cout << "Possible" << endl;
     
   }else{
     
      cout << "Impossible" << endl;
   }
  
 
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstdio>
#include<vector>

using namespace std;

int dp[67108864]; // 2 ^ 26

#define DPMAX 67108864
#define INF 2000000


string tobin(int n) {
    string s = "";
    for (int i = 31; i >= 0; --i) {
        s += (n >> i) & 1 ? "1" : "0";
    }
    return s;
}

int main() {
    char c;
    int code = 0;
    int i = 1;

    for (int i = 0; i < DPMAX; ++i) {
        dp[i] = INF;
    } 
    dp[0] = 1;
    for (int i = 0; i < 26; ++i) {
        dp[1 << i] = 1;
    } 
    while (scanf("%c", &c)) {
        if (c == '\n') break;
        code = code ^ (1 << (c - 'a'));
        //cout << "i = " << i << " code = " << tobin(code) << endl;
        int ncode = code;
        for (int k = 0; k <= 26; ++k) {
            
            dp[ncode] = min(dp[code] + 1, dp[ncode]);
            //cout << "    ncode = " << tobin(ncode) << " dp = " << dp[ncode] << endl;
            ncode = code ^ (1 << k);
        }
        i += 1;
    }

    cout << dp[code]<< endl;
}

Measured memory_bytes: 262528
# coding: utf-8
# Your code here!
A,B=input().split()

A=int(A)
B=int(B)

def abs(x):
    if x>=0:
        return x
    else:
        return -x
        
if abs(A-B)%2==0:
    print(min(A,B)+int(abs(A-B)/2))
else:
    print('IMPOSSIBLE')

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

vector<int> d;

inline bool isOK(int n){
    while(n>0){
        int m=n%10;
        n/=10;
        for(int x:d){
            if(m==x){
                return false;
            }
        }
    }
    return true;
}
signed main(){
    int n,k; cin>>n>>k;
    rep(i,k){
        d.push_back(0);
        cin>>d.at(i);
    }
    while(true){
        if(isOK(n)){
            cout<<n<<endl;
            return 0;
        }
        n++;
    }
}

Measured memory_bytes: 256
k,n = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

def from_the_first(house)
  house[-1] - house[0]
end

def from_the_other(house, point, end_point)
  house[(point - 1)] + end_point - house[point]
end 

distance = a.slice(0, a.length - 1).map.with_index { |e, i| a[(i+1)] - e }
departure_point = distance.index(distance.max) +1

puts  [from_the_other(a, departure_point, k), from_the_first(a)].min

Measured memory_bytes: 18308
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    map<string,ll> mp;
    for(ll i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout << "AC x " <<mp["AC"]<<"\n";
    cout << "WA x " <<mp["WA"]<<"\n";
    cout << "TLE x " <<mp["TLE"]<<"\n";
    cout << "RE x " <<mp["RE"]<<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3664