akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#include <unordered_map>
#include <unordered_set>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

using namespace std;

vector<int> primes;
void generatePrimes(int n);

class D {
	int n;
	static const int MAX{ 555555 };
public:
	D()
	{
		cin >> n;
		generatePrimes(MAX);
		reverse(ALL(primes));
	}

	void declare(const vector<int>& vec)
	{
		REP(i, n - 1)
			cout << vec[i] << " ";
		cout << vec.back() << endl;
	}

	void solve()
	{
		vector<int> ans;

		while (ans.size() < n)
		{
			int nxt{ primes.back() };
			primes.pop_back();

			if (1 == (nxt % 5))
				ans.PB(nxt);
		}

		// declare(ans);

		REP(i, SZ(ans))
			cout << ans[i] << " ";
		cout << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

void generatePrimes(int n)
{

	if (n < 2)
		return;

	int k{ 3 };

	if (primes.empty())
		primes.push_back(2);
	else if (primes.size() != 1)
		k = primes[primes.size() - 1] + 2;

	bool flag{ true };

	for (; k <= n; k += 2)
	{
		flag = true;
		int limit = (int)ceil(sqrt(k)) + 1;
		int sz{ (int)primes.size() };
		for (int i{ 0 }; i < sz && primes[i] < limit; i++)
		{
			if (!(k % primes[i]))
			{
				flag = false;
				break;
			}
		}

		if (flag)
			primes.push_back(k);
	}

	flag = true;
	k = n;
	for (int d : primes)
	{
		if (!(k % d))
		{
			flag = false;
			break;
		}
	}

	if (flag)
		primes.push_back(k);
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1 % mod;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int arr[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  ll k;
  cin >> k;
  cout << arr[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  private static boolean valid(int n, HashSet<Integer> ds) {
    while (n > 0) {
      if (ds.contains(n % 10)) {
        return false;
      }
      n /= 10;
    }
    return true;
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    HashSet<Integer> ds = new HashSet<Integer>();
    for (int i = 0; i < k; i++) {
      int d = s.nextInt();
      ds.add(d);
    }
    while(true) {
      if (valid(n, ds)) {
        System.out.println(n);
        return;
      }
      n++;
    }
  }
}


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

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

  int n;
  cin >> n;

  vector<int> a(n), b(n), c(n-1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n-1; ++i) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += b[a[i]-1];
    if (i && (a[i] - a[i-1]) == 1) ans += c[a[i-1]-1];
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3664
n = int(input())
a_array = list(map(int, input().split()))
a_sum = sum(a_array)
left = 0
for i in range(n):
    left += a_array[i]
    if left > a_sum / 2:
        break
print(min(abs(a_sum - 2 * left), abs(a_sum - 2 * left + 2 * a_array[i])))

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    vector<int> v(3);
    rep(i, 0, 3) cin >> v[i];
    sort(all(v), greater<int>());
    cout << 10 * v[0] + v[1] + v[2] << endl;
}

Measured memory_bytes: 3560
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,0,N) cin >> a[i];

    vector<int> a_sub(N-1);
    rep(i,0,N-1) a_sub[i] = a[i] ^ a[i+1];

    vector<int> ans_tmp(N);
    ans_tmp[0] = 0;
    rep(i,1,N) ans_tmp[i] = ans_tmp[i-1] ^ a_sub[i-1];

    int comp = 0;
    rep(i,1,N) comp = comp ^ ans_tmp[i];

    vector<int> ans(N);
    ans[0] = a[0] ^ comp;
    rep(i,1,N) ans[i] = ans[i-1] ^ a_sub[i-1];

    cout << ans[0];
    rep(i,1,N) cout << " " << ans[i];
    cout << endl;

//    rep(i,0,N) cout << ans_tmp[i] << endl;
//    cout << comp << endl;
}

Measured memory_bytes: 6420
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define eps 1e-6
using namespace std;
int n,x,y;
int k[2000000];
int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
      int len=0;
      for(int j=i+1;j<=n;j++)
      {
        if(i<=x)
        {
          if(j<y)len=min(j-i,x-i+1+y-j);
          else len=x-i+1+j-y;
        }
        else
        {
          int z=i-x+1+fabs(y-j);
          len=min(j-i,z);
        }
        k[len]++;
        //cout<<i<<" "<<j<<" "<<len<<endl;
      }
    }
    for(int i=1;i<n;i++)cout<<k[i]<<endl;
}


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

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int n;

