akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	ll n, k;
	scanll(n);
	scanll(k);
	printll(min(n % k, (k - n % k)));
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	solve();

	// __test {
	// 	solve();
	// }

	showTime;
	return 0;
}




Measured memory_bytes: 3828
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool isPrime(int x) {
	if (x < 2) {
		return false;
	} else if (x == 2) {
		return true;
	} else if (x % 2 == 0) {
		return false;
	}

	for (int i = 3; i * i <= x; i += x) {
		if (x % i == 0) {
			return false;
		}
	}

	return true;
}

int f(int x, vector<int> &vec) {
	int res = 0;
	for (auto v : vec) {
		if (v >= x) {
			res++;
		}
	}

	return res;
}

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

	int n;
	cin >> n;

	vector<int> div(n + 1);
	for (int i = 2; i <= n; i++) {
		int tmp = i;
		for (int j = 2; j <= i; j++) {
			while (isPrime(j) && tmp % j == 0) {
				div[j]++;
				tmp = tmp / j;
			}
		}
	}

	int ans = f(74, div)
		+ f(24, div) * (f(2, div) - 1)
		+ f(14, div) * (f(4, div) - 1)
		+ f(4, div) * (f(4, div) - 1) * (f(2, div) - 2) / 2;

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


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String... arvs){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    long sum=0;
    int i=1;
    while(sum<x){
      sum+=i;
      i++;
    }
    
      System.out.println(i-1);
    
    
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char** argv) {
    int n;
    cin >> n;

    std::vector<std::vector<long long>> dp;
    dp.push_back(std::vector<long long>(3));
    dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0;
    for (int i = 1; i < n+1; ++i) {
        std::vector<int> hap(3);
        cin >> hap[0] >> hap[1] >> hap[2];
        dp.emplace_back(std::vector<long long>(3));
        for (int j = 0; j < 3; ++j) {
            long long m{0};
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                long long h = dp[i-1][k] + hap[j];
                if (m < h) m = h;
            }
            dp[i][j] = m;
        }
    }
    long long ans{0};
    for (int i = 0; i < 3; ++i) {
        if (dp[n][i] > ans) ans = dp[n][i];
    }
    cout << ans << endl;

    return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(std::string s, std::string t) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int ans = 0;
    rep(i, s.size()) {
        if (s[i] == t[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;

    func(S, T);

    return 0;
}


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n; cin >> n;
    vi l(n); rep(i,n) cin >> l[i];
    sort(all(l));
    int cnt = 0;
    rep(i,n)rep(j,i)rep(k,j){
        if(l[i]==l[j]) continue;
        if(l[i]==l[k]) continue;
        if(l[k]==l[j]) continue;
        if(l[i]<l[j]+l[k]) cnt++;

    }
    cout << cnt << '\n';
    
}


Measured memory_bytes: 3664
n=gets.to_i
a=gets.split(' ').map(&:to_i)
big=Array.new(n)
small=Array.new(n)
for i in 0..n-1
  big[i]=i-a[i]
  small[i]=i+a[i]
end
ans=0
big_hash = big.group_by{|i|i}
small_hash = small.group_by{|i|i}

big_hash.each do |key,value|
  ans += value.size * small_hash[key]&.size.to_i
end


=begin
for i in 1..(n+a.max)
  ans+= big.count(i) * small.count(i)
end
=end
puts ans

Measured memory_bytes: 60828
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ln length()
#define mod 1000000007
#define MAX 1000000
#define umap unordered_map
#define uset unordered_set
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define V(x) vector<x>
#define deci(n) cout<<fixed<<setprecision(n)
#define pq priority_queue
#define dbg(x)      cout << #x << " = " << x << '\n'
#define FOR(i,s,e)    for(ll i=(ll)s;i<(ll)e;i++)

typedef long long int ll;
typedef long double ldb;

ll gcd(ll a, ll b){
    ll mi=min(a, b), mx=max(a, b), temp;
    while(mi){
        temp=mi;
        mi=mx%mi;
        mx=temp;
    }
    return mx;
}

ll pw(ll x, ll n){
    ll ans=1;
    while(n){
        if(n&1ll){
            ans*=x;
            // ans%=mod;
        }
        x*=x;
        // x%=mod;
        n>>=1ll;
    }
    return ans;
}


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n][3];
    FOR(i,0,n)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        if(i>0)
        {
            arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
            arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
            arr[i][2]+=max(arr[i-1][0],arr[i-1][1]);
        }
    }
    cout<<max(arr[n-1][0],max(arr[n-1][1],arr[n-1][2]))<<"\n";
    return 0;
}


