akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        int[] c = new int[m];
        int[][] dist = new int[n][n];

        for (int i = 0; i < n; i++) {
            Arrays.fill(dist[i], 100000000);
            dist[i][i] = 0;
        }

        for (int i = 0; i < m; i++) {
            a[i] = scanner.nextInt() - 1;
            b[i] = scanner.nextInt() - 1;
            c[i] = scanner.nextInt();

            dist[a[i]][b[i]] = Math.min(dist[a[i]][b[i]], c[i]);
            dist[b[i]][a[i]] = Math.min(dist[b[i]][a[i]], c[i]);
        }

        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dist[j][k] = Math.min(dist[j][k], dist[j][i] + dist[i][k]);

        int ans = m;
        for (int i = 0; i < m; i++) {
            boolean shortest = false;
            for (int j = 0; j < n; j++)
                if (dist[j][a[i]] + c[i] == dist[j][b[i]])
                    shortest = true;
            if (shortest)
                ans--;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26188
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(sx: int, sy: int, tx: int, ty: int):
    ret = ''
    ret += 'U' * (ty - sy)
    ret += 'R' * (tx - sx)
    ret += 'D' * (ty - sy)
    ret += 'L' * (tx - sx + 1)
    ret += 'U' * (ty - sy + 1)
    ret += 'R' * (tx - sx + 1)
    ret += 'D'
    ret += 'R'
    ret += 'D' * (ty - sy + 1)
    ret += 'L' * (tx - sx + 1)
    ret += 'U'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    sx = int(next(tokens))  # type: int
    sy = int(next(tokens))  # type: int
    tx = int(next(tokens))  # type: int
    ty = int(next(tokens))  # type: int
    solve(sx, sy, tx, ty)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	mountains = []
	for i in range(10):
		mountains.append(int(input()))
	
	mountains = sorted(mountains, reverse = True)

	for i in range(3):
		print(mountains[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 7736
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        
        long a = -1000;
        long b = -1000;
        boolean hasFinished = false;
        for(a = -1000;a <= 1000;a++) {
            for(b = -1000;b <= 1000;b++) {
                if(((a * a * a * a * a) - (b * b * b * b * b)) == x) {
                    hasFinished = true;
                    break;
                }
            }
            if(hasFinished) break;
        }
    
        System.out.println(a + " " + b);
    }
    
}


Measured memory_bytes: 38980
#include<stdio.h>

int main(){
	
	int i,j;

	char S[5];
	char T[5];
	
	scanf("%s",S);
	scanf("%s",T);
	
	j=0;
	
	for(i=0;i<3;i++){
		
		if(S[i]==T[i]){
			
			j++;
			
		}
		
	}
	
	printf("%d\n",j);
	
return 0;

}

Measured memory_bytes: 128
(defun get-input-array (n)
  (let ((rst (make-array n)))
    (dotimes (i n)
      (setf (aref rst i) (read)))
    rst))

(defun main ()
  (let* ((input (get-input-array 4))
         (start-max (if (>= (aref input 0) (aref input 2))
                        (aref input 0)
                      (aref input 2)))
         (end-min (if (<= (aref input 1) (aref input 3))
                        (aref input 1)
                      (aref input 3)))
         (rst (- end-min start-max)))
    '(format t "~A ~A~%" start-max end-min)
    (if (>= rst 0)
        rst
      0)))

(format t "~A~%" (main))


Measured memory_bytes: 7780
use proconio::{fastout, input};

use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        n: usize,
        ss: [Chars; n],
    }
    let mut p = vec![];
    for s in ss {
        let mut r = 0;
        let mut m = 0;
        for c in s {
            match c {
                '(' => {
                    r -= 1;
                }
                ')' => {
                    r += 1;
                    if r > m {
                        m = r
                    }
                }
                _ => {}
            }
        }
        p.push((m, m - r));
    }
    let (mut first, mut second): (Vec<(i32, i32)>, Vec<(i32, i32)>) =
        p.iter().partition(|&(a, b)| b - a >= 0);
    first.sort_by_key(|&(a, _)| a);
    second.sort_by_key(|&(_, b)| std::cmp::Reverse(b));
    let mut r = 0;
    for &(a, b) in first.iter().chain(second.iter()) {
        r -= a;
        if r < 0 {
            println!("No");
            return;
        }
        r += b;
    }
    if r == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 58588