void add_self(int &a, int b)
{
    a += b;

    if(a >= mod)
        a -= mod;
}

int mul(int a, int b)
{
    return (ll) a * b % mod;
}

struct M
{
    vector<vector<int>>t;

    M()
    {
        t.resize(n, vector<int>(n));
    }
    M(vector<vector<int>> &a)
    {
        t = a;
    }
    M operator* (const M& b) const
    {
        M c = M();

        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                for(int k = 0; k < n; ++k)
                    add_self(c.t[i][k], mul(t[i][j], b.t[j][k]));

        return c;
    }
};

int main()
{
    ll k;

    cin >> n >> k;

    vector<vector<int>>mat(n, vector<int>(n));

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            cin >> mat[i][j];

    M m = M(mat);
    M answer = M();

    for(int i = 0; i < n; ++i)
        answer.t[i][i] = 1;

    while(k)
    {
        if(k % 2)
            answer = answer * m;

        m = m * m;
        k /= 2;
    }

    int sol = 0;

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            add_self(sol, answer.t[i][j]);

    cout << sol;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	vector<ll> argA(5);
	for (ll i = 0; i < 5; ++i) {
		cin >> argA.at(i);
	}

	vector<ll> perm(5);
	iota(perm.begin(), perm.end(), 0);

	ll ret = LLMAX;
	do {
		ll tempTime = 0;
		for (ll i = 0; i < 5; ++i) {
			tempTime += argA.at(perm.at(i));
			if (tempTime % 10 != 0 && i != 4) {
				tempTime = (tempTime / 10 + 1) * 10;
			}
		}

		ret = min(ret, tempTime);
	} while (next_permutation(perm.begin(), perm.end()));

	cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int K, S, cnt = 0, z_init = 0;
	scanf("%d %d", &K, &S);

	if (S > 2 * K) z_init = S - 2 * K;

	for (int z = z_init; z <= K; ++z) {
		if (S - z < 0) break;

		if (S - z > K) cnt += (2 * K - S + z + 1);
		else cnt += (S - z + 1);
	}
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, K; cin >> N >> K;
    if((N-1)*(N-2)/2 < K){
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> ans;
    for(int i=2; i<=N; ++i) ans.push_back(make_pair(1, i));
    int cnt = (N-1)*(N-2)/2 - K;

    int left = 2, right = 3;
    for(int i=0; i<cnt; ++i){
        ans.push_back(make_pair(left, right));
        ++right;
        if(right == N+1){
            ++left;
            right = left+1;
        }
    }

    cout << ans.size() << endl;
    for(auto e:ans) cout << e.first << " " << e.second << endl;

    return 0;
}

Measured memory_bytes: 384
sx, sy, tx, ty = map(int, input().split())
ax, ay = tx - sx, ty - sy
print(('U'*ay+'R'*ax)+('D'*ay+'L'*ax)+('L'+'U'*(ay+1)+'R'*(ax+1)+'D')+('R'+'D'*(ay+1)+'L'*(ax+1)+'U'))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int n[] = new int[N];
		int p[] = new int[N];
		int a = 0;
		for (int i = 0; i < N; i++) {
			n[i] = i + 1;
			p[i] = sc.nextInt();
			if (n[i] != p[i]) {
				a++;
			}
		}
		sc.close();
		if (a <= 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGreenBin solver = new CGreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGreenBin {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            String[] s = new String[n];
            for (int i = 0; i < n; i++) {
                char[] line = sc.nextLine().toCharArray();
                Arrays.sort(line);
                s[i] = String.valueOf(line);
            }
            Arrays.sort(s);
            long nb = 1;
            long ans = 0;
            for (int i = 1; i < n; i++) {
                if (s[i].equals(s[i - 1])) {
                    nb++;
                } else {
                    ans += (nb * (nb - 1)) / 2;
                    nb = 1;
                }
            }
            if (nb > 1) {
                ans += (nb * (nb - 1)) / 2;
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

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

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

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

    }
}



Measured memory_bytes: 47660
#pragma warning(disable:4996)
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int N, M;
	cin >> N >> M;
	vec<int> P(M), Y(M);
	REP(i, M) {
		cin >> P[i] >> Y[i];
	}
	//pair<int, int> => year, city id
	vec<vec<pair<int, int>>> kuni(N);
	REP(i, M) {
		kuni[P[i] - 1].push_back({ Y[i], i });
	}
	REP(i, N) {
		sort(ALL(kuni[i]));
	}
	vec<pair<int, string>> nums;
	REP(i, N) {
		REP(j, kuni[i].size()) {
			std::ostringstream ss;
			ss << setw(6) << setfill('0') << i + 1;
			ss << setw(6) << setfill('0') << j + 1;
			nums.push_back({ kuni[i][j].second, ss.str() });
		}
	}
	sort(ALL(nums));
	REP(i, M) {
		cout << nums[i].second << endl;
	}
	return 0;
}

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

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	
	int train = A * N,
	    taxi = B,
	    cost = 0;
	
	if (train > taxi){
		cost = taxi;
	}
	else{
		cost = train;
	}
	cout << cost << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;


int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    long long nn[400001];
    long long mm[400001];
    for(int i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(i == 0) {
            nn[i] = tmp;
        }
        else {
            nn[i] = nn[i-1] + tmp;
        }
    }
    for(int i=0; i<m; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(i == 0) {
            mm[i] = tmp;
        }
        else {
            mm[i] = mm[i-1] + tmp;
        }
    }
    int nMax = n;
    int nMin = m;
    long long* nMaxArray = nn;
    long long* nMinArray = mm;
    if(n < m) {
        nMax = m;
        nMin = n;
        nMaxArray = mm;
        nMinArray = nn;
    }
    int nCount = 0;
    int n1 = 0;
    int m2 = 0;
    int kk = 1;
    for(int i=-1; i<nMax; i++) {
        int tmp = i + 1;
        long long ans = k;
        if(i != -1) {
            ans = k - nMaxArray[i];
            if(ans < 0) {
                break;
            }
            if(tmp > nCount) {
                nCount = tmp;
            }
        }
        
        for(int j=nMin-kk; j>=0; j--) {
            long long ans1 = ans - nMinArray[j];
            int tmp1 = tmp + j + 1;
            if(ans1 >= 0) {
                // printf("%d %d %lld\n", ans1, j, nMinArray[j]);
                if(tmp1 > nCount) {
                    nCount = tmp1;
                }
                break;
            }
            kk++;
        }
    }
    // while(n1 < n || m2 < m) {
    //     if(n1 >= n) {
    //         if((k-mm[m2]) >= 0) {
    //             nCount++;
    //             k = k - mm[m2];
    //             m2++;
    //         }
    //         else {
    //             break;
    //         }
    //     }
    //     else if(m2 >= m) {
    //         if((k-nn[n1]) >=0 ) {
    //             nCount++;
    //             k = k - nn[n1];
    //             n1++;
    //         }
    //         else {
    //             break;
    //         }
    //     }
    //     else {
    //         if(mm[m2] > nn[n1]) {
    //             if((k-nn[n1]) >=0 ) {
    //                 nCount++;
    //                 k = k - nn[n1];
    //                 n1++;
    //             }
    //             else {
    //                 break;
    //             }
    //         }
    //         else {
    //             if((k-mm[m2]) >= 0) {
    //                 nCount++;
    //                 k = k - mm[m2];
    //                 m2++;
    //             }
    //             else {
    //                 break;
    //             }
    //         }
    //     }
        
    // }
    printf("%d\n", nCount);
    return 0;
}