Measured memory_bytes: 5928
Ss = input()
Ts = input()
q = int(input())
querys = [tuple(map(lambda x: int(x) - 1, input().split())) for i in range(q)]

def countA(Cs):
    numAs = [0] * (len(Cs) + 1)

    for i, C in enumerate(Cs, 1):
        if C == 'A':
            numAs[i] = numAs[i - 1] + 1
        else:
            numAs[i] = numAs[i - 1]

    return numAs


numASs = countA(Ss)
numATs = countA(Ts)
        
for a, b, c, d in querys:
    lenS = b - a + 1
    numAS = numASs[b + 1] - numASs[a]
    lenT = d - c + 1
    numAT = numATs[d + 1] - numATs[c]

    if ((numAS - (lenS - numAS)) - (numAT - (lenT - numAT))) % 3 == 0:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 32312
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    ll n;
    cin >> n;
    vector<ll> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    sort(all(p));
    ll up = p[n/2 ];
    ll down = p[n/2 - 1];

    cout << up - down << endl;


}

Measured memory_bytes: 1024
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
	IOS;
	cin>>m>>n;
	forn(i,n){
		cin>>x;
		m-=x;
	}
	cout<<max(-1,m)<<ln;
}


Measured memory_bytes: 3660
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }


const int N = 1001, K = 17, inf = 1e9 + 1;


void solve() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  int bestw = 0, bests = 0;
  FOR(na, 0, 30) {
    int wa = na*a * 100;
    if (wa > f)break;
    FOR(nb, 0, 30) {
      int wb = nb*b * 100;
      if (wa + wb > f)break;
      FOR(nc, 0, 3000) {
        int sc = c*nc;
        if (wa + wb + sc > f)break;
        FOR(nd, 0, 3000) {
          int ssd = d*nd;
          if (wa + wb + sc + ssd > f)break;
          if ((sc + ssd) * 100 <= (wa + wb)*e) {
            if ((sc + ssd)*bestw >= (wa + wb)*bests) {
              bestw = wa + wb;
              bests = sc + ssd;
            }
          }
        }
      }
    }
  }
  cout << (bestw + bests) << ' ' << bests << ln;

}

void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 256
# -*- coding:utf-8 -*-
def euc(a,b):
    if b == 0:
        return a
    else:
        return euc(b, a%b)

N = int(input())
T = [ int(input()) for tmp in range(N) ]
if len(T) > 1:
    a = T.pop()
    b = T.pop()
    lcm = a*b//euc(a,b)
    for tmp in T:
        lcm = tmp*lcm//euc(tmp,lcm)
    print(lcm)
