akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
}

int main()
{
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> mat(H, vector<ll>(W, 0));
  rep(i, H) {
    rep(j, W) {
      cin >> mat[i][j];
    }
  }
  ll cnt = 0;
  vector<string> ans;
  rep(i, H) {
    rep(j, W) {
      if (mat[i][j] % 2 == 1) {
        if (i+1 < H && (mat[i+1][j] % 2 == 1)) {
          mat[i][j]--;
          mat[i+1][j]++;
          cnt++;
          ans.push_back(to_string(i+1) + " " + to_string(j+1) + " " + to_string(i+2) + " " + to_string(j+1));
        } else if (j+1 < W && mat[i][j+1] % 2 == 1) {
          mat[i][j]--;
          mat[i][j+1]++;
          cnt++;
          ans.push_back(to_string(i+1) + " " + to_string(j+1) + " " + to_string(i+1) + " " + to_string(j+2));
        } else {
          if (i+1 < H) {
            mat[i][j]--;
            mat[i+1][j]++;
            cnt++;
            ans.push_back(to_string(i+1) + " " + to_string(j+1) + " " + to_string(i+2) + " " + to_string(j+1));
          } else if(j+1 < W) {
            mat[i][j]--;
            mat[i][j+1]++;
            cnt++;
            ans.push_back(to_string(i+1) + " " + to_string(j+1) + " " + to_string(i+1) + " " + to_string(j+2));
          } 
        }
      }
    }
  }
  print(cnt);
  for(auto s : ans) {
    print(s);
  }
  return 0;
}

Measured memory_bytes: 12788
# ABC080 C - Shopping Street
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
f=[nl() for _ in range(n)]
p=[nl() for _ in range(n)]
o = []
ans = -10**10
for i in range(2**10):
    op = [0]*10
    for j in range(10):
        if ((i>>j)&1):
            op[10-1-j]=1
    if not any(op):
        continue
    else:
        o.append(op)

for oo in o:
    value = 0
    for i,ff in enumerate(f):
        t=0
        for j in range(10):
            if oo[j]==1 and ff[j]==1:
                t+=1
        value += p[i][t]
    ans = max(ans,value)

