akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
#define SpaceNewLine(a) Rep(i,a.size())cout<<a[i]<<(i==a.size()-1?'\n':' ')
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

vi A;

int main() {
    // setup {{{ 1
    cin.tie(0);
    ios::sync_with_stdio(false);
    // }}}

    int N;
    Scd(N);

    A.resize(N);

    Rep(i,N){
        Scd(A[i]);
    }

    vi B(N,0);

    vi ans;

    int di = 0;
    int k = 1;
    Rep(i,N){
        di = N-i;
        k = 1;
        if( A[di-1] != B[di-1] ){
            ans.push_back(di);
            // printf ("%d\n", di );
            while( di >= k*k ){
                if( di % k == 0 ){
                    B[di/k-1] = 1 ^ B[di/k-1];
                    B[k-1] = 1 ^ B[k-1];
                }
                if( k*k == di ) B[k-1] = 1 ^ B[k-1];
                k++;
            }
            /*Rep(i,N){
                printf ("%d ", B[i] );
            }
            printf ("\n");
            */
        }
    }

    sort( ans.begin(), ans.end() );
    int M = ans.size();
    Rep(i,N){
        if( A[i] != B[i] ) M = -1;
    }
    cout << M << endl;
    if( M > 0 ) SpaceNewLine(ans);

    return 0;
}



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



signed main(){
    int k,a,b;
    cin >> k >> a >> b;
    if(b-a >2&& k >a-1){
        if((k-a)%2 ==0){
            cout << a + 1 + (b-a)*(k-a)/2;
        }else cout << a + (b-a)*(k-a+1)/2;
    }else cout << 1+k;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int n;
    scanf("%d", &n);

    char c[n];
    scanf("%s", c);

    int numChange = 0;
    for (int i = 1; i < n; i++) {
        if (c[i] == 'E') { numChange++; }
    }

    int minNumChange = numChange;
    for (int i = 1; i < n; i++) {
        if (c[i-1] == 'W') { numChange++; }
        if (c[i] == 'E') { numChange--; }

        if (numChange < minNumChange) {
            minNumChange = numChange;
        }
    }

    printf("%d\n", minNumChange);
    return 0;
}

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

using namespace std;

typedef long long ll;

int const N = 2 * 100 * 1000 + 16;
int const inf = 1000 * 1000 * 1000;
int const M = inf + 7;

int n;
int a[26];
int b[26];
int vis[26];
char w[N];

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

  cin >> n;

  for(int i = 1; i <= n; ++i) {
    cin >> w;
    for(int j = 0; w[j]; ++j) {
      int idx = w[j] - 'a';
      
      if(i == 1) {
        a[idx]++;
        b[idx]++;
      } else {
        b[idx]++;
      }
    }

    for(int i = 0; i < 26; ++i)
      a[i] = min(a[i], b[i]);

    fill_n(b, 26, 0);
  }

  for(int i = 0; i < 26; ++i) {
    while(a[i]--)
      cout << char('a' + i);
  }
  cout << flush;
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    if (abs(a - b) <= k){
        for (int i = a; i <= b; i++) cout << i << endl;
        return 0;
    }
    for(int i = a; i < a+k; i++) cout << i << endl;
    if(a+k < b-k+1){
        for(int i = b-k+1; i <= b; i++) cout << i << endl;
    }else{
        for(int i = a+k; i <= b; i++) cout << i << endl;
    }
    return 0;
}

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

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

    int a, b, ansa = INT_MIN, ansb;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a > ansa){
            ansa = a;
            ansb = b;
        }
    }

    cout << ansa + ansb << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int,input().split()))
X =[0]*N
sum_=0
for i in range(N):
  if i%2==0:
    sum_=sum_+A[i]
  else:
    sum_=sum_-A[i]
X[0]=int(sum_/2)
for i in range(1,N):
  X[i]=A[i-1]-X[i-1]
X = list(np.array(X)*2)
print(*X)

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