Measured memory_bytes: 6888
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            if (S[0] != 'A')
            {
                WriteLine("WA");
                return;
            }
            else if (1 != S.Substring(2, N - 3).Count(s => s == 'C'))
            {
                WriteLine("WA");
                return;
            }
            else if (S[1] < 'a' || S[N - 1] < 'a')
            {
                WriteLine("WA");
                return;
            }
            else
            {
                for (var i = 2; i < N - 1; ++i)
                {
                    if (S[i] != 'C' && S[i] < 'a')
                    {
                        WriteLine("WA");
                        return;
                    }
                }
            }
            WriteLine("AC");
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26156
N,K = map(int,input().split())
MOD = 10**9+7
a = list(map(int,input().split()))
b = []
c = []
d = []
num_z = 0
for val in a:
    if val>0:
        b.append(val)
        d.append(val)
    elif val<0:
        c.append(-val)
        d.append(-val)
    else:
        num_z += 1
        d.append(0)
num_b = len(b)
num_c = len(c)
res = 1
if (N==num_c and K%2==1):
    d = sorted(d)
    for val in d[:K]:
        res = res*val%MOD
    res = -res%MOD
elif (N==K and num_c>0):
    c = sorted(c)
    for val in a:
        res = res*val%MOD
elif num_b==0:
    if K%2==0:
        if num_c >= K:
            c = sorted(c,reverse=True)
            for val in c[:K]:
                res = res*val%MOD
        else:
            res = 0
    else:
        res = 0
