akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int n = nextInt();

		out.println(180 * (n - 2));
	}

	private void solveB() {
		int n = nextInt();

		out.println("");
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std; 
typedef long long ll;
int main(void){
	ll a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+\n";
	else if(a*b==15)cout<<"*\n";
	else cout<<"x\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}
int main(){
  ll N,M;
  cin>>N>>M;
  
  ll ans;
  
  if(N==1&&M==1){
    cout<<1<<endl;
  }

  
  else if(N==1||M==1){
    ans=N*M-2;
     cout<<ans<<endl;
    
  }
  else{
 ans=N*M-(N+M-4)*2-4;
   cout<<ans<<endl;
  }
}


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

using namespace std;

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

    string s;
    cin >> s;

    if (s[b - 1] == 'A'){
        s[b - 1] = 'a';
    }else if(s[b - 1] == 'B'){
        s[b - 1] = 'b';
    }else{
        s[b - 1] = 'c';
    }
    
    cout << s << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,i,j;
	int data[10];
	for(i=0;i<10;i++){
		scanf("%d\n",&data[i]);
	}
	for(i=0;i<10;++i){
		for(j=i+1;j<10;j++){
			if(data[i]<data[j]){
				b = data[i];
				data[i] = data[j];
				data[j] = b;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

Measured memory_bytes: 604
from collections import deque
import collections
n = int(input())
edge = []
cl = dict()
edge_ar = []
for i in range(n+1):
    edge.append([])
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
    edge_ar.append((a,b))

q = deque([(0,1)])
used = set()
used.add(1)
while q:
    this = q.popleft()
    pre = this[0]
    here = this[1]
    k = 1
    for i in edge[here]:
        if i not in used:
            while True:
                if k != pre:
                    cl[(i,here)] = k
                    cl[(here,i)] = k
                    k += 1
                    break
                else:
                    k += 1
            used.add(i)
            q.append((k-1,i))
cl_num = collections.Counter(cl)
cl_num = max(list(cl_num.values()))
print(cl_num)
for i in edge_ar:
    print(cl[i])












Measured memory_bytes: 124960
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

map<int, vector<int>> A;
int color[101];
int D[101];
int d = 0;

void dfs(int u) {
    queue<int> Q;
    Q.push(u);
    color[u] = 1;
    int current;
    D[u] = d;
    while(!Q.empty()) {
        current = Q.front();
        Q.pop();
        vector<int>::iterator it = A[current].begin();
        while(it != A[current].end()) {
            if (color[*it] == 0) {
                Q.push(*it);
                color[*it] = 1;
                D[*it] = D[current] + 1;
            }
            it++;
        }
    }
}

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

    int u, k;
    for (int i = 1; i <= n; i++) {
        color[i] = 0;
        D[i] = -1;
        cin >> u >> k;
        int ad;
        for (int j = 0; j < k; j++) {
            cin >> ad;
            A[u].push_back(ad);
        }
    }

    dfs(1);

    for (int i = 1; i <= n; i++) {
        cout << i << " " << D[i] << endl;
    }
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pii pair<int, int>
#define ll long long
#define INF 1000000000
#define MAXN 55
#define MAXL 22

using namespace std;

int nums[MAXN], sum[MAXN];

int query(int l, int r)
{
	return sum[r] - sum[l - 1];
}

int main(int argc, char const *argv[])
{
	optimize;

	int N;

	cin >> N;


	sum[0] = 0;

	for(int i = 1; i <= N; i++)
	{
		cin >> nums[i];
		sum[i] = sum[i - 1] + nums[i];
	}

	int r = 0;

	for(int i = 1; i <= N; i++)
		r += query(i + 1, N) * nums[i];

	cout << r << endl;

	return 0;	
} 	

Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = list(list(map(int, list(input()))))
	K = int(input())
	
	#桁DP
	M = len(N)
	DP = [[[0] * 4 for i in range(M)] for j in range(2)]
	#最初の処理
	DP[0][0][1] = 1
	DP[1][0][1] = N[0] - 1
	for i in range(1, M):
		if N[i] == 0:
			DP[0][i][1] += DP[0][i - 1][1]
			DP[0][i][2] += DP[0][i - 1][2]
			DP[0][i][3] += DP[0][i - 1][3]

			DP[1][i][1] += DP[1][i - 1][1]
			DP[1][i][2] += DP[1][i - 1][1] * 9 + DP[1][i - 1][2]
			DP[1][i][3] += DP[1][i - 1][2] * 9 + DP[1][i - 1][3]
		else:
			DP[0][i][2] += DP[0][i - 1][1]
			DP[0][i][3] += DP[0][i - 1][2]

			DP[1][i][2] += DP[0][i - 1][1] * (N[i] - 1)
			DP[1][i][3] += DP[0][i - 1][2] * (N[i] - 1)
			DP[1][i][1] += DP[0][i - 1][1]
			DP[1][i][2] += DP[0][i - 1][2]
			DP[1][i][3] += DP[0][i - 1][3]

			DP[1][i][1] += DP[1][i - 1][1]
			DP[1][i][2] += DP[1][i - 1][1] * 9 + DP[1][i - 1][2]
			DP[1][i][3] += DP[1][i - 1][2] * 9 + DP[1][i - 1][3]
		DP[1][i][1] += 9

	ans = DP[0][M - 1][K] + DP[1][M - 1][K]
	# print(DP)
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
#include <math.h>/*M_PI*/
using namespace std;

int main(){
    double r;
    cin >> r;

    double s, l;

    s = M_PI * r * r;
    l = M_PI * 2 * r;

    printf("%f %f\n", s, l);
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int main(void){
  llint a, b,k;
  std::cin >> a >> b >> k;

  if(a < k){
    k-= a;
    a = 0;
  }else{
    a-=k;
    k = 0;
  }
  if(b < k){
    k-=b;
    b = 0;
  }else{
    b-=k;
    k = 0;
  }

  std::cout << a << " " << b << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	if(n>=2*k-1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

using namespace std;

int main(void){

	int n;
	while(cin >> n,n){
		int mx=0,a,cnt=0,sum=0;
		for(int i=0;i<n;i++){
			cin >> a,mx=max(mx,a);
			if(mx>=2)cnt++;
			if(a>0)sum++;
		}
		if(mx<2)cout <<"NA"<<endl;
		else if(cnt==1)cout << "2" << endl;
		else cout << sum+1 << endl;
	}

	return 0;
}

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


int main(void){
	int n;
	cin >> n;
	
	int a[101] = {0};
	int max_num = 0;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(max_num <= std::abs(a[j] - a[i])){
				max_num = std::abs(a[j] - a[i]);
			}
		}
	}
	cout << max_num << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
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(){
	int a,b,c,n,r;
	cin >> n >> r;
	cout << r+max(10-n,0)*100 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int nxt[200005][65];
LL sts[200005][65];
LL k;
int n, A[200005];
int l_occ[200005];

int main()
{
	scanf("%d%lld", &n, &k);
	rep(i, n) scanf("%d", &A[i]);
	for(int i = n - 1; i >= 0; i --) l_occ[A[i]] = i;
	for(int i = n - 1; i >= 0; i --) {
		nxt[i][0] = l_occ[A[i]];
		sts[i][0] = l_occ[A[i]] <= i;
		l_occ[A[i]] = i;
	}
	
	rep(i, n) if(nxt[i][0] == n - 1) {
		nxt[i][0] = 0;
		sts[i][0] ++;
	} else nxt[i][0] ++;
	
	rep1(i, 60) rep(j, n) {
		nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
		sts[j][i] = sts[j][i - 1] + sts[nxt[j][i - 1]][i - 1];
	}
	
	int cur = 0;
	for(int i = 60; i >= 0; i --) if(sts[cur][i] < k) {
		k -= sts[cur][i];
		cur = nxt[cur][i];
	}
	
	for(int i = cur; i < n; i ++)
	if(sts[i][0] == (nxt[i][0] == 0)) {
		if(nxt[i][0] == 0) break;
		i = nxt[i][0] - 1;
	} else printf("%d ", A[i]);
	return 0;
}

Measured memory_bytes: 155392
class combnk_mod(object):
    # pが素数かつaとpが互いに素であるとき
    # フェルマーの小定理より以下が成り立つ.
    # 1 / a = a ** (p - 2) (mod p)
    # これを使って (1 / k!) mod p を計算する.
    def __init__(self, maxn, p):
        self.maxn = maxn
        self.p = p
        self.x = [1] # 分母にあたる数 1 / n! mod p
        self.y = [1] # 分子にあたる数. n! mod p
        for i in range(1, self.maxn + 1):
            self.x.append(self.x[-1] * pow(i, self.p - 2, self.p) % self.p)
            self.y.append(self.y[-1] * i % self.p)

    def combnk(self, n, k):
        if n < k:
            return 0
        return (self.x[n - k] * self.x[k] * self.y[n]) % self.p

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
MOD = 10 ** 9 + 7
combnk = combnk_mod(n, MOD)
ans = 0
if k == 1:
    print(0)
else:
    x = [0 for _ in range(n)]
    y = [combnk.combnk(i, k - 2) for i in range(n + 1)]
    ya = [0]
    for yi in y:
        ya.append(ya[-1] + yi)

    for i in range(n):
        end = i + k - 1
        x[i] = ya[i] - ya[max(0, n - i - 1)]
    for xi, ai in zip(x, a):
        ans += xi * ai % MOD
        ans %= MOD
    print(ans)


Measured memory_bytes: 83876
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
size_t mod = 1e9 + 7;

int num_bits(int mask) {
    int res = 0;
    while (mask) {
        ++res;
        mask = (mask & (mask - 1));
    }
    return res;
}

int main() {
    int n; cin >> n;
    vector<vector<int>> m(n, vector<int>(n));
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cin >> m[i][j];
    vector<size_t> res(1 << n);
    for (int row = 0; row < n; ++row) {
        if (m[row][n - 1]) {
            res[1 << row] = 1;
        }
    }
    vector<vector<int>> masks(n + 1);
    for (int i = 0; i < (1 << n); ++i) {
        masks[num_bits(i)].push_back(i);
    }
    for (int col = n - 2; col >= 0; --col) {
        vector<size_t> new_res(1 << n);
        for (int row = 0; row < n; ++row) {
            if (m[row][col] == 0) continue;
            for (int mask : masks[n - 1 - col]) {
                if ((mask & (1 << row)) == 0) {
                    new_res[mask | (1 << row)] = (new_res[mask | (1 << row)] + res[mask]) % mod;
                }
            }
        }
        size_t wtf = 0;
        for (auto x : new_res) wtf += x;
        res.swap(new_res);
    }
    size_t ans = 0;
    for (auto x : res) ans = (ans + x) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 42552
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    string ans = "";
    rep(i,0,N){
        ans += S[i];
        ans += T[i];
    }
    print(ans);
    


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll a, b, c;
ll k;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
    }else if(k <= a+b){
        cout << a << endl;
    }else{
        cout << a-(k-(a+b)) << endl;
    }
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<limits.h>
#define MAX 100001
#define DATAMAX 500001
#define INF 3000001

typedef struct{
  int next;
  int pre;
  int cost;
}node;

typedef struct{
  int parent;
  int dis;
}distance;

int datanum;
node a[DATAMAX];
distance d[MAX];
int cnt,datanum;

void depthcheck();

int main(){
  int temp[MAX];
  int i,j,num,nodenum;
  cnt = 0;
  scanf("%d",&datanum);
  for(i=0;i<datanum;i++){
    scanf(" %d %d",&temp[i],&nodenum);
    for(j=0;j<nodenum;j++){
      a[cnt].pre = temp[i];
      scanf(" %d %d",&a[cnt].next,&a[cnt].cost);
      //printf("cnt = %d pre = %d next = %d cost = %d\n",cnt,a[cnt].pre,a[cnt].next,a[cnt].cost);
      cnt++;
    }
  }
  depthcheck();
  for(i=0;i<datanum;i++){
    printf("%d %d\n",temp[i],d[i].dis);
  }
  return 0;
}

void depthcheck(){
  int i;
  int flag = 1,lpcnt = 0;
  node temp;
  for(i=0;i<datanum;i++)d[i].dis = INF;
  d[0].dis = 0;
  while(1){
    if(flag == 0)break;
    //その周回に置いて、全てのdが決まっており、周回が必要ない場合break;
    flag = 0;
    for(i=0;i<cnt;i++){
      temp = a[i];
      if(temp.cost + d[temp.pre].dis < d[temp.next].dis){
	d[temp.next].dis = temp.cost + d[temp.pre].dis;
	flag = 1;//その周回に置いて一度でも値に変化があった場合は、ループから抜けない。
	//lpcnt++;
      }
    }
  }
  //printf("%d\n",lpcnt);
}



Measured memory_bytes: 7612
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e3+1;
const int M=1e9+7;

void solve()
{
	int n;
	cin>>n;
	int a[n+1];
	map<int,int> mm,pp;
	f(i,1,n){
		cin>>a[i];
		mm[(i+a[i])]++;
		pp[i-a[i]]++;
	}
	int ans=0;
	f(i,1,n){
		ans+=mm[i-a[i]];
		ans+=pp[a[i]+i];
		// ans--;
		// ans--;
	}
	ans/=2;
	cout<<ans;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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

int main(){
    int n, k, q;
    cin >> n >> k >> q ;
    vector<int>  p(n, k-q);
    rep(i, q){
        int a;
        cin >> a;
        --a;
        p[a]++;
    }
    rep(i,n){ 
        if (p[i] <= 0) puts("No");
        else puts("Yes");
        }
        return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n = 100;
  cin >> n;

  n /= 200;
  cout << 10-n << endl;

  return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
const int MAXN=100005;
int rt[MAXN],tot[MAXN];
int findrt(int x){return rt[x]==x?rt[x]:rt[x]=findrt(rt[x]);}
struct edge{int x,y;}w[MAXN];
LL answer[MAXN];
int main()
{
	int n=read(),m=read();
	for(int i=1;i<=n;i++)rt[i]=i,tot[i]=1;
	for(int i=1;i<=m;i++)w[i].x=read(),w[i].y=read();
	LL ans=1LL*(n)*(n-1)/2;answer[1]=ans;int cnt=1;
	for(int i=m;i>=1;i--)
	{
		int p=findrt(w[i].x),q=findrt(w[i].y);
		if(p!=q)
		{
			rt[p]=q;
			ans-=1LL*tot[p]*tot[q];
			tot[q]+=tot[p];
		}
		answer[++cnt]=ans;
	}
	for(int i=cnt-1;i>=1;i--)printf("%lld\n",answer[i]);
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> zorome(N);
    for(int i=0; i<N; i++) {
        int D1, D2;
        cin >> D1 >> D2;
        if(D1 == D2) zorome[i] = 1;
    }

    bool ans = false;
    for(int i=2; i<N; i++) {
        if(zorome[i-2] && zorome[i-1] && zorome[i]) ans = true;
    }

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


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    vi  ary;
    int cnt   = 1;
    int check = n;

    // 処理
    ary.push_back(check);
    while (true) {
        cnt++;
        if (check % 2 == 0) {
            check /= 2;
        } else {
            check = (3 * check) + 1;
        }

        if (find(all(ary), check) != ary.end()) {
            cout << cnt << endl;
            break;
        }
        ary.push_back(check);
    }

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m, c) = readInputLine().split(" ").map{it.toInt()}
    
    val bArr = readInputLine().split(" ").map{it.toInt()}
    
    var ans = 0
    
    for (i in 1..n) {
        val aArr = readInputLine().split(" ").map{it.toInt()}
        
        if (aArr.zip(bArr).sumBy{it.first * it.second} + c > 0) {
            ans++
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37744
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int M;
  cin >> M;
  ll sum = 0;
  ll k = 0;
  rep(i,M) {
    ll d,c;
    cin >> d >> c;
    sum += d * c;
    k += c;
  }
  cout << k-1 + ((sum-1)/9) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val h1 = input.split(" ").head.toInt
    val m1 = input.split(" ").tail.head.toInt
    val h2 = input.split(" ").tail.tail.head.toInt
    val m2 = input.split(" ").tail.tail.tail.head.toInt
    val k = input.split(" ").tail.tail.tail.tail.head.toInt

    max(h2 * 60 + m2 - h1 * 60 - m1 - k, 0).toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """10 0 15 0 30""".stripMargin -> """270
                                        |""".stripMargin,
    """10 0 12 30 120""".stripMargin -> """30
                                         |""".stripMargin
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 55304
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            int c = int.Parse(In[2]);
            int ans = c - (a - b);
            if (ans >= 0) Console.WriteLine(ans);
            else Console.WriteLine(0);
        }
    }
}


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

int main(void) {
    
    int n; cin >> n;
    string line; cin >> line;
    int l = 0, r = 0;
    for(int i = 0; line[i] == '<'; i++){
        l++;
    }

    for(int i = n-1; line[i] == '>'; i--){
        r++;
    }
    cout << n - min(r, l) << endl;
    return 0;
}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
#define ll long long
#define mod 998244353
#define N 40009
using namespace std;

int n,m,w[2][N],pos[N],fac[N],inv[N],a[N],b[N],na[N],fa[N],fb[N];
char s1[N],s2[N];
int ksm(int x,int y){
	int z=1; for (; y; y>>=1,x=(ll)x*x%mod) if (y&1) z=(ll)z*x%mod;
	return z;
}
int pwk(int m){
	int i,n=1; for (; n<=m; n<<=1);
	int x=ksm(3,(mod-1)/n);
	for (i=w[0][0]=w[1][0]=1; i<n; i++)
		w[0][i]=w[1][n-i]=(ll)w[0][i-1]*x%mod;
	for (i=0; i<n; i++) pos[i]=pos[i>>1]>>1|((i&1)?n>>1:0);
	return n;
}
void fft(int *a,int n,int p){
	int i,j,k,l,x,y;
	for (i=0; i<n; i++) na[pos[i]]=a[i];
	for (i=0; i<n; i++) a[i]=na[i];
	for (k=1; k<n; k<<=1)
		for (i=0,x=n/k>>1; i<n; i+=k<<1)
			for (j=i,l=0; j<i+k; j++,l+=x){
				y=(ll)a[j+k]*w[p][l]%mod;
				a[j+k]=(a[j]-y+mod)%mod; a[j]=(a[j]+y)%mod;
			}
	if (p){
		x=ksm(n,mod-2);
		for (i=0; i<n; i++) a[i]=(ll)a[i]*x%mod;
	}
}
void mul(int *a,int *b,int *c,int n,int m){
	int i;
	for (i=0; i<n; i++){
		fa[i]=a[i]; fb[i]=b[i];
	}
	fft(fa,n,0); fft(fb,n,0);
	for (i=0; i<n; i++) c[i]=(ll)fa[i]*fb[i]%mod;
	fft(c,n,1);
	for (i=m+1; i<n; i++) c[i]=0;
}
int main(){
	scanf("%s%s",s1+1,s2+1);
	int i,len=strlen(s1+1);
	for (i=1; i<=len; i++) if (s1[i]=='1')
		if (s2[i]=='1') n++; else m++;
	fac[0]=inv[0]=inv[1]=1;
	for (i=1; i<N; i++) fac[i]=(ll)fac[i-1]*i%mod;
	for (i=2; i<N; i++) inv[i]=mod-(ll)inv[mod%i]*(mod/i)%mod;
	for (i=2; i<N; i++) inv[i]=(ll)inv[i-1]*inv[i]%mod;
	for (i=0; i<=n; i++) a[i]=inv[i+1];
	b[0]=1;
	len=pwk(n<<1);
	for (i=m; i; i>>=1,mul(a,a,a,len,n)) if (i&1) mul(b,a,b,len,n);
	int ans=0;
	for (i=0; i<=n; i++) ans=(ans+b[i])%mod;
	printf("%lld\n",(ll)ans*fac[m]%mod*fac[n]%mod*fac[m+n]%mod);
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;


#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    
    vector<pair<int,pair<int,bool> > >graph[n+1];
    
    set<int>nodes;
    loop(i,0,m)
    {
        int l,r,c;
        cin>>l>>r>>c;
        graph[l].pb(mp(r,mp(c,true)));
        graph[r].pb(mp(l,mp(c,false)));
        nodes.insert(l);
        nodes.insert(r);
    }
    
    int dist[n+1];
    fill(dist,dist+n+1,-BINF);
    int flag=0;
   // exit(0);
    while(nodes.size()>0)
    {
        auto it=nodes.begin();
        int currnode=*it;
        nodes.erase(nodes.begin());
       // exit(0);
        stack<int>q;
        q.push(currnode);
        dist[currnode]=1;
        while(q.size()>0)
        {
            int s=q.top();
            q.pop();
            for(auto v:graph[s])
            {
                int idx=v.first;
                bool right=v.second.second;
                int coord=dist[s];
                if(right)
                 coord+=v.second.first;
                else
                 coord-=v.second.first;
                
                if(dist[idx]==-BINF)
                {
                    dist[idx]=coord;
                    nodes.erase(idx);
                    q.push(idx);
                }
                else
                {
                    if(dist[idx]!=coord){
                     flag=1;
                     break;
                    }
                }
            }
            if(flag==1)
             break;
        }
        
        if(flag==1)
         break;
    }
    
    if(flag)
     cout<<"No";
    else
     cout<<"Yes";
    
    return 0;
}

Measured memory_bytes: 22912
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
struct E {
  int u,v,c;
  E(int u,int v,int c):u(u),v(v),c(c){}
};

const ll inf = -1e18L;
vector<int> g[2][1000];
bool used[2][1000];
void dfs(int x, int u){
  if(used[x][u]) return;
  used[x][u] = true;
  for(int v:g[x][u]) dfs(x,v);
}

int main() {
  int n,m;
  cin >> n >> m;
  vector<E> e;
  rep(i,m){
    int u,v,c;
    cin >> u >> v >> c;
    --u, --v;
    e.emplace_back(u,v,c);
    g[true][u].emplace_back(v);
    g[false][v].emplace_back(u);
  }
  dfs(true,0);
  dfs(false,n-1);
  vector<bool> b(n);
  rep(i,n) b[i] = used[true][i] && used[false][i];

  vector<ll> d(n,inf);
  d[0] = 0;
  rep(c,n+1){
    bool upd = false;
    rep(i,m){
      int u=e[i].u, v=e[i].v, c=e[i].c;
      if(!b[u] || !b[v]) continue;
      if(d[v] < d[u]+c){
        d[v] = d[u]+c;
        upd = true;
      }
    }
    if(!upd) break;
    if(c==n){
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << d[n-1] << endl;
}

Measured memory_bytes: 512
program main
  implicit none
  type pair
    integer :: a, b
  end type pair
  integer :: n, i, j, t2, t, res
  type(pair), allocatable :: ab(:)
  integer :: dp(0:3000)
  read *, n, t
  allocate (ab(n))
  do j = 1, n
    read *, ab(j)
  end do
  call quicksort(ab)

  res = 0
  dp(:) = 0
  do j = 1, n
    res = max(res, maxval(dp(0:t - 1)) + ab(j)%b)
    do i = 3000, 0, -1  ! 配る
      t2 = ab(j)%a + i
      if (t2 > 3000) cycle
      dp(t2) = max(dp(t2), dp(i) + ab(j)%b)
    end do
  end do

  print "(i0)", res

  contains
  recursive subroutine quicksort(ab)
    type(pair), intent(inout) :: ab(:)
    type(pair) :: pivot, tmp
    integer :: i, j, k, n
    real(4) :: r
    n = size(ab)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = ab(k)
    do
      do while (pivot % a > ab(i) % a)
        i = i + 1
      end do
      do while (ab(j) % a > pivot % a)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = ab(i)
      ab(i) = ab(j)
      ab(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(ab(1:i - 1))
    call quicksort(ab(j + 1:n))
  end subroutine quicksort
end program main


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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[41][1 << 17];

ll mod_pow(ll m, ll n, ll mod) {
    if (n == 0) {
        return 1;
    }

    ll rv = mod_pow(m * m % mod, n/2, mod);

    if (n % 2) {
        return (rv * m) % mod;
    } else {
        return rv;
    }
}

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

    ll N;
    ll X;
    ll Y;
    ll Z;
    cin >> N >> X >> Y >> Z;

    int mask = (1 << 17) - 1; // 17bit

    dp[0][0] = 1;

    for (ll i = 1; i <= N; ++i) {
        for (int s = 0; s < (1 << 17); ++s) {
            for (int d = 1; d <= 10; ++d) {
                int ns = ((s << 1) + 1) << (d-1);
                ns = mask & ns;

                if (((ns >> (Z-1)) & 1) && ((ns >> (Y+Z-1)) & 1) && ((ns >> (X+Y+Z-1)) & 1)) {
                } else {
                    dp[i][ns] = (dp[i][ns] + dp[i-1][s]) % MOD;
                }
            }
        }
    }

    ll ans = mod_pow(10, N, MOD);
    for (int s = 0; s < (1 << 17); ++s) {
        //cout << s << " " << bitset<32>(s) << endl;
        ans = (ans + (MOD - dp[N][s])) % MOD;
    }
    cout << ans << endl;

    return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%ull",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define MOD 1000000007
#define var    int i,j,k,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,m,a[200005];
map<string,ll> mp;
string s;

int main()
{
    ll var;
    sfl(n);
    z=0;
    for(i=0;i<n;i++)
    {
        cin>>s;
        mp[s]++;
    }
    z=0;
    for(auto x: mp)
    {
        z=max(x.yy,z);
    }
    for(auto x: mp)
    {
        if(x.yy==z)
        {
            cout<<x.xx<<endl;
        }
    }
}

Measured memory_bytes: 25216
(let* ((n (read))
       (m (read))
       (x (make-array m))
       (y (make-array m))
       (w (make-array n :initial-element 1))
       (red (make-array n :initial-element nil)))
  (dotimes (i m)
    (setf (aref x i) (read)
          (aref y i) (read)))
  (setf (aref red 0) t)
  (dotimes (i m)
    (let ((xi (1- (aref x i)))
          (yi (1- (aref y i))))
      (if (aref red xi)
          (setf (aref red yi) t))
      (decf (aref w xi))
      (incf (aref w yi))
      (if (zerop (aref w xi))
        (setf (aref red xi) nil))))
    (format t "~A~%" (loop for ri across red unless (null ri) count ri)))

Measured memory_bytes: 61800
#include <iostream>

using namespace std;
long long N;


int main()
{




	cin >> N;
	long long ans = 0;

	if (N % 2 == 0) {
		long long b = 10;
		for (int i = 0; i < 18; i++) {
			long long  c = N / b;

			ans += c;

			long long f = 5;
			for (int j = 0; j < 100; j++) {
				long long fa = (c / f + 1) / 2;
				ans += fa;

				if (fa == 0) { break; }
				f *= 5;
			}


			b *= 10;
		}

	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
H, W = map(int, input().split())
field = [['#'] * (W + 2)]
for i in range(H):
    field.append(list('#' + input() + '#'))
field.append(['#'] * (W + 2))

dp = [[0 for _ in range(W+2)] for _ in range(H+2)]
dp[H][W] = 1

for i in range(H,0,-1):
    for j in range(W,0,-1):
        if field[i][j] == '#':
            continue
        else:
            dp[i][j] += dp[i][j+1] + dp[i+1][j]
        dp[i][j] %= MOD

print(dp[1][1])

Measured memory_bytes: 52468
N=int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
l=prime_factorize(N)
L=set(l)
z=0
for j in L:
  i=1
  while i*(i+1)//2<=l.count(j):
    i+=1
  z+=i-1
print(z)

Measured memory_bytes: 8992
#include<iostream>
#include<cmath>
#include<vector>
#define N 250000

using namespace std;

int main(){
  int i, j, n, isFound;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=N; i+=2){
    for(j=1, isFound=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
	isFound = 1;
	break;
      }
    }
    if(isFound == 0) data.push_back(i);
  }

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<data.size(); ++i){
      if(data[i] > n) break;
    }
    for(j=i+1; j<data.size(); ++j){
      if(data[j] >= 2*n) break;
    }

    cout << j-i << endl;
  }

  return 0;
}

Measured memory_bytes: 1008
n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
ps = [0]*n
t = [0]*n
for i in range( n ):
    ps[i], t[i] = raw_input( ).split( " " )

qsum = 0
while t:
    psi = ps.pop( 0 )
    ti = int( t.pop( 0 ) )
    if ti <= q:
        qsum += ti
        print( "{:s} {:d}".format( psi, qsum ) )        
    else:
        t.append( ti - q )
        ps.append( psi )
        qsum += q

Measured memory_bytes: 8688
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int a[123456];
signed main() {
	int n; cin >> n;
	for1(i, n) { cin >> a[i]; }
	int ans1 = n, ans2 = a[n];
	for (int i = n; i >= 1; i--) {
		if (a[i] <= ans2) {
			ans2 = a[i];
			ans1 = i;
		}
	}
	cout << ans1 << endl;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, m; cin >> n >> m;

    vector<pair<int, int>> p(m);

    for (int i = 0; i < m; ++i) {
        int s, c; cin >> s >> c;

        p[i] = make_pair(s, c);
    }

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

    for (int i = 0; i < m-1; ++i) {
        if (p[i].first == p[i+1].first && p[i].second != p[i+1].second) {
            cout << -1 << endl;
            return 0;
        }
    }

    for (int i = 0; i < m; ++i) {
        if (n != 1 && p[i].first == 1 && p[i].second == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> ans;

    for (int i = 1; i <= n; ++i) {
        bool match = false;

        for (int j = 0; j < m; ++j) {
            if (i == p[j].first) {
                ans.push_back(p[j].second);
                match = true;
                break;
            }
        }

        if (!match) {
            ans.push_back(0);
        }
    }

    if (n != 1 && ans[0] == 0) {
        ans[0] = 1;
    }

    for (auto t : ans) {
        cout << t;
    }

    cout << endl;
}

Measured memory_bytes: 256
def comb(n,r):
    if n < r:
        return 0
    si,bo = 1,1
    for i in range(n):
        si *= i+1
    for i in range(r):
        bo *= i+1
    for i in range(n-r):
        bo *= i+1
    return si//bo

N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse=True)

print(sum(v[:A])/A)
n = 0
r = 0
for i in range(A):
    if v[i] == v[A-1]:
        r += 1
        n += 1
for i in range(A,N):
    if v[i] == v[A-1]:
        n += 1
ans = 0
if v[0] != v[A-1]:
    print(comb(n,r))
    exit()
for _ in range(A,B+1):
    ans += comb(n,r)
    r += 1
print(ans)


Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- map (read::String -> Int) . words <$> getLine
  if solve arr (minBound::Int)
    then putStrLn "Yes"
    else putStrLn "No"



solve::[Int] -> Int -> Bool
solve (x:y:xs) maximum
  | x > y && maximum >= y + 2 = False
  | otherwise = solve (y:xs) $ max maximum y
solve (x:xs) maximum = True


Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	if(n>=30) cout<<"Yes";
	else cout<<"No";

	return 0;
}


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

int N;
int ans = INT_MIN;
int bit[10]{};
static const int MAX = 100;
int F[MAX][10]{};
int P[MAX][11]{};
bool flag = false;

void solve() {
  // 一番最初に呼ばれるときはビット列がすべて0なので、営業している店が0となり不適当
  if (!flag) {
    flag = true;
    return;
  }
  int profit = 0;
  // cnt: 両方が営業している時間帯の個数
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < 10; j++) {
      if(F[i][j] == 1 && bit[j] == 1) cnt++;
    }
    profit += P[i][cnt];
  }
  ans = max(ans, profit);
}
void rec(int k) {
  if( k == 10) {
    solve();
    return;
  }
  rec(k + 1);
  bit[k] = 1;
  rec(k + 1);
  bit[k] = 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 5; j++) {
      cin >> F[i][2 * j] >> F[i][2 * j + 1];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  rec(0);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
wmax,hmax,n=map(int,input().split())
wmin,hmin=0,0
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    wmin=max(wmin,x)
  elif a==2:
    wmax=min(wmax,x)
  elif a==3:
    hmin=max(hmin,y)
  elif a==4:
    hmax=min(hmax,y)

if hmin>=hmax or wmin>=wmax:
  print(0)
else:
  print((hmax-hmin)*(wmax-wmin))


Measured memory_bytes: 62640
import collections
v_odd,v_even=[],[]
ans=0
n=int(input())
all_v=input().split()
for i in range(1,n+1):
    if i % 2 == 0:
        v_even.append(all_v[i-1])
    else:
        v_odd.append(all_v[i-1])

v_odd_count = collections.Counter(v_odd)
v_even_count = collections.Counter(v_even)
v1=v_odd_count.most_common(2)
v11=v_even_count.most_common(2)
if v1[0][0] != v11[0][0]:
    ans = n-v1[0][1]-v11[0][1]
else:
    if len(v1)==len(v11)==1:
        ans = n//2
    elif len(v1)==1:
        ans = n//2 - v11[1][1]
    elif len(v11)==1:
        ans = n//2 - v1[1][1]
    else:
        ans = min((n - v1[0][1] - v11[1][1]),(n - v1[1][1] - v11[0][1]))
print(ans)



Measured memory_bytes: 19820