int main(){
    int n; cin >> n;
    int x[n]; rep(i, n) cin >> x[i];

    int sum = accumulate(x, x+n, 0);
    int p = sum/n;
    double ave = double(sum)/n;
    if((ave - p) > 0.5) p++;

    int ans = 0;
    rep(i, n) ans += (x[i] - p)*(x[i] - p);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s1, s2, s3;
  scanf("%c%c%c", &s1, &s2, &s3);

  int ans = (int)(s1 - '0') + (int)(s2 - '0') + (int)(s3 - '0');
  printf("%d\n", ans); 
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	int tc;
	char input[105];
	scanf("%d",&tc);
	scanf("%s",input);
	int len = strlen(input);
	for(int i = 0;i<tc;i++)
	{
		if(tc >= len)
		{
			printf("%s",input);
			break;
		}
		else if(tc < len)
		{
			printf("%c",input[i]);
		}
	}
	if(tc < len ) printf("...\n");
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a;
  vector<int> list;
  int sum=0;
  
  for(int i=0;i<n;i++){
    int b;
    cin>>b;
    a.push_back(b);
  }
  
  int result=0;
  
  for(int i=*min_element(a.begin(),a.end());i<=*max_element(a.begin(),a.end());i++){
    sum=0;
    for(int j=0;j<n;j++){
      sum+=pow(a.at(j)-i,2);
    }
    list.push_back(sum);
  }
  result=*min_element(list.begin(),list.end());
  
  cout<<result<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int v[202020];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,x;
	cin>>n>>x;
	if (x==1||x==n*2-1) {
		cout<<"No"<<endl;
		return 0;
	}
	else{
		cout<<"Yes"<<'\n';
		if (n==2){
			cout<<1<<endl<<2<<endl<<3<<endl;
			return 0;
		}
		set<int> fr;
		for (int i=1;i<=n*2-1;i++) fr.insert(i);
		v[n-1]=x;
		fr.erase(x);
		v[n-2]=x-1;
		fr.erase(x-1);
		v[n]=x+1;
		fr.erase(x+1);
		if (x+2<=n){
			v[n-3]=x+2;
			fr.erase(x+2);
		}
		else{
			v[n+1]=x-2;
			fr.erase(x-2);
		}
		for (int i=0;i<2*n-1;i++){
			if (v[i]) cout<<v[i]<<'\n';
			else{
				auto it=fr.begin();
				cout<<(*it)<<'\n';
				fr.erase(it);
			}
		}
	}
}

Measured memory_bytes: 10880
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
card = [0 for i in range(n + 1)]
for i, j in lr:
    card[i - 1] += 1
    card[j] -= 1

for i in range(1, n + 1):
    card[i] += card[i - 1]
ans = 0
for i in card[:-1]:
    if i == m:
        ans += 1
print(ans)

Measured memory_bytes: 66520
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

//I imitated Ant-Book version 1.0 P.120

int func(int a,int b,int& ans_x,int& ans_y){
	if(b == 0){
		ans_x = 1;
		ans_y = 0;
		return a;
	}else{
		int ret = func(b,(a%b),ans_y,ans_x);
		ans_y -= (a/b)*ans_x;
		return ret;
	}
}

int main(){

	int A,B,ans_x,ans_y;

	scanf("%d %d",&A,&B);

	func(A,B,ans_x,ans_y);

	printf("%d %d\n",ans_x,ans_y);

	return 0;
}



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

const long double PI = (acos(-1));