else:
    print(T.pop())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(a,b) for(int i=a;i<b;++i)

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 10; ++i) {
    if (n < (1 << (i+1))) {
      cout << (1<<i) << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3600
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long a = saori.saorihayami();
		long b = saori.saorihayami();
		long k = saori.saorihayami();
		long num = k - a;
		if(num <= 0){
			a = a - k;
		} else {
			a = a - k;
			b = b - num;
			if(b < 0){
				b = 0;
			}
		}
		if(a < 0){
			a = 0;
		}
		System.out.println(a + " " + b);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);
	int X;
	cin >> X;
	/*
	rep(i, 1e7){
		if(180*(i-2) == (180-X)*i){
			cout << i;
			return 0;
		}
	}
	*/
	vvi a;
	int cnt = 0;
	repk(i, 1, 180){
		rep(j, 361){
			if(180*(i-2) == (180-j)*i){
				a.push_back(vi());
				a.at(cnt).push_back(i);
				a.at(cnt).push_back(j);
				//cout << i << " " << j << endl;
				cnt++;
			}
		}
	}
	
	int min_num = 360;
	rep(i, cnt){
		if(X % a.at(i).at(0) == 0){
			//cout << X << " " << a.at(i).at(0) << " " << a.at(i).at(1) << endl;
			if(min_num > a.at(i).at(1)){
				min_num = a.at(i).at(1);
			}
		}
	}
	cout << min_num << endl;
	return 0;
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> c(H, vector<int>(W + 1, 1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c[i][j];
		}
	}
	vector<vector<int>> dp(H + 1, vector<int>(W + 1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W + 1; j++) {
			if (c[i][j]) {
				dp[i + 1][j] = 0;
			}
			else {
				dp[i + 1][j] = dp[i][j] + 1;
			}
		}
	}
	int res = 0;
	for (int i = 0; i < H; i++) {
		vector<int> st(1, 0), p(1, -1);
		for (int j = 0; j <= W; j++) {
			int tp = j;
			while (st.back() > dp[i + 1][j]) {
				res = max(res, st.back() * (j - p.back()));
				tp = p.back();
				st.pop_back();
				p.pop_back();
			}
			if (st.back() < dp[i + 1][j]) {
				st.push_back(dp[i + 1][j]);
				p.push_back(tp);
			}
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 18148
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int c[300010];
int main()
{
  int N,Q;
  cin >> N >> Q;
  int mex = 0;
  rep(i,N)
    {
      int c1;
      cin >> c1;
      c[c1] = c1;
      mex = max(mex,c1);
    }
  c[0] = 0;
  for(int i=1;i<mex+1;i++)
    c[i] = max(c[i-1],c[i]);

  rep(i,Q)
    {
      int q;
      cin >> q;
      int ans = 0;
      for(int i=q;i<mex+1 && ans != q-1;i+=q)
	ans = max(ans,c[i-1]%q);
      ans = max(ans,c[mex]%q);
      cout << ans << endl;
    }

  return 0;
}

Measured memory_bytes: 2328
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
count = 0
ans = 0
start = 0
for i in range(N):
    if count < C:
        if count == 0:
            count += 1
            start = T[i]
        else:
            if T[i] <= start + K:
                count += 1
            else:
                ans += 1
                count = 1
                start = T[i]
    else:
        count = 1
        ans += 1
        start = T[i]

    if i == N - 1:
        ans += 1
print(ans)


Measured memory_bytes: 7384
#include <iostream>
#include <vector>

using namespace std;

uint64_t search(string s, int b, int pos) {
  uint last = s.size() - 1;
  if (pos == last) {
    uint64_t sum = 0;
    uint i = 0, j = 1;
    while (j < s.size()) {
      if (b & 1) {
        sum += stoi(s.substr(i, j - i));
        i = j;
      }
      b >>= 1;
      j++;
    }
    sum += stoll(s.substr(i, j - i));
    return sum;
  }
  return search(s, (1 << pos) | b, pos + 1) + search(s, b, pos + 1);
}

int main() {
  string S;
  cin >> S;
  cout << search(S, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  if(y%2==1){
    cout<<"No";
    return 0;
  }
  if(y>x*4){
    cout<<"No";
    return 0;
  }
  if(y<x*2){
    cout<<"No";
    return 0;
  }
  cout<<"Yes";
  
  return 0;
    
    
}

Measured memory_bytes: 3628
//AtCoder ABC122 C - GeT AC
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,Q; cin>>N>>Q;
    string S; cin>>S;
    vector<ll> sum(S.size(),0);
    ll cnt=0;
    for(ll i=1;i<S.size();++i){
        if (S[i-1]=='A'&&S[i]=='C') {
            ++cnt;
        }
        sum[i]=cnt;
    }
    vector<ll> ans;
    for(int i=0;i<Q;++i){
        ll l,r; cin>>l>>r;
        --l;
        --r;
        ans.push_back(sum[r]-sum[l]);
    }
    for(const auto& a:ans){
        cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
int main() {
	int A,B, ans;
	scanf("%d %d", &A, &B);
	if(A<=5)
		ans = 0;
	else if(A<=12)
		ans = B/2;
	else
		ans = B;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 764
# -*- coding: utf-8 -*-
from sys import stdin

def selection_sort(A, N):  #N個の要素を含む0-オリジンの配列 A
  exchange_cnt=0
  for i in range(0, N):
    minj = i
    for j in range(i, N):
      if A[j] < A[minj]:
        minj = j
    else:
      if i != minj:
        A[i], A[minj] = A[minj], A[i]
        exchange_cnt += 1
  return A,exchange_cnt

n = int(stdin.readline().rstrip())
A = list(map(int, stdin.readline().split()))
ans = selection_sort(A, n)
print(' '.join(map(str,ans[0])))
print(ans[1])


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

bool binarySearch(vector<int> A, int key){
	int left = 0, right = A.size();
	while(left < right){
		int mid = (left + right) / 2;
		if(A[mid] == key)
			return true;
		else if(key < A[mid])
			right = mid;
		else
			left = mid + 1;
	}
	return false;
}

int main(){
	int n, q, num, T, count = 0;
	vector<int> S;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num;
		S.push_back(num);
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>T;
		count += binarySearch(S, T);
	}

	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 1932
using System;

namespace Range
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input = Console.ReadLine();

			char[] CharSeparators = new char[] {' '};
			string[] array = input.Split(CharSeparators);

			string array1 = array[0];
			string array2 = array[1];
			string array3 = array[2];

			int a = int.Parse (array1);
			int b = int.Parse (array2);
			int c = int.Parse (array3);

			if(a < b && b < c){
				Console.WriteLine ("Yes");
			}else{
				Console.WriteLine ("No");
			}

		}
	}
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
int x[3][3];

int main () {
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			scanf ("%d", &x[i][j]);
	for (int i = 1; i < 3; i++)
		for (int j = 1; j < 3; j++)
			if (x[i][j] != x[i][0] + x[0][j] - x[0][0]) {
				printf ("No\n");
				re 0;
			}
	printf ("Yes\n");
	return 0;
}

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

const int mod = 1e9+7;

int main() {
    int N,M,a,b;
    cin >> N >> M;
    ll ans=1;
    if(abs(M-N) > 1) ans = 0;
    else if(M == N) {
        for(int i=N;i>=2;--i) ans = ans*i%mod;
        for(int i=M;i>=2;--i) ans = ans*i%mod;
        ans = ans*2%mod;
    }
    else {
        if(N >= M) {
            a = N;
            b = M;
        }
        else {
            a = M;
            b = N;
        }
        for(int i=a;i>=2;--i) ans = ans*i%mod;
        for(int i=b;i>=2;--i) ans = ans*i%mod;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
a = [0] * n
for i in range(n):
    if i == 0:
        a[i] = b[i]
    elif i == n-1:
        a[i] = b[i-1]
    else:
        a[i] = min(b[i-1], b[i])

print(sum(a))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int n;
int cont =0;
int Max = -1;
int ans;

int main(){
	scanf("%d",&n);
	for(int i = n;i >=1;i--){
		int k = i;
		cont = 0;
		if(k%2 == 1)continue;
		else {
			while(k%2 != 1){
				k /= 2;
				cont++;
			}
			if(cont > Max){
				ans = i;
				Max = cont;
			}
		}
	}
	if(ans ==0)printf("1\n");
else	printf("%d\n",ans);
}

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

bool dp[5010][5010];
long long mx[5010];
int main(){
    long long i,j,n,k,x,ans=0;
    vector<long long> a;
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> x;
        a.push_back(x);
    }
    sort(a.rbegin(),a.rend());
    for(i=0;i<k;i++){
        dp[0][i] = false;
    }
    dp[0][0] = true;

    for(i=1;i<=n;i++){
        for(j=0;j<k;j++){
            if(j-a[i-1]>=0){
                if(dp[i-1][j] || dp[i-1][j-a[i-1]]){
                    dp[i][j] = true;
                }else{
                    dp[i][j] = false;
                }
            }else{
                if(dp[i-1][j]){
                    dp[i][j] = true;
                }else{
                    dp[i][j] = false;
                }
            }
        }
    }
    
    for(i=0;i<n;i++){
        for(j=k-1;j>=0;j--){
            if(dp[i][j]){
                mx[i] = j;
                break;
            }
        }
    }

    for(i=n-1;i>=0;i--){
        if(mx[i]+a[i]>=k){
            break;
        }
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 24832
n = int(input())
a, b, c = [list(map(int, input().split()))for i in range(3)]

ans = 0
prev = -1
for i in range(n):
    ans += b[i]
    if(prev+1==a[i]): ans += c[a[i]-2]
    prev = a[i]
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);
int n, M[N][N];
int d[N];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
	}
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front();
		q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0) continue;
			if (d[v] != INFTY) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}
int main() {
	int u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);
	return 0;
}


Measured memory_bytes: 3104
import Data.List

g n = [n, n+1, n+2,n+9,n+10,n+11,n+18,n+19,n+20]
h n = map (\i -> i * 9 + n) [0..8]

gp = [ [ 0.. 8], [ 9..17], [18..26], [27..35], [36..44], [45..53], [54..62], [63..71], [72..80],
       (g 0), (g 3), (g 6), (g 27), (g 30), (g 33), (g 54), (g 57), (g 60),
       (h 0), (h 1), (h 2), (h 3), (h 4), (h 5), (h 6), (h 7), (h 8)]

chk g =
  let m = concat $ filter (\f -> length(f) > 1) $ map (\ n -> filter (\(i,v) -> v == n) g) [1..9]
  in
    m

to_s' :: [Int] -> (Int,Int) -> String
to_s' p (i,v) =
  if elem i p
  then '*':(show v)
  else ' ':(show v)

to_s :: [Int] -> [(Int,Int)] -> String
to_s _ [] = []
to_s p x =
  let d = concat $ map (to_s' p) $ take 9 x
      r = drop 9 x
  in
    d ++ "\n" ++ (to_s p r)

ans' x =
  let z  = zip [0..] x
      gs = map (\g -> filter (\(i,v) -> elem i g) z ) gp
      gr = map fst $ concat $ map chk gs
  in
    to_s gr z

ans [] = []
ans x =
  let i = concat $ take 9 x
      r = drop 9 x
  in
    (ans' i):(ans r)

pr (l:[]) = do
  putStr l
pr (l:ls) = do
  putStrLn l
  pr ls

main = do
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  pr o



Measured memory_bytes: 4472
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;
#define INF (1 << 29)
int d[201][201];
int N,M,R;
int r[9];
bool used[9];

int res;

void dfs(int c,int las,int dist){

	if(c == R + 1){
		if(res > dist) res = dist;
		return;
	}
	for(int i = 1;i <= R;i++){
		if(!used[i]){
		   used[i] = true;
		   if(las ==  -1)dfs(c+1,i,0);
		   else dfs(c+1,i,dist + d[r[las]][r[i]]);
		   used[i] = false;
		}
	}

}

int main(){

	int A,B,C;
	cin >> N >> M >> R;

	for(int i = 1;i <= N;i++){
		for(int j = 1;j <= N;j++){
		   if(i!=j){
			   d[i][j] = INF;
		   }
		}
	}


	for(int i = 1;i <=R;i++){
		scanf("%d",&r[i]);
	}

	for(int i = 1;i <= M;i++){
		scanf("%d%d%d",&A,&B,&C);
		if(d[A][B] > C) d[A][B] = d[B][A] = C;
	}

	for(int k = 1;k <= N;k++){
		for(int i =1; i <= N;i++){
		  for(int j =1;j <=N;j++){
			  if(d[i][j] > d[i][k] + d[k][j]){
				  d[i][j] = d[i][k]  + d[k][j];
			  }
		  }
		}
	}

	res = INF;
    dfs(1,-1,0);
    cout << res << endl;

    return 0;
}


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

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

LL solve(int w, int h, int k)
{
	LL ret = 0;
	for(int a = 1; a <= w - 1 && a * h <= 2 * k + 2 * h - 2; a ++)
	rep1(x, h - 1) {
		int ub = 2 * k + __gcd(a, h - x) - 2 - a * x;
		ret += min(ub / (h - x), w - 1) >= a ? (min(w - 1, ub / (h - x)) - a) * 2 + 1 : 0;
		for(int b = max(a, min(ub / (h - x), w - 1) + 1); b <= w - 1 && b * (h - x) <= ub + h + x; b ++)
		if(b * (h - x) - __gcd(h, b - a) - __gcd(b, x) <= ub) ret += b == a ? 1 : 2;
	}
	return ret;
}

int main()
{
	int w, h, k;
	scanf("%d%d%d", &w, &h, &k);
	printf("%lld\n", 2 * solve(w, h, k) + 2 * solve(h, w, k));
	return 0;
}

Measured memory_bytes: 3824
#include <stdio.h>
#include <stdlib.h>

int main(){
    int H, W, K_max;
    
    scanf("%d%d%d", &H, &W, &K_max);

    char **s = (char **) malloc(sizeof(char *) * H);

    for(int i = 0; i < H; i ++){
        s[i] = (char *) malloc(sizeof(char) * (W + 1));

        scanf("%s", s[i]);
    }
    int **ans = (int **) malloc(sizeof(int *) * H);
    
    for(int i = 0; i < H; i ++){
        ans[i] = (int *) malloc(sizeof(int) * W);

        for(int j = 0; j < W; j ++){
            ans[i][j] = -1;
        }
    }
    int K = 1;
    int s_i = 0;
    int s_j = 0;
    int e_i = 0;
    int found = 0;

    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            if(found == 0){
                if(s[i][j] == '#'){
                    found = 1;

                    int ii, jj;

                    for(ii = i + 1; ii < H; ii ++){
                        for(jj = 0; jj < W; jj ++){
                            if(s[ii][jj] == '#'){
                                break;
                            }
                        }
                        if(jj < W){
                            break;
                        }
                    }
                    if(ii == H){
                        e_i = H - 1;
                    }else{
                        e_i = ii - 1;
                    }
                }
            }
            if(found == 1){
                if(j + 1 == W){
                    int e_j = W - 1;

                    for(int ii = s_i; ii <= e_i; ii ++){
                        for(int jj = s_j; jj <= e_j; jj ++){
                            ans[ii][jj] = K;
                        }
                    }
                    K ++;
                    s_i = i + 1;
                    s_j = 0;
                    found = 0;
                }else if(s[i][j + 1] == '#'){
                    int e_j = j;

                    for(int ii = s_i; ii <= e_i; ii ++){
                        for(int jj = s_j; jj <= e_j; jj ++){
                            ans[ii][jj] = K;
                        }
                    }
                    K ++;
                    s_j = j + 1;
                    found = 0;
                }
            }
        }
    }
    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            printf("%d ", ans[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1152
while (line = gets)
  p0, q0 = line.chomp.split(" ").map{|s| s.to_i}

  k = 0
  quot = []
  remhash = {p0 => 0}

  while p0 > 0
    k += 1
    p0 *= 10
    quot.push p0 / q0
    p0 %= q0
    break if ! remhash[p0].nil?
    remhash[p0] = k
  end

  puts quot.join("")

  if p0 > 0
    k0 = remhash[p0]
    puts " " * k0 + "^" * (k - k0)
  end
  #p [remhash, k, p0]
end

Measured memory_bytes: 6136
#include <stdio.h>
const double eps = 1e-8;

#define N (100010)
int a,b,c,d,e,f;
int g[N], h[N];
int main(){
    scanf("%d%d%d%d%d%d", &a,&b,&c,&d,&e,&f);
    g[0] = 1;
    for (int i = 1; i <= f; ++i){
        if (i % (a*100) == 0){
            g[i] = 1;
        }
    }
    for (int i = b * 100; i <= f; ++i){
        g[i] |= g[i-b*100];
    }
    h[0] = 1;
    for (int i = 1; i <= f; ++i){
        h[i] = i % (c) == 0;
    }
    for (int i = d; i <= f; ++i){
        h[i] |= h[i-d];
    }
    double ans = -1;
    int d1 = 0, d2 = 100 * a;
    double m = e *1.0 / (100 + e);
    for (int i = 0; i <= f; ++i){
        for (int j = 0; j <= f; ++j){
            if (i + j <= f && g[i] && h[j]){
                double c = j * 1.0 / (j + i);
                if (c < m + eps && c > ans + eps){
                    ans = c;
                    d1 = j;
                    d2 = i + j;
                }
            }
        }
    }
    printf("%d %d\n", d2, d1);
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	int MAX = 10005;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(), r = sc.nextInt();
			if ((n|r) == 0) break;
			E[] G = new E[MAX];
			for (int i = 0; i < MAX;i++) G[i] = new E();
			for (int i=0;i<n;i++) {
				int x1 = sc.nextInt()+1, y1 = sc.nextInt()+1, x2 = sc.nextInt()+1, y2 = sc.nextInt()+1;
				G[y1].add(new P(x1, x2, true));
				G[y2].add(new P(x1, x2, false));
			}
			int a = 0, l = 0, t = 1, minx = MAX, maxx = 0;
			int[][] area = new int[2][MAX];
			for (E e: G) {
				fill(area[t], 0);
				for (P p: e) {
					area[t][p.x1] += p.c ? 1: -1; area[t][p.x2] += p.c ? -1 : 1;
					minx = min(minx, p.x1); maxx = max(maxx, p.x2);
				}
				for (int i = minx; i <= maxx; i++) {
					area[t][i] += area[t][i-1] + area[1-t][i] - area[1-t][i-1];
					if (area[t][i] > 0) a++;
					if (((area[t][i] | area[1-t][i]) != 0 ) && area[t][i] * area[1-t][i] == 0) l++;
					if (((area[t][i] | area[t][i-1]) != 0 ) && area[t][i] * area[t][i-1] == 0) l++;
				}
//				debug(area[t]);
				t ^= 1;
			}
			System.out.println(a);
			if (r == 2) System.out.println(l);
		}
	}
	
	class E extends ArrayList<P>{};
	
	class P {
		int x1, x2; boolean c;
		P(int x1, int x2, boolean c) {
			this.x1 = x1;
			this.x2 = x2;
			this.c = c;
		}
	}
	
	void debug(Object... os) {
		System.out.println(deepToString(os));
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		new Main().run();
	}
}

Measured memory_bytes: 66376
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
    ll n;
    cin>>n;
    ll A[n];
    map<ll,ll> m;
    rep(i,0,n){
        cin>>A[i];
        m[A[i]-i]++;
    }
    ll cnt=0;
    rep(i,0,n){
        cnt += (m[-A[i]-i]);
        m[A[i]-i]--;
    }
    cout<<cnt<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll no;
    // cin>>no;
    no = 1;
    while(no--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 27840
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] chs = str.toCharArray();
        int evenCnt = 0; // even digit is 0
        int oddCnt = 0; // odd digit is 0

        for(int i = 0; i < chs.length; i++) {
          if(i % 2 == 0) {// even digit
            if(chs[i] == '1')
              evenCnt++;
            else
              oddCnt++;
          } else { // odd digit
            if(chs[i] == '0')
              evenCnt++;
            else
              oddCnt++;
          }
        }
        System.out.println(Math.min(evenCnt, oddCnt));
    }
}

Measured memory_bytes: 27860
#include <iostream>
#include <algorithm>

using namespace std;

long long q,h,s,d,n;

int main() {
    cin >> q >> h >> s >> d >> n;
    s = min(s, 4 * q);
    s = min(s, 2 * h);
    d = min(d, 2 * s);
    cout << (n / 2) * d + (n % 2) * s << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Problem
{
	int status;	//0--wa, 1--ac
	int waTimes;	//	
};
Problem probs[100010];

int n, m;


int main()
{
	scanf("%d%d\n", &n, &m);
	
	for (int i = 1 ; i <= n ; i++) {
		probs[i].status = 0;
		probs[i].waTimes = 0;
	}
	
	int p;
	char s[10];
	for (int i = 0 ; i < m ; i++) {
		scanf("%d %s\n", &p, &s);
		if (strcmp(s, "WA") == 0) {
			if (probs[p].status != 1) {
				probs[p].waTimes++;
			}
		} else if (strcmp(s, "AC") == 0) {
			probs[p].status = 1;
		}
	}
	
	int count = 0;
	int pently = 0;
	for (int i = 1 ; i <= n ; i++) {
		if (probs[i].status == 1) {
			count++;
			pently = pently + probs[i].waTimes;
		}
	}
	
	printf("%d %d\n", count, pently);
	
	
	return 0;
}



Measured memory_bytes: 896
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; 
  cin >> n ;
  if(n==1) cout << "Hello World" << endl;
  else{
    int a,b; cin >> a >> b ;
    cout << a+b << endl;
  }
  return 0;
}


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

int n;
int a[100055], b[100055], c[100055];
int dp[100055][3];

int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}
	
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] = max(dp[i + 1][0], max(dp[i][1], dp[i][2]) + a[i]);
		dp[i + 1][1] = max(dp[i + 1][1], max(dp[i][0], dp[i][2]) + b[i]);
		dp[i + 1][2] = max(dp[i + 1][2], max(dp[i][0], dp[i][1]) + c[i]);
	}
	
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
#define INF 1000000001
#define MAX 500001