print(ans)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
void func(vector<string>& map, ll x, ll y) {
    if (x < 0) return;
    if (x >= map.size()) return;
    if (y < 0) return;
    if (y >= map[x].length()) return;

    auto& m = map[x][y];
    if (m != '#') {
        m++;
    }
}
int main() {
    ll H, W;
    cin >> H >> W;

    vector<string> map(H);
    for (ll i = 0; i < H; ++i) {
        cin >> map[i];
        for (ll j = 0; j < map[i].length(); ++j) {
            if (map[i][j] == '.') {
                map[i][j] = '0';
            }
        }
    }

    for (ll i = 0; i < H; ++i) {
        for (ll j = 0; j < map[i].length(); ++j) {
            if (map[i][j] == '#') {
                for (ll x = -1; x <= 1; ++x) {
                    for (ll y = -1; y <= 1; ++y) {
                        if (x == 0 && y == 0) continue;
                        func(map, i + x, j + y);
                    }
                }
            }
        }
    }

    for (ll i = 0; i < H; ++i) {
        cout << map[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E09 + 1;
const int MAX_N = 1E+05;

int N;
ll H;

ll A[MAX_N + 1], B[MAX_N + 1];

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

    cin >> N >> H;

    ll amax = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i] >> B[i];
        amax = max(amax, A[i]);
    }

    ll ans = 0;
    ll ats = 0;
    sort(B + 1, B + N + 1, greater<ll>());
    for (int i = 1; i <= N; i++) {
        if (B[i] <= amax || ats >= H)
            break;
        ans++;
        ats += B[i];
    }
    if (H - ats > 0) {
        //ans += ceil(double(H - ats) / amax);
        ans += (H - ats) / amax + ((H - ats) % amax == 0 ? 0 : 1);
    }
    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;

int main(){
    int a, b;
    cin >>a >> b;
    cout << 6 - a - b << endl;
}

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


int main() {
  int A, B;
  cin >> A >> B;
  
  int ans = 0;
  for(int i=A; i<=B; i++) {
    string ii = to_string(i);
    string iii = ii;
    reverse(ii.begin(), ii.end());
    if(ii == iii) ans++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
Scanner sc = new Scanner(System.in);
// 最初の文字の固まりを整数値と想定して読み込む while (true) {
	int i;
	int j;
	while(true){
		int H = sc.nextInt();
		int W = sc.nextInt();

		if (H == 0 && W == 0) {
			break;
// 二重ループ(forの中にfor)を書いて、H x W個の # を表示しよう!
		}else{
			for(i=0; i<H; i++){
				for(j=0; j<W; j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		} 
	}
}
}


Measured memory_bytes: 34668
#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() {
  string S;
  cin >> S;
  bool ans = false;
  rep(i, 3) {
    if (S[i] == '7') {
      ans = true;
      break;
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main(int argc, char const *argv[])
{
    int N, K;
    std::cin >> N >> K;

    std::vector<int> D(K);
    for (int i = 0; i < K; i++) {
        std::cin >> D[i];
    }
    
    int i;
    for (i = N;; i++) {
        int x = i;
        bool dislike = false;
        while (x > 0) {
            int y = x % 10;
            // std::cout << y << " ";
            auto it = std::find(D.begin(), D.end(), y);
            if (it != D.end()) { // found
                dislike = true;
                break;
            }
            x = x / 10;
        }
        if (!dislike) break;
    }
    std::cout << i << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define MOD 1000000007
#define Nmax 2000010
using namespace std;

//***
long long inv[Nmax],fact[Nmax],invfact[Nmax];
void PRE(){
	inv[1]=fact[0]=invfact[0]=1;
	for(int i=1;i<Nmax;i++){
		if(i>1)inv[i]=(MOD-(MOD/i)*inv[MOD%i]%MOD)%MOD;
		fact[i]=fact[i-1]*i%MOD;
		invfact[i]=invfact[i-1]*inv[i]%MOD;
	}
}
long long C(int n,int k){
	long long a=fact[n]*invfact[k]%MOD*invfact[n-k]%MOD;
	if(a<0)a+=MOD;
	return a;
}
//***

int vis[100010];
int main(){
	PRE();
	int n,m;cin>>n;
	for(int i=0;i<100010;i++)vis[i]=-1;
	for(int i=0;i<=n;i++){
		int a;cin>>a;a--;
		if(vis[a]!=-1){
			m=n+vis[a]-i;
		}
		else vis[a]=i;
	}//cout<<"#"<<m<<endl;
	for(int k=1;k<=n+1;k++){
		long long ans=C(n+1,k);
		if(k-1<=m){
			ans-=C(m,k-1);
		}
		ans%=MOD;
if(ans<0)ans+=MOD;
		cout<<ans<<endl;
	}
	return 0;
}


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

int main() {

  string s;
  cin >> s;
  int n = s.length();
  vector<int> ans(n);

  for (int i = 0; i < 2; i++) {
    {//solve R
      //RRRR_ _ _RRR_ _
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if (s[j] == 'R') {
          cnt++;
        } else {
          ans[j] += cnt/2;
          ans[j-1] += (cnt+1)/2;
          cnt = 0;
        }
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    for (int j = 0; j < n; j++) {
      //cout << ans[j] << " ";
      if (s[j] == 'L') {
        s[j] = 'R';
      } else {
        s[j] = 'L';
      }
    }
    //cout << endl;
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << (i==n-1?'\n':' ');
  }

  return 0;
}

Measured memory_bytes: 1024
n = int(input())
nums = list(map(int,input().split()))
print(" ".join(map(str,nums)))
for i in range(1,n): #未ソートの部分列の先頭を示すループ変数
    v = nums[i] #nums[i]の値を一時的に保持しておくための変数
    j = i - 1 #ソート済み部分列からvを挿入するための位置を探すループ変数
    while j >= 0 and nums[j] > v:
        nums[j+1] = nums[j] #jにあった数をj+1(つまりi)に移す
        j -= 1 #jの位置を下げて、Falseになるまで確認する
    nums[j+1] = v
    print(" ".join(map(str,nums)))



Measured memory_bytes: 5600
#include <iostream>
#include <string>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

string s;

int main(){
  cin >> s;
  int cnt = 0;
  int n = s.size();

  rep(i, 0, n/2){
    if(s[i] == '(') s[i] = ')';
    else if(s[i] == ')') s[i] = '(';
    if(s[i] != s[n-i-1]) cnt++;
  }
  if(n%2) if(s[n/2] == '(' || s[n/2] == ')') cnt++;

  cout << cnt << endl;
}

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

using namespace std;


int main(){
    int len_set1,len_set2;
    int temp;
    

    scanf("%d",&len_set1);
    vector<int> set_array1(len_set1);
    for(int i = 0; i < len_set1;i++){
        scanf("%d",&temp);
        set_array1[i] = temp;
    }

    scanf("%d",&len_set2);
    vector<int> set_array2(len_set2);
    for(int i = 0; i < len_set2;i++){
        scanf("%d",&temp);
        set_array2[i] = temp;
    }

    vector<int> intersection_set;
    set_symmetric_difference(set_array1.begin(),set_array1.end(),
                            set_array2.begin(),set_array2.end(),
                            inserter(intersection_set,intersection_set.end()));

    for(auto itr = intersection_set.begin();itr!=intersection_set.end();itr++){
        printf("%d\n",*itr);
    }
    return 0;   
}



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

typedef long long ll;

ll MOD = 1e9 + 7;

ll inv_mod( ll a, ll m = MOD )
{
  ll b, x, u, q, abs_m, tmp; 

  abs_m = ( m < 0 ) ? -m : m;
  b = m; x = 1; u = 0; 
  while ( b > 0 ) {
    q = a / b; 
    tmp = u; u = x - q * u; x = tmp;
    tmp = b; b = a - q * b; a = tmp;
  }

  return ( x < 0 ) ? abs_m + x : x;
}

ll fact[100010];

ll nCr(int n,int r)
{
	return fact[n] * inv_mod(fact[r]) % MOD * inv_mod(fact[n - r]) % MOD;
}

int n;
int a[100010];
int cou[100010];

int main()
{
	fact[0] = 1;
	for(int i = 1;i < 100010;i++)
	{
		fact[i] = (fact[i - 1] * i) % MOD;
	}

	cin >> n;

	for(int i = 0;i < 100010;i++)
	{
		cou[i] = -1;
	}

	int d1;
	int d2;


	for(int i = 0;i <= n;i++)
	{
		cin >> a[i];
		
		if(cou[a[i]] == -1)
		{
			cou[a[i]] = i;
		}
		else
		{
			d1 = cou[a[i]];
			d2 = i;
		}
	}

	int l = d1;
	int r = n - d2;


	for(int k = 1;k <= n + 1;k++)
	{
		ll minus = 0;
		if(l + r >= k - 1) minus = nCr(l + r,k - 1);
		cout << (MOD + nCr(n + 1,k) - minus) % MOD << endl;
	}
}




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

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  ll p = abs(X)/D;
  if (p >= K) cout << abs(abs(X)-K*D) << endl;
  else {
    ll a1 = abs(X)-p*D;
    ll a2 = abs(a1-D);
    if ((K-p)%2 == 0) cout << a1 << endl;
    else cout << a2 << endl;
  }
}

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

const int MAX = 1000000;
const int MOD=1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll x,y,N;
  cin >> x >> y; 
  //1
  if((x+y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  //2
  N = (x+y)/3;
  if(!(N<=x && x<=2*N && N<=y && y<=2*N)){
    cout << 0 << endl;
    return 0;
  }
  //3
  COMinit();
  ll startX = N;
  ll ans;
  rep(i,N+1){
    if(x==startX+i){
      ans = COM(N, i);
    }
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#define pi acos(-1)

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double x,y;
    x=(60*h+m)*pi/360;
    y=m*pi/30;
    double thetax=abs(x-y);
    if(thetax > pi){
        thetax=2*pi-thetax;
    }
    double ans=(a*a)+(b*b)-(2*a*b*cos(thetax));

    cout << fixed << setprecision(10);
    cout << sqrt(ans) << endl;

    }




Measured memory_bytes: 4132
import java.util.*;
import java.util.regex.*;

class Main{
	public static void main(String []args){
		Scanner s=new Scanner(System.in);
		
		Pattern p=Pattern.compile("[ .,]");
		boolean first=true;
		while(s.hasNext()){
			String a=s.next();
			String[] b=p.split(a);
			for(int i=0;i<b.length;i++)if(b[i].length()>2&&b[i].length()<7){
				if(!first)System.out.print(" ");
				else first=false;
				System.out.print(b[i]);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;
const int MAX=510000;
//階乗,逆元,逆元の階乗
long long fac[MAX],finv[MAX],inv[MAX];

//テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
}
}

//二項係数計算
long long COM(int n,int k){
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    //前処理
    COMinit();
    int h,w,a,b; cin>>h>>w>>a>>b;
    long long ans=0;
    for(int i=0;i<h-a;i++){
        ans+=COM(b-1+i,i)*COM(w+h-b-2-i,w-b-1);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12160
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars
    }
    let mut m: HashMap<char, char> = HashMap::new();
    for i in 0..s.len() {
        if m.contains_key(&t[i]) {
            if m[&t[i]] != s[i] {
                println!("No");
                return;
            }
        } else {
            m.insert(t[i], s[i]);
        }
    }
    let mut m2: HashMap<char, char> = HashMap::new();
    for i in 0..s.len() {
        if m2.contains_key(&s[i]) {
            if m2[&s[i]] != t[i] {
                println!("No");
                return;
            }
        } else {
            m2.insert(s[i], t[i]);
        }
    }
    println!("Yes");
}

Measured memory_bytes: 6396
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, count = 0;
	long long A[210];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	while (true) {
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 1) {
				printf("%d", count);
				return 0;
			}
			else {
				A[i] /= 2;
			}
		}
		count++;
	}
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
as = gets.split.map(&:to_i).sort
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i).sort
ans = 0
bs.each do |b|
  i = as.bsearch_index { |a| a >= b }
  i = as.size if i.nil?
  j = cs.bsearch_index { |c| c > b }
  j = cs.size if j.nil?
  j = cs.size - j
  ans += i * j
end
p ans

Measured memory_bytes: 23912
N = int(input())
A = [[0,0,0]]
dp = [[0]*3 for i in range(N+2)]
for i in range(N):
  a,b,c = [int(x) for x in input().split()]
  A.append([a,b,c])
for i in range(N+1):
  dp[i+1][0] = max(dp[i][1]+A[i][0],dp[i][2]+A[i][0],dp[i+1][0])
  dp[i+1][1] = max(dp[i][0]+A[i][1],dp[i][2]+A[i][1],dp[i+1][1])
  dp[i+1][2] = max(dp[i][1]+A[i][2],dp[i][0]+A[i][2],dp[i+1][2])
print(max(dp[N+1][0],dp[N+1][1],dp[N+1][2]))
    

Measured memory_bytes: 75332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        long res = 0;
        for (int i = 0; i < N; i++) {
            res = gcd(res, Math.abs(X - Long.parseLong(sc.next())));
        }
        System.out.println(res);
    }

    private static long gcd(long a, long b) {
        return b > 0 ? gcd(b, a % b) : a;
    }
}


Measured memory_bytes: 45060
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
typedef pair<int,int> P;
vector<P> ans;

int main() {
  string s;
  cin >> s;
  if(s[0] == '0' || s[s.length() - 1] == '1') {
    cout << -1 << endl;
    return 0;
  }

  int l = 0, r = s.length() - 2;
  while(l <= r) {
    if(s[l] == s[r]) {
      l++,r--;
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }

  int ances = s.length();
  for(int i = s.length() - 2; i >= 0; i--) {
    if(s[i] == '1') {
      ans.push_back(P(ances,i+1));
      ances = i+1;
    }
    else ans.push_back(P(ances,i+1));
  }

  for(int i = 0; i < ans.size(); i++) {
    cout << ans[i].first<<" "<<ans[i].second << endl;
  }
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

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

  ll minv = INF;
  for(ll i = 1; i*i <= N; i++){
    ll count = 0;
    if(N%i == 0){
      ll j = N/i;
      count = i-1 + j-1;
      minv = min(minv, count);
    }
  }

  cout << minv << endl;
}

Measured memory_bytes: 256
// abc155_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b,c;
  cin>>a>>b>>c;
  if ((a==b&&b==c)||(a!=b&&b!=c&&c!=a)){
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
  return 0;
}


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

int main(int argc, char* argv[]){
  std::string s1, s2;
  std::cin >> s1;
  std::cin >> s2;
  

  for(std::size_t i = 0; i < s1.length(); i++){
    if (s1 == s2){
      std::cout << "Yes" << std::endl;
      return 0;
    }

    char last = s1[0];
    s1.erase(s1.begin());
    s1.push_back(last);
  }
  std::cout << "No" << std::endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    if(s.size() == 3) reverse(all(s));
    cout << s << endl; 
}

Measured memory_bytes: 3624
void main() {
	auto ip = readAs!(long[]), N = ip[0], K = ip[1];
	auto A = readAs!(long[]);

	ulong p;
	auto rbt = redBlackTree!long;
	long[] ptrs;
	while(rbt.insert(p)) {
		ptrs ~= p;
		p = A[p] - 1;
	}
	debug rbt.writeln;
	debug ptrs.writeln;
	long k;
	while(ptrs[k] != p) {
		k++;
	}
	auto loopc = ptrs.length - k; //ok
	debug writefln("k: %d, loopc: %d", k, loopc);

	if(K < k) {
		writeln(ptrs[K]+1);
	} else {
		writeln(ptrs[(K - k) % loopc + k] + 1);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 22788
#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()
{
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1)
        cout << 1 << endl;
    else
        cout << (H * W + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_homework(void) {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	int sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int remain = n - sum;

	if (remain >= 0) cout << remain << endl;
	else             cout << "-1" << endl;
}

int main()
{
    b_homework();

    return 0;
}

Measured memory_bytes: 3564
n = int(input())
a = list(map(int,input().split()))
ans = 1

check = True
zero = False

for i in range(0,n):
    if a[i]==0:
        zero = True
        break;




for i in range(0,n):
    ans = ans*a[i]

    if ans>1000000000000000000:
        check = False
        break;




if zero:
    print(0)
else:
    if check:
        print(ans)
    else:
        print(-1)

Measured memory_bytes: 84756
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
signed main()
{
	long long n, ans = 0;
	scanf("%lld", &n);
	for(int i = 2; i <= sqrt(n) + 1; ++i)
	{
		for(int j = 0, k = 1; n % i == 0; )
		{
			n /= i;
			if(++j >= k)
			{
				++ans;
				j = 0;
				++k;
			}
		}
	}
	if(n > 1)
	{
		++ans;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3836
c = []

def listcreate():
    global c
    c = []
    for y in range(a[0]):
        b = []
        for x in range(a[1]):
            if (x + y) % 2 == 0:
                b.append("#")
            else:
                b.append(".")
        c.append(b)
    return

def listdraw():
    global c
    for y in range(len(c)):
        for x in range(len(c[0])):
            print(c[y][x], end='')
        print()
    return

for i in range(10000):
    a = list(map(int,input().split()))
    if sum(a)==0:
        break
    listcreate()
    listdraw()
    print()



Measured memory_bytes: 7216
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= 13){
            System.out.println(b);
        }
        if (6 <= a && a <= 12){
            System.out.println(b/2);
        }
        if (a<6){
            System.out.println(0);
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

#define pb push_back
#define sz size() 
#define ll long long

ll binpow(ll a, ll b, ll mod) {
    a %= mod;
    ll res = 1ll;
    while (b>0) {
        if (b & 1)
            res = res * a % mod;
        a = a*a % mod;
        b>>= 1; 
    }
    return res;
}

int main() {
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    
    int n;
    string s;
    cin>>n;
    cin>>s;

    n = s.size();

    int i;
    int nuli = 0;
    for (i=0;i<n;i++)
    if (s[i] == '1') {
        nuli++;
    }

    int n1 = nuli - 1;
    int n2 = nuli + 1;

    ll presm1 = 0;
    ll presm2 = 0;

    for (i=0;i<n;i++)
    if (s[i] == '1') {
        if (n1>0) presm1 += binpow(2, n-i-1, n1);
        presm2 += binpow(2, n-i-1, n2);
    }

    if (n1>0) presm1 %= n1;
    if (n2>0) presm2 %= n2;

    int powBuck[200001];
    memset(powBuck, -1, sizeof(powBuck));

    for (i=0;i<n;i++) {

        int curr=0;

        if (s[i] == '1') {
            
            if (nuli == 1) {
                cout<<"0\n";
                continue;
            }
            if (n1>0) {    
                curr = presm1;
                ll kolku = binpow(2, n-i-1, n1);
                curr = (curr + n1 - kolku) % n1;   
            }
        } else {
            curr = presm2;
            ll kolku = binpow(2, n-i-1, n2);
            curr = (curr + kolku) % n2;
        }

        int br=1;
        while (curr) {

            if (powBuck[curr] == -1)
                powBuck[curr] = __builtin_popcount(curr);

            curr = curr % powBuck[curr];
            br++;
        }
        cout<<br<<"\n";
    }

    return 0;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll n;
	cin >> n;
	ll a[200010],v[200010];
	ll ans=0;
	FOR(i,n){
		cin >> a[i];
		v[a[i]]=i;
	}

	set<ll> x;
	x.insert(-1ll);
	x.insert(n);


	for(int i=1;i<=n;i++){
		auto itr=x.lower_bound(v[i]);
		ll r=*itr-v[i];
		itr--;
		ll l=v[i]-*itr;
		ans+=l*r*i;
		x.insert(v[i]);
	}

	cout << ans << endl;

	
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
char s[N];

int main() {
	int n, ans = 0;
 	cin>>n;
 	scanf("%s", s);
    char now = 'A';
    for(int i=0;i<n;i++) {
    	if(s[i] != now) {
        	ans ++;
            now = s[i];
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    LL N,sum=0;
    vector<LL> A;
    vector<LL> D;
    cin>>N;
    REP(i,N){int a;cin>>a;A.pb(a);}
    REP(i,N){
        D.pb(A[(i+1)%N]-A[i]);
        sum+=A[i];
    }
    LL k=sum/(N*(N+1)/2);
    int ok=true;
    if(sum%(N*(N+1)/2)!=0){
        ok=false;
    }
    REP(i,N){
        if(0<D[i]-k||(D[i]-k)%N!=0)ok=false;
    }
    if(ok)cout<<"YES"<<endl;
    else  cout<<"NO"<<endl;
     return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int N;
    cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a.at(i);

    vector<ll> s(N+1,0);
    map<ll,ll> nums;
    for(int i=0; i<N; i++) s.at(i+1)=s.at(i)+a.at(i);
    for(int i=0; i<N+1; i++) nums[s.at(i)]++;
    ll res=0;
    for(auto it : nums) {
        long long num=it.second;
        res+=num*(num-1)/2;
    }
    cout << res << endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;

using ll = long long;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b)cout << 2 * a;
	else {
		a = max(a, b);
		cout << 2 * a - 1;
	}
	return 0;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

struct edge {int to;ll cost; edge(int t,ll c):to(t),cost(c){}};

int n,m;
vector<edge> g[1000];
ll d[1000];

bool bellman_ford() {
	REP(i,n) d[i]=LINF;
	d[0]=0;
	REP(i,n) {
		REP(v,n) {
			REP(k,g[v].size()) {
				edge e=g[v][k];
				if(d[v]!=LINF&&d[e.to]>d[v]+e.cost) {
					d[e.to]=d[v]+e.cost;
					if(i>=n-1&&e.to==n-1) return true;
				}
			}
		}
	}
	return false;
}

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

	cin>>n>>m;
	REP(i,m) {
		int a,b; ll c; cin>>a>>b>>c; a--; b--;
		g[a].push_back(edge(b,-c));
	}
	if(bellman_ford()) cout<<"inf"<<endl;
	else cout<<-d[n-1]<<endl;

	return 0;
}


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

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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    vector<string> Only;
    map<string, int> str;

    //案１TLE
    // for (int i = 0; i < N; i++) {
    //     cin >> S[i];
    //     bool only = true;
    //     int size = Only.size();
    //     if (i != 0) {
    //         for (auto x : Only) {
    //             if (S[i] == x) only = false;
    //         }    
    //     }
    //     if (only) Only.push_back(S[i]);
    // }

    /// for (int i = 0; i < N; i++) {
    ///     cin >> S[i];
    /// }

    //案２ 通ったけどきな臭い
    // for (int i = 0; i < N; i++) {
    //     Only.push_back(S[i]);
    // }

    // sort(Only.begin(), Only.end());
    // Only.erase(unique(Only.begin(), Only.end()), Only.end());

    // int size = Only.size();

    // for (int i = 0; i < size; i++) {
    //     str[Only[i]] = 0;
    // }

    // for (int i = 0; i < N; i++) {
    //     str[S[i]] ++;
    // }

    // vector<string> ans;
    // int MAX = 0;
    // for (int i = 0; i < size; i++) {
    //     MAX = max(MAX, str[Only[i]]);
    // }

    // for (int i = 0; i < size; i++) {
    //     if (str[Only[i]] == MAX) ans.push_back(Only[i]);
    // }
    
    // sort(ans.begin(), ans.end());
    // for (int i = 0; i < ans.size(); i++) {
    //     cout << ans[i] << endl;
    // }

    //案３
    int MAX = 0;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        str[S[i]] ++;
        MAX = max(MAX, str[S[i]]);
    }

    for (pair<string, int> t : str) {
        if (t.second == MAX) cout << t.first << endl;
    }

    return 0;
}

Measured memory_bytes: 27648
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MOD = 998244353;

const int MX = 307;

using bs = bitset<MX>;

bs a[MX];
int pw[2 * MX];
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, m;
    cin >> n >> m;
    pw[0] = 1;
    for (int i = 1; i < 2 * MX; i++) {
        pw[i] = (pw[i - 1] + pw[i - 1]) % MOD;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int x;
            cin >> x;
            if (x == 1) {
                a[i][j] = true;
            }
        }
    }

    int basis = 0;
    int ptr = 1;
    for (int i = 1; i <= m; i++) {
        int pos = ptr;
        while (pos <= n && a[pos][i] == false) {
            pos++;
        }
        if (pos == n + 1) {
            continue;
        }
        basis++;
        swap(a[pos], a[ptr]);
        for (int j = ptr + 1; j <= n; j++) {
            if (a[j][i]) {
                a[j] ^= a[ptr];
            }
        }
        ptr++;
    }

    int nz = (pw[n] - pw[n - basis] + MOD) % MOD;
    int ans = (1ll * nz * pw[m - 1]) % MOD;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]


ans = -1 << 40
for mask in range(1, 1 << 10):
    t = 0
    for i in range(N):
        c = 0
        for j in range(10):
            if (mask >> j) & F[i][j]:
                c += 1
        t += P[i][c]
    ans = max(ans, t)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
}
inline void putll(ll x){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 100005
int n,h[maxn],d[maxn];
int main(){
  n = getint();
  for(int i = 1;i <= n;i++) h[i] = getint();
  for(int i = n;i >= 1;i--){
    if(h[i - 1] > h[i]){
      h[i - 1]--;
    }
  }
  for(int i = 1;i < n;i++){
    if(h[i] > h[i + 1]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())
#define Max(a, b, c)    max(a, max(b, c))

#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 5e3 + 5;
ll n, m, k, ans, q, s, t;
ll a[N], sum[N];

void Solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        a[x]++;
    }
    for(int i = 1; i <= 2e3; i++){
        sum[i] = a[i] + sum[i - 1];
    }
    for(int i = 1; i <= 1e3; i++){
        for(int j = i + 1; j <= 1e3; j++){
            if(a[i] > 0 && a[j] > 0){
                ans += a[i] * a[j] * (sum[i + j - 1] - sum[j]);
                if(a[i] > 1 && 2 * i > j){
                    ans += a[i] * (a[i] - 1) * a[j] / 2;
                }
                if(a[j] > 1){
                    ans += a[j] * (a[j] - 1) * a[i] / 2;
                }
            }
           //cout << i << " " << j << " " << ans << endl;
        }
        if(a[i] >= 3) ans += a[i] * (a[i] - 1) * (a[i] - 2) / 6;
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(6);
    Solve();
}



Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		out.println((N-(N>>1))/((double)N));
	}

}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  for(int i = 0;i < n;i++){
    cin >> b.at(i);
  }
  for(int i = 0;i < n;i++){
    cin >> c.at(i);
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  long kekka = 0;
  for(int i = 0;i < n;i++){
    long ccapa,acapa;
    ccapa = c.end() - upper_bound(c.begin(),c.end(),b.at(i));
    acapa = lower_bound(a.begin(),a.end(),b.at(i)) - a.begin();
    kekka += acapa*ccapa; 
  }
  cout << kekka << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D,N;
    cin >> D >> N;
    int ans = N * pow(100,D);
    if(N == 100){
        ans += pow(100,D);
        print(ans);
    }else{
        print(ans);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define N 100
using namespace std;
int m,n,a,b;
vector<int> in[N],out[N],s,ans;

int main(){
  cin>>m>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    in[b-1].push_back(a-1);
    out[a-1].push_back(b-1);
  }
  for(int i=0;i<m;i++)
    if(!in[i].size()) s.push_back(i);
  while(s.size()){
    int k=s[0];
    s.erase(s.begin());
    ans.push_back(k);
    for(int i=0;i<out[k].size();i++){
      int l=out[k][i];
      out[k].erase(out[k].begin()+i);
      for(int j=0;j<in[l].size();j++)
	if(in[l][j]==k) in[l].erase(in[l].begin()+j);
      if(!in[l].size())	s.push_back(l);
      i--;
    }
  }
  for(int i=0;i<m;i++) cout<<ans[i]+1<<endl;
  return 0;
}

Measured memory_bytes: 1224
import java.io.BufferedReader
import java.io.BufferedWriter

fun main() = Case().exec(::solve)
//fun main() = TestExecutor.assert(testCase) { Case(it.r, it.w).exec(::solve) }

/** https://atcoder.jp/contests/abc178/tasks/abc178_c **/
fun solve(c: Case) {
    val n = c.long().toInt()
    var last = listOf(ModInt(8), ModInt(1), ModInt(1), ModInt(0))
    repeat(n - 1) {
        val next = listOf(
            last[0] * ModInt(8),
            last[0] + (last[1] * ModInt(9)),
            last[0] + (last[2] * ModInt(9)),
            last[1] + last[2] + (last[3] * ModInt(10))
        )
        last = next
    }
    c.println(last[3].v.toString())
}

class ModInt(var v: Long) {
    companion object {
        const val MOD = 1000000007L
    }

    override operator fun equals(other: Any?) = other != null && other is ModInt && v == other.v
    override fun hashCode() = v.hashCode()
    override fun toString() = "ModInt($v)"

    operator fun plus(o: ModInt): ModInt = ModInt(v).also { it += o }
    operator fun minus(o: ModInt): ModInt = ModInt(v).also { it -= o }
    operator fun times(o: ModInt): ModInt = ModInt(v).also { it *= o }
    operator fun div(o: ModInt): ModInt = ModInt(v).also { it /= o }

    operator fun plusAssign(o: ModInt) {
        v += o.v; if (v > MOD) v -= MOD
    }

    operator fun minusAssign(o: ModInt) {
        v -= o.v; if (v < 0) v += MOD
    }

    operator fun timesAssign(o: ModInt) {
        v = v * o.v % MOD
    }

    operator fun divAssign(o: ModInt) {
        v = v * o.v.inv() % MOD
    }

    fun inv(): ModInt {
        var (g, x, y, r) = listOf(MOD, 0L, 1L, v)
        while (r != 0L) {
            val q = g / r
            g %= r
            g = r.also { r = g }
            x -= q * y
            x = y.also { y = x }
        }
        return ModInt(if (x < 0) x + MOD else x)
    }
}

class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }
    private fun execInThread(fn: (Case) -> Unit) =
        Thread(null, { fn(this) }, "solve", 64 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
            .apply { start() }.join()

    fun println(c: CharSequence?) = out.appendln(c)
    fun string(): String = input.readLine().trimEnd()
    fun long(): Long = input.readLine().toLong()
    fun intList(): List<Int> = input.readLine().split(" ").map { it.toInt() }
    fun longList(): List<Long> = input.readLine().split(" ").map { it.toLong() }
}

Measured memory_bytes: 55140