int main() {
    long double a, b, x;
    cin >> a >> b >> x;

    long double ans;
    if (a * a * b / 2.0 <= x) {
        ans = atan(2.0 * (a * a * b - x) / (a * a * a)) * 180 / PI;
    } else {
        ans = atan((a * b * b) / (2.0 * x)) * 180 / PI;
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int w, a, b;
    cin >> w >> a >> b;
    int ans = 0;
    if (a <= b) {
        ans = max(b - (a + w), 0);
    } else {
        ans = max(a - (b + w), 0);
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define s_cin(X) scanf("%s",&X)


#define  i_cout(X) printf("%d\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

int main(void) {
	int   N, i, j, cnt,ocnt=0;
	i_cin(N);
	if (N <= 24) {i_cout(0); return 0;}
	for (i = 25; i <= N; i++) {
		if (!(i%2)) continue;
		if (i == pow((int)sqrt(i), 2)) continue;
		cnt = 2;
		for (j = 2; j < i; j++) {
			if (!(i % j)) cnt++;
			if (cnt > 8)break;
		}
		if (cnt == 8) ocnt++;
	}
	i_cout(ocnt);
	return 0;
}



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

int main()
{
	long long sum=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
		sum+=(int)(s[i]-'0');
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    string s; cin>>s;
    s += '#';
    ll ans = 0;
    ll tmp = 0;
    rep(i,4){
        chmax(ans,tmp);
        if(s[i] == 'R'){
            tmp ++;
        }else{
            tmp = 0;
        }
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3616
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int m = sc.nextInt();
    int d = sc.nextInt();

    int ans = 0;
    for(int i = n; i <= m; i++){
      if(i % d == 0){
        ans++;
      }
    }
    System.out.println(ans);


  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 25348
while true
	n = gets
	exit if n == nil
	count = 0
	n = n.to_i
	10.times do |a|
		10.times do |b|
			10.times do |c|
				10.times do |d|
					count += 1 if a + b + c + d == n
				end
			end
		end
	end
	puts count
end

Measured memory_bytes: 8480
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    int N;
    vector<int> p;

    cin >> N;
    for (int i = 0; i < N; ++i) {
        int pp;
        cin >> pp;
        p.push_back(pp);
    }

    int max =0;
    for (int i = 0; i < N; ++i) {
        if(max <p[i]){
            max = p[i];
        }
    }
    int result = 0;
    for (int i = 0; i < N; ++i) {
        result+=p[i];
    }
    result -= max / 2;

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	static final int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();

        if((X+Y) %3 != 0) {
        	System.out.print(0);
        	return;
        }

        int m = (2 * X - Y) / 3;
        int n = X -2 * m;

        if(m < 0 || n < 0) {
        	System.out.print(0);
        	return;
        }
        
        intFactorial() ;
        System.out.println(combination(m+n, m));
	}

	//階乗時の各値をMODの元で計算しておく
	static long[] factorial = new long[10000000];
	static void intFactorial() {
		factorial[0] = 1;
		for(int i = 1; i < 10000000; i++) {
			factorial[i] = factorial[i-1] * i % MOD;
		}

	}

	//フェルマーの小定理を利用して,pを法としてのaの逆元a^p-2を求める
	public static long MODinv(long a ,long p) {
		return modpow(a ,p-2 ,p);
	}

	//a^n (mod p)を二分累乗法で計算する
	public static long modpow(long a, long n, long p) {
		long ans = 1;
		while(n > 0) {
			if(n%2 == 1) {
				ans = ans * a % p;
			}
			n = n / 2;
			a = a * a % p;
		}
		return ans;
	}

	//nCrをMODを法として計算する
	static long combination(int n, int r) {
		if(n==0 && r==0) return 1;
		if(n<r || n<0) return 0;
		
		return (factorial[n] * MODinv(factorial[r], MOD)) % MOD * MODinv(factorial[n-r], MOD) % MOD;
	}








}







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

int main(){
    int N;
    cin >> N;
    multiset<ll> A;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.insert(a);
    }
    
    int ans = 0;
    while (!A.empty()) {
        auto it = A.end();
        it--;
        ll t = 1;
        while (t <= (*it)) t *= 2;
        auto it2 = A.find(t-(*it));
        if (it2 != it && it2 != A.end() && (*it)+(*it2) == t) {
            ans++;
            A.erase(it2);
            it = A.end();
            it--;
            A.erase(it);
        }
        else {
            A.erase(it);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
unordered_map<ll,ll> mp;
//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c>>d;
    mp[a]++;mp[b]++;mp[c]++;mp[d]++;
    if(mp[1]!=0&&mp[9]!=0&&mp[7]!=0&&mp[4]!=0)Cout("YES");
    else Cout("NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	ll m=k;
	int sum=0;
	while(k<=n)
	{
		k*=m;
		sum++;
	}
	cout<<sum+1<<endl;
	return 0;
}



Measured memory_bytes: 256
A, B = map(int, input().split())

a = [i for i in range(int((A-1)*100/8 ), int((A+1)*100/8 ))]
b = [i for i in range(int((B-1)*100/10), int((B+1)*100/10))]

a = [i for i in a if int(i*0.08) == A]
b = [i for i in b if int(i*0.10) == B]

ans = list(set(a) & set(b))
if ans and min(ans) > 0:
    print(min(ans))
else:
    print(-1)


Measured memory_bytes: 9192
import math

Q = int(input())
lr = [list(map(int, input().strip().split())) for _ in range(Q)]

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
sosu_list = get_sieve_of_eratosthenes(10**5)
sosu = [0]*10**5
for i in sosu_list:
  sosu[i] = 1
acc = [0]*10**5
for i in range(3, 10**5, 2):
  if sosu[i] and sosu[(i+1)//2]:
    acc[i] = acc[i-2] + 1
  else:
    acc[i] = acc[i-2]

for l, r in lr:
  if l == 1:
    print(acc[r])
  else:
  	print(acc[r]-acc[l-2])


Measured memory_bytes: 33012
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, C;
  cin >> A >> B >> C;
  int ans = 3 * max({A, B, C}) - (A + B + C);
  if (ans % 2 == 1)
    ans += 3;
  print(ans / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi a,b;

int main(){
  cin>>n>>m;
  a=vi(n);b=vi(m);
	for(auto &i:a) cin>>i;
  for(auto &i:b) cin>>i;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll res=1,x=n-1,y=m-1;
  for(int i=n*m;i>0;i--){
    bool c=0,d=0;
    if(x>=0&&a[x]==i) c=1;
    if(x>0&&a[x-1]==i) res=0;
    if(y>=0&&b[y]==i) d=1;
    if(y>0&&b[y-1]==i) res=0;
    if(c&&d) res*=1;
    else if(c) res*=m-y-1;
    else if(d) res*=n-x-1;
    else res*=max(0ll,(n-x-1)*(m-y-1)-n*m+i);
    if(c) x--;if(d) y--;
    res%=mod;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long k, std::vector<long long> a){
    i64 ng = 0, ok = *max_element(a.begin(), a.end());
    while(ok - ng > 1){
        i64 val = (ok + ng) / 2;
        i64 cnt = 0;
        for(auto x : a){
            cnt += (x - 1) / val;
        }
        (cnt <= k ? ok : ng) = val;
    }
    cout << ok << endl;
}


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


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define Task "B"

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, h, k, res = 0;
    cin >> n >> k;
    for(int i = 1; i<=n; ++i){
        cin >> h;
        if (h >= k) res++;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i, a) for(int i = 0; i < a; ++i)

int main(void) {
  char ts[150], p[150], s[300];
  int i, j;
  scanf("%s", ts);
  scanf("%s", p);
  rep(i, strlen(ts)) s[i] = ts[i];
  rep(i, strlen(ts)) s[i + strlen(ts)] = ts[i];
  s[strlen(ts) * 2] = 0;
  rep(i, strlen(ts)) {
    rep(j, strlen(p)) {
      if(s[i + j] != p[j]) break;
      if(j == strlen(p) - 1) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 2688
n, k = map(int, input().split())
mod = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    mn = (i - 1) * i // 2
    mx = (2 * n - i + 1) * i // 2
    ans += mx - mn + 1
    ans %= mod

print(ans)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int n; cin >> n;
    int same=0;
    bool ans=false;
    rep(i,n){
        int di, dii; cin >> di >> dii;
        if (di==dii) same++;
        else same=0;
        if (same==3) ans=true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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


typedef struct{
  int p, l, r;
  
}no;

void p(int);
void in(int);
void po(int);

no *data;

int main(){
  int i, a, o, r;

  scanf("%d",&o);
  
  data=(no *)malloc(sizeof(no)*o);
  
  for(i=0;i<o;i++){
    data[i].p=-1;
  }

  
  for(i=0;i<o;i++){
    scanf("%d",&a);
    scanf(" %d %d",&data[a].l,&data[a].r);
    data[data[a].l].p=a;
    data[data[a].r].p=a;
  }


  i=0;


  
  while(data[i].p!=-1){
    i++;
  }
  r=i;
  printf("Preorder\n");
  p(r);
  printf("\n");
  printf("Inorder\n");
  in(r);
  printf("\n");
  printf("Postorder\n");
  po(r);
  printf("\n");
  
  free(data);
  return 0;
}
void po(int p){

  if(data[p].l!=-1) po(data[p].l);
  if(data[p].r!=-1) po(data[p].r);

  printf(" %d",p);
}
  void p(int p1){
    printf(" %d",p1);

    if(data[p1].l!=-1) p(data[p1].l);
    if(data[p1].r!=-1) p(data[p1].r);
  }

  void in(int in1){
    if(data[in1].l!=-1) in(data[in1].l);

    printf(" %d",in1);

    if(data[in1].r!=-1) in(data[in1].r);
  }




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

typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    
    if (n&1 == 1) { cout << 0 << endl; return 0; }
    
    n = n/2;
    ll cnt = 0;
    while (n) { n /= 5; cnt += n; }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

N = int(input())
e = [0 for _ in range(N + 1)]

for x in range(2, N + 1):
    for p in range(2, x + 1):
        while x % p == 0:
            x //= p
            e[p] += 1

a = tuple(filter(lambda v: v > 0, e))
# print(a)
t = 1
for aa in a:
    t *= (aa + 1)
    t %= MOD
print(t)


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> l, r;
  int cnt = 0;
  rep(i, S.size()) {
    if (i == 0)
      cnt++;
    else {
      if (S[i - 1] == S[i])
        cnt++;
      else {
        if (S[i - 1] == 'L')
          l.eb(cnt);
        else
          r.eb(cnt);
        cnt = 1;
      }
    }
  }
  if (S.back() == 'L')
    l.eb(cnt);
  else
    r.eb(cnt);

  int ans = 0;

  if (l.size() == r.size()) {
    if (K >= l.size())
      ans = (l.size() - 1) * 2 + 1;
    else
      ans = K * 2;
  } else {
    int m = min(l.size(), r.size());
    if (K >= m)
      ans = m * 2;
    else
      ans = K * 2;
  }

  rep(i, N) {
    if (i < l.size()) ans += l[i] - 1;
    if (i < r.size()) ans += r[i] - 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1020
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
        /*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
ll i,j;
void solve()
{
	 ll n;
         cin>>n;
         ll a[40001]={0};
         for(int i=1;i<=200;i++)
         {
         	 for(int j=1;j<=200;j++)
         	 {
         	 	for(int k=1;k<=200;k++)
         	 	{
         	 		 ll m=i*i+j*j+k*k+i*j+j*k+k*i;
         	 		 if(m<=40000)
         	 		   a[m]++;
         	 		   else
         	 		   break;
         	 	}
         	 }
         }
         for(int i=1;i<=n;i++)
          cout<<a[i]<<endl;
}
    
int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
}    	

Measured memory_bytes: 3848
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	new aoj0059().doIt();
    }
    class aoj0059{
    	double roop(double x,double q){
    		if(Math.abs(x*x*x-q) < 0.00001*q)return x;
    		return roop(x-(x*x*x-q)/(3*x*x),q);
    	}
    	void doIt(){
    		while(true){
    			double q = sc.nextDouble();
    			if(q == -1)break;
    			double x = q / 2.0;
    			System.out.printf("%.6f\n", roop(x,q));
    		}
    	}
    }
}

Measured memory_bytes: 28136
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()


signed main(){
  int n;
  cin>>n;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  V<int> b(n);
  fo(i,n){
    cin>>b[i];
  }
  V<int> c(n);
  fo(i,n){
    c[i]=i+1;
  }
  int d,e;
  int i=0;
  do{
    if(a==c)
      d=i;
    if(b==c)
      e=i;
    i++;
  }while(next_permutation(all(c)));
  cout<<abs(d-e)<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApp1
{
    public class node
    {
        public List<node> connect = new List<node>();
        public int index;
    }
    class Program
    {
        static void Main(string[] args)
        {
            var temp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var n = temp[0];
            var k = temp[1];

            node[] nodes = Enumerable.Range(1, (int)n+1).Select(x => new node { index = x }).ToArray();

            int[] a = new int[n + 1];
            int[] b = new int[n + 1];
            for (int i = 1; i < n; i++)
            {
                var t= Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                a[i] = t[0];
                b[i] = t[1];
                nodes[a[i]].connect.Add(nodes[b[i]]);
                nodes[b[i]].connect.Add(nodes[a[i]]);
            }
            int ans = int.MaxValue;
            if (k%2==0)ans = (int)n - nodes.Select(x => search(x, null, (int)k/2)).Skip(1).Max();
            else
            {
                for (int i = 0; i < n; i++)
                {
                    var q1 = search(nodes[a[i]], nodes[b[i]], (int)(k - 1) / 2);
                    var q2 = search(nodes[b[i]], nodes[a[i]], (int)(k - 1) / 2);
                    var result = (int)n - q1 - q2;
                    if (result < ans) ans = result;
                }
            }
            Console.WriteLine(ans);
        }

        /// <summary>k個以内のノード数(自分含めて)</summary>
        static int search(node node,node pre, int k)
        {
            if (k == 0) return 1;
            int result = 1;
            foreach (var item in node.connect)
            {
                if (item == pre) continue;
                result += search(item, node, k - 1);
            }
            return result;
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int len;
string s[62];
int step;
int ask(string s){
assert(++step<=850);
	cout<<"? "<<s<<endl;
	int x;cin>>x;return x;
}
string solve(int l,int r){
	if(l==r)return s[l];
	int m=l+r>>1;
	string L=solve(l,m),R=solve(m+1,r);
	if(L.empty())return R;
	if(R.empty())return L;
	string ret;int i=0,j=0;
	for(;i<L.size() || j<R.size();)
		if(i<L.size() && (j==R.size() || ask(ret+L[i]+string(R.begin()+j,R.end()))
				==len-ret.size()-1-(R.size()-j)))ret=ret+L[i++];
			else ret=ret+R[j++];
	return ret;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int p=0;char c;
	for(c='a';c<='z';++c)s[p++]=string(128-ask(string(128,c)),c);
	for(c='A';c<='Z';++c)s[p++]=string(128-ask(string(128,c)),c);
	for(c='0';c<='9';++c)s[p++]=string(128-ask(string(128,c)),c);
	for(auto u:s)len+=u.size();
auto zz=solve(0,61);
assert(zz.size()<=128 && zz.size()==len);
	cout<<"! "<<zz<<endl;
}

Measured memory_bytes: 3800
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 2e5 + 10, INF = 1e9 + 100, lg = 19;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, mx = 0;
	cin >> n;
	map < string, int > mp1, mp2;
	string s[n + 1];
	for(int i = 1; i <= n; i++){
		cin >> s[i];
		mp1[s[i]] ++;
		mx = max(mx, mp1[s[i]]);
	}
	vector < string > ans;
	for(int i = 1; i <= n; i++){
		if(mp2[s[i]] == 1)continue;
		if(mp1[s[i]] == mx)ans.push_back(s[i]);
		mp2[s[i]] = 1;
	}
	sort(ans.begin(), ans.end());
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
  cin >> N >> K;
  vector<int> A(N,0);
  for(int a = 0;a < N;a++)cin >> A[a];
  sort(A.begin(),A.end());
  int count = 0;
  for(int a = 0;a < K;a++){
   count += A[a]; 
  }
  cout << count << endl;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p[i];
  
  int cnt = 0;
  for(int i=0; i<(n-2); i++){
    if(p[i]<p[i+1] and p[i+1]<p[i+2]){
      cnt += 1;
    }else if(p[i]>p[i+1] and p[i+1]>p[i+2]){
      cnt += 1;
    }
  
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n;
int a[224514];
map<int, int>mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (i - a[i] + 1 >= 0)mp[i - a[i] + 1]++;
	}
	rep(i, n)ans += mp[a[i] + i + 1];
	cout << ans << endl;
	ggr
}


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

int main()
{
	string a;
	cin >> a;
	
	if (a.size()!=6)
	{
		cout << "No";
		return 0;
	}
	for (int i=0;i<a.size();i++)
	{
		if (a[i]<'a' || a[i]>'z'){
	        cout << "No";
			return 0;
		}
		 	  
	}
	
	if(a[2]==a[3] && a[4]==a[5])
	{
		cout << "Yes";
		return 0;
	}
	
	cout <<"No";
	return 0;
 } 

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

const int MAX_N = 110000;

int dp[MAX_N];

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

    for (int i = 0; i < MAX_N; ++i) dp[i] = N;
    dp[0] = 0;

    for (int n = 0; n < N; ++n) {
        for (int pow6 = 1; n + pow6 <= N; pow6 *= 6) {
            dp[n+pow6] = min(dp[n + pow6], dp[n] + 1);
        }
        for (int pow9 = 1; n + pow9 <= N; pow9 *= 9) {
            dp[n+pow9] = min(dp[n+pow9], dp[n] + 1);
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

void printArray(vector<int> v){
    rep(i, v.size()){
        if(i) cout << " ";
        cout<< v[i];
    }
    cout << endl;
}

void print2dArray(vector<vector<int> > vv){
    rep(i, vv.size()){
        rep(j, vv[i].size()){
            if(j) cout << " ";
            cout << vv[i][j];
        }
        cout << endl;
    }
}

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int a, b;
    cin >> a >> b;
    for(int i=1; i<=3; i++){
        if(i != a && i != b)cout << i << endl;
    }
    
    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;
import java.util.function.Function;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            String[] sp = str.split(" ");
            int m = Integer.parseInt(sp[0]);
            int f = Integer.parseInt(sp[1]);
            int r = Integer.parseInt(sp[2]);
            if(isFin(m,f,r))break;
            System.out.println(judge(m, f, r));
        }
    }

    boolean isFin(int m, int f, int r) {
        return m == -1 && f == -1 && r == -1;
    }

    String judge(int m, int f, int r) {
        int sum = m + f;
        if (m == -1 || f == -1 || sum < 30) return "F";
        if (sum < 50) return r >= 50 ? "C" : "D";
        if (sum < 65) return "C";
        if (sum < 80) return "B";
        return "A";
    }
}


Measured memory_bytes: 26164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll a[100010];

int main(){
    ll n, k;
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    ll g = a[0];
    ll mx = a[0];
    rep(i, n-1){
        g = __gcd(g, a[i+1]);
        mx = max(mx, a[i]);
    }

    if (k%g == 0 && k <= mx) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n;
  cin>>n;
  vector<int> a(3,0);
  int tmp,cnt=0;
  r(i,n){
    cin>>tmp;
    cnt=0;

    while(tmp>0){
      if(tmp%2==0){
        tmp/=2,cnt++;
        if(cnt==2)break;
      }else{break;}
    }
    if(cnt==1)a.at(1)++;
    else if(cnt>=2)a.at(2)++;
    else a.at(0)++;
  }
  //r(i,3)cout<<a.at(i)<<endl;

  if(a.at(1)!=0){
    if(a.at(0)<=a.at(2)){cout<<"Yes"<<endl;}
    else cout<<"No"<<endl;
  }else{
    if(a.at(0)-1<=a.at(2)){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }

  return 0;
}


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

int main(){
      int n;cin >> n;
      int l;cin >> l;
      int arr[n + 10];
      int ans = 0;
      int minn = 1;
      for(int i = 1;i <= n;i++){
            arr[i] = l + i - 1;
            ans += arr[i];
            if(abs(arr[i]) < abs(arr[minn]))minn = i;
      }
      ans -= arr[minn];
      cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define eps 1e-7
#define int ll
using pii = pair <int, int>;

int32_t main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int st = (n/(a+b));
    int left = n-(st*(a+b));
    int blue = st*a;
    cout << blue+(min(left, a));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(i,a) for(ll i=0LL;i<a;i++)
#define fab(i,a,b) for(ll i=a;i<=b;i++)
#define fba(i,a,b) for(ll i=b;i>=a;i--)
#define rf(i,a) for(ll i=a;i>=0;i--)
#define arr(n) ll a[n]; fr(i,n) cin>>a[i];
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 10000000007
#define MAX 10000007
#define endl "\n"
#define ui unsigned int
#define ull unsigned long long int
#define ll long long int
#define V1 vector<ll>v
#define V2 vector<int>v
#define VP1 vector<pair<ll,ll>> vp
#define VP2 vector<pair<int,int>>vp
#define pb push_back

ll dp[MAX][3];

ll vac(ll i,ll n,ll a[][3],ll piv)
{
    if(i<0)
    return 0;
    if(i==n)
    {
        dp[i][0]= a[i][0] + max(vac(i-1,n,a,1),vac(i-1,n,a,2));
        dp[i][1]= a[i][1] + max(vac(i-1,n,a,0),vac(i-1,n,a,2));
        dp[i][2]= a[i][2] + max(vac(i-1,n,a,1),vac(i-1,n,a,0));
        return max(dp[n][0],max(dp[n][1],dp[n][2]));
    }
    else if(dp[i][piv]!=-1)
    return dp[i][piv];
    else
    {
        if(piv==0)
        {
            dp[i][piv]= a[i][piv] + max(vac(i-1,n,a,1),vac(i-1,n,a,2));
            return dp[i][piv];
        }
        if(piv==1)
        {
            dp[i][piv]= a[i][piv] + max(vac(i-1,n,a,0),vac(i-1,n,a,2));
            return dp[i][piv];
        }
        if(piv==2)
        {
            dp[i][piv]= a[i][piv] + max(vac(i-1,n,a,1),vac(i-1,n,a,0));
            return dp[i][piv];
        }

    }
}

int main() {
	sup;
	ll m,cost=0;
	cin>>m;
	ll a[m][3];
	fr(i,m)
	    cin>>a[i][0]>>a[i][1]>>a[i][2];
	fr(i,m)
    {
        dp[i][0]=-1;
        dp[i][1]=-1;
        dp[i][2]=-1;
    }
	cost=vac(m-1,m-1,a,0);
	cout<<cost<<endl;
	return 0;
}




Measured memory_bytes: 14464
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str=br.readLine();
			String[] num=str.split(" ");
			int a=Integer.parseInt(num[0]);
			String op=num[1];
			int b=Integer.parseInt(num[2]);
			
			if(op.equals("+")){
				System.out.println(a+b);
			}
			else if(op.equals("-")){
				System.out.println(a-b);
			}
			else if(op.equals("*")){
				System.out.println(a*b);
			}
			else if(op.equals("/")){
				System.out.println(a/b);
			}
			else{
				break;
			}
		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string a[H];
  for (int i = 0; i < H; i++) {
    cin >> a[i];
  }
  string st = "##";
  for (int i = 0; i < W; i++)
    st += "#";
  
  cout << st << endl;
  for (int i = 0; i < H; i++)
    cout << "#" << a[i] << "#" << endl;
  cout << st << endl;
}

Measured memory_bytes: 256