using namespace std;

int LEFT[MAX/2 + 2],RIGHT[MAX/2 + 2];
int if_counter=0;

void debug(int num){
    cout << num << endl;
}

void comb(int A[],int left,int mid,int right){
    int n1,n2;
    n1 = mid - left;
    n2 = right - mid;
    for (int i = 0; i < n1; i++) LEFT[i] = A[left + i];
    for (int i = 0; i < n2; i++) RIGHT[i] = A[mid + i];
    
    LEFT[n1] = INF;
    RIGHT[n2]= INF;
    
    int N = n1 + n2;
    int count_l=0,count_r=0;
    
    for (int i = 0; i < N; i++) {
        if (LEFT[count_l] <= RIGHT[count_r]) {
            A[left + count_l + count_r] = LEFT[count_l];
            count_l++;
        }else{
            A[left + count_l + count_r] = RIGHT[count_r];
            count_r++;
        }
        if_counter++;
    }
}

void divide(int A[],int left,int right){
    int mid = (left + right)/2;
    if (right - left > 1) {
        divide(A,left,mid);
        divide(A,mid,right);
        comb(A,left,mid,right);
    }
}

int main(){
    int n,A[MAX];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    divide(A,0,n);
    
    for (int i = 0; i < n-1; i++) {
        cout << A[i] << " ";
    }
    cout << A[n-1] << endl;
    cout << if_counter << endl;
    
    return 0;
}

