akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N],y[M];
    rep(i,N) cin >> x[i];
    rep(i,M) cin >> y[i];
    int xmax=*max_element(x,x+N);
    int ymin=*min_element(y,y+M);
    bool ans=false;
    for(int i=xmax+1;i<=ymin;i++) if(i>X && i<=Y) ans=true;
    if(ans) cout << "No War" << endl;
    else cout << "War" << endl; 
}

Measured memory_bytes: 256
n, m, c = (int(i) for i in input().split())
B = [int(i) for i in input().split()]
calc = 0
ans = 0
for i in range(n):
    A = [int(i) for i in input().split()]
    calc = 0
    for j in range(m):
        calc +=  A[j] * B[j]
    if 0 < calc + c:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
dict=Hash.new(0)
N.times do|i|
    s=get_nsp.sort.join("")
  dict[s]+=1
end
ans=0
dict.each do|k,v|
    ans+=v*(v-1)/2
end
puts ans

Measured memory_bytes: 18172
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) cout << c << endl;
  else if(a == c) cout << b << endl;
  else cout << a << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>

int Mod(int L, int R){
  int i, j, n;
  if(R - L >= 2019 || L % 2019 > R % 2019) return 0;
  n = 2019;
  for(i = L % 2019;i < R % 2019;i++){
    for(j = (i + 1) % 2019;j <= R % 2019;j++){
      if(n > i * j % 2019) n = i * j % 2019;
      if(n == 0) break;
    }
  }
  return n;
}  

int main(void){
  int L, R;
  scanf("%d %d", &L, &R);
  printf("%d\n", Mod(L, R));
  return 0;
}


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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;