#include<stdio.h>
int main()
{

    int d;
    scanf("%d",&d);
    if(d==25)
        printf("Christmas\n");
    else if(d==24)
        printf("Christmas Eve\n");
    else if(d==23)
        printf("Christmas Eve Eve\n");
    else if(d==22)
        printf("Christmas Eve Eve Eve\n");
    return 0;

}

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	if(n%10 == 7 || (n/10)%10 == 7 || n/100 == 7){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

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

int main()
{
    int n,ans = 1;
    std::cin >> n;

    std::vector<int> h(n);

    for (int i = 0; i < n; i++)
        std::cin >> h[i];

    int max = h[0];

    for(int i=1;i<n;i++){
        if(h[i] >= max){
            ans++;
            max = h[i];
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,A=0,Z=0,ans;	
	char a[20];
	scanf("%s",a);
	for(i=0;i<20;i++){
		if(a[i]=='A'&&A==Z){A++;}
		if(a[i]=='Z'&&Z<A){Z++;}
	}
	ans=Z;
	if(ans==0){printf("-1\n");}
	else {
		for(i=0;i<ans;i++){
			printf("AZ");	
		}
		printf("\n");
	}		
	
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>

int main()

{
	int w, h, x, y, r, f;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	f = 0;
	if (x + r > w)f = 1;
	if (y + r > h)f = 1;
	if (r > x)f = 1;
	if (r > y)f = 1;

	if (f == 0)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1940
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int X,A,B;
   cin>>X>>A>>B;
   if(A>=B){cout<<"delicious"<<endl;}
   else if(B-A<=X){cout<<"safe"<<endl;}
   else{cout<<"dangerous"<<endl;}
return 0;}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int N,count=0;
  char pre = '0',cur = '0';
  cin >> N;
  REP(i,N){
    cin >> cur;
    if(pre != cur){
      count++;
    }
    pre = cur;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        int N;
        while ((N = int.Parse(Console.ReadLine())) != 0)
        {
            var otsuri = 1000 - N;
            var count = 0;
            var a = new[] { 500, 100, 50, 10, 5, 1 };
            foreach (var item in a)
            {
                var coin = otsuri / item;
                count += coin;
                otsuri -= coin * item;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13876
#include<bits/stdc++.h>
#define ll long long int
#define REP(i,a,b)  for(i=a;i<=b;i++)
#define REPr(i,a,b) for(i=b;i>=a;i--)
#define pi 3.14159265358979323846
#define pb push_back
#define umap(x,y) unordered_map<x,y>
#define f first
#define s second
using namespace std;

//intialization for a tree
vector<int> adj[100005];
bool visited[100005]={false};

void solve(){
    ll n,m,k;   cin>>n>>m>>k;
    vector<ll> A(n),B(m);
    ll i;
    REP(i,0,n-1)    cin>>A[i];
    REP(i,0,m-1)    cin>>B[i];
    vector<ll>  sumA(n+1),sumB(m+1);
    REP(i,0,n-1)    sumA[i+1]=sumA[i]+A[i];
    REP(i,0,m-1)    sumB[i+1]=sumB[i]+B[i];

    ll total=0;
    REP(i,0,n){
        ll other=k-sumA[i];
        if(other<0) continue;
        ll l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
        if(l>m || sumB[l]>other)    l--;
        total=max(total,i+l);
    } 
    cout<<total<<endl;
}

int main(){
    int t;
    t=1;

    while(t--){
        solve();
    }
}

Measured memory_bytes: 11976
#include <iostream>

int main() {
    int A, B, C, X;
    std::cin >> A >> B >> C >> X;

    auto result = 0;
    auto amount = 0;

    for (auto i = 0; i <= A; ++i) {
        amount = i * 500;

        if (amount == X) {
            ++result;
            break;
        }

        if (amount > X) {
            break;
        }

        for (auto j = 0; j <= B; ++j) {
            amount = i * 500 + j * 100;

            if (amount == X) {
                ++result;
                break;
            }

            if (amount > X) {
                break;
            }

            for (auto k = 0; k <= C; ++k) {
                amount = i * 500 + j * 100 + k * 50;
                if (amount == X) {
                    ++result;

                    break;
                }

                if (amount > X) {
                    break;
                }
            }
        }
    }

    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int[] l = in.nextIntArray(n);

        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    int[] lengths = new int[]{l[i], l[j], l[k]};
                    Arrays.sort(lengths);
                    if (lengths[0] == lengths[1] || lengths[1] == lengths[2] || lengths[0] == lengths[2]) continue;
                    if (lengths[0] + lengths[1] > lengths[2]) ans++;
                }
            }
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
    int n;cin >>n;
    string s;cin >>s;
    int k;cin >> k;
    k--;
    char t=s[k];
    rep(i,n){
        if(s[i]==t)cout <<t;
        else cout << "*" ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
// time sentou
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <complex>
#include <functional>
#include <utility>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000
//#define int long long int

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  LL n, t;
  cin >> n >> t;
  LL ans = 0;
  //ULL til = 0; 
  //ULL p;
  LL p1;
  scanf("%lld", &p1);
  ans += t;
  LL p2;
  REP(i, n-1) {
    scanf("%lld", &p2);
    ans += min(t, p2 - p1);
    p1 = p2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	int[] p;
	{
		Arrays.fill(p=new int[200000], -1);
	}
	
	int root(int x) {
		return p[x]<0?x:(p[x]=root(p[x]));
	}
	
	void unite(int x,int y) {
		x=root(x);y=root(y);
		if (x!=y) p[x]=y;
	}
	
	boolean equiv(int x,int y) {
		return root(x)==root(y);
	}
	
	void run() {
		var sc=new Scanner(System.in);
		int N=sc.nextInt();
		int Q=sc.nextInt();
		var pw=new PrintWriter(System.out);
		while (Q-->0) {
			int t=sc.nextInt();
			int u=sc.nextInt();
			int v=sc.nextInt();
			if (t==0) unite(u,v);
			else pw.println(equiv(u,v)?1:0);
		}
		pw.flush();
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 60160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    //string S;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    ll cur = A[0];
    REP(i,1,N){
        if(A[i] < cur){
            ans += cur - A[i];
        }else{
            cur = A[i];
        }
        //ans += max(A[i] - cur, 0LL);

    }
    cout << ans << endl;
}

Measured memory_bytes: 4832
a,b,c,x,y = map(int, input().split())

if a+b <= 2*c:
	print(a*x + b*y)
else:
	#買えるだけABピザを買う
	z = min(x,y)
	res = c * 2 * z
	#残り
	if x>=y:
		cand1 = (x-z)*a
	else:
		cand1 = (y-z)*b
	cand2 = (max(x,y)-z)*2*c
	print(min(cand1,cand2) + res)


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;  //nearly 1.07e9
const ll INFLL = 1ll << 60;       //nearly 1.15e18
const int MOD = 1e9 + 7;
const long double EPS = 1.0e-14;
const int dx[2] = {1, 0};
const int dy[2] = {0, 1};

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    int h, w;
    cin >> h >> w;
    bool isWhite[w][h];
    int ch[w][h];
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            isWhite[j][i] = (s[j] == '.');
            ch[j][i] = INF;
        }
    }

    //init
    ch[0][0] = !isWhite[0][0];

    rep(y, h) {
        rep(x, w) {
            rep(i, 2) {
                if(x + dx[i] >= w || y + dy[i] >= h /* || ch[x + dx[i]][y + dy[i]] <= ch[x][y] + !isWhite[x + dx[i]][y + dy[i]]*/) continue;
                //cout << "dbg: (" << x << ", " << y << ") -> (" << x + dx[i] << ", " << y + dy[i] << ")  ==>  ";
                if(!isWhite[x + dx[i]][y + dy[i]] && isWhite[x][y]) {
                    chmin(ch[x + dx[i]][y + dy[i]], ch[x][y] + 1);
                } else {
                    chmin(ch[x + dx[i]][y + dy[i]], ch[x][y]);
                    //cout << "(!) ";
                }
                //dbg
                //cout << ch[x + dx[i]][y + dy[i]] << endl;
            }
        }
    }

    cout << ch[w - 1][h - 1] << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 256
use std::cmp::min;
use std::io::{stdin, Read};
fn dfs(
    g: &Vec<Vec<usize>>,
    s: usize,
    t: usize,
    parents: &mut Vec<usize>,
    seen: &mut Vec<bool>,
) -> bool {
    seen[s] = true;
    if s == t {
        true
    } else {
        let n = g.len();
        for v in 0..n {
            if !seen[v] && g[s][v] > 0 && dfs(g, v, t, parents, seen) {
                parents[v] = s;
                return true;
            }
        }
        false
    }
}

fn calc_maxflow(g: &Vec<Vec<usize>>, s: usize, t: usize) -> usize {
    let n = g.len();
    let mut ret = 0;
    let mut parents = vec![0; n];
    let mut seen = vec![false; n];
    let mut rg = g.clone();
    while dfs(&rg, s, t, &mut parents, &mut seen) {
        let mut d = std::usize::MAX;
        let mut v = t;
        while v != s {
            let u = parents[v];
            d = min(d, rg[u][v]);
            v = u;
        }
        ret += d;
        let mut v = t;
        while v != s {
            let u = parents[v];
            rg[u][v] -= d;
            rg[v][u] += d;
            v = u;
        }
        seen = vec![false; n];
    }
    ret
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n = parse!(it);
    let mut g = vec![vec![0; 2 * n + 2]; 2 * n + 2];
    for i in 0..n {
        g[0][i + 1] = 1;
    }
    for j in 0..n {
        g[j + n + 1][2 * n + 1] = 1;
    }
    let mut r: Vec<(usize, usize)> = (0..n).map(|_| parse!(it, 2)).collect();
    for i in 0..n {
        let j = i + n + 1;
        let bx: (usize, usize) = parse!(it, 2);
        for (i, &rx) in r.iter().enumerate() {
            if rx.0 < bx.0 && rx.1 < bx.1 {
                g[i + 1][j] = 1;
            }
        }
    }
    println!("{}", calc_maxflow(&g, 0, 2 * n + 1));
}


Measured memory_bytes: 4352
#include <iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<vector>
#include<cmath>
#define maxn 100005
#define inf 1000000009
#define cle(n) memset(n,0,sizeof(n))
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

int n,m,t;
map<char,int>a[55];
char b[55];
int main()
{
   cin>>n;
   for(int i=0;i<n;i++)
{
    for(int j=0;j<26;j++)
   a[i][(char)('a'+j)]=0;
}

   for(int i=0;i<n;i++)
   {
        cin>>b;
        int len=strlen(b);
        for(int j=0;j<len;j++)
            a[i][b[j]]++;
   }

for(int i=0;i<n;i++)
{
    for(int j=0;j<26;j++)
    a[0][(char)('a'+j)]=min(a[0][(char)('a'+j)],a[i][(char)('a'+j)]);
}

   for(int i=0;i<26;i++)
   {
       for(int j=0;j<a[0][(char)('a'+i)];j++)
      cout<<(char)('a'+i);
   }
cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int d,t,s;
    cin >> d >> t >> s;
    if(t >= (int)ceil(d/(double)s)){
    	cout << "Yes\n";
    }
    else{
    	cout << "No\n";
    }
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3636
def test():
    N, X = map(int, input().split())
    D = list(map(int, input().split()))
    d = 0
    for i in range(N):
        d += D[i]
        if d > X:
            print(i+1)
            return
    print(N+1)
    

if __name__ == '__main__':
    test()


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void y(bool c) {
	if (c)print("Yes");
	else print("No");
}

ll dp[20][10][2][2];
ll f(int X) {
	REP(i, 20)REP(j, 10)REP(k, 2)REP(l,2)dp[i][j][k][l] = 0;
	string S = to_string(X);
	//REP(i, 10)dp[0][i][0] = 1;
	dp[0][0][0][1] = 1;
	dp[1][0][1][1] = 1;
	int n = S[0] - '0';
	FOR(i,1, n)dp[1][i][1][0] = 1;
	dp[1][n][0][0] = 1;
	int N = S.size();
	FOR(i,1, N) {
		REP(j, 10) {
			REP(k, 2) {
				REP(l, 2) {
					if (k) {
						if (l) {
							FOR(m, 1, 10)dp[i + 1][m][k][0] += dp[i][j][k][l];
							dp[i + 1][0][k][1] += dp[i][j][k][l];
						}
						else{
							REP(m, 10)if (abs(j - m) <= 1)dp[i + 1][m][k][0] += dp[i][j][k][l];
						}
					}
					else {
						int num = S[i] - '0';
						REP(m, num)if(abs(m-j)<=1)dp[i + 1][m][1][l] += dp[i][j][k][l];
						if(abs(num-j)<=1)dp[i + 1][num][0][l] += dp[i][j][k][l];
					}
				}
			}
		}
	}
	ll sum = 0;
	REP(j, 10)REP(k, 2)sum += dp[N][j][k][0];
	return sum;
}

void test() {
	REP(i, 50) {
		pe(i); print(f(i));
	}
}

void solve() {
	//test();
	int K; cin >> K; K--;
	ll ok = 0, ng = 1e18;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		//pe(mid); print(f(mid));
		if (f(mid) <= K)ok = mid;
		else ng = mid;
	}
	print(ng);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 256
fun main() {
    val (a, b, c, k) = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0
    if (k <= a) {
        ans = k
    } else {
        ans = a
        if (k <= a + b) {
        } else {
            ans -= k - (a + b)
        }
    }
    println(ans)
}

Measured memory_bytes: 36420
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N = int(input())
A = list(map(int, input().split()))
max_A = max(A)
ans = 1<<60
for i in range(1, max_A+1):
  P = sum([(a-i)**2 for a in A])
  ans = min(ans, P)
print(ans)  

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
bool IsPrime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
                    return false;
        }
    }
    return true;
}
 
int main(void) {
    int count = 0, n;
    cin >> n; 
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (IsPrime(p)) {
            count++;
            }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
  int now=0,cnt=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='S'){
      now++;
    }
    else if(now>0){
      now--;
      cnt++;
    }
  }
  cout<<s.size()-2*cnt<<endl;
  return(0);
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
using namespace std;

inline double alength(double x1,double y1,double x2,double y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main(void){
  double x[20],y[20];
  int i=0;
  double S=0.0;
  while(scanf("%lf,%lf",&x[i],&y[i])!=EOF)++i;
  for(int p=1;p<i-1;++p){
      double a=alength(x[0],y[0],x[p],y[p]);
      double b=alength(x[p],y[p],x[p+1],y[p+1]);
      double c=alength(x[p+1],y[p+1],x[0],y[0]);
      double s=(a+b+c)/2.0;
      double dS=sqrt(s*(s-a)*(s-b)*(s-c));
      S+=dS;
    }
  printf("%.6f\n",S);
  return 0;
}

Measured memory_bytes: 1084
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	ll A, B;
	cin >> A >> B;

	ll ans = 0;
	if(A&1){
		if((B-A)%4==0||(B-A)%4==1){
			ans++;
		}
	} else {
		if((B-A)%4==1||(B-A)%4==2){
			ans++;
		}
	}

	for(int k=1; k<60; k++){
		ll n=0;
		if(1&(A>>k)){
			n += (1L<<(k+1))-(A&((1L<<(k+1))-1));
			//cout << k << "A" << (1L<<(k+1)) << " " << (A&((1L<<(k+1))-1)) << endl;
		}
		if(1&(B>>k)){
			n += (B&((1L<<(k+1))-1))-((1L<<k)-1);
			//cout << k << "B" << n << endl;
		}

		if(n%2){
			ans += 1L<<k;
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
n = int(input())
cnt = [0 for i in range(10001)]

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      ans = x * x + y * y + z * z + x * y + y * z + z * x
      if ans <= 10000:
        cnt[ans] += 1

for i in range(1, n + 1):
  print(cnt[i])

Measured memory_bytes: 9140
/*ex3_2
series2*/
 
# include <stdio.h>
int main(void){
    //各文字の箱を作って読み取り
    int pen;
    scanf("%d", &pen);
    //一のくらいは10で割った余りとして分類できる。
    if(pen%10==3){
        printf("bon\n");
    }else if(pen%10==0 ||pen%10==1||pen%10==6||pen%10==8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    return 0;
}


Measured memory_bytes: 1620
n,k = input().split()

list = list(map(int,input().split()))
nulist = [0] * int(n)

for i in range(int(k)):
    a,b = input().split()
    a = int(a)-1
    b = int(b)-1
    if(list[a] > list[b]):
        nulist[b] = 1
    elif(list[a] < list[b]):
        nulist[a] = 1
    else:
        nulist[a] = 1
        nulist[b] = 1
print(nulist.count(0))


Measured memory_bytes: 85036
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n, k;
    scan(n, k);

    writeln(1 + (n - k + k - 2) / (k - 1));
}







































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int N, x[1005], y[1005];
int odd, even, bit;
vector<int> v;

void calc(int U, int V){
  
  int flagU = 0, flagV = 0;
  
  if( U < 0 ){
    flagU = 1;
    U = abs(U);
  }
  
  if( V < 0 ){
    flagV = 1;
    V = abs(V);
  }
  
  int A = (1LL<<bit) - 1;
  
  if( even ) A = (1LL<<(bit-1)) - 1 + 1;
  
  vector<int> a;
  
  for(int i=(int)v.size()-1;i>=0;i--){
    
    if( A - 2 * v[i] >= U ){
      A -= 2 * v[i];
      a.push_back(-1);
    }else{
      a.push_back(1);
    }
    
  }
  
  reverse( a.begin(), a.end() );
    
  int B = (1LL<<bit) - 1;
  
  if( even ) B = (1LL<<(bit-1)) - 1 + 1;
  
  vector<int> b;
  
  for(int i=(int)v.size()-1;i>=0;i--){
    
    if( B - 2 * v[i] >= V ){
      B -= 2 * v[i];
      b.push_back(-1);
    }else{
      b.push_back(1);
    }
    
  }
  
  reverse( b.begin(), b.end() );
  
  if( flagU ){
    
    for(int i=0;i<(int)a.size();i++) a[i] *= -1;
    
  }
  
  if( flagV ){
    
    for(int i=0;i<(int)b.size();i++) b[i] *= -1;
    
  }
  
  vector<char> ans;
  
  for(int i=0;i<(int)a.size();i++){
    
    if( a[i] == -1 && b[i] == -1 ) ans.push_back('L');
    if( a[i] == 1 && b[i] == 1 ) ans.push_back('R');
    if( a[i] == 1 && b[i] == -1 ) ans.push_back('U');
    if( a[i] == -1 && b[i] == 1 ) ans.push_back('D');
    
  }

  for(int i=0;i<(int)v.size();i++){
    cout<<ans[i];
  }

  cout<<endl;
  
}

signed main(){
  
  cin>>N;
  
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
    if( abs( x[i] + y[i] ) % 2 == 1 ) odd = 1;
    else even = 1;
  }
  
  if( odd == 1 && even == 1 ){
    cout<<-1<<endl;
    return 0;
  }
  
  if( even ){
    cout<<33<<endl;
    bit = 33;
  }
  else{
    cout<<32<<endl;
    bit = 32;
  }
  
  if( even ){
    v.push_back(1);
    cout<<1<<' ';
  }
  
  for(int i=0;i<=31;i++){
    v.push_back(1LL<<i);
    cout<<(1LL<<i);
    if( i != 31 ) cout<<' ';
  }
  
  cout<<endl;
  
  for(int i=0;i<N;i++){
    calc( x[i] + y[i], x[i] - y[i] );
  }
  
  return 0;
}


Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;
 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 10 ; 

int n , m ;
string s [ N ] ;
bool mark [ N ] [ N ] ; 

bool dfs ( int x , int y ) {
	if ( s [ x ] [ y ] != '#' )
		return false ;
	mark [ x ] [ y ] = true ; 
	if ( x == n - 1 && y == m - 1 )
		return true ;
	int ret = 0 ; 
	if ( x + 1 < n && s [ x + 1 ] [ y ] == '#' )
		++ ret ;
	if ( y + 1 < m && s [ x ] [ y + 1 ] == '#' )
		++ ret ;
	if ( ret != 1 )
		return false ;
	
	if ( x + 1 < n && s [ x + 1 ] [ y ] == '#' )
		return dfs ( x + 1 , y ) ; 
	if ( y + 1 < m && s [ x ] [ y + 1 ] == '#' )
		return dfs ( x , y + 1 ) ; 
}

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m ;
	for ( int i = 0 ; i < n ; ++ i )
		cin >> s [ i ] ;
	bool okay = dfs ( 0 , 0 ) ;
	if ( !okay ) return cout << "Impossible" , 0 ; 
	for ( int i = 0 ; i < n ; ++ i )
		for ( int j = 0 ; j < m ; ++ j )
			if ( mark [ i ] [ j ] ^ ( s [ i ] [ j ] == '#' ) )
				return cout << "Impossible" , 0 ;
	cout << "Possible" ; 
}


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

int main(){
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;

	if(x<0||y<0){
		cout << "No" << endl;
		return 0;
	}
	if( x+r > w || y+r > h){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
t=list(input())
q=int(input())
s=[]

for i in range(q):
  query=list(input().split())
  if query[0]=='1':
    s,t=t,s
  else:
    if query[1]=='1':
      s.extend(query[2])
    else:
      t.extend(query[2])
if s==[]:
  s=t
else:
  s.reverse()
  s.extend(t)

moji=''.join(s)
print(moji)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int H, W;

signed main()
{
  cin >> H >> W;
  if (W < H) {
    swap(W,H);
  }
  if (H == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (H*W)/2 + (H*W)%2 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int V;
	static int E;
	static ArrayList<Integer>[] g;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		V = sc.nextInt();
		E = sc.nextInt();
		g = new ArrayList[V];
		for (int i = 0; i < V; ++i)
			g[i] = new ArrayList<>();

		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}

		ord = new int[V];
		vis = new boolean[V];
		pending = new boolean[V];

		sort();

		for (int i = 0; i < V; ++i) {
			System.out.println(ord[i]);
		}
	}

	static int[] ord;
	static boolean[] vis;
	static boolean[] pending;
	static int now = 0;

	static void sort() {
		for (int i = 0; i < V; ++i) {
			if (!vis[i])
				dfs(i, -1);
		}
	}

	static void dfs(int cur, int pre) {
		for (int to : g[cur]) {
			if (to != pre && !vis[to]) {
				if (pending[to])
					throw new AssertionError();
				dfs(to, cur);
			}
		}
		ord[V - now - 1] = cur;
		vis[cur] = true;
		++now;
	}
}

Measured memory_bytes: 69604
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    N=int(input())
    ans=0
    for i in range(1,N+1):
        if i%3==0 or i%5==0:
            continue
        ans+=i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72772
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b,p,i,j;
	char s;
	while(~scanf("%d%d",&a,&b))
	{
		char c[200][200]={'0'};
		getchar();
		for(i=0;i<a;i++)
		scanf("%s",c[i]);
		for(i=0;i<a-1;i++)
		for(j=i+1;j<a;j++)
		{
			if(strcmp(c[i],c[j])>0)
			for(p=0;p<b;p++)
			{
				 s=c[i][p];
				c[i][p]=c[j][p];
				c[j][p]=s;
			}
		}
		for(i=0;i<a;i++)
		printf("%s",c[i]);
		printf("\n");
	}
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

int_fast64_t mpow(int_fast64_t m,int_fast64_t x,int_fast64_t n){
  using i64=int_fast64_t;
  if(n==0)return 1;
  if(n%2)return ((x%m)*(mpow(m,x,n-1)%m))%m;
  else {
    i64 half=mpow(m,x,n/2)%m;
    return (half*half)%m;
  }
}

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

  int N;
  string X;
  cin>>N>>X;
  reverse(rng(X));

  ll bits=0;
  for(int i=0;i<N;i++)if(X[i]=='1')bits++;
  ll Bm=0,Bp=0;
  for(int i=0;i<N;i++)if(X[i]=='1'){
    if(bits-1!=0)Bm=(Bm+mpow(bits-1,2,i))%(bits-1);
    else Bm=0;
    Bp=(Bp+mpow(bits+1,2,i))%(bits+1);
  }
  reverse(rng(X));
  vector<ll>dp(200001,0);
  for(int i=1;i<=200000;i++){
    dp[i]=dp[i%__builtin_popcount(i)]+1;
  }
  for(int i=0;i<N;i++){
    ll ans=0;
    if(X[i]=='1'){
      ll m=bits-1;
      if(m!=0){
        ans=Bm;
        ans=((ans-mpow(m,2,N-i-1))%m+m)%m;
      }
      else{
        cout<<0<<endl;
        continue;
      }
    }
    else{
      ll m=bits+1;
      ans=Bp;
      ans=(ans+mpow(m,2,N-i-1))%m;
    }
    cout<<dp[ans]+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238 


long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
void solve(){
    ll ans =0;
    ll n;
    cin>>n;
    ll a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    map<ll,ll> cnt;
    for(int i=1;i<=n;i++){
        ll sum = i-a[i];
        ans += cnt[sum];
        cnt[a[i] + i]++;
    }
    cout<<ans<<endl;
}  

 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }    
}

Measured memory_bytes: 27760
# AGC036A_Triangle.py

import math
import sys

s = int(input())

a1 = int(math.sqrt(s))
if 0 < s - a1**2:
    a1 += 1

b2 = (s + a1 - 1) // a1

rest = a1 * b2 - s

if rest == 0:
    print(0, 0, a1, 0, 0, b2)
else:
    a2 = 1
    b1 = rest
    print(0, 0, a1, a2, b1, b2)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int max = 0; int[] Throw = new int[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                max = Math.Max(max,a[0]);
                Throw[i] = a[1];
            }
            int swing = 0;
            for (int i = 0; i < x[0]; i++)
            {
                if (Throw[i] > max) swing++;
                else Throw[i] = 0;
            }
            if (Throw.Sum() >= x[1])
            {
                Array.Sort(Throw); Array.Reverse(Throw);
                int damage = 0; int i = 0;
                for (; ; i++)
                {
                    damage += Throw[i];
                    if (damage >= x[1]) break;
                }
                Console.WriteLine(i + 1);
            }
            else
            {
                Console.WriteLine(swing + ((x[1] - Throw.Sum() - 1) / max + 1));
            }
        }
    }
}

Measured memory_bytes: 15584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a){
        b *= 2;
        k--;
    }
    while (c <= b){
        c *= 2;
        k--;
    }
    cout << (k >= 0 ? "Yes" : "No") << endl;
    return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long A, long long B){
    ll cycle = (N / (A + B));
    cout << cycle * A + min(A, (N - cycle * (A + B))) << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		int b1=100000,  b2=0;

		int[] b = new int[n];

		for(int i=1;i<n;i++) {
			b[i] = sc.nextInt();
		}

		b[0] = b[1];
		ans += b[n-1];
		for(int i=1;i<n;i++) {
			ans += Math.min(b[i], b[i-1]);
		}

		System.out.println(ans);
	}
}


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

const int limit = 50;
int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];
void dfs(int v) {
  visited [v] = true;
  for (int w = 0; w < n; w++) {
    if (graph[v][w] == false) continue;
    if (visited[w] == true) continue;
    dfs(w);
  }
}
int main (void) {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    for (int j = 0; j < n; j++) visited[j] = false;
    dfs(0);
    bool bridge = false;
    for (int j = 0; j < n; j++) {
      if (visited[j] == false) bridge = true;
    }
    if (bridge) ans++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 256