Measured memory_bytes: 5064
n, W = map(int,input().split())
dp = [W+1]*(10**5 + 1)
maxv=0
for i in range(n):
  w,v= map(int,input().split())
  for j in range(10**5-v,-1,-1):
  	cw=w+dp[j]
  	if cw<=W:
  		dp[j+v]=min(dp[j+v],cw)
  		maxv=max(maxv,j+v)
  dp[v]=min(w,dp[v])
  maxv=max(v,maxv)
print(maxv)



			
		

 



Measured memory_bytes: 69156
l = [int(i) for i in input().split()]
lf = [0]*(l[1]+1)
for i in range(l[0]):
    for j in [int(k) for k in input().split()][1:]:
        lf[j] += 1
print(list(map(lambda x:str(x), lf)).count(str(l[0])))


Measured memory_bytes: 3060
import Control.Applicative
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S

main = do
  n <- readLn :: IO Int
  xs <- readInts <$> B.getContents
  let ans = S.size $ S.fromAscList $ map fst $ lis $ zip xs $ reverse [1..n]
  print ans

lis :: Ord a => [a] -> [a]
lis = S.toList . snd . foldl go (S.empty, S.empty)
  where
    go (acc, acc0) x = case S.lookupGT x acc of
      Nothing -> let acc1 = S.insert x acc in (acc1, acc1)
      Just g -> (S.insert x (S.delete g acc), acc0)

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readInts :: B.ByteString -> [Int]
readInts = map readInt . B.words


Measured memory_bytes: 50156