else:
    b = sorted(b,reverse=True)
    c = sorted(c,reverse=True)
    bidx = 0
    cidx = 0
    tmp = 0
    if num_b+num_c < K:
        res = 0
    else:
        if num_b >= K:
            bidx = K
        elif num_c>=2:
            bidx = num_b
            cidx = K-bidx
            if (K-num_b)%2==1:
                if cidx == num_c:
                    print(0)
                    exit()
                bidx -= 1
                cidx += 1
        else:
            print(0)
            exit()
        #print(bidx,cidx)
        for val in b[:bidx]:
            res = res*val%MOD
        for val in c[:cidx]:
            res = res*val%MOD
        for k in range(100000):
            if bidx<=1 or cidx+1 >= num_c:
                break
            if b[bidx-1]*b[bidx-2] > c[cidx]*c[cidx+1]:
                break
            else:
                res *= c[cidx]
                res *= c[cidx+1]
                res = res%MOD
                res = res*pow(b[bidx-1],MOD-2,MOD)
                res = res*pow(b[bidx-2],MOD-2,MOD)
                res = res%MOD
                bidx -= 2
                cidx += 2
print(res%MOD)



Measured memory_bytes: 123880
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll X;

int main()
{
    cin >> X;
    ll n500 = X / 500;
    X = X - 500 * n500;
    ll n5 = X / 5;
    cout << n500 * 1000 + n5 * 5 << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    if n%2:
        if i==n//2:
            b[i]=a[0]
        elif i<n//2:
            b[i]=a[n-i*2-1]
        else:
            b[i]=a[(i-n//2)*2-1]
    else:
        if i<n//2:
            b[i]=a[n-i*2-1]
        else:
            b[i]=a[(i-n//2)*2]
print(' '.join(map(str,b)))

Measured memory_bytes: 34664
import java.util.Scanner;

/**
 * http://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		
		System.out.println(s.substring(0,s.length()-8));

	}

}


Measured memory_bytes: 23764
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
 
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
 
int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
 
    ll i,j,h;
    ll N,K;
    ll temp;
    ll ans = 1;
    vector<ll> aa;
    ll count_minus=0;
   cin >> N>>K;
    rep(i,N){
        cin >> temp;
        aa.push_back(temp);
        if(temp<0){
            count_minus++;
        }
    }
//cout<<aa[0]<<endl;
 
if(N == K){
    rep(i,N){
        ans = ans*aa[i]%MOD;
 
    }
    if(ans<0){
        ans = MOD + ans;
        }
    cout << ans <<endl;
    return 0;
}
 
 
 
    if(( N == count_minus && K%2==1)|| (N==K && count_minus%2==1)   ){
        //cout << "a"<<endl;
        rep(i,N){
            aa[i] = abs(aa[i]);
        }
        sort(aa.begin(),aa.end());
        rep(i,K){
            ans = ans*aa[i]%MOD;
        }
        ans = -ans;
        if(ans<0){
        ans = MOD + ans;
        }
        cout << ans<<endl;
        return 0;
    }
 
    sort(aa.begin(),aa.end(),greater<int>());
    ll back_count = 0;
    ll mae_count = 0;
    ll count = K;
 
//cout<<aa[0]<<endl;
 
    while(1){
        if(count == 0){
            break;
        }else if(count ==1){
 
           
            ans = ans*aa[mae_count]%MOD;
            break;
            
        }
 
        if(aa[N-1-back_count]<0 &&aa[N-1-back_count-1]<0 ){
            if(aa[N-1-back_count]*aa[N-1-back_count-1]>aa[mae_count]*aa[mae_count+1]){
                ans=ans*aa[N-1-back_count]%MOD;
                ans=ans*aa[N-1-back_count-1]%MOD;
                back_count +=2;
                count -=2;
            }else{
                
 
                    ans=ans*aa[mae_count]%MOD;
                   
                    mae_count+=1;
                    count -=1;
                
            }
        }else{
            ans=ans*aa[mae_count]%MOD;
       
            mae_count+=1;
            count -=1;
        }
    }
 
 
 
    if(ans<0){
        ans = MOD + ans;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int a[102];
    for(int i = 0; i < n; i++) cin >> a[i];
    bool dp[100003];
    fill(dp, dp + k + 1, true);
    for(int i = 0; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i - a[j] >= 0 && dp[i - a[j]]) dp[i] = false;
        }
    }
    if(dp[k]) cout << "Second" << endl;
    else cout << "First" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const int maxn = 3e3 + 7;
const int maxm = 5e5 + 10;
double s[maxn];
double dp[maxn][maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> s[i];
    dp[1][1] = s[1];
    dp[1][0] = 1.0 - s[1];
    for (int i = 2; i <= n; ++i)
    {
        for (int j = 0; j <= n; ++j)
        {
            if (j == 0)
                dp[i][j] = dp[i - 1][j] * (1.0 - s[i]);
            else
                dp[i][j] = dp[i - 1][j - 1] * s[i] + dp[i - 1][j] * (1.0 - s[i]);
        }
    }
    double ans = 0.00;
    for (int i = (n + 1) / 2; i <= n; ++i)
        ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

signed main() {
	int N, K, oneInd;
	vector<int> A;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
		if (tmp == 1) oneInd = i;
	}
	int l, r;
	l = oneInd;
	r = N - 1 - oneInd;
	int div = K - 1;
	int ans = 0;
	if (l%div == 0) {
		ans += l / div;
	}
	else {
		ans += (l / div+1);
		r -= div - l % div;
		if (r < 0) r = 0;
	}
	if (r%div == 0) {
		ans +=  r / div;
	}
	else {
		ans += (r / div + 1);
	}

	//if (K == N) {
		//ans = 1;
	//}
	

	cout << ans << "\n";



	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
      int a = scan.nextInt();
      int b = scan.nextInt();
      int c = scan.nextInt();

      int i = 0 ;

        for (; a <= b ; a++){
           if( c % a == 0 ){
               i ++ ;
        }
    }
   System.out.println(i);
 }
}


Measured memory_bytes: 26336
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1e7+11, mo = 1e9+7, inv2 =(mo+1)/2;
const ll MOD=7LL*mo*mo;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}

int fac[N],ifac[N];
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
int res;
int calc(int a, int t, int b){
	return 1ll*fac[a+b-1]*a%mo*fac[a+b+t]%mo*ifac[a+b]%mo;
}
int getans(int a, int t, int b){
	int res=0;rep(i,0,a)res=(res+1ll*(i&1?mo-1:1)*C(a,i)%mo*calc(a-i,t,b))%mo;
	return res;
}
int main() {
	int n,a;read(n);read(a);iniC(n+1);
	res=getans(a,0,n-a);
	rep(i,1,a)add(res,getans(i-1,a-i,n-a));
	cout<<res;
	return 0;
}


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

int main(){
  int n , l , r ,x;
  cin >> n ;
  x = 0;
  
  for(int i = 0; i < n; i++){
    cin >> l >> r;
    x += r - l + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,t;
    cin>>n>>t;
    int v[n];
    for(int i=0;i<n;i++)
        cin>>v[i];
        int ans=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
             if((i+j)>n)break;
            vector< int > w;
            for(int h=0;h<i;h++)
                w.push_back(v[h]);
            for(int h=0;h<j;h++)
                w.push_back(v[n-1-h]);
                sort(w.begin(),w.end());
            for(int k=0;k<=(i+j);k++)
            {
                if((i+j+k)>t)continue;
                int res=0;
                for(int l=k;l<w.size();l++)
                    res+=w[l];
                ans=max(res,ans);
            }
        }
    }
    cout<<ans;
      return 0;
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
l = [0 for x in range(n)]
for _ in range(q):
    l[int(input())-1] += 1

ans = []
for i in l:
    if k- q + i > 0:
        ans += list("Yes\n")
    else:
        ans += list("No\n")
print("".join(ans))

Measured memory_bytes: 8232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
ll a,b,k;
cin >> a >> b >> k;

if(k <= a){
    cout << a-k << ' ' << b << endl;
}else if(k <= a+b){
    cout << 0 << ' ' << b-(k-a) << endl;
}else{
    cout << 0 << ' ' << 0 << endl;
}


return 0;
}

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

long long llmax(long long a, long long b)
{
    return a > b ? a : b;
}

int main()
{
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    long long ans = (long long)n / 2 * min(q * 8, min(h * 4, min(s * 2, d)));
    n = n - ((n / 2) * 2);
    ans += n * min(q * 4, min(h * 2, s));

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
XYH = []
for i in range(N):
    x,y,h = map(int, input().split())
    XYH.append((x,y,h))

XYH = sorted(XYH, key=lambda x:x[2],reverse=True)

ans_xy = [(0,0)]
ans_H  = 0
for X in range(101):
    for Y in range(101):
        for i in range(N):
            x,y,h = XYH[i]

            if i == 0:
                H_q = h + abs(X-x) + abs(Y-y)
            else:
                h_now = max(0, H_q - abs(X-x) - abs(Y-y))
                if h_now != h:
                    break
        else:
            ans_H = H_q
            print(X,Y,ans_H)
            exit()


Measured memory_bytes: 3064
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = s[0];
        int m = s[1];
        int[][] l = new int[m][];
        for (int i = 0; i < m; i ++) {
            l[i] = new int[4];
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            l[i][0] = i;
            l[i][1] = a[0];
            l[i][2] = a[1];
        }
        Array.Sort(l, (a, b) => a[2] - b[2]);
        int[] c = new int[n];
        for(int i = 0; i < m; i ++) {
            c[l[i][1]-1] ++;
            l[i][3] = c[l[i][1]-1];
        }
        Array.Sort(l, (a, b) => a[0] - b[0]);
        for(int i = 0; i < m; i ++) {
            Console.WriteLine(String.Format("{0:D6}", l[i][1]) + String.Format("{0:D6}", l[i][3]));
        }
    }
}

Measured memory_bytes: 26492
while True:
    m,f,r=map(int, raw_input().split())
    s=m+f
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1 or s <30:
        print 'F'
    elif s <50 and r <50:
        print 'D'
    elif s <65:
        print 'C'
    elif s <80:
        print 'B'
    else:
        print 'A'

Measured memory_bytes: 6444
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 200005
using namespace std;
const ll MOD=1e9+7;

int dp[MAX]={};
int dp2[MAX]={};

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

  rep(i,M){
    ll a,b,max,min;
    cin >> a >> b;
    vector< pair<ll,ll> > n;
    if(a>b){
      max=a;
      min=b;
    }else{
      max=b;
      min=a;
    }
    if(min==1) dp[max]=1;
    else if(max==N) dp2[min]=1;
  }

  for(ll key=1;key<=N;key++){
    if(dp[key]&&dp2[key]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

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

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------

int main() {

  int r, d, xi, x;
  cin >> r >> d >> xi;

  x = xi;
  for(int i=0; i<10; ++i) {
    x = r*x-d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;

struct Node{
	vector<int> next;
	int depth=0;
	int visited=0;
	int type;
};
int get_path(vector<string> &s, int x, int y){
	queue<pair<int, int>> que;
	int depth_max=0;
	int H=s.size();
	int W=s[0].size();
	int depth[H][W];
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(s[i][j]=='#'){
				depth[i][j]=-2;
			}
			else{
				depth[i][j]=-1;
			}
		}
	}
	que.push(make_pair(x, y));
	depth[x][y]=0;
	while(!que.empty()){
		pair<int, int>n = que.front();
		int nx=n.first;
		int ny=n.second;
//		printf("%d, %d\n", nx, ny);
		que.pop();
		if(depth_max<depth[nx][ny]) depth_max=depth[nx][ny];
		if(depth[nx+1][ny]==-1&&nx+1<=H-1){
			depth[nx+1][ny] = depth[nx][ny]+1;
			que.push(make_pair(nx+1, ny));
		}
		if(depth[nx-1][ny]==-1&&nx-1>=0){
			depth[nx-1][ny] = depth[nx][ny]+1;
			que.push(make_pair(nx-1, ny));
		}
		if(depth[nx][ny+1]==-1&&ny+1<=W-1){
			depth[nx][ny+1] = depth[nx][ny]+1;
			que.push(make_pair(nx, ny+1));
		}
		if(depth[nx][ny-1]==-1&&ny-1>=0){
			depth[nx][ny-1] = depth[nx][ny]+1;
			que.push(make_pair(nx, ny-1));
		}
	}
//		printf("%d,%d %d\n", x, y, depth_max);
	return depth_max;

	}

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

		int H, W;
		scanf("%d %d", &H, &W);
		vector<string> s(H);
		char input[W];
		for(int i=0; i<H; i++){
			scanf("%s", input);
			s[i] = input;
		}


		int max_path=0;
		for(int i=0; i<H; i++){
			for(int j=0; j<W; j++){

				if(s[i][j]=='.'){
					int path = get_path(s, i, j);
					if(path>max_path) max_path=path;
				}
			}
		}
		printf("%d\n", max_path);

		return 0;
	}







Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		n=1000-n;
		int coins[]={500,100,50,10,5,1};
		int res=0;
		rep(i,6){
			res+=n/coins[i];
			n%=coins[i];
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, A[200001], ans=0;
    map<ll,ll> mp;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];

        ans += mp[i-A[i]];

        mp[i+A[i]]++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 27900
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

void bfs(vvll& es, vll& d, ll s) {
  queue<ll> q;
  q.push(s);
  d[s] = 0;
  while (!q.empty()) {
    ll u = q.front();
    q.pop();
    for (auto v : es[u]) {
      if (d[v] == -1) {
        q.push(v);
        d[v] = d[u] + 1;
      }
    }
  }
}

int main() {
  ll n, u, v;

  cin >> n >> u >> v;
  u--;
  v--;
  vvll es(n);
  vll dt(n, -1);
  vll da(n, -1);
  for (ll i = 0; i < n - 1; i++) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    es[x].push_back(y);
    es[y].push_back(x);
  }

  bfs(es, dt, u);
  bfs(es, da, v);

  ll tnige = -1;
  ll tmax = 0;
  for (ll i = 0; i < n; i++) {
    if (dt[i] <= da[i]) {
      tnige = i;
      chmax(tmax, da[i]);
    }
  }
  assert(tnige != -1);

  cout << tmax-1 << endl;

  return 0;
}

Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String a = line.substring(0, 1);
		String c = line.substring(line.length() - 1);
		int b = line.length() - 2;

		System.out.println(a + b + c);

	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,k,ans = 0;cin >> a >> b >> c >> k;
  ans += min(a,k);k -= min(a,k);
  k -= min(b,k);
  ans -= min(c,k);
  cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;

const static int MAX = 50;
int main(){
    int N, M;
    cin >> N >> M;
    int a[MAX], b[MAX];
    for (int i=0;i<M;i++) cin >> a[i] >> b[i];
    
    int count[MAX] = {0};
    for (int i=0;i<M;i++){
        ++count[a[i] - 1];
        ++count[b[i] - 1];
    }
    for (int i=0;i<N;i++) cout << count[i] << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    double x;
    cin >> x;
    double k=360/x;
    bool ok=1;
    if(k!=(int)k){
        ok=0;
    }
    double l=1;
    while(ok==0){
        l++;
        double temp=l*k;
        if(temp==(int)temp){
            k=temp;
            ok=1;
        }
    }
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll n,a,b;
	bool can=true;
	cin >>n>>a>>b;
	if(a*b <n){
		//clog<<"A";
		can=false;
	}
	if(a+b -1>n){
		//clog<<"B";
		can=false;
	}
	if(!can){
		cout<<-1<<endl;
		return 0;
	}
	ll at=n;
	ll count=0;
	ll lim=b+1;
	ll last=0;
	ll det=0;
	V ans(n);
	for(int i=0;i<b;i++){
		lim--;
		if(i==0){
			//clog<<"["<< n-a+1<<" ... "<<n<<"]"<<endl;
			for(ll j=n-a+1;j<=n;j++){
				ans[count]=j;
				//clog<<ans[count]<<" ";
				count++;
			}
			//clog<<endl;
			last=n-a+1;
		}else{
			//clog<<"lim:"<<lim<<endl;
			det=max(lim,last-a);
			for(ll j=det;j<last;j++){
				ans[count]=j;
				//clog<<ans[count]<<" ";
				count++;
			}
			last=det;
			//clog<<endl;
		}
	}
	//clog<<endl;
	rep(i,n){
		cout<<ans[i];
		if(i!=n-1){
			cout<<" ";
		}
	}
	cout<<endl;
}
/*
5 3 2 => [3,4,5] [1,2]
3 4 1 5 2

6 3 3  => [4 5 6 ][3] [1 2]
4 5 3 6 1 2
[4 5 6] [2 3] [1] 
4 5 2 3 6 1
6 3 4 -> [4 5 6] [3] [2] [1]
4  3 5  2 6 1
n a b => nから最大a要素のグループをb作る
6 2 4
[5 6] [3 4] [2] [1]
5 3 6 4 2 1
6 2 5
[5 6] [4] [3] [2] [1]
5 4 6 3 2 1
6 2 3
[5 6] [3 4] [2 1]
7 2 3
[6 7] [4 5] [2 3] [1]

*/

Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b;
string s;
char w;
cin >> a >> s >> b;
w = s[b-1];
for (int i = 0; i < s.size(); i++){
	if (s[i] == w)
	int mx = 0;
	else
	s[i] = '*';
}
cout << s;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int r, D, x_2000;

int main(){
    cin >> r >> D >> x_2000;

    long long int x = x_2000;

    for(long long int i=0;i<10;i++){
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256