akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;
char str[maxn];

int main(){
    scanf("%s", str);
    int n = strlen(str);
    for(int i = 0; i + 1 < n; i++){
        if(str[i] == str[i + 1]){
            printf("%d %d\n", i + 1, i + 2);
            return 0;
        }
    }
    for(int i = 0; i + 2 < n; i++){
        if(str[i] == str[i + 2]){
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    }
    puts("-1 -1");
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int N; long long A[20002];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%lld", &A[i]);

	int ans = 0;
	for (long long p = 1, d = 0; d < 17; p *= 10, d++)
	{
		long long x = p * 10;
		for (int s = 9; s >= 0; s--) {
			vector<pair<long long, long long> > now;
			now.emplace_back(s * p, (s + 1) * p - 1);

			for (int i = 0; i < N; i++) {
				vector<pair<long long, long long> > nxt = now;
				for (auto &p : now) {
					long long s = (p.first - A[i] % x + x) % x;
					long long e = (p.second - A[i] % x + x) % x;
					if (s <= e) nxt.push_back({ s,e });
					else {
						nxt.push_back({ 0,e });
						nxt.push_back({ s,x - 1 });
					}
				}

				sort(nxt.begin(), nxt.end());
				long long s = nxt[0].first, e = nxt[0].second;
				now.clear();
				for (auto &p : nxt) {
					if (p.first <= e + 1) {
						e = p.second;
					}
					else {
						now.push_back({ s,e });
						s = p.first;
						e = p.second;
					}
				}
				now.push_back({ s,e });
			}

			if (now[0].first == 0) {
				ans += s;
				break;
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int a,b,max;
  cin >> a >> b;
  max = a + b;
  if(max < a-b) max = a-b;
  if(max < a*b) max = a*b;
  cout << max << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll INF = 1e18;

int main() {
    ll n, W; cin >> n >> W;
    vector<ll> vvec(n, 0);
    vector<ll> wvec(n, 0);
    ll Vmax = 0;
    for(int i = 0; i < n; ++i) {
        cin >> vvec[i] >> wvec[i];
        chmax(Vmax, vvec[i]);
    }
    
    vector< vector<ll> > dp(n+1, vector<ll>(Vmax*110, INF));
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= Vmax*100; ++j) {
            if(j+vvec[i] <= Vmax*100) chmin(dp[i+1][j+vvec[i]], dp[i][j]+wvec[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    for(int j = 0; j <= Vmax*100; ++j) {
        if(dp[n][j] <= W) ans = j;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
bool good(string s){
	string tmp = s;
	reverse(all(tmp));
	return tmp == s;
}
bool check(string s, int i, int j){
	string tmp = "";
	for(int k = i; k <= j; k++){
		tmp += s[k];
	}
	return good(tmp);
}
int main(){
	string a; cin>>a;
	int n = sz(a);
	a = ' ' + a;
	cout<<(check(a, 1, n) && check(a, 1, (n - 1) / 2) && check(a, (n + 3) / 2, n) ? "Yes\n" : "No\n");
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll tmpC = b / c - a / c;
  ll tmpD = b / d - a / d;
  ll l = lcm(c, d);
  ll tmp = b / l - a / l;
  if (a % c == 0) ++tmpC;
  if (a % d == 0) ++tmpD;
  if (a % l == 0) ++tmp;
  cout << b-a+1 - tmpC - tmpD + tmp << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define SZ(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const int inf=1e9;
int k,dist[123456];

int main() {
	cin>>k;
	deque<int> q;
	q.pb(1);
	fill_n(dist,123456,inf);
	dist[1]=1;
	while (!q.empty()) {
		int x=q.front();
		q.pop_front();
		if (dist[x]<dist[10*x%k]) {
			dist[10*x%k]=dist[x];
			q.push_front(10*x%k);
		}
		if (dist[x]+1<dist[(x+1)%k]) {
			dist[(x+1)%k]=dist[x]+1;
			q.pb((x+1)%k);
		}
	}
	printf("%d\n",dist[0]);
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int r = Integer.parseInt(in.readLine());
    System.out.println(r*r);
  }
}

Measured memory_bytes: 21588
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

ll sumf(const vector<ll> &a,ll lb){
	ll re=0;
	for(auto x:a) re+=max(0ll,x-lb);
	return re;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n,m;
	ll t;
	cin>>n>>m>>t;
	vector<ll> a(n);
	for(auto &x:a) cin>>x;
	sort(all(a));
	int rem=m;
	while(a.size() && rem>=a.back()){
		rem-=a.back();
		a.pop_back();
	}
	if(a.empty()){
		cout<<0 NL;
		return 0;
	}
	out(a,1);
	//keep x==rem if pos
	if(t>sumf(a,rem+1)){
		assert(a.back()>=rem);
		t-=a.back()-rem;
		rem=0;
		a.pop_back();
	}
	if(a.empty()){
		cout<<0 NL;
		return 0;
	}
	out(a,1);

	if(t>=sumf(a,0)){
		cout<<0 NL;
		return 0;
	}
	int l=0,r=MOD;
	while(r-l>1){
		int m=(l+r)/2;
		(sumf(a,m)<=t?r:l)=m;
	}
	out(a,r,1);
	t-=sumf(a,r);
	for(auto &x:a) MN<ll>(x,r);
	rep(i,t) --a[a.size()-1-i];
	sort(rall(a));
	ll re=0;
	for(ll x:a){
		ll t=min<ll>(x,rem);
		rem-=t;
		re+=x*(x+1)/2-t*(t+1)/2;
	}
	cout<<re NL;
  return 0;
}




Measured memory_bytes: 3628
/**
*    author:  boutarou
*    created: 15.08.2020 21:04:28
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int now = 0;
    rep(i, 3) {
        if (s[i] == 'S') now = 0;
        if (s[i] == 'R') now++;
        chmax(ans, now); 
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> hight(N);
  for(int i=0;i<N;i++)
    cin>>hight.at(i);
  
  int count=1;
  int R=0;
  for(int i=1;i<N;i++){
    for(int j=0;j<i;j++){
    	if(hight.at(j)<=hight.at(i))
          R++;
    }
    if(R==i)
      count++;
    R=0;
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = "APPROVED"
for i in range(len(A)):
    flag = 1
    if A[i]%2 == 0:
        if A[i]%3 != 0:
            flag = flag - 1
        if A[i]%5 != 0:
            flag = flag - 1  
        if flag < 0: 
            ans = "DENIED"
print(ans)

Measured memory_bytes: 3060
from string import ascii_uppercase
import sys
readline = sys.stdin.readline
write = sys.stdout.write

conv = ascii_uppercase.find

def solve():
    N = int(readline())
    if N == 0:
        return False
    W = [tuple(map(conv, readline().strip())) for i in range(N)]
    S = []
    T = set()
    for s in readline().strip()[:-1].split():
        e = tuple(map(conv, s))
        S.append(e)
        T.add(e)
    *T, = T
    U = []
    for s in T:
        g = []
        for i, w in enumerate(W):
            if len(w) != len(s):
                continue
            p = [-1]*26
            l = len(w)
            for k in range(l):
                if p[s[k]] == p[w[k]] == -1:
                    p[s[k]] = w[k]
                    p[w[k]] = s[k]
                elif p[s[k]] == -1 or p[w[k]] == -1 or p[s[k]] != w[k]:
                    break
            else:
                g.append(i)
        U.append((s, g))
    L = len(U)
    U.sort(key = lambda x: len(x[1]))
    res = None
    cnt = 0
    def dfs(i, p0, used):
        nonlocal res, cnt
        if i == L:
            res = p0[:]
            cnt += 1
            return
        p = [0]*26
        s, g = U[i]
        for j in g:
            if used[j]:
                continue
            w = W[j]
            p[:] = p0

            l = len(w)
            for k in range(l):
                if p[s[k]] == p[w[k]] == -1:
                    p[s[k]] = w[k]
                    p[w[k]] = s[k]
                elif p[s[k]] == -1 or p[w[k]] == -1 or p[s[k]] != w[k]:
                    break
            else:
                used[j] = 1
                dfs(i+1, p, used)
                used[j] = 0
            if cnt >= 2:
                return
    dfs(0, [-1]*26, [0]*N)
    if cnt != 1:
        write("-.\n")
    else:
        cA = ord("A")
        ans = []
        for s in S:
            t = []
            for e in s:
                t.append(chr(res[e] + cA))
            ans.append("".join(t))
        write(" ".join(ans))
        write(".\n")
    return True
while solve():
    ...


Measured memory_bytes: 6928
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        a:u64,
        b:u64,
        c:u64,
        d:u64
    }
    
    
    let mut temp:u64;

    let mut m = d.clone();
    let mut n = c.clone();

    while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}

    let min_multi = d*c/n;

    //println!("{}", min_multi);

    let diff_c = b/c - (a-1)/c;
    let diff_d = b/d - (a-1)/d;
    let diff_mulit = b/min_multi - (a-1)/min_multi;

    //println!("{} {} {}", diff_c, diff_d, diff_mulit);

    let muti_num = diff_c + diff_d -diff_mulit;

    let ans = b-a+1-muti_num;
    println!("{}", ans)

}

Measured memory_bytes: 4352
import itertools

def is_same(tpl, lst):
    for i in range(len(lst)):
        if tpl[i] != lst[i]:
            return False
    return True

# 整数の入力
n = int(input())
# スペース区切りの整数の入力
p_list_str = input().split(' ')
q_list_str = input().split(' ')

p_list = []

for item in p_list_str:
    p_list.append(int(item))
    
q_list = []

for item in q_list_str:
    q_list.append(int(item))

l = range(1, n+1)

iter_list = list(itertools.permutations(l))
a = 0
b = 0

for i in range(len(iter_list)):
    item = iter_list[i]
    if is_same(item, p_list):
        a = i
    if is_same(item, q_list):
        b = i

print(abs(a-b))


Measured memory_bytes: 8052
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail]=x;
    if(tail+1==n){
        tail=0;
    }
    else{
        tail++;
    }
}

P dequeue(){
    P x;
    x=Q[head];
    if(head+1==n){
        head=0;
    }
    else{
        head++;
    }
    return x;
}


int main(){
  int elaps = 0, c=0;
  int i, q, k=0,timec=0;
  P u,Q2[100000];
  scanf("%d %d", &n, &q);

  for ( i=0;i<n;i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  for(i=0;i<n;i++){
      elaps=Q[i].t-q;
      u=Q[i];
      dequeue();
      if(elaps>0){
          u.t=elaps;
          enqueue(u);
          timec+=q;
      }
      else{
          timec+=u.t;
          u.t=timec;
          Q2[c]=u;
          c++;
          if(c==n){
              break;
          }
      }
      if(i==n-1){
          i=-1;
      }
  }
  for(i=0;i<n;i++){
      printf("%s %d\n",Q2[i].name,Q2[i].t);
  }
  return 0;
}


Measured memory_bytes: 12020
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n,count = 0;
    string s,t,ans;

    cin >> n;
    cin >> s >> t;

    for(int i = 0;i < 2*n;i++){
        if(i % 2 != 0){
            ans += t[count];
            count++;
        }else{
            ans += s[count];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,flg;
	char s[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%c",&s[i]);
	flg=0;
	for(i=0;i<n;i++)	{
		if(s[i]=='Y')	flg=1;
	}
	if(flg==0)	printf("Three\n");
	else  printf("Four\n");
	return 0;
}
		

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(x,a) for(auto& (x) : (a) )
int main(){
  int n;
  cin >> n;
  vi a(n),p(n),q(n);
  rep(i,n)cin>>p[i];
  rep(i,n){
    cin>>q[i];
    a[i]=i+1;
  }
  ll count_p=0;ll count_q=0;
  ll p_ans,q_ans;
  do{
    count_p++;
    bool ff= true;
    rep(i,n){
      if(p[i]!=a[i]){
        ff=false;}
    }
    if(ff){p_ans=count_p;}
  }while(next_permutation(been(a)));
  rep(i,n)a[i]=i+1;
  do{
    count_q++;
    bool ff= true;
    rep(i,n){
      if(q[i]!=a[i]){
        ff=false;
      }
    }
    if(ff){q_ans=count_q;}
  }while(next_permutation(been(a)));

  cout<<abs(q_ans-p_ans)<<endl;
  
}

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

int main(){
  long long x;
  cin >> x;

  bool flg = true;
  while(true){
    flg = true;
    for (long long i = 2; i * i <= x; i++)
    {
      if(x%i == 0) {
        flg = false;
        break;
      }
    }
    if(flg) break;
    x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
#define Inf 1000000000
using namespace std;
int H,W;


int X[111111];
int Y[111111];
int C[111111];

int Ym[111111];

int good[3333][3333];

bool base[111111];

int main() {
    // (dx,dy)
    // parity of (i+dx)/K+(i+dy)/K
    
    int N,K;
    
    N=100000;
    K=1000;
    
   cin>>N>>K;
    

    clock_t starttime=clock();

    vector<pair<int,int> > blacks,whites;
    
    for(int i=1;i<=N;i++) {
        int x,y;
        string color;
        
        x=rand()%1000000000+1;
        y=rand()%1000000000+1;
        color=(rand()%2?"B":"W");
        
        cin>>x>>y>>color;
        

        
        X[i]=x;
        Y[i]=y;
        C[i]=(color[0]=='W'?1:0);
        Ym[i]=Y[i]%K;
        
        base[i]=((Y[i]-Ym[i])/K)&1;
    }
    

    
    for(int i=0;i<3333;i++)
        for(int j=0;j<3333;j++)
            good[i][j]=0;
    
    for(int i=1;i<=N;i++) {
        
        
        for(int dx=-X[i]%K;dx<2*K;dx+=K)
            for(int dy=-Y[i]%K;dy<2*K;dy+=K) {
                
                bool curr = ((X[i]+dx)/K+(Y[i]+dy)/K)&1;
                
                if (curr == C[i]) {
                    // dx to dx+K-1
                    // dy to dy+K-1
                    
                    good[max(0,dx)][max(0,dy)]++;
                    good[dx+K][max(0,dy)]--;
                    good[max(0,dx)][dy+K]--;
                    good[dx+K][dy+K]++;
                    
                }
                
                
            }
        
        
        
    }
    
  
    int maxx=0;
    
    for(int i=0;i<3333;i++)
        for(int j=0;j<3333;j++) {
            
            good[i][j]+=(i>0?good[i-1][j]:0)+(j>0?good[i][j-1]:0)-(i>0&&j>0?good[i-1][j-1]:0);
            maxx=max(maxx, good[i][j]);
            
        }
    cout << maxx << endl;
    
}

Measured memory_bytes: 45440
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;
int nums[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
  int k;
  cin >> k;
  k--;
  print(nums[k]);
  return 0;
}

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

using namespace std;

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

    // int cnt = 0;
    // for(int i = 1; i <= N; i++){
    //     if(i % 2 == 1){
    //         cnt++;
    //     }
    // }

    int odd = (N+1)/2;

    printf("%.10f", (double)odd/N);


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a == b) {
			System.out.println("Draw");
		}
		else if(a == 1) {
			System.out.println("Alice");
		}
		else if(b == 1) {
			System.out.println("Bob");
		}
		else
			System.out.println(a > b ? "Alice" : "Bob");

		sc.close();

	}
}



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

struct SegTree
{
    int N;
    vector<int> seg;

    SegTree(int n)
    {
        N = 1;
        while (N < n) N<<=1;
        seg.assign((N<<1)-1,0);
    }

    void add(int k,int x)
    {
        k += N-1;

        seg[k] += x;

        while(k>0)
        {
            k = (k-1)>>1;
            seg[k] = seg[(k<<1)+1] + seg[(k<<1)+2];
        }
    }

    int sum(int a,int b) { return sum(a,b,0,0,N); }

    int sum(int a,int b,int k,int l,int r)
    {
        if ( r <= a || b <= l ) return 0;
        if ( a <= l && r <= b ) return seg[k];

        return sum(a,b,(k<<1)+1,l,(l+r)>>1) + sum(a,b,(k<<1)+2,(l+r)>>1,r);
    }
};

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

    SegTree seg(N);

    for(int i=0; i<Q; i++)
    {
        int c,x,y;
        cin >> c >> x >> y;

        if(c)
        {
            cout << seg.sum(x-1,y) << endl;
        }
        else
        {
            seg.add(x-1,y);
        }
    }
}

Measured memory_bytes: 2064
n = input()
l = len(n)

ac = 0
bc = 0

for idx, s in enumerate(n):
    if(idx % 2 == 0):
        if(s == '0'):
            ac += 1
        else:
            bc += 1
    else:
        if(s == '0'):
            bc += 1
        else:
            ac += 1

if(ac < bc):
    print(ac)
else:
    print(bc)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////


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=1; i<n-1; i++) {
        if(p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
        if(p[i-1] > p[i] && p[i] > p[i+1]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

// EOF


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

int main(int argc, const char * argv[]) {
    string cor = "CODEFESTIVAL2016";
    string s ;
    cin >> s;
    int ans =0;
    
    for(int i=0;i<s.length();i++){
        if(cor[i]!=s[i]) ans++;
    }
    cout <<ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i];
    long ans = 0L;

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    for (int i = 0; i < n; ++i) {
        auto lower = lower_bound(a.begin(), a.end(), b[i]);
        auto upper = upper_bound(c.begin(), c.end(), b[i]);

        int l = lower - a.begin();
        int u = c.end() - upper;
        ans += (long)l * u;
    }

    cout << ans << endl;

    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    double n,m,d; cin >> n >> m >> d;
    if(d == 0) cout << fixed << setprecision(10) << 1/n*(m-1) << endl;
    else cout << fixed << setprecision(10) << 2*(n-d)/(n*n)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
lis = [list(map(int, input().split())) for _ in range(n)]
minCost = float("inf")
cnt = 0
for i in lis:
    if i[1] <= t:
        if i[0] < minCost:
            minCost = i[0]
            cnt += 1
if cnt != 0:  
    print(minCost)
else:
    print('TLE')

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var Q = input[0];
            var H = input[1];
            var S = input[2];
            var D = input[3];
            var N = ReadLong();
            var lit = Q * 4;
            if (lit > H * 2) lit = H * 2;
            if (lit > S) lit = S;
            var ans = 0L;
            if (lit * 2 > D && N >= 2)
            {
                if (N % 2 == 0)
                {
                    ans += (N / 2) * D;
                }
                else
                {
                    ans += (N / 2) * D + lit;
                }
            }
            else
            {
                ans += N * lit;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main() {
string moji;
  cin>>moji;
  if(moji=="RRS" || moji=="SRR"){
    cout<<"2"<<endl;
}
  else if(moji=="RRR"){cout<<"3"<<endl;}
else if(moji=="SSS"){cout<<"0"<<endl;}
  else{cout<<"1"<<endl;}
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll a[26] {0};
    for(int i = 0; i < n; i++){
        a[s[i] - 'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 26; i++){
        ans = (ans * (a[i] + 1)) % MOD;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
n = int(input())
st = input()
b = 0
for i in range(n):
    k = list(set(st[:i]))
    u = 0
    for j in range(len(k)):
        if k[j] in st[i:]:
            u += 1
    if u > b:
        b = u
print(str(b))

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

using namespace std;

int main(){
  int N, T;
  cin >> N >> T;
  int c[N], t[N];
  int min = 1100;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    cin >> c[i] >> t[i];
    if(t[i] <= T){
      if(min > c[i]) min = c[i];
    }else cnt++;
  }
  if(cnt == N) cout << "TLE" << endl;
  else cout << min << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;
string s;
signed main(){
	cin>>n>>k>>s;
	int cnt0=0,lef=0;
	rep(rig,n){
		if(s[rig]=='0'){
			cnt0++;
			while(s[rig]!='1' && rig<n)rig++;
		}
		if((cnt0==k && s[rig+1]=='0')||rig==n-1){
			ans=max(ans,rig-lef+1);//DEB(lef)END DEB(rig)END
			lef++;
			while((s[lef-1]!='0' || s[lef]!='1') && lef<n)lef++;
			cnt0--;
		}
	}
	ans=max(ans,n-1-lef+1);
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const ll INF_LONG = 1LL << 62;
const ll INF_LONG_NEG = INF_LONG * -1;

inline int absInt(int i)
{ if (i >= 0) return i; else return i * (-1); }
template<class T> inline bool chmin(T& a, T b)
{ if (a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b)
{ if (a < b){ a = b; return true; } return false; }

int main()
{
    ll N; cin >> N;
    ll rootN = ll(sqrt(N));

    ll side1, side2;
    for (side1 = rootN; side1 >= 1; --side1){
        if (N % side1 == 0) break;
    }
    side2 = N / side1;
    cout << side1 + side2 - 2 << endl;    

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int h, w; cin >> h >> w;
    int maxdif = 0;
    vector<VI> dif(h, VI(w, 0));
    REP(i, h) REP(j, w) cin >> dif[i][j];
    REP(i, h) REP(j, w){
        int b; cin >> b;
        dif[i][j] = abs(dif[i][j] - b);
        chmax(maxdif, dif[i][j]);
    }

    // dp[i][j][k] (i, j) で偏りkにできるか?
    vector<vector<VB>> dp(h, vector<VB>(w, VB((h+w)*maxdif+1, false)));
    dp[0][0][dif[0][0]] = true;
    REP(i, h) REP(j, w){
        if(i == h-1 && j == w-1) continue;
        REP(k, (h+w)*maxdif+1){
            if(!dp[i][j][k]) continue;
            if(i < h-1){
                dp[i+1][j][k+dif[i+1][j]] = true;
                dp[i+1][j][abs(k-dif[i+1][j])] = true;
            }
            if(j < w-1){
                dp[i][j+1][k+dif[i][j+1]] = true;
                dp[i][j+1][abs(k-dif[i][j+1])] = true;
            }
        }
    }
    REP(i, (h+w)*maxdif+1){
        if(dp[h-1][w-1][i]){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 10752
using System;
using System.Collections.Generic;

namespace AtCoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]+ input[1]);

            string ans = "";

            if (Math.Sqrt(a) % 1 == 0){
                ans = "Yes";
            }else{
                ans = "No";
            }
            Console.WriteLine(ans);
    //        Console.ReadLine();

        }
    }
}

Measured memory_bytes: 11092
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007
	n, m := nextInt(), nextInt()
	cannot := make([]bool, n+1)
	for i := 0; i < m; i++ {
		a := nextInt()
		cannot[a] = true
	}

	dp := make([]int, n+1)
	dp[0] = 1
	for i := 1; i <= n; i++ {
		if cannot[i] {
			continue
		}
		if i >= 2 {
			dp[i] = (dp[i-1] + dp[i-2]) % mod
		} else {
			dp[i] = dp[i-1]
		}
	}

	puts(dp[n])
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, K, Q, ans = 1e9;
    cin >> N >> K >> Q;
    vector<int> A(N), B(N);
    set<int> s = {-1, N};
    map<int, int> m;
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
        m[A[i]] = i;
    }
    sort(B.begin(), B.end());
    rep(i, N - K + 1) {
        auto j = s.begin();
        int l = *j + 1;
        vector<int> v;
        rep(k, s.size() - 1) {
            j++;
            int r = *j;
            if (r - l >= K) {
                vector<int> w;
                for (int p = l; p < r; p++) {
                    w.push_back(A[p]);
                }
                sort(w.begin(), w.end());
                rep(p, r - l - K + 1) v.push_back(w[p]);
            }
            l = r + 1;
        }
        if (v.size() < Q) break;
        sort(v.begin(), v.end());
        ans = min(ans, v[Q - 1] - v[0]);
        s.insert(m[B[i]]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    int n = sz(s);
    vector<int> ss(26);
    rep(i, n) {
        ss[s[i] - 'a']++;
    }
    bool ans = true;
    rep(i, 26) {
        if (ss[i] % 2) {
            ans = false;
            break;
        }
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
from itertools import permutations
input = sys.stdin.readline
n = int(input())
p = int(''.join([x for x in input().strip().split()]))
q = int(''.join([x for x in input().strip().split()]))
d = [str(i) for i in range(1, n+1)]
l = sorted([int(''.join(i)) for i in permutations(d)])
print(abs(l.index(p)-l.index(q)))

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

using namespace std;

int main() {
  long long n; cin >> n;
  long long ans = 0;
  for(long long i = 1; i <= n; i++) ans += (i * (n/i) * (1 + n/i))/2;
	cout << ans;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii Dir[8] = { //?????????
	{ 0,1 },{ 0,-1 },{ 1,0 },{ -1,0 },
	{ 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 }
};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
int point(int a, int b) {
	return 50 * a + (int) ((500 * a) / (8 + 2 * b));
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

	ll cur = 1;

	REP(i, n-1) {
		ll ecou = cur/k;
		ll add = ecou;
		while (add) {
			cur += add;
			add = cur / k - ecou;
			ecou = cur / k;
		}
		cur++;
	}
	printf("%lld\n", cur-1);
	return 0;
}

Measured memory_bytes: 3196
import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n = int(input())
ret = ''
while(n > 0):
    n -= 1
    ret += chr(ord('a') + n % 26)
    n //= 26
print(ret[::-1])


Measured memory_bytes: 27224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){
    ll k; cin >> k;
    ll root = sqrt(k);
    ll res = 2;
    if (k == 2) {
        cout << 1 << endl;
        return 0;
    }
    
    for(int i = 2; i <= root; i++){
        if(k%i == 0){
            ll j = k;
            while (j % i == 0) j /= i;
            if(j%i == 1)
                res++;
        }
    }
    root = sqrt(k-1);
    k--;
    for(int i = 2; i <= root; i++){
        if(k%i == 0)
            res+=2;
    }
    if(root*root == k) res--;
    
    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

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

//-----------------------------------------
int dp[1000+10][1000+10];



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

  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    string s, t;
    cin >> s >> t;
    int ss = s.size();
    int st = t.size();
    for(int i=0;i<=ss;i++){
      for(int j=0;j<=st;j++){
        if(i==0 || j==0) dp[i][j] = 0;
        else dp[i][j] = -1;
      }
    }
    for(int i=1;i<=ss;i++){
      for(int j=1;j<=st;j++){
        if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
        else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
    cout << dp[ss][st] <<endl;
  }

  return 0;
}




Measured memory_bytes: 7068
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[5][5],b[5][5];
int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		for(int i=1;i<=3;i++){
			for(int j=1;j<=3;j++){
				if(a[i][j]==x){
					b[i][j]=1;	
				}
			}
		}			
	}
	int ok=0;
	for(int i=1;i<=3;i++){
		if(b[i][1]==b[i][2]&&b[i][2]==b[i][3]&&b[i][1]==1){
			ok=1;break;
		}
	}
	for(int i=1;i<=3;i++){
		if(b[1][i]==b[2][i]&&b[2][i]==b[3][i]&&b[1][i]==1){
			ok=1;break;
		}
	}
	if(b[1][1]==1&&b[1][1]==b[2][2]&&b[2][2]==b[3][3]){
		ok=1;
	}
	if(b[1][3]==1&&b[1][3]==b[2][2]&&b[2][2]==b[3][1]){
		ok=1;
	}
	if(ok){
		cout<<"Yes"; 
	} 
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define un unordered_map
#define us unordered_set
using namespace std;

 int main()
 {
    
     string s;
      cin>>s;
       int count=0;
       int maxi=0;
        for(int i=0; i<s.size(); i++)
        {
             if(s[i]=='R')
              count++;
              else
              {
                  maxi=max(count, maxi);
                   count=0;
              }
        }
        maxi=max(count,maxi);
         cout<<maxi<<endl;
       return 0;
     
 }
  

Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
int main(){
	string kurasu[9];
	int am[9],pm[9];
	for(int i = 0; i < 9; i++){
		cin >> kurasu[i] >> am[i] >> pm[i];
		cout << kurasu[i] << " " << am[i] + pm [i] << " " << am[i]*200 + pm[i]*300 << endl;
	}
}

Measured memory_bytes: 1208
//https://agc028.contest.atcoder.jp/tasks/agc028_a
#include<cstdio>
using namespace std;
char s[100005],t[100005];
int tmp,n,m,i,j,pos1,pos2;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);} 
int main()
{
	scanf("%d%d%s%s",&n,&m,s,t);
	tmp=gcd(n,m);
	pos1=0;pos2=0;
	for(i=0;i<tmp;i++,pos1+=n/tmp,pos2+=m/tmp)
	{
		if(s[pos1]!=t[pos2])
		{
			printf("-1");
			return 0;
		}
	}
	printf("%lld\n",1LL*n*m/tmp);
	return 0;
} 

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

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;
ll n, cnt, ans, a, b, c, d, tmp, m, h[ohara], w, x, y, sum, k, q;

bool check(ll kai) {
  ll now[n + 10] = {}, ret = 0;
  rep(i, n) now[i] = h[i];
  rep(i, n) {
    ld hika1, hika2;
    hika1 = (ld)now[i] / (ld)b;
    hika2 = (ld)kai;
    if (hika1 < hika2) {
      now[i] = 0;
    } else {
      now[i] -= b * kai;
    }
  }
  ll hera = a - b;
  rep(i, n) {
    if (now[i] <= 0) continue;
    ll cost = (now[i] % hera == 0 ? now[i] / hera : now[i] / hera + 1);
    ret += cost;
  }
  if (ret <= kai)
    return true;
  else
    return false;
}

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

  cin >> n >> a >> b;
  rep(i, n) cin >> h[i];
  ll le = 0, ri = LINF, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (check(mid))
      ri = mid;
    else
      le = mid;
  }
  rrep(i, max(0LL, le - 3), min(ri + 4, LINF)) {
    if (check(i)) {
      Cout(i);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int n;
int a[200005],b[200005];
map<int,int>k;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    rep(i,1,n+1) cin>>a[i];
    ll sum=0;
    rep(i,1,n+1){
    	b[i]=i-a[i];
    	a[i]=i+a[i];
    	if(b[i]>0)
    	sum+=1ll*k[b[i]];
    	k[a[i]]++;
    	//cout<<a[i]<<" "<<b[i]<<endl;
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 15500