int solve() {
    string s;
    int q;
    cin >> s >> q;
    int cnt = 0;
    while(q--) {
        int ck; Int(ck);
        if(ck == 1) cnt ^= 1;
        else {
            char c;
            cin >> ck >> c;
            if(ck == 1) {
                if(cnt == 0) {
                   s.insert(s.begin(), c);
                }
                else {
                    s.push_back(c);
                }
            }
            else {
                if(cnt == 1) {
                   s.insert(s.begin(), c);
                }
                else {
                    s.push_back(c);
                }
            }
        } 
    }
    if(cnt) reverse(all(s));
    cout << s << endl;
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    int X[100100];
    int ans[100100];
    cin >> N;
    REP(i,N) cin >> X[i];
    REP(i,N){
        ans[X[i]-1] = i+1;
    }
    REP(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        ll A, B, N;
        cin >>A >>B >>N;
        if (N>=B-1)
                cout <<(A*(B-1))/B <<endl;
        else
                cout <<(A*N)/B <<endl;
        return 0;
}


Measured memory_bytes: 3636
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	aa := make([]AA, n)
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		aa[i].a = a
		aa[i].x = make([]int, a)
		aa[i].y = make([]int, a)
		for j := 0; j < a; j++ {
			aa[i].x[j] = getNextInt(scanner) - 1
			aa[i].y[j] = getNextInt(scanner)
		}
	}

	ans := 0
	for i := 0; i < 1<<uint(n); i++ {
		sum := 0
		valid := true
		for j := 0; j < n && valid; j++ {
			for k := 0; k < aa[j].a && valid; k++ {
				if i>>uint(j)&1 == 1 {
					if i>>uint(aa[j].x[k])&1 != aa[j].y[k] {
						valid = false
					}
					continue
				}

			}
			sum += i >> uint(j) & 1
		}
		if valid && ans < sum {
			ans = sum
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type AA struct {
	a    int
	x, y []int
}


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


int main(){
    int zeikomi,zeinuki,kenzan1,kenzan2;
    cin >> zeikomi;
    zeinuki = zeikomi / 1.08;
    kenzan1 = zeinuki * 1.08;
    kenzan2 = (zeinuki + 1) * 1.08;
    if(kenzan1 == zeikomi){
        cout << zeinuki;
    }
    else if (kenzan2 == zeikomi)
    {
        cout << (zeinuki+1);
    }
    
    else
    {
        cout << ":(";
    }
    
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline

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

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

AA = sorted(A[1:])
#print(AA)

if N % 2 == 0:
    b = AA[N//2 - 1]
else:
    b = AA[(N-1)//2]

ans = 0
for i in range(N):
    ans += abs(AA[i]-b)

print(ans)

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

using namespace std;

long long mem[3005][3005][2];
int n;
int arr[3005];

long long go(int x,int y,int p)
{
	if(x>y) return 0;
	if(mem[x][y][p]!=-1) return mem[x][y][p];
	if(p==0) return mem[x][y][p]=max(arr[x]+go(x+1,y,1),arr[y]+go(x,y-1,1));
	return mem[x][y][p]=min(go(x+1,y,0),go(x,y-1,0));
}

int main()
{
	cin >> n;
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
		sum+=arr[i];
	}
	memset(mem,-1,sizeof mem);
	long long x=go(0,n-1,0);
	cout << x-(sum-x) << endl;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pipipii = pair<ll, pair<int, pii>>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    vector<int> a(3);
    for(int i = 0; i < 3; ++i){
        cin >> a[i];
    }
    sort(begin(a), end(a));
    cout << a[0] << " " << a[1] << " " << a[2] << "\n";
    return 0;
}


Measured memory_bytes: 3220
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
#define FAST_IO {ios::sync_with_stdio(0);cin.tie(0);}
using namespace std;
signed main() {
  int A, B; cin >> A >> B;
  if (A > B*2) {
    cout << A-B*2 << endl;
  } else {
    cout << 0 << endl;
  }    
}



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

int main(void){

	int stairs[32],years[32];

	stairs[0]=1;
	stairs[1]=1;
	stairs[2]=stairs[0]+stairs[1];
	years[0]=1;
	years[1]=1;
	years[2]=1;

	int maxi=2;

	int input;
	cin >> input;

	while(input){
		if(input>maxi){
			while(maxi<input){
				maxi++;
				stairs[maxi]=stairs[maxi-1]+stairs[maxi-2]+stairs[maxi-3];
				years[maxi]=stairs[maxi]/3650;
				if(stairs[maxi]%3650)
					years[maxi]++;
			}
			cout << years[input] << endl;
		}else{
			cout << years[input] <<endl;
		}
		cin >> input;
	}

	return 0;

}



Measured memory_bytes: 3080
from collections import deque

class Node():
    def __init__(self, name, cost):
        self.name = name
        self.cost = int(cost)

n, p = map(int,input().split(" "))
nodes = deque([])

for i in range(n):
    tmp = list(input().split(" "))
    nodes.append(Node(tmp[0],tmp[1]))

time = 0
while not len(nodes) == 0:
    node = nodes.popleft()
    if node.cost > p:
        node.cost -= p
        nodes.append(node)
        time += p
    elif node.cost <= p:
        time += node.cost
        print(node.name + " " + str(time))



Measured memory_bytes: 17552
//AtCoder Beginner Contest 149
//C - Next Prime

#include <iostream>
#include <math.h> 

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0) return false;
    }
    return true;
}

int main()
{
    int x;

    cin >> x;

    while(IsPrime(x) == false){
        x++;
    }
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int c=a+b;
    int d=a*b;
    int e=a-b;
    int g=max(c,d);
    printf("%d\n",max(g,e));
    return 0;
}


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

int main()
{
	int i,N; cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++) {
		cin >> T.at(i);
	}
	int M; cin >> M;
	vector<int> P(M);
	vector<int> X(M);
	for (i = 0; i < M; i++) {
		cin >> P.at(i) >> X.at(i);
	}

	int sum = 0;
	vector<int> T_P(M);
	for (int i = 0; i < N; i++) {
		sum += T.at(i);
	}

	for (int i = 0; i < M; i++) {
		T_P.at(i) = -T.at(P.at(i) - 1) + X.at(i);
	}

	for (i = 0; i < M; i++) {
		cout << sum + T_P.at(i) << endl;
	}
}


Measured memory_bytes: 256
import sys


N = int(sys.stdin.readline())


V = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(N):
    if V[i] - C[i] > 0:
       ans += V[i] - C[i]

print(ans)

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;


