akhauriyash/Code-Regression huggingface dataset:
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps -1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long int

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int n,w;

ii a[200];

int dp[101][100001];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n>>w;
	for(int i=0;i<n;i++)cin>>a[i].fi>>a[i].se;
	for(int i=0;i<n;i++)
		for(int j=0;j<100001;j++)
			dp[i][j] = eps;
	dp[0][0] = 0;
	dp[0][a[0].fi] = a[0].se;
	for(int i=1;i<n;i++){
		for(int j=0;j<100001;j++){
			dp[i][j] = dp[i-1][j];
			if((j-a[i].fi)>=0){
				dp[i][j] = max(dp[i][j],dp[i-1][j-a[i].fi] + a[i].se);
			}
		}
	}
	int output =0;
	for(int j=0;j<=w;j++){
		if(dp[n-1][j]>=0){
			output = max(output,dp[n-1][j]);
		}
	}
	cout<<output; 
	return 0;
}


Measured memory_bytes: 78336
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a,b,k;
    a=scan.nextLong();
    b=scan.nextLong();
    k=scan.nextLong();
    if(a>=k){
      long temp = a-k;
      System.out.println(temp + " " + b);
    }else if(a+b>=k){
      long temp = a+b-k;
      System.out.println("0 "+ temp);
    }else{
      System.out.println("0 0");
    }
  }
}

Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s1 = in.next();
		String s2 = in.next();
		String s3 = in.next();
		
		char c1 = Character.toUpperCase(s1.charAt(0));
		char c2 = Character.toUpperCase(s2.charAt(0));
		char c3 = Character.toUpperCase(s3.charAt(0));
		
		System.out.println(""+c1 + c2 + c3);
	}
}

Measured memory_bytes: 23764
# なぜかACしない

N, K = map(int, input().split())

lower = 0
upper = (N-1) * (N-2) / 2

ans = []

if lower <= K  and K <= upper:

    for i in range(1, N):
        for j in range(i+1, N+1):
            ans.append((i, j))

    k = 0
    while k < K:
        del ans[-1]
        k += 1

    print(len(ans))

    for ptn in ans:
        print('{} {}'.format(ptn[0], ptn[1]))


    # 距離が２の点の組を表示する
    # res = []
    # n = len(ans)

    # for i in range(n):
    #     for j in range(i+1, n):
    #         if ans[i][1] == ans[j][0]:
    #             res.append((ans[i][0], ans[j][1]))        

    # for r in res:
    #     print('{} {}'.format(r[0], r[1]))

else:
    print('-1')

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split().Select(int.Parse);
            Console.WriteLine(A.All(a => a % 2 == 1 || a % 3 == 0 || a % 5 == 0) ? "APPROVED" : "DENIED");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int original = N;

  // 桁数を計算する
  int ten = 10;
  int digit = 1;
  while(N / ten >= 1){
    ten *= 10;
    digit++;
  }

  int divide = 1;
  for(int i = 1; i < digit; i++){
    divide *= 10;
  }

  int sum = 0;
  for(int i = digit; i >= 1; i--){
     sum += N / divide;
     N %= divide;
     divide /= 10;
  }

  if(original % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int age;
    cin >> age;
    if(age == 7 || age == 5 || age == 3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
using namespace std;
int a[10010]={0};
int b[10010]={0};
int ans=1001,w;
void kotani(int i,int j,int c,int n);
int main(){
	while(1){
	int n;
	scanf("%d",&n);
		w=n;
		ans=n;
		if(n==0)break;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<=3;j++){
			memcpy(b,a,sizeof(int) *n);
			if(b[i]!=j){
				b[i]=j;
				kotani(0,1,1,n);
			}
		}
	}
	printf("%d\n",ans);
	}
}
void kotani(int i,int j,int c,int n){
	if(b[i]==b[j]&&j<n){
		//cout<<"wwww"<<endl;
		kotani(i,j+1,c+1,n);
	}
	else{
		//cout<<"ttttt"<<endl;
		if(c>=4){
			int u=0;
			for(int z=j;z<n;z++){
				//cout<<"jjjjj"<<endl;
				b[i+u]=b[z];
				u++;
			}
			ans=min(ans,n-c);
			//cout<<n-c<<endl;
			//cout<<i<<" "<<j<<" "<<c<<" "<<n<<" "<<n-c<<endl;
			kotani(0,1,1,n-c);
		}
		else if(i+1<n){
			kotani(i+1,i+2,1,n);
		}
		else{
			/*cout<<"WWWWWWW"<<endl;
			for(int u=0;u<n;u++){
				cout<<b[u];
			}
			cout<<endl;*/
		}
	}
}

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

