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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

const int column = 50;

class WarchallFloyd {

    int n;
    vector<vector<ll>> distances;

public:
    WarchallFloyd(int n) : n(n), distances(n, vector<ll>(n, INF)) {
        rep(i, n) distances[i][i] = 0;
    };

    void warshall_floyd() {
        for (int k = 0; k < n; k++) {       // 経由する頂点
            for (int i = 0; i < n; i++) {    // 始点
                for (int j = 0; j < n; j++) {  // 終点
                    if (distances[i][j] == INF && (distances[i][k] == INF || distances[k][j] == INF)) {
                        distances[i][j] = INF;
                    } else {
                        distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
                    }
                }
            }
        }
    }

    ll distance(int from, int to) {
        return distances[from][to];
    }


    friend std::istream &operator>>(std::istream &in, WarchallFloyd &o) {
        int from, to;
        ll c;
        cin >> from >> to >> c;
        from--;
        to--;

        o.distances[from][to] = c;
        o.distances[to][from] = c;
        return in;
    }


};

int main() {
    int n, m, r;
    cin >> n >> m >> r;

    vector<int> visit(r);
    rep(i, r) cin >> visit[i];
    rep(i, r) visit[i]--;
    sort(visit.begin(), visit.end());

    WarchallFloyd wf(n);
    rep(i, m) cin >> wf;
    wf.warshall_floyd();
    ll ans = INF;
    do {
        ll now = 0;
        for (int i = 1; i < r; i++) {
            now += wf.distance(visit[i - 1], visit[i]);
        }
        cmin(ans, now);
    } while (std::next_permutation(visit.begin(), visit.end()));
    cout << ans << endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<unordered_map>
#include<cmath>
using namespace std;
typedef  long long ll;

int main_a(int argc, char const *argv[])
{
    double h,a;
    cin >> h >> a;

    cout << round(ceil(h/a))<<endl;
    
    return 0;
}

int main(int argc, char const *argv[])
{
    ll h,n;
    cin >> h >> n;
    vector<int> a(n);
    ll sum=0;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    if(sum >= h)
    {
        cout <<"Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 640
#C
N= map(int, input().split())
d = list(map(int, input().split()))
sort_d =sorted(d)
len_d = len(d)
half_low = int(len_d/2-1)
half_up = int(len_d/2)
ans =sort_d[half_up]-sort_d[half_low]
print(ans)

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

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

    int ans = 0;

    for (int i = 0; i < N; ++i){
        int h;
        cin >> h;
        if( h >= K)
            ++ans;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
L_dict = Counter(map(int, input().split()))
L = sorted(L_dict.keys())

count = 0

for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        for k in range(j+1, len(L)):
            if L[k] < L[i]+L[j]:
                count += L_dict[L[k]] * L_dict[L[j]] * L_dict[L[i]]
print(count)

Measured memory_bytes: 9460
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	string s;
	cin >> s;
	if (s[0] == 'R' && s[2] == 'R' && s[1] == 'R') {
		cout << 3 << "\n";
	} else if (s[1] == 'R' && s[0] == 'R') {
		cout << 2 << "\n";
	} else if (s[1] == 'R' && s[2] == 'R') {
		cout << 2 << "\n";
	} else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		cout << 1 << "\n";
	} else {
		cout << 0 << "\n";
	}
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto &el: v) cin >> el;
    sort(v.begin(), v.end());
	int count = 0;
	unordered_set<int> s;
	for(int i = 0; i < n; ++i) {
		if(i + 1 < n && v[i] == v[i + 1]) {
			goto k;
		}
		for(int j = 1; j * j <= v[i]; ++j) {
			if(v[i] % j == 0) {
				if(s.count(j) || s.count(v[i] / j)) {
					goto k;
				}
			}
		}
		count++;
k:
		s.insert(v[i]);

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


Measured memory_bytes: 11456
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;



int main(){
  int N;
  long Y;

  std::cin >> N>>Y;

  int flag=0;
  int a,b,c;

  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if((i*10000+j*5000+(N-i-j)*1000)==Y){
        flag=1;
        a=i;
        b=j;
        c=N-i-j;
        break;
      }
    }
  }

  if(flag==1){
    std::cout << a<<" "<<b<<" "<<c << '\n';
  }else{
    std::cout << "-1 -1 -1" << '\n';
  }
}


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

int main(){
	int ABCD;
    cin >> ABCD;
    int A, B, C, D;
    A = ABCD / 1000;
    ABCD %= 1000;
    B = ABCD / 100;
    ABCD %= 100;
    C = ABCD / 10;
    ABCD %= 10;
    D = ABCD;
  
    char op[3];
  
  for(int tmp = 0; tmp < (1 << 3); tmp++){
  	bitset<3> S(tmp);
    int x, y, z;
    char optest[3];
    if(S.test(2)){
    	x = B*(-1);
        optest[0] = '-'; 
    }
    else{
        x = B;
        optest[0] = '+';
    }
     if(S.test(1)){
    	y = C*(-1);
        optest[1] = '-';
    }
    else{
        y = C;
        optest[1] = '+';
    }
     if(S.test(0)){
    	z = D*(-1);
        optest[2] = '-';
    }
    else{
        z = D;
        optest[2] = '+';
    }
    
    if(A+x+y+z == 7){
      for(int i=0; i<3; i++){
      	op[i] = optest[i];
      }
      break;
    }
  }
  
  cout << A << op[0] << B << op[1] << C << op[2] << D << "=7" << endl;  
}

Measured memory_bytes: 256
def sum_of_digits(n)
   n.to_s.split("").map { |s| s.to_i }.inject(:+)
end

N = gets.to_i

ans = 99999 * 2

(1...N).each do |i|
  
  tmp = sum_of_digits(i) + sum_of_digits(N-i)
  if ans > tmp
    ans = tmp
  end
end

puts ans

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

#define LL 					long long
#define ULL 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#define setmin_rv(x)		for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) (x)[i][j] = -1
#define setnul_rv(x)		for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) (x)[i][j] = 0
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const LL infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

map<LL,int> memo;
int n;

int main() {
	LL sum = 0LL, ans = 0LL;
	gi(n);
	memo[0] = 1;
	for (int i=1; i<=n; i++) {
		LL x; gi(x);
		sum += x;
		if (memo.count(sum)) {
		 	ans += (LL)memo[sum];
		 	memo[sum]++;
		} else memo[sum] = 1;
	}
	printf ("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 12800
/*
Powered by 0736TuT
Code + Music + Games = Life
*/

#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAXN 10010

typedef long long qwq;

using namespace std;

int scan(int *buf_tar)
{
    char buf_c=0; bool is_rev=0;
    while(buf_c!='-'&&(buf_c<'0'||buf_c>'9')) {buf_c=getchar(); if(buf_c==EOF) return EOF;}
    if(buf_c=='-') is_rev=1,buf_c=getchar();
    *buf_tar=0;
    while(buf_c>='0'&&buf_c<='9') {*buf_tar*=10; *buf_tar+=buf_c-'0'; buf_c=getchar();}
    if(is_rev) *buf_tar=-*buf_tar;
    return 0;
}

int cnt=0;
int num[MAXN];

inline bool cp(const int &,const int &);

int main()
{
    for(cnt=1;scan(&num[cnt])!=EOF;cnt++);
    sort(num+1,num+cnt,cp);
    printf("%d\n%d\n%d\n",num[1],num[2],num[3]);
    return 0;
}

inline bool cp(const int &a,const int &b)
{
    return a>b;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

int r[40][100010];
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,L,Q;
    cin>>N;
    vector<int> x(N);
    REP(i,N) cin>>x[i];
    cin>>L>>Q;

    REP(i,N) {
        r[0][i]=distance(begin(x),upper_bound(ALL(x),x[i]+L))-1;
    }
    REP(j,39) {
        REP(i,N) {
            r[j+1][i]=r[j][r[j][i]];
        }
    }

    REP(q,Q) {
        int a,b;
        cin>>a>>b;
        a--; b--;
        if(a>b) swap(a,b);

        int ans=0;
        for(int i=19;i>=0;i--) if(r[i][a]<b) {
			a=r[i][a];
		    ans+=1<<i;
		}
        cout<<ans+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define N 3001
using namespace std;
int w,h;
int dx[]={0,1,0,-1};//^>v<
int dy[]={-1,0,1,0};
vector<int> X,Y,d;
map<int,int> x,y;
int mp[N][N];

int compless(vector<int> A,map<int,int> &M){
  sort(A.begin(),A.end());
  int c=0;
  for(int i=0;i<A.size();i++)if(!M.count(A[i]))M[A[i]]=c++;
  return c;
}

int calc(int y,int x){
  vector<vector<bool> > used(h,vector<bool>(w,0));
  int res=0;
  while(1){
    res++;
    int i=mp[y][x];
    used[y][x]=1;
    while(1){
      y+=dy[i],x+=dx[i];
      if(y<0||x<0||x>=w||y>=h)return res;
      if(mp[y][x]!=-1&&!used[y][x])break;
    }
  }
  assert(0);
}

int main(){
  int n;
  cin>>n;
  X.resize(n),Y.resize(n),d.resize(n);
  for(int i=0;i<n;i++){
    char ch;
    cin>>X[i]>>Y[i]>>ch;
    if(ch=='^')d[i]=0;
    if(ch=='>')d[i]=1;
    if(ch=='v')d[i]=2;
    if(ch=='<')d[i]=3;
  }
  h=compless(Y,y);
  w=compless(X,x);
  
  memset(mp,-1,sizeof(mp));
  for(int i=0;i<X.size();i++)mp[y[Y[i]]][x[X[i]]]=d[i];
  int ans=1;
  for(int i=0;i<n;i++)ans=max(ans,calc(y[Y[i]],x[X[i]]));
  cout <<ans<<endl;

  return 0;
}

Measured memory_bytes: 38636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");
		int a = Integer.parseInt(nums[0]);
		int b = Integer.parseInt(nums[1]);
		int c = Integer.parseInt(nums[2]);
		int k = Integer.parseInt(br.readLine());

		int sum = a + b + c;

		int max = 0;
		if (max < a)
			max = a;
		if (max < b)
			max = b;
		if (max < c)
			max = c;

		System.out.println(sum + max * (int) Math.pow(2, k) - max);

	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	std::string str;
	std::cin >> str;
	int ans = 0;

	for (int i = 0; i < 4; ++i) {
		if (str[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())
n = str(N)
l = len(n)
dp0 = [[0 for _ in range(K+1)]  for _ in range(l+1)]
dp1 = [[0 for _ in range(K+1)]  for _ in range(l+1)]
dp0[0][0] = 1

for i in range(l):
    x = int(n[i])
    for j in range(K):
        dp1[i+1][j+1] += dp1[i][j]*9
        dp1[i+1][j] += dp1[i][j]
        if x > 0:
            dp1[i+1][j] += dp0[i][j]
            dp1[i+1][j+1] += dp0[i][j]*(x-1)
            dp0[i+1][j+1] += dp0[i][j]
        else:
            dp0[i+1][j] += dp0[i][j]
    dp1[i+1][K] += dp1[i][K]
    if x > 0:
        dp1[i+1][K] += dp0[i][K]
    else:
        dp0[i+1][K] += dp0[i][K]
print(dp0[-1][-1]+dp1[-1][-1])


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

int main(){
  int N, a[110];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ans=0;
  for(int i = 0; i < N; i++){
    for(int j = N-1; j > i-1; j--){
      if(a[j] < a[j-1] && j-1 >= 0){
	int tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	ans++;
      }
    }
  }
  for(int i = 0; i < N;i++){
    if(i < N-1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int N,M;cin>>N>>M;
    vector<pair<int,int>> war(M);
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        war.at(i).first=b;
        war.at(i).second=a;
    }
    sort(war.begin(),war.end());

    int res=0;
    int x=0;
    
    for(int i=0;i<M;i++){
        if(x<=war.at(i).second){
            res++;
            x=war.at(i).first;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bitset<10010>ok[2010];
pair<int,int>p[2][10010];
char s[2010][10010],ans[1001000];
int len[2010],n,k,cnt=0,ncnt=0;
int main()
{
    //freopen("H:\\c++1\\in.txt","r",stdin);
    //freopen("H:\\c++1\\out.txt","w",stdout);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);//
        len[i]=strlen(s[i]+1);//
    }
    ok[n+1][0]=1;
    for(int i=n;i>=1;i--){
        ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
    }
    for(int i=1;i<=n;i++){
        if(ok[i+1][k-len[i]]){
            p[0][++cnt]=make_pair(i,1);//
        }
    }
    int f=0;
    for(int i=1;i<=k;i++){//
        char mi='z';
        for(int j=1;j<=cnt;j++){
            mi=min(mi,s[p[f][j].first][p[f][j].second]);
        }
        ans[i]=mi;
        //cout<<ans[i]<<endl;
        ncnt=0;
        int pp=n+1;
        for(int j=1;j<=cnt;j++){
            int id=p[f][j].first,pos=p[f][j].second;
            if(mi!=s[id][pos])continue;
            if(pos==len[id])pp=min(pp,id);//
            else p[f^1][++ncnt]=make_pair(id,pos+1);
        }
        for(int j=pp+1;j<=n;j++){
            if(k>=i+len[j]&&ok[j+1][k-i-len[j]])p[f^1][++ncnt]=make_pair(j,1);//
        }
        f^=1;
        cnt=ncnt;
    }
    printf("%s\n",ans+1);//
    return 0;
}

Measured memory_bytes: 22016
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int N=0;
long X=0;
long ans=0;
long l(int n) {return pow(2,n+2)-3;}
long p(int n) {return pow(2,n+1)-1;}
long b(int n) {return pow(2,n+1)-2;}
int pat[6]={0,0,1,2,3,3};
 
void burger(int n,long x){
  	if(n==1) {
      	ans+=pat[x];
    }
  	else if(x>=l(n)-2 ){
    	ans+=p(n);
    }
	else if(x > l(n-1)+3) {
      	ans+=p(n-1)+1;
     	burger(n-1,x-l(n-1)-2);
    }
  	else if(l(n-1)+2==x || x==l(n-1)+3){
    	ans+=p(n-1)+1;
    }
  	else if (x>1){
    	burger(n-1,x-1);
    }
}

int main(){
  	cin >>N >>X;
	
  	burger(N,X);
  
  	cout <<ans <<endl;
  
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<(int)(b);i++)
#define reps(i,n) for(int i=0;i<=(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

int main()
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0]*a[1]/2 << endl;

  return 0;
}


Measured memory_bytes: 256
mod = 1000000007
n,m = map(int,input().split())
A = [int(input()) for _ in range(m)]
dp = [0] * (n + 1)
broken = [False] * (n + 1)
dp[0] = 1
for a in A:
  broken[a] = True
if broken[1] == False:
  dp[1] = 1
for i in range(2,n + 1):
  if broken[i] == False:
    dp[i] = dp[i - 2] + dp[i - 1]
print(dp[n] % mod)

Measured memory_bytes: 460788
import itertools
N = int(input())
lis = list(itertools.permutations(range(1, N+1)))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
P = tuple(P)
Q = tuple(Q)
a = lis.index(P) + 1
b = lis.index(Q) + 1
ans = abs(a - b)
print(ans)

Measured memory_bytes: 13888
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
        int t;
        int h,m,s;
        t = sc.nextInt();
        
        h = t/3600;
        m = (t/60)-(h*60);
        s = (t-((h*3600)+(m*60)));
        
        System.out.println(h+":"+m+":"+s+"");
        
        sc.close();

	}
}


Measured memory_bytes: 26236
d = {}

i = int(input())

for m in range(i):
	word = input()
	d[m] = word
for n in range(1, i):
	h = n - 1
	a = d[h]
	b = d[n]
	if a[-1] == b[0]:
		continue
	else:
		print('No')
		exit()
for x in range (i - 1):
	for j in range (x + 1, i):
		if d[x] == d[j]:
			print('No')
			exit()
print('Yes')


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int k = n % 10;
		String ans = "pon";
		if (k == 2 || k ==4  || k ==5  || k ==7  || k ==9 ) {
			ans = "hon";
		} else if (k == 3) {
			ans = "bon";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27060
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d[] = new int[n];
    
    for(int i = 0 ; i < n ; ++i){
      d[i] = sc.nextInt();
    }
    
    int sum = 0;
    for(int i = 0 ; i < n ; ++i){
      for(int j = i+1 ; j < n ; ++j){
        sum += d[i]*d[j];
      }
    }
    System.out.println(sum);
    
  }
}

Measured memory_bytes: 35932
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
       Scanner in=new Scanner(System.in);
       int a,b,c;
       a=in.nextInt();
       b=in.nextInt();
       c=in.nextInt();
       if((a+b+c)>=22){
           System.out.println("bust");
       }
       else{
           System.out.println("win");
       }
    }
    
}

Measured memory_bytes: 21972
// B - Counting of Trees
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
#define MOD 998244353

int main(){
	int N; cin>>N;
	map<int,int> M;
	rpz(i, N){
		// int d; cin>>d;
		int d; scanf("%d",&d);
		if((i==0 && d!=0) || (i>0 && d<=0)){
			cout<< 0 <<endl;
			return 0;
		}
		M[d]++;
	}
	ll ans = 1;
	rp(d, 1, M.size()) rpz(i, M[d]) ans  = ans * M[d-1] % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<map>

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


int main(){
    while(1){
		int N,M;
		cin >> N >> M;
		if(N==0&&M==0)break;

		int r,q,t,n,m,s,ts,te;
		int pc_min[1001][720]={0};
		cin >> r;
		//いもす法っぽいやーつ
		REP(i,0,r){
			cin >> t >> n >> m >> s;
			t=t-540;
			if(s){
				pc_min[n][t]=m;
			}else{
				pc_min[n][t]=-m;
			}
		}

		//累積和とってログイン履歴完成
		REP(i,1,N+1){
			REP(j,1,720){
				pc_min[i][j]+=pc_min[i][j-1];
			}
		}
		/**
		REP(i,1,N+1){
			REP(j,1,720){
				cout << pc_min[i][j];
			}
			cout << endl;
		}
		**/

		cin >> q;
		REP(i,0,q){
			int ans=0;
			cin >> ts >> te >> m;
			ts=ts-540;
			te=te-540;
			REP(j,ts,te){
				bool flag=false;
				REP(k,1,N+1){
					if(pc_min[k][j]==m)flag=true;
				}
				if(flag)ans++;
			}
			p(ans);
		}
	}
}



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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    REP(i, S.length()){
        if (S[i] != T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main() {
    ll n, k;
    ll i;
    cin >> n >> k;
    k--;
    ll a, key=0;
    
    for(i=1; i<=n; i++) {
        cin >> a;
        if(a==1)
            key=i;
    }
    
    n-=(k+1);
    if(n<=0) {
        cout << 1;
        return 0;
    }else if(n%k!=0) {
        cout << n/k+2;
        return 0;
    }else
        cout << n/k+1;
    
}


Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
using namespace std;

int N;
vector<int> A;

void solve() {
	cin >> N;
	A.resize(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	int x = A[0];
	for (int n = 1; n < N; n++)x = x ^ A[n];
	if (x == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	//cin.sync_with_stdio(false); cin.tie(0);
	//cin.exceptions(cin.failbit);

	for (;;) {
		int n, l; cin >> n >> l; if (!n) break;
		vector<char> d(n); vector<int> p(n);
		rep(i, 0, n) cin >> d[i] >> p[i];

		int left = n;

		for (int t = 0;; t++) {
			vector<int> b(205), lefts;
			rep(i, 0, n) if (p[i] != 0 && p[i] != l) {
				if (d[i] == 'L') p[i]--; else p[i]++;
				b[p[i]]++;
				if (p[i] == 0 || p[i] == l) lefts.push_back(i), left--;
			}
			rep(i, 0, n) {
				if (b[p[i]] == 2) d[i] ^= 'L' ^ 'R';
			}
			//printf("%d - ", t); rep(i, 0, n) { printf("%d:%d(%c) ", i, p[i], d[i]); } puts("");
			if (left == 0) {
				//cerr << "Lefts: " << left << "," << lefts.size() << endl;
				cout << t + 1 << " ";
				if (lefts.size() == 1) {
					cout << lefts.front() + 1 << endl;
				} else {
					cout << (p[lefts.front()] == 0 ? lefts.front() + 1 : lefts.back() + 1) << endl;
				}
				break;
			}
		}
	}
}



Measured memory_bytes: 3008
table[1001][1001],i,j;
main(p,W,a,b,c){
	for(;scanf("%d",&W),W;){
		for(i=!scanf("%d",&c);i<c&&scanf("%d,%d",&b,&a);i++){
			for(j=0;j<=W;j++){
				table[i+1][j]=(j<a)?table[i][j]:(table[i][j]>table[i][j-a]+b)?table[i][j]:(table[i][j-a]+b);
			}
		}
		for(j=0;j<=W;j++){
			if(table[c][j]==table[c][W]){
				printf("Case %d:\n%d\n%d\n",p++,table[c][W],j);
				break;
			}
		}
	}
return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
f = [0] * 3
ans = 1
m = 1000000007
for x in a:
  c = 0
  for y in f:
    if x == y:
      c += 1
  ans = ans * c % m
  for i in range(3):
    if f[i] == x:
      f[i] += 1
      break
print(ans)

Measured memory_bytes: 53044
// 2014/10/27 Tazoe

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int min_cost(string r, map<string, int>& itm, map<string, vector<string> >& rcp)
{
	if(rcp.find(r)==rcp.end())
		return itm[r];

	int sum = 0;
	for(int i=0; i<rcp[r].size(); i++){
		sum += min_cost(rcp[r][i], itm, rcp);
	}

	if(sum<itm[r])
		return sum;
	else
		return itm[r];
}

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

		if(n==0)
			break;

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

			itm[s] = p;
		}

		int m;
		cin >> m;

		map<string, vector<string> > rcp;
		for(int i=0; i<m; i++){
			string o;
			int k;
			cin >> o >> k;

			for(int j=0; j<k; j++){
				string q;
				cin >> q;

				rcp[o].push_back(q);
			}
		}

		string r;
		cin >> r;

		cout << min_cost(r, itm, rcp) << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
s = input()
s_num = s.count("S")
e_num = s.count("E")
n_num = s.count("N")
w_num = s.count("W")
c = 0
if ((s_num > 0) & (n_num > 0)) | (s_num + n_num == 0):
    c += 1
if ((e_num > 0) & (w_num > 0)) | (e_num + w_num == 0):
    c += 1
if c == 2:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int n;
vec A, B;

int bit[202020];

void add(int i) {
  while (i <= 202020) {
    bit[i]++;
    i += i & -i;
  }
}

int sum(int i) {
  int res = 0;
  while (i > 0) {
    res += bit[i];
    i -= i & -i;
  }
  return res;
}

signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    A.pb(tmp);
    B.pb(tmp);
  }

  sort(ALL(B));
  map<int, int> mp;
  for (int i = 0; i < B.size(); i++) {
    mp[B[i]] = i + 1;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    add(mp[A[i]]);
    ans += i + 1 - sum(mp[A[i]]);
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 20072
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	while(1){
		string s1,s2;
		cin >> s1;
		if(s1 == ".") break;
		cin >> s2;
		vector<string> moji1,moji2,code1,code2;
		
		int last = 0;
		int dq = 0;
		for(int i = 0;i < s1.size();i++){
			if(s1[i] == '"'){
				dq++;
				if(i != 0){
					if(dq % 2 == 1){
						if(dq == 1){
							code1.push_back(s1.substr(0,i-1));
						}else{
							code1.push_back(s1.substr(last+1,i-last-1));
						}
					}else{
						moji1.push_back(s1.substr(last+1,(i-last-1)));
					}
				}
				last = i;
			}
		}
		if(dq == 0){
			code1.push_back(s1);
		}else if(s1[s1.size()-1]!= '"'){
			code1.push_back(s1.substr(last,s1.size()-last-1));
		}
		
		last = 0;
		dq = 0;
		for(int i = 0;i < s2.size();i++){
			if(s2[i] == '"'){
				dq++;
				if(i != 0){
					if(dq % 2 == 1){
						if(dq == 1){
							code2.push_back(s2.substr(0,i-1));
						}else{
							code2.push_back(s2.substr(last+1,i-last-1));
						}
					}else{
						moji2.push_back(s2.substr(last+1,(i-last-1)));
					}
				}
				last = i;
			}
		}
		if(dq == 0){
			code2.push_back(s2);
		}else if(s2[s2.size()-1]!= '"'){
			code2.push_back(s2.substr(last,s2.size()-last-1));
		}
		
		int cdif = 0;
		if(code1.size() == code2.size()){
			for(int i = 0;i < code1.size();i++){
				if(code1[i]!=code2[i]) cdif++;
			}
		}else{
			cdif = 1;
		}
		int mdif = 0;
		if(moji1.size() == moji2.size()){
			for(int i = 0;i < moji1.size();i++){
				if(moji1[i]!=moji2[i]) mdif++;
			}
		}else{
			mdif = 2;
		}
		if(cdif == 0){
			if(mdif == 0){
				cout << "IDENTICAL" << endl;
			}else if(mdif == 1){
				cout << "CLOSE" << endl;
			}else{
				cout << "DIFFERENT" << endl;
			}
		}else{
			cout << "DIFFERENT" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define _GLIBCXX_DEBUG
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  ll a,b,c,n;cin >> a >> b >> c >> n;
  ll Ans = 0;
  if(n<a)rep(i,n) Ans++;
  if(n>=a) {
  rep(i,a) Ans++;
  if(n>a+b) rep(i,n-a-b) Ans--;
  }
  cout << Ans << endl; 
}


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

int main(){
    int A, B, C, K;
    bool flag = false;
    std::cin >> A >> B >> C >> K;
    for (int i = 0; i <= K; ++i) {
        for (int j = 0; j <= K; ++j) {
            for (int k = 0; k <= K; ++k) {
                int x = A * (1 << i), y = B * (1 << j), z = C * (1 << k);
                if(i + j + k <= K && x < y && y < z){
                    flag = true;
                }
            }
        }
    }
    if (flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3588
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int a,b;
   cin>>a>>b;
   if(a%b) cout<<"1"<<endl;
   else cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
//'A' = 65, 'a' = 97

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

    int ans = 0;
    for (int i = 0; i < (int)s.size() - 1; i++)
    {
        if (s[i] != s[i + 1]) ans ++;
    }

    cout << ans << endl;

}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int32_t main()
{
	run();
	int n, W;
	cin >> n >> W;
	vector<int> w(n + 1), v(n + 1);
	int sum = 0;
	rep(i, 1, n + 1)
	{
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	int dp[n + 1][sum + 1];
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	for (int i = 0; i <= n; i++)
	{
		dp[i][0] = 0;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= sum; j++)
		{
			if (j >= v[i])
			{
				if (dp[i - 1][j - v[i]] >= 0)
				{
					if (dp[i - 1][j] >= 0)
					{
						dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j]);
					}
					else {
						dp[i][j] = dp[i - 1][j - v[i]] + w[i];
					}
				}
				else {
					if (dp[i - 1][j] >= 0)
					{
						dp[i][j] = dp[i - 1][j];
					}
					else {
						dp[i][j] = -2;
					}
				}
			}
			else {
				if (dp[i - 1][j] >= 0)
				{
					dp[i][j] = dp[i - 1][j];
				}
				else {
					dp[i][j] = -3;
				}
			}
			if (dp[i][j] <= W and dp[i][j] >= 0)
			{
				ans = max(ans, j);
			}
			else {
				dp[i][j] = -4;
			}
		}
	}
	// for (int i = 0; i <= n; i++)
	// {
	// 	for (int j = 0; j <= sum; j++)
	// 	{
	// 		cout << '#' << i << '#' << j << '#' << dp[i][j] << "  ";
	// 	}
	// 	cout << endl << endl;
	// }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39680
# C - pushpush
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if n % 2 == 0:
        if i % 2 ==0:
            b.append(a[i])
        else:
            b.appendleft(a[i])
    else:
        if i % 2 !=0:
            b.append(a[i])
        else:
            b.appendleft(a[i])

print(*b, end=" ")

Measured memory_bytes: 25532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        int n;
        cin>>n;

        map<ll,ll> p;
        ll m[n+1];

        for( int i=1 ; i<=n ; i++ )
        {
            ll x;
            cin>>x;
            m[i]=i-x;
            p[i+x]++;
        }

        ll ans=0;
        for( int i=1 ; i<=n ; i++ )
        {
            ans+=p[m[i]];
        }

        cout<<ans;
    }
    return 0;
}












Measured memory_bytes: 27884
// 2012/02/18 Tazoe

#include <iostream>
using namespace std;

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

	int K;
	cin >> K;

	int J[1001][1001];
	int O[1001][1001];
	for(int y=0; y<=M; y++){
		J[y][0] = 0;
		O[y][0] = 0;
	}
	for(int x=0; x<=N; x++){
		J[0][x] = 0;
		O[0][x] = 0;
	}

	for(int y=1; y<=M; y++){
		for(int x=1; x<=N; x++){
			char c;
			cin >> c;

			J[y][x] = J[y-1][x]+J[y][x-1]-J[y-1][x-1];
			O[y][x] = O[y-1][x]+O[y][x-1]-O[y-1][x-1];

			if(c=='J'){
				J[y][x]++;
			}
			else if(c=='O'){
				O[y][x]++;
			}
		}
	}

	for(int i=0; i<K; i++){
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		int cntJ = J[c][d]-J[a-1][d]-J[c][b-1]+J[a-1][b-1];
		int cntO = O[c][d]-O[a-1][d]-O[c][b-1]+O[a-1][b-1];
		int cntI = (c-a+1)*(d-b+1)-cntJ-cntO;

		cout << cntJ << ' ' << cntO << ' ' << cntI << endl;
	}

	return 0;
}

Measured memory_bytes: 8624
#include <stdio.h>

int main(void){
    long long int i, max, sum;
    scanf("%lld", &max);

    sum = 0;

    for(i = 1; i <= max; i++){
        if((i % 3 == 0) && (i % 5 == 0)){
            
        }

        else if(i % 3 == 0){
            
        }

        else if(i % 5 == 0){
            
        }

        else sum += i;
    }

    printf("%lld\n", sum);

    return 0;

}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include "boost/multiprecision/cpp_int.hpp"

int main() {


	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int N, K; std::cin >> N >> K;
	std::string S; std::cin >> S;

	if (S[K-1] == 'A')S[K-1] = 'a';
	if (S[K-1] == 'B')S[K-1] = 'b';
	if (S[K-1] == 'C')S[K-1] = 'c';


	std::cout << S;


	return 0;
}


Measured memory_bytes: 256
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID
/*#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<=n;i++)
#define FORd(n) for(ll i=n;i>=0;i--)
#define FORrd(a,b) for(ll i=a;i>=b;i--)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ff first
#define ss second
#define w(t) ll t;cin>>t;while(t--)

int main()
{
    FIO;
    ll n,m=0;
    cin>>n;
    map<string,ll> mp;
    set<string> ans,aux;
    FOR(n-1)
    {
        string s;
        cin>>s;
        mp[s]++;
        m=max(m,mp[s]);
        aux.insert(s);
    }
    for(auto it:mp)
    {
        if(it.ss==m)
            ans.insert(it.ff);
    }
    for(auto it:ans)
    {
        cout<<it<<'\n';
    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

int main(){
    string s,t;
    cin >> s >> t;
    if(s.at(0)==t.at(2)&&s.at(1)==t.at(1)&&s.at(2)==t.at(0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

uint64_t solve(uint64_t n, uint64_t k) {
        uint64_t r = n % k;
        uint64_t p = k - r;
        if (p < r) {
                return p;
        } else {
                return r;
        }
}

int main() {
        uint64_t n, k;

        if (scanf("%19lu %19lu", &n, &k) == 0) {
                perror("scanf");
                return 1;
        }

        printf("%-19lu\n", solve(n, k));

        return 0;
}


Measured memory_bytes: 128
#[test]
fn test_solve() {
    assert_eq!(solve("3\n1\n2 1\n1\n1 1\n1\n2 0\n"), "2\n");
    assert_eq!(solve("3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n"), "0\n");
    assert_eq!(solve("2\n1\n2 0\n1\n1 0\n"), "1\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let xys: Vec<Vec<(usize, usize)>> = (0..n)
        .map(|_| {
            let a: usize = sc.read();
            (0..a).map(|_| (sc.read(), sc.read())).collect()
        })
        .collect();

    let mut ans = 0;
    'lp: for stt in 0..(1 << n) {
        let mut scr = 0;
        for p in 0..n {
            if stt & (1 << p) != 0 {
                scr += 1;
                for &(x, y) in &xys[p] {
                    match y {
                        0 => if stt & (1<<(x-1)) != 0 {
                            continue 'lp;
                        },
                        1 => if stt & (1<<(x-1)) == 0 {
                            continue 'lp;
                        },
                        _ => unreachable!()
                    }
                }
            }
        }
        ans = std::cmp::max(ans, scr);
    }

    format!("{}\n", ans)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

bool isPal(string &s){
    deque<char> d;
    for(unsigned i=0;i<s.length();i++)
        d.push_back(s[i]);
    while(d.size() > 1){
        if(d.front() != d.back())
            return false;
        else{
            d.pop_back();
            d.pop_front();
        }
    }
    return true;
}

int main(){
    string s;
    getline(cin,s);
    unsigned n=s.length();
    string sf {s,0,(n-1)/2}, sb {s,(n+1)/2};
    if(isPal(s) && isPal(sf) && isPal(sb))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

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 n,k,ans=0;
    cin >> n >> k;
    vector<int> s(n);
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int e;
            cin >> e;
            s[e-1]++;
        }
    }
    rep(i,s.size()){
        if(s[i]==0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int A,B;
    cin >> A >> B;
    
    if(A+B<10){
        cout << A+B << endl;
    }else{
        cout << "error" << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}


int g[1000010];

vector<int> c[1000010];

int cc[1000100];

void solve(long long N, std::vector<long long> A) {
    for (int i = 0; i <= 1000000; i++)
        g[i] = i;
    for (int i = 2; i <= 1000000; i++) {
        if( c[i].size() == 0 ) {
            for (int j = i; j <= 1000000; j += i) {
                if (g[j] % i == 0) {
                    c[j].push_back(i);
                    while (g[j] % i == 0) {
                        g[j] /= i;
                    }
                }
            }
        }
    }

    int g = A[0];
    for (auto a : A) {
        g = __gcd<int>(g, a);
        for (auto b : c[a]) {
            cc[b]++;
        }
    }
    bool pairwise = true;


    for (int i = 0; i <= 1000000; i++) {
        if (cc[i] > 1) {
            pairwise = false;
        }
    }
    if(pairwise){
        cout << "pairwise coprime" << endl;
        return;
    }
    if(g == 1 ){
        cout << "setwise coprime" << endl;
        return;
    }
    cout << "not coprime" << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    ve<ve<int>> s0(10);
    rep(i,n){
        rep(j,10){
            if(s[i]-'0' == j){
                s0[j].push_back(i);
                break;
            }
        }
    }
    ll ans = 0;
    rep(i,1000){
        int a,b,c,num=i;
        a = num/100;
        num %= 100;
        b = num/10;
        c = num%10;
        auto ita = upper_bound(s0[a].begin(), s0[a].end(),-1);
        if(ita == s0[a].end())continue;
        auto itb = upper_bound(s0[b].begin(), s0[b].end(),*ita);
        if(itb == s0[b].end())continue;
        auto itc = upper_bound(s0[c].begin(), s0[c].end(),*itb);
        if(itc != s0[c].end()) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512