fn main() {
    let mut s:Vec<_> = read::<String>().chars().collect();
    let mut t:Vec<_> = read::<String>().chars().collect();

    s.sort();
    let s:String = s.into_iter().collect(); 
    let s = s.as_str();
    
    t.sort();
    t.reverse();
    let t: String = t.into_iter().collect();
    let t = t.as_str();

    let ans = if s < t {"Yes"} else {"No"};
    
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 100000

using namespace std;

const ll mod = 1000000007LL;
ll fct[maxn+5], v[maxn+5];

void mad (ll &a, ll b) { a = (a + b) % mod; }
void msb (ll &a, ll b) { a = (a - b + mod) % mod; }
void mml (ll &a, ll b) { a = (a*b) % mod; }

ll lgput (ll a, int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  ll c = lgput (a, b/2); mml(c,c);
  if (b % 2 == 1) mml(c,a);
  return c;
}

ll inv (ll x) { return lgput(x, mod-2); }

ll comb (int n, int k) {
  ll ans = fct[n];
  mml(ans, inv(fct[k]));
  mml(ans, inv(fct[n-k]));
  return ans;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, k; cin >> n >> k;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  for (fct[0] = 1, i = 1; i <= n; i++) fct[i] = (fct[i-1] * i) % mod;
  sort(v+1, v+n+1);
  ll ans = 0;
  for (i = k; i <= n; i++) mad(ans, v[i]*comb(i-1, k-1)%mod);
  for (i = n-k+1; i > 0; i--) msb(ans, v[i]*comb(n-i, k-1)%mod);
  cout << ans;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	size_t n = s.size();
	string s1 = s.substr(0, (n-1)/2);
	string s2 = s.substr(((n+3)/2-1), (n-(n+3/2)));
	bool f = true;
	for(int i=0;i<s.size();i++){
		if(s[i] != s[s.size()-i-1]){
			f = false;
		}
	}for(int i=0;i<s1.size();i++){
		if(s1[i] != s1[s1.size()-i-1]){
			f = false;
		}
	}for(int i=0;i<s2.size();i++){
		if(s2[i] != s2[s2.size()-i-1]){
			f = false;
		}
	}
	if(f){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
string s;
int f[310000][3][3],n;
inline int Mod(int u){return u < MOD?u:u-MOD;}
int main()
{
	cin >> s,n = s.size();
	f[0][0][0] = 1;
	for(int i = 1;i<=n;++i)
	{
		if(s[i-1] != '1')
		{
			f[i][0][1] = Mod(f[i-1][0][0]+f[i-1][0][2]),f[i][0][2] = f[i-1][0][1];
			f[i][1][1] = Mod(f[i-1][1][0]+f[i-1][1][2]),f[i][1][2] = f[i-1][1][1];
			f[i][2][1] = Mod(f[i-1][2][0]+f[i-1][2][2]),f[i][2][2] = f[i-1][2][1];
		}
		if(s[i-1] != '0')
		{
			f[i][0][0] = f[i-1][0][1],f[i][1][0] = Mod(f[i-1][0][0] + f[i-1][1][1]);
			f[i][2][0] = Mod(Mod(f[i-1][1][0]+f[i-1][2][0])+f[i-1][2][1]);
			f[i][0][1] = Mod(f[i][0][1] + f[i-1][0][2]);
			f[i][1][1] = Mod(f[i-1][1][2] + f[i][1][1]);
			f[i][2][1] = Mod(f[i-1][2][2] + f[i][2][1]);
		}
	}
	printf("%d\n",Mod(Mod(Mod(Mod(f[n][0][0]+f[n][1][0])+f[n][2][0])+Mod(f[n][1][1] + f[n][2][1]))+f[n][2][2]));
	return 0;
}

Measured memory_bytes: 11268
#include<bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int N = 1e6 + 6;

int answer[N];
int vis[N];
vector<int>gr[N];
int n,m;


void BFS(){

        queue<int>q;
        q.push(1);
        vis[1] = 1;
        while(q.size()){
                int x = q.front();
                q.pop();
                for(auto to : gr[x]){
                        if(!vis[to]){
                                answer[to] = x;
                                vis[to] = 1;
                                q.push(to);
                        }
                }
        }
}

int main(){
        ios::sync_with_stdio(0); //cin.tie(0); cout.tie(0);
        cin >> n >> m;
        for(int i = 1; i <= m; i++){
                int x , y;
                cin >> x >> y;
                gr[x].pb(y);
                gr[y].pb(x);
        }

        BFS();

        for(int i = 1; i <= n; i++){
                if(!vis[1]){
                        cout << "No" << endl;
                        return 0;
                }
        }

        cout << "Yes" << endl;
        for(int i = 2; i <=n; i++) cout << answer[i] << " ";
}


Measured memory_bytes: 32064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;cin>>n>>m;
	int i=2*n;
	if(n%m==0)
	{
		cout<<-1<<endl;
		return 0;
	}
	while(i%m==0)
		i+=n;
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n, times=0;
  cin >> n;
  int A[n];
  for(int i = 0; i<n; i++){
    cin >> A[i];
  }
  //???????????????
  int minj;

  for(int i = 0; i<n; i++){
    minj = i;
    for(int j = i; j<n; j++){
      if(A[j] < A[minj]){
        minj = j;
            }
    }
    if(i != minj){
    swap(A[i],A[minj]);
    times++;
    }
  }

  for(int i = 0; i<n-1; i++){
    cout << A[i] << " ";
  }
  cout << A[n-1] << endl;
  cout << times << endl;
}

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

bool isMonth(int x) {
	if(x < 1)  return false;
	if(x > 12) return false;
	return true;
}

int main() {
	int s;
	int ab, cd;
	
	cin >> s;
	
	ab = floor(s / 100);
	cd = s - ab * 100;
	
	string ans = "";
	
	if(isMonth(ab)) {
		if(isMonth(cd)) { ans = "AMBIGUOUS"; }
		else { ans = "MMYY"; }
	} else {
		if(isMonth(cd)) { ans = "YYMM"; }
		else { ans = "NA"; }
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
l_l get_inp(){
    string s;cin>>s;
    ll now=0;
    ll a=0,b=0;
    bool up=false;
    ll n=sz(s);
    rep(i,n){
        if(s[i]=='.')up=true;
        else{
            now*=10;
            now+=s[i]-'0';
            if(up)a--,b--;
        }
    }
    while(now%2==0)now/=2,a++;
    while(now%5==0)now/=5,b++;
    return l_l(a,b);
}
int main(){
    ll n;cin>>n;
    map<l_l,ll> mp;
    rep(i,n){
        l_l p=get_inp();
        mp[p]++;
    }
    ll ans=0;
    for(auto it=mp.begin();it!=mp.end();it++){
        l_l p=it->fi;
        if(p.fi>=0&&p.se>=0)ans+=(ll)it->se*(it->se-1)/2;
        auto its=it;
        while(1){
            its++;
            if(its==mp.end())break;
            l_l q=its->fi;
            if(p.fi+q.fi>=0&&p.se+q.se>=0)ans+=(ll)it->se*its->se;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    ll res = n-1;
    reps(i, 2, n) {
        res += (n-1) / i;
    }
    cout << res << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

int main()
{
	int a, b, c;
	int temp;

	scanf("%d %d %d", &a, &b, &c);

	temp = a;
	a = b;
	b = temp;
	temp = a;
	a = c;
	c = temp;

	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T> T gcd(T a, T b){a = abs(a); b = abs(b); if(a<b) swap(a,b); while(b>0){a %= b; swap(a,b);} return a;}
template <typename T> T lcm(T a, T b){return (1LL * a * b) / gcd(a,b);}
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}
template <typename T> bool isSquare(T n){T rt = sqrt(n); return rt*rt == n;}

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

  int n; cin >> n;

  if(!isSquare(1+8*n)){
    cout << "No" << endl;
    return 0;
  }

  int k = ((int)sqrt(1+8*n)+1)/2;

  cout << "Yes" << endl;
  cout << k << endl;

  vector<vector<int>> s(k);

  int t = 1;
  
  FOR(i,0,k){
    FOR(j,t,t+k-1-i){
      s[i].push_back(j);
    }
    FOR(j,0,k-1-i){
      s[i+j+1].push_back(t+j);
    }

    t += k-1-i;
  }
  
  REP(i,k){
    cout << k-1 << " ";
    REP(j,s[i].size()){
      if(j!=0) cout << " ";
      cout << s[i][j];
    }
    cout << endl;
  }
  

  
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, t;
    cin >> n >> t;
    int A[n];
    int mn = 1 << 30;
    int dif = 0;
    int count = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        mn = min(mn, A[i]);
        if (A[i] - mn > dif) {
            dif = A[i] - mn;
            count = 1;
        } else if (A[i] - mn == dif) {
            count++;
        }
    }

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

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

int cnt=0;

void merge(int a[],int l,int m,int r){
	int n1=m-l;
	int n2=r-m;
	vector<int> L;
	vector<int> R;
	int i,j;
	for(i=0;i<n1;i++){L.push_back(a[l+i]);}
	for(i=0;i<n2;i++){R.push_back(a[m+i]);}
	L.push_back(1<<30);
	R.push_back(1<<30);
	i=j=0;
	for(int k=l;k<r;k++){
		if(L[i]<=R[j]){
			a[k]=L[i++];
		}else{
			a[k]=R[j++];
		}
		cnt++;
	}
}

void mergeSort(int a[], int l, int r){
	if(l+1<r){
		int mid=l+(r-l)/2;
		mergeSort(a,l,mid);
		mergeSort(a,mid,r);
		merge(a,l,mid,r);
	}
}

int main(){
	int n, a[500000];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	mergeSort(a,0,n);
	cout << a[0];
	for(int i=1;i<n;i++){
		cout << " " << a[i];
	}
	cout << endl;
	cout << cnt << endl;
	return 0;
}



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

int main(){
  int N;cin>>N;
  vector<string> name(N);
  for(int i=0;i<N;i++) cin>>name.at(i);
  sort(name.begin(),name.end());
  vector<long> count(5,0);
  for(int i=0;i<N;i++){
    //if(i>0 && name.at(i-1)==name.at(i)) continue;
    if(name.at(i).at(0)=='M') count.at(0)++;
    if(name.at(i).at(0)=='A') count.at(1)++;
    if(name.at(i).at(0)=='R') count.at(2)++;
    if(name.at(i).at(0)=='C') count.at(3)++;
    if(name.at(i).at(0)=='H') count.at(4)++;
  }
  long ans=0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        ans+=count.at(i)*count.at(j)*count.at(k);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6436
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    double a,b,x;
    cin >> a >> b >> x;
    
    if(x>=a*a*b/2.0){
        double ans = atan((2*b*a*a - 2*x)/a/a/a) / M_PI * 180.0;
        cout<<fixed<<setprecision(10)<<ans<<endl;
    }else{
        double ans = atan(b*b*a/x/2.0) / M_PI * 180.0;
        cout<<fixed<<setprecision(10)<<ans<<endl;
    }
    return 0;
}


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

#define int long long

using pii = pair<int, int>;
int ans[111111];

int N;

const int maxV = 111111;
vector<pii> G[maxV]; // 頂点情報のみのグラフ

// 木のDFS
void treeDFS(int from, int current, int dist) {
  if (dist % 2 == 1) {
    ans[current] = 1;
  }

  for (auto p : G[current]) {
    int to = p.first;
    int d = p.second;
    // 逆流を防ぐ
    if (to == from) continue;
    treeDFS(current, to, dist + d);
  }
}

// 木のDFSを呼び出す関数
void searchTree() {
  int root = 0; // 根
  int from = -1; // 根の親。根の親はないので-1を指定する
  treeDFS(from, root, 0);
}

signed main() {
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }

  searchTree();

  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 10496
def main():
    n, x, m = map(int, input().split())
    n_copy = n

    sum_a = x
    rem = [None] * m
    n -= 1
    rem[x] = (x, n)
    while n > 0:
        x = x * x % m
        sum_a += x
        n -= 1
        if rem[x] is None:
            rem[x] = (sum_a, n)
        else:
            unit = rem[x][1] - n
            unit_sum = sum_a - rem[x][0]
            ans = sum_a + (n // unit) * unit_sum
            n = n % unit
            while n > 0:
                x = x * x % m
                ans += x
                n -= 1
            print(ans)
            exit()


    print(sum_a)

main()

Measured memory_bytes: 65620
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    short n,m;
    cin>>n>>m;
    string a[n],b[m],ans="Yes";
    bool f=0;
    for (int i = 0; i < n; i++)cin>>a[i];
    for (int i = 0; i < m; i++)cin>>b[i];
    for (int k = 0; k < n-m+1; k++){
        for (int l = 0; l < n-m+1; l++){
            bool f1=1;
            for (int i = 0; i < m; i++){
                for (int j = 0; j < m; j++){
                   if(b[i][j]!=a[i+k][j+l])f1=0;
                }
            }
            f|=f1;
        }
    }
    cout<<(f?"Yes":"No")<<'\n';
}

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

int main(void) {
    int A,B;cin>>A>>B;
    if (A == B) {
        cout << "Draw" << endl;
        return 0;
    }
    if (A > B) {
        if (B == 1) cout << "Bob" << endl;
        else cout << "Alice" << endl;
    } else {
        if (A == 1) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: i64,
        b: i64,
        c: i64,
        s: [String; n],
    }
    let result = greedy(&s, Variable::new(a, b, c));
    if result.len() < n {
        println!("No");
    } else {
        println!("Yes");
        for chosen in result {
            println!("{}", chosen);
        }
    }
}

struct Variable {
    a: i64,
    b: i64,
    c: i64,
}
impl Variable {
    fn new(a: i64, b: i64, c: i64) -> Self {
        Self { a, b, c }
    }

    fn valid(choose: i64) -> i64 {
        if choose < 0 {
            -1
        } else {
            1
        }
    }

    fn alive(&self) -> bool {
        !(self.a < 0 || self.b < 0 || self.c < 0)
    }

    fn choice(&self, selectable: &String, choose: i64) -> Self {
        match &selectable[..] {
            "AB" => self.choice_ab(Self::valid(choose)),
            "AC" => self.choice_ac(Self::valid(choose)),
            "BC" => self.choice_bc(Self::valid(choose)),
            _ => unreachable!(),
        }
    }

    fn choice_ab(&self, choose: i64) -> Self {
        Self::new(self.a + choose, self.b - choose, self.c)
    }

    fn choice_ac(&self, choose: i64) -> Self {
        Self::new(self.a + choose, self.b, self.c - choose)
    }

    fn choice_bc(&self, choose: i64) -> Self {
        Self::new(self.a, self.b + choose, self.c - choose)
    }

    fn choices(&self, selectable: &String) -> (Self, Self) {
        (self.choice(selectable, 1), self.choice(selectable, -1))
    }
}

fn greedy(s: &Vec<String>, variable: Variable) -> Vec<char> {
    let (mut selected, mut variable) = (Vec::new(), variable);
    for sns in s.windows(2) {
        let (s, ns) = (sns.first().unwrap(), sns.last().unwrap());
        let (choice01, choice10) = variable.choices(&s);
        let next01 = choice01.choices(&ns);
        let next10 = choice10.choices(&ns);
        if choice01.alive() && (next01.0.alive() || next01.1.alive()) {
            selected.push(s.chars().nth(0).unwrap());
            variable = choice01;
        } else if choice10.alive() && (next10.0.alive() || next10.1.alive()) {
            selected.push(s.chars().nth(1).unwrap());
            variable = choice10
        } else {
            return selected;
        };
    }
    let last = s.last().unwrap();
    let end = variable.choices(last);
    if end.0.alive() {
        selected.push(last.chars().nth(0).unwrap());
    } else if end.1.alive() {
        selected.push(last.chars().nth(1).unwrap());
    };
    selected
}


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

int main()
{
	int view = 0;
	int max_current = 0;
	
	int N;
	cin >> N;
	
	int H;
	for (int i = 0; i < N; i++) {
		cin >> H;
		if (max_current <= H){
			max_current = H;
			view++;
		}
	}
	
	cout << view << endl;
	
	return 0;
}

Measured memory_bytes: 256
a = int(input())

res = ''

i = 1
while True:
    x = i
    if x % 3 == 0:
        res += " " + str(i)
    else:
        while True:
            if x % 10 == 3:
                res += " " + str(i)
                break
            x = x // 10
            if x == 0:
                break
    i += 1
    if i > a:
        break

print(res)



Measured memory_bytes: 5628
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long int
using namespace std;

int main(void) {
  int n;
  cin >> n;
  double sum, a[n];
  
  rep(i, n) {
    cin >> a[i];
    sum += 1/a[i];
  }
  
  printf("%f\n", 1/sum);
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		WriteLine(GetString().Replace("?", "D"));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 29056
def main():
    n, k = [int(v) for v in input().strip().split(' ')]
    lst_is_possession = [False for _ in range(n)]

    for _ in range(k):
        _ = input()
        lst_possession_peple = [int(v) - 1 for v in input().strip().split(' ')]
        for p in lst_possession_peple:
            lst_is_possession[p] = True
    ans = n - sum(lst_is_possession)
    print(int(ans))


if __name__ == '__main__':
    main()


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

int main(){
    long long n, x;
    cin >> n>> x;
    long long ans = 0 ;
    for(int i = 1 ;i <=n ; i++){
        long long  z ;
        cin >> z;
        ans = __gcd(ans,abs(z-x));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)

const int N = 5e5 + 7;
const ll mod = 1e9 + 7;

int diff(string s, string t) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += s[i] != t[i];
	}
	return cnt;
}


int main() {
	fastIO;
	string s;
	cin >> s;
	string x, y;
	bool b = 0;
	for (int i = 0; i < s.size(); i++) {
		x += '0' + b;
		y += '0' + !b;
		b = !b;
	}
	cout << min(diff(s, x), diff(s, y));
}


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

int main(){
  vector<int> data(5);
  int k;
  for(int i=0; i<5; ++i) {
    int j;
    cin >> j;
    data[i] = j;
  }
  cin >> k;
  
  for(int i=0; i<5; ++i) {
    for(int j=i+1; j<5; ++j) {
      if(data[j] - data[i] > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    string = list(input())
    #1文字ずつ配列に入ってる
    if "-" in string:
        break

    shuffle = int(input())
    for i in range(shuffle):
        h = int(input())
        for j in range(h):
            string.append(string[0])
            del string[0]
    for i in range(len(string)):
        if i != len(string)-1:
            print(string[i],end="")
        else:
            print(string[i])



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    vi A(N);
    in(N,A);
    map<int,int> B;
    rep(i,N) B[i-A[i]]++;
    
    ll ans = 0;
    rep(i,N) ans += (ll)B[i+A[i]];
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 21036
s=list(
  map(
    int, input().split())
  )
x1=s[0]
y1=s[1]
x2=s[2]
y2=s[3]
x3=x2+y1-y2
y3=y2-x1+x2
x4=x1+y1-y2
y4=y1-x1+x2
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
import math
n = int(input())
a = list(map(int,input().split(" ")))
pts = [0]*10
for p in a:
	ca = int(math.floor(p/400))
	if ca>7:
		ca = 8
	pts[ca] +=1
	
min = 0
for p in pts:
	if p>0:
		min+=1

if pts[8]>0:
	if min>1:
		min -=1
		max = min + pts[8]
	else:
		max = pts[8]
else:
	max = min


print(str(min)+" "+str(max))

Measured memory_bytes: 3064
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  13 - 6 - 2020 +   13 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int, int>
#define pb push_back
#define pi acos(-1.0)
#define eps 1e-12
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int rust;
    scanf("%d", &rust);
    double perl = 2 * rust;
    double ocaml = perl * pi;
    cout<<ocaml<<"\n";
    return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a;
  load(a, n);

  int count = 0;
  rep(i, n) {
    int day = 1;
    while (true) {
      if (day <= d) {
        day += a[i];
        count++;
      } else {
        break;
      }
    }
  }
  count += x;
  p(count);
}

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

int main(){
  vector<char> s;
  string S;
  cin >> S;
  int n = S.size(),prenum = 1;
  for(int i = 0;i < n;i++){
    s.push_back(S.at(i));
  }
  int i = 1,ans = 1;
  while(i < n){
    if(prenum == 1){
      if(s.at(i-1) == s.at(i)){
        if(i == n-1) break;
        ans++;
        prenum = 2;;
        i += 2;
      }
      else{
        ans++;
        prenum = 1;
        i++;
      }
    }
    else{
      ans++;
      prenum = 1;
      i++;
    }
  }
  cout << ans << endl;
}    

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

using namespace std;

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 1e5 + 10;

int n, a[N], b[N];

int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = n; i >= 1; i--) {
    int p = 0;
    for (int j = i; j >= 1; j--) {
      if (a[j] == j) {
        p = j;
        break;
      }
    }
    if (!p) {
      puts("-1");
      return 0;
    }
    b[i] = p;
    for (int j = p; j < i; j++) {
      a[j] = a[j + 1];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", b[i]);
  return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> vec(1, 1000), v2(1, 1000);
  for (int i = 0; i < N; i++ ) {
    if (L + i < 0) {
      vec.push_back(- (L + i));
    }
    else {
      v2.push_back (L + i);
    }
  }
  sort(vec.begin(), vec.end());
  sort(v2.begin(), v2.end());
  int x = vec.at(0);
  int y = v2.at(0);
  if (x < y) {
    cout << N * (L - 1) + N * (N + 1) / 2 + x << endl;
  }
  else { 
    
    cout << N * (L - 1) + N * (N + 1) / 2 - y << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    int v[3];
    cin >> v[0] >> v[1] >> v[2];
    for (int i = 0; i < 3;i++) {
        if (v[0] > v[1]) {
            swap(v[0], v[1]);
        }
        if (v[1] > v[2]) {
            swap(v[1], v[2]);
        }
    }
    cout << v[0] <<" "<< v[1] <<" "<< v[2] << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  
  vl vec(a[n-1]+1);
  rep(i, n) {
    if(vec[a[i]]>=2) continue;
    rep2(j, a[n-1]/a[i]) vec[a[i]*j]++;
  }
  
  ll ans=0;
  rep(i, n) if(vec[a[i]]==1) ans++;
  cout << ans << newl;
  return 0;
}


Measured memory_bytes: 12576
A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mi = min(a) + min(b)

for i in range(M):
  c1, c2, c3 = [int(j) for j in input().split()]
  m =  a[c1-1] + b[c2-1] - c3
  if mi > m:
    mi = m

print(mi)

Measured memory_bytes: 18500
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,k;
ll mp[3005][3005];
ll dp[3005][3005][4];
ll dfs(int i,int j,int t)
{
    if(i<1||i>n||j<1||j>m||t>3) return -1e18;
    if(dp[i][j][t]!=-1) return dp[i][j][t];
   // printf("//%d %d %d\n",i,j,t);
    if(i==n&&j==m)
    {
        if(t<3) return mp[i][j];
        return 0;
    }
    ll ans=0;
    ans=max(ans,max(dfs(i+1,j,0),dfs(i,j+1,t)));
    ans=max(ans,mp[i][j]+dfs(i,j+1,t+1));
    if(t<3) ans=max(ans,mp[i][j]+dfs(i+1,j,0));

    return dp[i][j][t]=ans;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    scanf("%d%d%d",&n,&m,&k);
    while(k--)
    {
        int x,y,v;
        scanf("%d%d%d",&x,&y,&v);
        mp[x][y]=v;
    }
    printf("%lld\n",dfs(1,1,0));
//    for(int k=0;k<=3;k++)
//    {
//        printf("k=%d\n",k);
//        for(int i=1;i<=n;i++)
//        {
//            for(int j=1;j<=m;j++)
//                printf("%d ",dp[i][j][k]);
//                puts("");
//
//        }
//
//            puts("");
//
//    }
    return 0;
}
/*
1 4 4
1 1 1
1 2 2
1 3 3
1 4 4
*/


Measured memory_bytes: 357000