typedef long long ll; 

int main() {
	int n, ans; 
	cin >> n;
	ans = n%10;
	if(ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans ==9) {
		cout << "hon" << endl;
	} else if(ans == 3) {
		cout << "bon" << endl;
	} else cout << "pon" << endl; 
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {
    var (n, k) = getInts()

    var out = 0
    while (n > 0) {
        out++
        n /= k
    }
    println(out)
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 37568
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cmath>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int N, K;
VI A;

bool trace;
bool check(int x) {
   llong rem_cuts = K;
   REP(i, N) {
      int req_cuts = (A[i] - 1) / x;
      if (trace)
         DEBUG(i, A[i], req_cuts);
      rem_cuts -= req_cuts;
      if (rem_cuts < 0)
         return false;
   }
   return true;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);
   cout.precision(10);
   cout << fixed;

   cin >> N >> K;
   A = VI(N);
   REP(i, N)
      cin >> A[i];

   int lo = 1, hi = 1000000000;
   int res = -1;
   while (lo <= hi) {
      int mid = (lo + hi)/2;
      if (check(mid)) {
         hi = mid-1;
         res = mid;
      }
      else {
         lo = mid+1;
      }
   }

   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3892
#include <stdio.h>

int main(void){
    int a, b, c, x;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    int ans = 0;
    for (int i = 0; i < a+1; i++){
        if(500 * i > x) break;
        else{
            for (int j = 0; j < b+1; j++){
                if(500 * i + 100 * j > x) break;
                else{
                    if((x - 500 * i - 100 * j) / 50 <= c){
                        ans += 1;
                    }
                }
            }
        } 
    }
    printf("%d\n", ans);
    return 0; 
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    bool prime[100010]={};
    prime[1]=1;
    rep2(i,1,100010){
        if(!prime[i]){
            rep2(j,2,100010/i){
                prime[i*j]=1;
            }
        }      
    }
    //素数は0,それ以外は1
    int num=0;
    int ans[100010]={};
    rep(i,50005){
        if(!prime[i*2+1]&&!prime[(i*2+2)/2]){
            num++;
        }
        ans[i*2+1]=num;
    }
    int q;
    cin>>q;
    int l,r;
    rep(i,q){
        cin>>l>>r;
        if(l>1){
          cout<<ans[r]-ans[l-2];
        }
      else{
        cout<<ans[r]-ans[l];
      }
      cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	string T = S;
	reverse(S.begin(), S.end());
	if (S == T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;


}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#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 For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    vector<int> data(n+1);
    for (int i = 0; i < n; i++) {
        cin >> data[i+1];
    }

    rep(i, n) {
        data[i+1] += data[i];
    }

    vi funami;
    Rep(i, n+1) {
        for (int j = 0; j < i; j++) {
            funami.pb(data[i] - data[j]);
        }
    }

    sort(all(funami));
    vi mmn(funami.size(), 1);

    for (int i = 45; i >= 0; i--) {
        int mask = 1ll << i;
        vi mm(funami.size(), 0);
        int cnt = 0;
        rep(i, funami.size()) {
            if (mmn[i] && funami[i] & mask) {
                cnt++;
                mm[i] = 1;
            }
        }
        if (cnt >= k) {
            rep(i, funami.size()) {
                mmn[i] &= mm[i];
            }
        }
    }

    int ans = (1ll << 45) - 1;
    rep(i, funami.size()) {
        if (mmn[i]) {
            ans &= funami[i];
        }
    }

    std::cout << ans << std::endl;



    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N; cin >> N;
    int ones = 0, twos = 0, threes = 0;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        if (x == 1)
            ++ones;
        else if (x == 2)
            ++twos;
        else if (x == 3)
            ++threes;
    }

    vector< vector< vector<double> > > dp(threes + 1, vector< vector<double> >(N + 1, vector<double>(N + 1, 0.0)));

    dp[0][0][0] = 0.0;
    for (int i = 0; i <= threes; ++i)
        for (int j = 0; j <= N; ++j)
            for (int k = 0; k <= N; ++k) {
                if (i + j + k == 0)
                    continue;
                double aux = 1.0;
                if (i > 0 && j < N)
                    aux += double(i) / N * dp[i - 1][j + 1][k];
                if (j > 0 && k < N)
                    aux += double(j) / N * dp[i][j - 1][k + 1];
                if (k > 0)
                    aux += double(k) / N * dp[i][j][k - 1];
                dp[i][j][k] = aux * double(N) / (i + j + k);
            }

    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(9);
    cout << dp[threes][twos][ones] << "\n";
}


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

using namespace std;

int main() {
    vector<int> b;
    int n;

    cin >> n;

    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        b.push_back(tmp);
    }

    sort(b.begin(), b.end());

    b.erase(unique(b.begin(), b.end()), b.end());

    cout << b.size() << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N, S := sc.NextInt(), []byte(sc.Next())

	for i := 0; i < len(S); i++ {
		S[i] += byte(N)
		if S[i] > 'Z' {
			S[i] = S[i] - 'Z' + 'A' - 1
		}
	}
	fmt.Println(string(S))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 768
num,length = list(map(int,input().split()))
if length != 0:
  lst = list(map(int,input().split()))
else:
  pass

if length == 0:
  print(num)
else:
  sett = set(lst)
  for i in range(100):
    if not (num-i in lst):
      print(num-i)
      break
    if not (num+i in lst):
      print(num+i)
      break

Measured memory_bytes: 61640
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
int x,y;
int keep = 0;

while(1){
cin >> x >> y;

if(x == 0 && y == 0)break;

if(x<y){
}else{
keep = y;
y = x;
x = keep;
}
cout << x << " " << y << endl;

}

return 0;
}


Measured memory_bytes: 3100
// #include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    int h, w;
    while(true){
        cin >> h >> w;
        if(h==0) break;

        string s = "";
        for(int i=0;i<w;i++){
            s += "#";
        }
        for(int i=0;i<h;i++){
            cout << s << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int main()
{
    char sz[4],a[4]={"abc"};

    scanf("%s",sz);
    int j=0,i;
    for(i=0;i<3;i++)
    {
        if(sz[j]==a[i])
        {

            a[i]='0';
            i=-1;
            j++;
        }

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


Measured memory_bytes: 256
#define rep(i,n) for (int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
 
 
int main(){
  int n;
  ll co=0;
  cin >> n;
  vector <ll> a(n);
  vector <ll> b(n);
  
  rep(i,n)
    cin >> a.at(i) >> b.at(i);
  
  rep(i,n){
    a.at(n-i-1)+=co;
    if(a.at(n-i-1)%b.at(n-i-1)==0)
      continue;
    co+=(b.at(n-i-1)-a.at(n-i-1)%b.at(n-i-1));
    //rep(j,n-i)
      //a.at(j)+=(b.at(n-i-1)-a.at(n-i-1)%b.at(n-i-1));
    //cout << co << endl;
    
  }
  cout << co << endl;
    
}

Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int y,m,d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (m < 5) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,ans =1;
    cin >> N;

    for(ll i = 1;i <= N /2;i++){
        if(i * i <= N)
            ans = i * i;
        else
        {
            break;
        }
        
    }

    cout << ans << endl;
    

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N; --N;
    ll now=1;
    for (int i=1;;++i){
        now*=26;
        if (N<now){
            string ans="";
            for (int j=0;j<i;++j){
                now/=26;
                ans+=('a'+N/now);
                N%=now;
            }
            cout << ans << '\n';
            return 0;
        } else N-=now;
    }
}

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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
//////////////////////



void solve(){
	
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

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

	solve();
	int ans = (24 - n) + 24;

	printf("%d\n",ans);

	return 0;
}

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

const int MAXN = 1 << 18; // 2.6e5
int n, N = 200001, h[200000], a[200000];
ll seg[2 * MAXN]; // root is seg[1]

void update(int p, ll val)
{
    for (seg[p += N] = val; p > 0; p >>= 1)
        seg[p >> 1] = max(seg[p], seg[p ^ 1]);
}

ll query(int l, int r)
{
    ll res = 0;
    for (l += N, r += N; l <= r; l >>= 1, r >>= 1)
    {
        if (l & 1)
            res = max(res, seg[l++]);
        if (!(r & 1))
            res = max(res, seg[r--]);
    }
    return res;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        update(h[i], a[i] + query(0, h[i] - 1));
    cout << seg[1];
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe";
    } else {
        cout << "safe";
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class UnionFind {
	vector<int> data;
	int num;
public:
	UnionFind(int size) : data(size, -1), num(size) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			num--;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
	int numSet() {
		return num;
	}
};

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

	ll n, m;
	cin >> n >> m;
	Array p(n, 0);
	REP(i, n) cin >> p[i];

	UnionFind uni(n);
	REP(i, m) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		uni.unionSet(x, y);
	}

	ll con = 0;
	REP(i, n) {
		if (uni.findSet(i, p[i]-1)) con++;
	}

	cout << con << endl;

	return 0;
}

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

int N;
int x[1000];
int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> x[i];
	int m = INT_MAX;
	for(int i=0; i<=2000; i++){
		int tmp = 0;
		for(int j=0; j<N; j++){
			tmp = max(tmp, abs(x[j]-i));
		}
		m = min(m, tmp);
	}
	cout << m << endl;
	return 0;
}


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

int main(){
  char mp[100][100];
  int h,w,ans=0;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mp[i][j]=='#'){
	int cnt=0;
	for(int k=0;k<4;k++){
	  int nx=j+dx[k];
	  int ny=i+dy[k];
	  if(0<=nx&&nx<w&&0<=ny&&ny<h&&mp[ny][nx]=='#'){
	    cnt++;
	  }
	}
	if(cnt==0)ans++;
      }
    }
  }
  if(ans==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  ll sumA = 0, sumB = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sumA += a[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> b[i];
    sumB += b[i];
  }

  ll c = sumB - sumA;
  for(int i = 0; i < n; i++) {
    if(a[i] < b[i]) {
      // b[n - 1] += (b[i] - a[i] + 1) / 2;
      c -= (b[i] - a[i] + 1) / 2;
    } else if(a[i] == b[i]) {
      continue;
    } else {
      // a[i + 1] += (a[i] - b[i]) * 2;
      // c -= a[i] - b[i];
    }
  }
  if(c >= 0) {
    cout << "Yes\n";
  } else {

    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 384
A, B, C = map(int, input().split())
K = int(input())

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k != K:
                continue
            a = A*pow(2,i)
            b = B*pow(2,j)
            c = C*pow(2,k)
            if a < b and b < c:
                print("Yes")
                exit()
print("No")

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

int main() {
	int m, f, r;
	char grade;
	cin >> m >> f >> r;
	while (!(m == -1 && f == -1 && r == -1)) {
		if (m == -1 || f == -1)
			grade = 'F';
		else if (m + f >= 80)
			grade = 'A';
		else if (m + f >= 65)
			grade = 'B';
		else if (m + f >= 50)
			grade = 'C';
		else if (m + f >= 30) {
			if (r >= 50)
				grade = 'C';
			else
				grade = 'D';
		} else
			grade = 'F';
		cout << grade << endl;
		cin >> m >> f >> r;
	}
	
	return 0;
}


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

struct Point { double x, y; };

void koch( int d, Point a, Point b ){
    if( !d ) return;

    double th = M_PI * 60 / 180;
    Point s, u, t;

    s.x = ( 2.0 * a.x + 1.0 * b.x ) / 3;
    s.y = ( 2.0 * a.y + 1.0 * b.y ) / 3;
    t.x = ( 2.0 * b.x + 1.0 * a.x ) / 3;
    t.y = ( 2.0 * b.y + 1.0 * a.y ) / 3;
    u.x = ( t.x - s.x ) * cos( th ) - ( t.y - s.y ) * sin( th ) + s.x;
    u.y = ( t.x - s.x ) * sin( th ) + ( t.y - s.y ) * cos( th ) + s.y;

    koch( d - 1, a, s );
    printf( "%.8f %.8f\n", s.x, s.y );
    koch( d - 1, s, u );
    printf( "%.8f %.8f\n", u.x, u.y );
    koch( d - 1, u, t );
    printf( "%.8f %.8f\n", t.x, t.y );
    koch( d - 1, t, b );
}

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

    Point a, b;

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf( "%.8f %.8f\n", a.x, a.y );
    koch( n, a, b);
    printf( "%.8f %.8f\n", b.x, b.y );

    return 0;
}



Measured memory_bytes: 3132
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
s = ns()

print(s[:k-1] + s[k-1].lower() + s[k:])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD = 1000000007;
ll INF = 90000000001000;

int N,k;
ll dp[1 << 21];
int a[25][25];
vector<int> G[100009];
ll white[100009],black[100009];

void rec(int u,int P){
    black[u]=1;
    white[u]=1;
    for (int v : G[u])
    {
        if(v==P) continue;
        rec(v,u);
        black[u] *= white[v];
        black[u] %= MOD;
        white[u] *= white[v] + black[v];
        white[u] %= MOD;
    }


}
int main() {
    cin >> N;
    
for (int i = 0; i < N-1; ++i)
{
    int x,y;cin >> x>> y;
    x--;y--;
    G[x].push_back(y);
    G[y].push_back(x);
}

rec(0,-1);

cout << (black[0] + white[0])%MOD << endl;


return 0;
}




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

public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int count = 0;
            while (x >= 10) {
                x = getMax(x);
                count++;
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
    
    static int getMax(int x) {
        int max = 0;
        for (int i = 10; i <= x; i *= 10) {
            max = Math.max(max, (x / i) * (x % i));
        }
        return max;
    }
}


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

int main() {
    int k;
    cin >> k;
    int val[] = {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};

    cout << val[k - 1];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int N, ans = 0;
	bool flag = 1;
	cin >> N;
	int A[N];

	rep(i, N) cin >> A[i];
	while (flag) {
		rep(i, N) {
			if (A[i] % 2) flag = 0;
			else A[i] /= 2;
		}
		if (flag) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math


def main():
    n = int(input())
    # n, k = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    ans = 0

    for i in range(1, n):
        ans += (n - 1) // i
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second



int main(){
    ll sh,sw,gh,gw;
    ll h,w;

    cin >> h >> w;
    cin >> sh >> sw >> gh >> gw;
    char c[h][w];
    ll memo[h][w];
    bool is_visited[1000][1000];
    rep(i,0,h) rep(j,0,w) cin >> c[i][j];       
    rep(i,0,h) rep(j,0,w) memo[i][j] = LINF;
    memo[sh-1][sw-1] = 0;

    is_visited[sh-1][sw-1] = true;
    deque<P> q;
    q.push_front(P(sh-1,sw-1));
    while(!q.empty()){
        P v = q.front();
        q.pop_front();
        ll y = v.fs, x = v.sc;

        rep(k,-2,3){
            rep(l,-2,3){
                if(y+k < 0 || y+k >= h || x+l < 0 || x+l >= w) continue;
                if(c[y+k][x+l] == '#') continue;

                if(abs(k) + abs(l) == 1){
                    if(memo[y+k][x+l] > memo[y][x]){
                        memo[y+k][x+l] = memo[y][x];
                        q.push_front(P(y+k,x+l));
                    }
                }
                else{
                    if(memo[y+k][x+l] > memo[y][x] + 1){
                        memo[y+k][x+l] = memo[y][x] + 1;  
                        q.push_back(P(y+k,x+l));
                    }
                }
            }
        }
    }
    


    if(memo[gh-1][gw-1] != LINF) cout << memo[gh-1][gw-1] << endl;
    else cout << -1 << endl;
}



Measured memory_bytes: 12588
#include<bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define FOR(i, a, b) for(long long i = a; i < b; ++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int n;
    scanf("%d", &n);
    int x, y, b, p;

    REP(i, n) {
        scanf("%d%d%d%d", &x, &y, &b, &p);
        if (b >= 5 && p >= 2) {
            printf("%d\n", (int)((x * b + y * p) * 0.8));
        } else {
            int tmp = (x * b + y * p);
            if (b < 5) tmp += (5 - b) * x;
            if (p < 2) tmp += (2 - p) * y;
            printf("%d\n", (int)min((double)(x * b + y * p), tmp * 0.8));
        }
    }

    return 0;
}




Measured memory_bytes: 3220
#include <iostream>

using namespace std;

bool f(int a, int b, int c) {

    if (a == 7 && b == 5 && c == 5) {
        return true;
    }

    if (a == 5 && b == 7 && c == 5) {
        return true;
    }

    if (a == 5 && b == 5 && c == 7) {
        return true;
    }

    return false;
}

int main() {

    int a, b, c;
    cin >> a >> b >> c;

    if (f(a, b, c)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub trait LexicalPermutation {
    fn next_permutation(&mut self) -> bool;
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T] where T: Ord {
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 { return false; }
        let mut i = self.len() - 1;
        while i > 0 && self[i-1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i-1]  {
            j -= 1;
        }
        self.swap(j, i-1);
        self[i..].reverse();
        true
    }

    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 { return false; }
        let mut i = self.len() - 1;
        while i > 0 && self[i-1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j-1] < self[i-1]  {
            j -= 1;
        }
        self.swap(i-1, j);
        true
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u64 = read();
    
    println!("{}", n*(n-1)/2);
    
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main {
  
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
          
        int n=Integer.parseInt(br.readLine());
        int [] in=new int[n];
        int max=Integer.MIN_VALUE;
        int mini=0;  
        for(int i=0;i<n;i++)
            in[i]=Integer.parseInt(br.readLine());
              
        for(int i=0;i<n-1;i++){if(in[i]>in[mini])continue;
            for(int j=i+1;j<n;j++){
                int tmp=in[j]-in[i];
                if(tmp>max) {max=tmp;mini=i;}
            }
        }
System.out.println(max);
  
  
  
  
    }
  
}

Measured memory_bytes: 37712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double kaku = 0;
  kaku = abs(double((h * 60 + m) / 2) - double(m * 6));
  double memo = 0;
  memo = M_PI / 180;
  double res = 0;
  res = a*a + b*b - 2*a*b*cos(memo * kaku);
  res = sqrt(res);
  cout << fixed << setprecision(20) << (double)res << endl;
}

Measured memory_bytes: 4152
#include<cstdio>
#include<iostream>
using namespace std;
int n,x;
int ans=0;
int a[100010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x>n) ans++;
		else a[x]++;
	}
	for (int i=1;i<=n;i++)
	{
		if (a[i]>=i) ans+=a[i]-i;
		else ans+=a[i];
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define Pl pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
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 = 1e+18;
int iINF = 1e9;



int main()
{
  int N; cin >> N;
  vector<vector<int>> arr(N, vector<int>(N));
  rep(i, 0, N) rep(k, 0, N) cin >> arr[i][k];
  vector<vector<int>> dp(N + 1, vector<int>((1 << N), 0));
  dp[0][0] = 1;

  rep(i, 0, N){
    for(int bit = 0; bit < (1 << N); ++bit){
      if(dp[i][bit]){
        rep(k, 0, N){
          if(arr[i][k] == 1 && (bit & (1 << k)) == 0){
            dp[i + 1][(bit | (1 << k))] += dp[i][bit];
            dp[i + 1][(bit | (1 << k))] %= MOD;
          }
        }
      }
    }
  }

  cout << dp[N][(1 << N) - 1] << endl;
}




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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

template <typename T>
T zero_sum_ranges(vector<T> A) {
    T n = A.size();
    map<T, T> mp;
    T ret = 0;
    for(size_t i = 0; i < n; i++) {
        if(mp.count(A[i])) ret += mp[A[i]];
        mp[A[i]]++;
    }
    cout << ret << endl;
}

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> a(n);
    map<ll,ll> mp;
    for(i=0;i<n;i++){
        cin >> a[i];
        mp[i+1-a[i]]++;
        //cout << a[i] << endl;
    }
    ll ret=0;
    for(i=0;i<n;i++){
        mp[i+1-a[i]]--;
        ret += mp[a[i]+i+1];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 27380
#include <stdio.h>

int main() {
	char A[100001];
	int i;
	scanf("%s",A);
	
	int a=0,b=0;
	
	for(i=0;A[i]!='\0';i++){
		if(A[i]=='0'){
			if(i%2==0)a++;
			else b++;
		}else{
			if(i%2==0)b++;
			else a++;
		}
	}
	if(a>b)printf("%d\n",b);
	else printf("%d\n",a);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [abs(i) for i in a]

counter = 0
for i in range(n):
    if a[i] < 0:
        counter += 1


if counter & 1 == 1:
    print(sum(b) - min(b) * 2)
else:
    print(sum(b))

Measured memory_bytes: 14412
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	bool len_flag = (s.length() % 2 == 0) ? true : false;
	bool equal_flag = (s[0] == s[s.length() - 1]) ? true : false;

	if(len_flag xor equal_flag) cout << "Second" << endl;
	else cout << "First" << endl;
}


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

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

    static class CChocolateBar {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long h = in.nextInt(), w = in.nextInt();

            long answer = Long.MAX_VALUE;
            answer = Math.min(answer, sameDirection(h, w));
            answer = Math.min(answer, sameDirection(w, h));
            answer = Math.min(answer, differentDirection(h, w));
            answer = Math.min(answer, differentDirection(w, h));

            out.println(answer);
        }

        static long sameDirection(long w, long h) {
            if (w % 3 == 0) {
                return 0;
            }
            return h;
        }

        static long differentDirection(long w, long h) {
            long ans = Long.MAX_VALUE;

            for (long w1 = w / 3; w1 <= w / 3 + 1; w1++) {
                long[] areas = {w1 * h, (w - w1) * (h / 2), (w - w1) * ((h + 1) / 2)};
                Arrays.sort(areas);
                ans = Math.min(ans, areas[2] - areas[0]);
            }

            return ans;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX=100000;
static const int NIL=-1;

int n;
vector<int> g[MAX];
int color[MAX];

void dfs(int r,int c){
  stack<int> S;
  S.push(r);
  color[r]=c;
  while(!S.empty()){
    int u=S.top();
    S.pop();
    for(int i=0;i<g[u].size();i++){
      int v=g[u][i];
      if(color[v]==NIL){
	color[v]=c;
	S.push(v);
      }
    }
  }
}

void assignColor(){
  int id=1;
  for(int i=0;i<n;i++) color[i]=NIL;
  for(int u=0;u<n;u++){
    if(color[u]==NIL) dfs(u,id++);
  }
}

int main(){
  int s,t,m,q;

  cin>>n>>m;

  for(int i=0;i<m;i++){
    cin>>s>>t;
    g[s].push_back(t);
    g[t].push_back(s);
  }

  assignColor();

  cin>>q;

  for(int i=0;i<q;i++){
     cin>>s>>t;
     if(color[s]==color[t]){
       cout<<"yes"<<endl;
     }else{
       cout<<"no"<<endl;
     }
  }
  return 0;
}



Measured memory_bytes: 9000
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 100000

struct Info{
	void set(int arg_start,int arg_end){
		start = arg_start;
		end = arg_end;
	}
	int start,end;
};

int table1_start[100002],table1_end[100002],table2[100002];
Info info[200000];


int main(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i <= 100001; i++){
		table1_start[i] = 0;
		table1_end[i] = 0;
		table2[i] = 0;
	}

	int a,b,maximum = 0;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&a,&b);
		maximum = max(maximum,b);
		info[loop].set(a,b);
		table1_start[a]++;
		table1_end[b]++;
		table2[a]++;
		table2[b]--;
	}

	for(int i = 1; i <= maximum; i++){
		table1_start[i] += table1_start[i-1];
		table1_end[i] += table1_end[i-1];
	}

	int max_1 = 0;
	int end_after_i_start_num,start_after_i_end_num;

	for(int i = 0; i < N; i++){
		end_after_i_start_num = table1_end[maximum]-table1_end[info[i].start];
		start_after_i_end_num = table1_start[maximum]-table1_start[info[i].end-1];
		max_1 = max(max_1,end_after_i_start_num-start_after_i_end_num);
	}

	int max_2 = 0;
	for(int i = 1; i <= maximum; i++){
		table2[i] += table2[i-1];
		max_2 = max(max_2,table2[i]);
	}

	printf("%d %d\n",max_1,max_2);

	return 0;
}

Measured memory_bytes: 5960
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
string s;
ll rean(char moji){
    ll result = 0;
    string s_now = s;
    for (int i =  s.length()-1; i > 0; i--) {
        result++;
        for (int j = 0; j < i; j++) {
            if( s_now[j] == moji || s_now[j+1] == moji ){
                s_now[j] = moji;
            }else{
                s_now[j] = s_now[j+1];
            }
        }
        
        if(i==1){
            return result;
        }
        
        for (int j = 0; j < i-1; j++) {
            if(s_now[j] == s_now[j+1]){
                if(j == i-2){
                    return result;
                }
                continue;
            }else{
                break;
            }
        }
    }
}

int main() {
    std::cin >> s;
    if(s.length()==1){
        std::cout << 0 << std::endl;
        return 0;
    }
    for (int i = 0; i < s.length()-1; i++) {
        if(s[i] == s[i+1]){
            if(i == s.length()-2){
                std::cout << 0 << std::endl;
                return 0;
            }
            continue;
        }else{
            break;
        }
    }
    ll ans = 1e9;
    for(auto moji='a'; moji<='z'; ++moji){
        ans =min(ans,rean(moji));
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256