akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)
#define PI 3.14159265358979323846264338327950L


int main()
{
    IOS;
    
   ll a,b,c,k;
   cin>>a>>b>>c>>k;

   int ans = 0;

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

Measured memory_bytes: 3604
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}

Measured memory_bytes: 32476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
double n,i,t,k,x,a,y,j,b,d,c,sum1,sum2,rmin=INT_MAX,rmax=INT_MIN,cmin=INT_MAX,cmax=INT_MIN;
int main()
{
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        b=sqrt(x*x+y*y);
        if(b<=d)
            c++;
    }
    cout<<c;
}


Measured memory_bytes: 3840
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from itertools import permutations
N = ii()
xy = li2(N)
ans = float('inf')
tmp = 0.0
for l in permutations([i for i in range(N)]):
    for i in range(N-1):
        tmp += pow(pow(xy[l[i+1]][0]-xy[l[i]][0], 2) + pow(xy[l[i+1]][1]-xy[l[i]][1], 2), 0.5)

bunshi = 1
for i in range(1, N+1):
    bunshi *= i
print(tmp / bunshi)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B; cin >> A >> B;

    cout << ((A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) ? "Possible" : "Impossible") << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math

input=stdin.readline

def isPrime(x):
  if x % 2 == 0:
    return False
  for div in range(3, math.floor(x **(0.5)) + 1,2):
    if x % div == 0:
      return False

  return True

X = int(input())
if X == 2:
  print(2)
  exit()

if X % 2 == 0:
  X+=1

if isPrime(X):
   print(X)
   exit()

while (True):
  X += 2
  if isPrime(X):
    print(X)
    exit()


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

int main()
{
  int n;
  cin >> n;
  vector<queue<int>> ueven(n), uodd(n), veven(n), vodd(n);
  for (int i = 0; i < n-1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    w %= 2;
    if (w == 0) {
      ueven[u-1].push(v-1);
      veven[v-1].push(u-1);
    }
    else {
      uodd[u-1].push(v-1);
      vodd[v-1].push(u-1);
    }
  }
  
  queue<int> que;
  que.push(0);
  bool tof[n];
  tof[0] = false;
  while(!que.empty()) {
    int x = que.front();
    que.pop();
    while(!ueven[x].empty()) {
      int y = ueven[x].front();
      ueven[x].pop();
      tof[y] = tof[x];
      que.push(y);
    }
    while(!veven[x].empty()) {
      int y = veven[x].front();
      veven[x].pop();
      tof[y] = tof[x];
      que.push(y);
    }
    while(!uodd[x].empty()) {
      int y = uodd[x].front();
      uodd[x].pop();
      tof[y] = !tof[x];
      que.push(y);
    }
    while(!vodd[x].empty()) {
      int y = vodd[x].front();
      vodd[x].pop();
      tof[y] = !tof[x];
      que.push(y);
    }
  }
  
  for (int i = 0; i < n; ++i) cout << tof[i] << endl;
  return 0;
}

Measured memory_bytes: 269312
#include <stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  
  int i = 0;
  if (a == b)
  {
    while (i < a)
    {
      printf("%d", a);
      i++;
    }
  }
  else if (a > b)
  {
    while (i < a)
    {
      printf("%d", b);
      i++;
    }
  }
  else if (a < b)
  {
    while (i < b)
    {
      printf("%d", a);
      i++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    ll a[n];
    inrep(n,a);

    rrep(i,n,1){
	if(a[i-1] > a[i]){
	    a[i-1]--;
	}
	if(a[i-1] > a[i]){
	    No;
	    ret 0;
	}
    }
    Yes;
    return  0;
}


Measured memory_bytes: 1024
def isvalid(a, b):
    return abs(a - b) < 2
while 1:
    n = input()
    if n==0:
        break
    W = map(int, raw_input().split())
    dp = [[0]*n for i in xrange(n)]
    for i in xrange(n-1):
        if isvalid(W[i], W[i+1]):
            dp[i][i+1] = 1
    for l in xrange(1, n+1):
        for j in xrange(n-l):
            i = j+l
            # [i,j]
            if j+2 < i and isvalid(W[j], W[j+1]) and dp[j+2][i]:
                # ab[...]
                dp[j][i] = 1
            elif j < i-2 and isvalid(W[i-1], W[i]) and dp[j][i-2]:
                # [...]ab
                dp[j][i] = 1
            elif j+1 < i-1 and isvalid(W[j], W[i]) and dp[j+1][i-1]:
                # a[...]b
                dp[j][i] = 1
            else:
                # [...][...]
                for k in xrange(j+1, i-1):
                    if dp[j][k] and dp[k+1][i]:
                        dp[j][i] = 1
                        break
    res = [0]*n
    for i in xrange(n):
        r = res[i-1]
        for j in xrange(i):
            if dp[j][i]:
                r = max(r, res[j-1]+(i-j+1))
        res[i] = r
    print res[n-1]

Measured memory_bytes: 7876
import copy
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int, read().split()))

max_a = max(a)
b = copy.copy(a)
b.remove(max_a)
nxt_a = max(b)

for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(nxt_a)


Measured memory_bytes: 21072
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int A, B;
	cin >> A >> B;
	if (!IsEven(A * B)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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


void solve(long long N, std::vector<long long> H){
    int cnt = 0;
    int trueCnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            if (H[j] <= H[i]) {
                cnt++;
            }   
        } 
        if (cnt == i) trueCnt++; 
          
        cnt = 0;
    }   
    cout << trueCnt << endl;                                                                                     
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


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

int main(void)
{
	int i,j;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>
int main(){
    int d, s, t;
    scanf("%d %d %d", &d, &s, &t);
    long long eq= t*s;
    if (eq>=d)
        printf("Yes\n");
    else
        printf("No\n");

    
    return 0;
}

Measured memory_bytes: 1640
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    dp := make([]int, n+1)
    for i:=1; i<=n; i++{
        dp[i]=100000000
    }
    dp[0]=0
    for i:=0; i<=n; i++{
        for j:=1; i+j<=n; j*=6{
            dp[i+j]=min32(dp[i+j],dp[i]+1)
        }
        for j:=1; i+j<=n; j*=9{
            dp[i+j]=min32(dp[i+j],dp[i]+1)
        }
    }
    fmt.Println(dp[n])
}





// Pairsort
type Pair struct {
    first int
    second int
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 1408
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize,
    ps: [usize; n],
  }
  let mut count = 0;
  for i in 1 .. n - 1 {
    if ps[i-1] < ps[i] && ps[i] < ps[i+1] || ps[i-1] > ps[i] && ps[i] > ps[i+1] {
      count += 1;
    }
  }

  println!("{}", count);
}


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

int dp[100][100] = {0};
int h, w;

/*void search(int pre_r, int pre_c, int r, int c, int *ans, int ans_now){
    if(r >= h || c >= w) return;
    else{
        if(pre_r == r && pre_c == c){
            if(maze[pre_r][pre_c] == '#') ans_now++;
        }
        if(maze[pre_r][pre_c] == '.' && maze[r][c] == '#') ans_now++;
        //cout << ans_now << endl;
        if(r == h-1 && c == w-1) *ans = min(*ans, ans_now);
    }
    search(r, c, r+1, c, ans, ans_now);
    search(r, c, r, c+1, ans, ans_now);
}*/

int main() {
    int i, j, ans = INT_MAX;
    cin >> h >> w;
    char maze[h][w];
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            cin >> maze[i][j];
        }
    }
    if(maze[0][0] == '#') dp[0][0] = 1;
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            bool kuro = (maze[i][j] == '#');
            if(i == 0 && j == 0) continue;
            else if(i == 0) dp[i][j] = dp[i][j-1] + (maze[i][j-1] == '.' && kuro);
            else if(j == 0) dp[i][j] = dp[i-1][j] + (maze[i-1][j] == '.' && kuro);
            else dp[i][j] = min(dp[i-1][j] + (maze[i-1][j] == '.' && kuro), dp[i][j-1] + (maze[i][j-1] == '.' && kuro));
        }
    }
    //search(0, 0, 0, 0, &ans, 0);
    cout << dp[h-1][w-1] << endl;
}

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

int h, w, n, sr, sc;
int sdc[128], tdc[128];
int psdc[128], ptdc[128];
char s[200002], t[200002];

int main() {
    std::cin >> h >> w >> n;
    std::cin >> sr >> sc;
    std::cin >> s >> t;
    sr--;
    sc--;
    std::string res = "YES";
    for (int i = 0; i < n; i++) {
        sdc[s[i]]++;
        psdc[s[i]]++;
        if ((s[i] == 'L' || s[i] == 'R') && psdc[s[i]] >= w) {
            res = "NO";
            break;
        }
        if ((s[i] == 'U' || s[i] == 'D') && psdc[s[i]] >= h) {
            res = "NO";
            break;
        }
        if (sdc['L'] - tdc['R'] - sc > 0 ||
                sdc['R'] - tdc['L'] + sc >= w ||
                sdc['U'] - tdc['D'] > sr ||
                sdc['D'] - tdc['U'] + sr >= h
           ) {
            res = "NO";
            break;
        }
        tdc[t[i]]++;
        if (psdc[t[i]]-- < 0)
            psdc[t[i]] = 0;
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N= 1e5 +10;

int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	int n, x, flag= 0 ;
	scanf("%d", &n);
	for (int i=0, x; i<n; ++i){
		scanf("%d", &x);
		flag |= x&1;
	}
	puts(flag?"first":"second");	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    cout << (a-1) /(b*2+1)+1 << endl;
}

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

typedef long long ll;
const ll INF = 1e+18;

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

  int a[2000], b[2000];
  ll c[2000];

  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i] >> c[i];
  }

  ll dist[1001];
  for(int i = 1; i <= n; i++) dist[i] = INF;
  dist[1] = 0;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(dist[a[j]] == INF) continue;

      if(dist[b[j]] > dist[a[j]] - c[j]){
        dist[b[j]] = dist[a[j]] - c[j];
      }
    }
  }

  ll ans = -dist[n];

  bool used[1001];

  for(int i = 1; i <= n; i++) used[i] = false;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(dist[a[j]] == INF) continue;

      if(dist[b[j]] > dist[a[j]] - c[j]){
        dist[b[j]] = dist[a[j]] - c[j];
        used[b[j]] = true;
      }

      if(used[a[j]]) used[b[j]] = true;
    }
  }

  if(used[n]) cout << "inf" << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long wa=0;
		int kosu=sc.nextInt();
		for(int i=0; i<kosu; i++) {
			wa+=sc.nextInt()-1;
		}
		System.out.println(wa);
	}
}

Measured memory_bytes: 25576
n,t = gets.split.map(&:to_i)
list = (1..n).map{gets.split.map(&:to_i)}.sort
dp = [0]*(t)
ans = 0
list.each{|a,b|
  if ans < tmpans=dp[t-1]+b
    ans = tmpans
  end
  (t-1-a).downto(0){|ti|
    if dp[tia=ti+a] < dpb=dp[ti]+b
      dp[tia] = dpb
    end
  }
}
p ans

Measured memory_bytes: 2172
import java.util.*;


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

		int counter  = 0;
		int input[];
		boolean isOdd;
		Scanner scan = new Scanner( System.in );
		
		input = new int[scan.nextInt()];
		
		
		for( int i = 0; i < input.length;  i++) {
			input[i] = scan.nextInt();

		}
		
		
		while(true){
			isOdd = false;
			
			for(int i = 0; i < input.length; i++ ) {
				if( input[i] % 2 != 0 ) {
					isOdd = true;
				
					break;
				}
				else {
					input[i] = input[i] /2;
				}
			}
			
			if( isOdd == true ) {
				break;
			}
			else {
				counter++;
			}
			
		}
		
		System.out.println( counter );
		
		scan.close();
		
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxn=1e5+1e2;

#define LL long long

int a[maxn],n;
LL sum[maxn],sumo[maxn];

inline int lowbit(int x)
{
	return x&-x;
}

void add(int p,LL v)
{
	while(p<=n)
	{
		sumo[p]+=v;
		p+=lowbit(p);
	}
}

LL query(int p)
{
	LL re=0;
	while(p>0)
	{
		re+=sumo[p];
		p-=lowbit(p);
	}
	return re;
}

int getint()
{
	char ch;int b=1;
	for(ch=getchar();ch>'9'||ch<'0';ch=getchar())if(ch=='-')b=-1;
	int num=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar())num=num*10+ch-'0';
	return num*b; 
}

LL solve()
{
	memset(sumo,0,sizeof(sumo));
	for(int i=1;i<=n;i++){add(i,sum[i]);add(i+1,-sum[i]);}
	LL re=0;
	for(int i=1;i<=n;i++)
	{
		sum[i]=query(i);
		if(sum[i]>=0&&sum[i-1]>0)
		{
			re+=sum[i]+1;
			add(i,-sum[i]-1);
			sum[i]=-1;
		}
		else if(sum[i]<=0&&sum[i-1]<0)
		{
			re+=-sum[i]+1;
			add(i,-sum[i]+1);
			sum[i]=1;
		}
	}
	return re;
}

int main()
{
	n=getint();
	for(int i=1;i<=n;i++)
	{
		a[i]=getint();
		sum[i]=sum[i-1]+a[i];
	}
	LL ans=1e17;
	sum[0]=-1;
	ans=min(ans,solve());
	sum[0]=0;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
	sum[0]=1;
	ans=min(ans,solve());
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        scanner.nextLine();

        HashMap<String, Integer> map = new HashMap<>();
        long ans = 0;
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            char[] c = line.toCharArray();
            Arrays.sort(c);
            String sortedLine = new String(c);

            if(map.containsKey(sortedLine)) {
                ans += map.get(sortedLine);
                map.put(sortedLine, map.get(sortedLine) + 1);
            } else {
                map.put(sortedLine, 1);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 104540
#include <bits/stdc++.h>
using namespace std;
#define int long long
void run();
signed main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13); run(); }
mt19937 rng(random_device{}());

void run() {
    string s, t;
    cin >> s;
    for (char i : s)
        cout << "x";
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
ll fact[100009];
ll facti[100009];

#define mod 1000000007
ll po(ll n, ll k, ll m)
{
    ll x = 1;
    while (k)
    {
        if (k & 1)
        {
            x *= n;
            x %= m;
        }
        n *= n;
        n %= m;
        k >>= 1;
    }
    return x;
}

ll ncr(ll n, ll r)
{
    if (n < r)
        return 0;
    ll ans = (fact[n] % mod * facti[n - r] % mod * facti[r] % mod) % mod;
    return ans;
}

int main()
{
    FASTIO
    fact[0] = 1;
    fact[2] = 1;

    fw(i, 1, 100008)
    {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
    fw(i, 0, 100008)
    {
        facti[i] = po(fact[i], mod - 2, mod);
        facti[i] %= mod;
    }
    in(n);
    in(k);
    ll a[n + 90];
    fw(i, 0, n)
    {
        in(x);
        a[i] = x;
        // a[i] = (a[i] + mod) % mod;
    }

    sort(a, a + n);
    ll ans = 0;
    fw(i, 0, n)
    {
        ans += (a[i] % mod * (ncr(i, k - 1) - ncr(n - i - 1, k - 1)) % mod);
        ans = (ans + mod) % mod;
    }
    cout << ans % mod << endl;

    return 0;
}

Measured memory_bytes: 5896
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


int N, K;
int A[100010], B[100010];

ll calc(int k) {
	ll res = 0;
	REP(i, N) {
		bool ok = true;
		REP(j, 30) {
			if (A[i] & (1 << j))if (!(k&(1 << j)))ok = false;
		}
		if (ok)res += B[i];
	}
	return res;
}
void solve() {
	cin >> N >> K;
	REP(i, N) {
		cin >> A[i] >> B[i];
	}
	ll ans = calc(K);
	REP(j,30){
		if (!(K&(1 << j)))continue;
		int tmp = K;
		tmp -= (1 << j);
		REP(l, j)tmp |= (1 << l);
		ans = max(ans, calc(tmp));
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 1792
N,M=map(int,input().split())
P=[0]*M
S=[0]*M
cor=[0]*N
ac,wa=0,0
for i in range(M):
    P[i],S[i]=input().split()
    P[i]=int(P[i])
    if(S[i]=="AC"):
        cor[P[i]-1]+=1
    else:
        pass
for i in range(M):
    if(cor[P[i]-1]>=1 and S[i]=="WA"):
        wa+=1
    elif(cor[P[i]-1]>=1 and S[i]=="AC"):
        cor[P[i]-1]=0
        ac+=1
    else:
        pass
print("{0} {1}".format(ac,wa))

Measured memory_bytes: 14068
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i;
  string s;
  cin >> s;
  n=s.size();
  for(i=0;i<n/4+1;i++)
    if(s[i]!=s[n/2-i-1]||s[i]!=s[n/2+i+1]||s[i]!=s[n-i-1]){
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    string s; cin>>s;
    ll q; cin>>q;
    vector<int> line1(q);
    vector<int> line2(q);
    vector<char> line3(q);
    rep(i,q){
        cin>>line1[i];
        if (line1[i]==1) continue;
        cin>>line2[i]>>line3[i];
    }

    bool isreversed=false;
    string mae="";
    string ato="";

    rep(i,q){
        if(line1[i]==1){
            isreversed= !isreversed;
            continue;
        }
        if(line1[i]==2){
            if(line2[i]==2){
                if(isreversed==false) ato+=line3[i];
                else mae=line3[i] +mae;
            }else{
                if(isreversed==false) mae=line3[i] +mae;
                else ato+=line3[i];
            }
        }
    }

    if(isreversed==false){
        s=mae+s+ato;
        cout<<s<<endl;
    }else{;
        s=mae+s+ato;
        reverse(all(s));
        cout<<s<<endl;
    }
}

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

using namespace std;

const int N = 101;
bool marked[N];
int d[N];
int f[N];

void dfs(vector<vector<int>>& g, int vertex, int& counter) {
    if (marked[vertex])
        return;
    marked[vertex] = true;
    counter++;
    d[vertex] = counter;
    for (int x : g[vertex]) {
        if (!marked[x])
            dfs(g, x, counter);
    }
    counter++;
    f[vertex] = counter;
}

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

    vector<vector<int>> g(n + 1);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            g[u].push_back(v);
        }
    }

    int counter = 0;
    for (int i = 1; i <= n; i++)
        dfs(g, i, counter);

    for (int i = 1; i <= n; i++) {
        cout << i << " ";
        cout << d[i] << " ";
        cout << f[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3152
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = 0
for i in range(n):
    res += min(A[i], B[i])
    if B[i] > A[i]:
        tmp = min(B[i] - A[i], A[i+1])
        res += tmp
        A[i+1] -= tmp
print(res)

Measured memory_bytes: 18468
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a*c<=b){
        cout<<c<<endl;
    }
    else{
        cout<<b/a<<endl;
    }

}


Measured memory_bytes: 256
import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
N = int(input())
E = {i:[] for i in range(N+1)}
for i in range(N-1):
    a,b= inputs()
    E[a].append(b)
    E[b].append(a)
stkf = [[1,-1,0]]
visitedf=[0]*(N+1)
visiteds=[0]*(N+1)
stks = [[N,-1,0]]
cntf=0
cnts=0
while stkf:
    v,p,cost=stkf.pop()
    if v==N:
        visitedf[N]=cost
        continue
    visitedf[v]=cost
    cntf+=1
    for i in E[v]:
        if i!=p:
            stkf.append([i,v,cost+1])
while stks:
    v,p,cost=stks.pop()
    if v==1:
        visiteds[1]=cost
        continue
    visiteds[v]=cost
    cnts+=1
    for i in E[v]:
        if i!=p:
            stks.append([i,v,cost+1])
for i in range(1,N+1):
  if visitedf[i] and visiteds[i]:
    if visitedf[i]<=visiteds[i]:
      cnts-=1
    else:
      cntf-=1
#print(cntf-1,cnts-1,visitedf[N]-1,visiteds[1]-1)
"""
if (visitedf[N]-1)%2!=0:
  cntf=cntf-1-(visitedf[N]-1)//2
  cnts=cnts-1-(visitedf[N]-1)//2-1
else:
  cntf=cntf-1-(visitedf[N]-1)//2
  cnts=cnts-1-(visitedf[N]-1)//2
"""
print("Fennec" if cntf>cnts else "Snuke")
#print(visitedf,cntf,cnts)

Measured memory_bytes: 63076
#!python3

LI = lambda: list(map(int, input().split()))

# input
a, b, x = LI()


def main():
    if a % x == 0:
        v = a
    else:
        v = (a // x + 1) * x
    if v > b:
        ans = 0
    else:
        ans = (b - v) // x + 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
	int x, y;
	cin >> x >> y;

	bool yes = false;
	for (int i = 0; i < 100; ++i) {
		for (int j = 0; j < 100; ++j) {
			if (x != (i + j)) {
				continue;
			}

			if ((i * 2 + j * 4) == y) {
				yes = true;
			}
		}
	}
	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define forn(i,n) for(int i=0; i<(int)n; i++)
ll power(ll x,ll n);
bool isprime(ll n);
ll mod=1e9+7;

void test_case()
{
    int x,y;
    cin>>x>>y;
    if(y%2==0 && y>=2*x && y<=4*x) {
        cout<<"Yes";
    }
    else cout<<"No";
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}
ll power(ll x,ll n)
{
    ll ans=1;
    while(n>0) {
        if(n&1)
            ans*=x;
        n>>=1;
        x*=x;
    }
    return ans;
}

bool isprime(ll n)
{
    if(n==2 || n==3)
        return true;
    if(n<=1 || n%2==0 || (n%6!=1 && n%6!=5))
        return false;
    for(int i=3;i*i<=n;i+=2) {
        if(n%i==0)
            return false;
    }
    return true;
}


Measured memory_bytes: 3608
// author:-*mdragneell*

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=3001;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll dp[N][N];
string x,y;
string s="";

ll solve(ll i,ll j)
{
	ll a=x.length(),b=y.length();
	if(i>=a||j>=b) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	if(x[i]==y[j]) return dp[i][j]=1+solve(i+1,j+1);
	return dp[i][j]=max(solve(i,j+1),solve(i+1,j));

}
void path(ll i,ll j,ll m,ll n)
{
	if(i>=m||j>=n) return;

	if(x[i]==y[j]) {
		s+=x[i];
		path(i+1,j+1,m,n);
		return ;
	}

	else if(solve(i+1,j)>solve(i,j+1)){
		path(i+1,j,m,n);
		return;
	}

	else{
		path(i,j+1,m,n);
		return ;
	}

}


int main()
{
	ll i;
	cin>>x>>y;
	memset(dp,-1,sizeof(dp));
	solve(0,0);
	path(0,0,x.length(),y.length());
	cout<<s<<endl;



}


Measured memory_bytes: 70784
#include <iostream>
using namespace std;
using P = pair<int, int>;

int main(){
    int n, m;
    P op[100001];
    P box[100001];
    
    cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> op[i].first >> op[i].second;
    box[1].first = 1;
    box[1].second = 1;
    for(int i = 2; i <= n; i++){
        box[i].first = 1;
        box[i].second = 0;
    }
    
    for(int i = 0; i < m; i++){
        if(box[op[i].first].second == 1) box[op[i].second].second = 1;
        if(--box[op[i].first].first == 0) box[op[i].first].second = 0;
        box[op[i].second].first++;
    }
    
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(box[i].second == 1) res++;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
ab = []

for i in range(n):
    a,b = map(int,input().split())
    ab.append([b,a])
ab.sort()

due = 0
time = 0
for i in range(n):
    due = ab[i][0]
    time += ab[i][1]
    
    if time > due:
        print("No")
        exit()
print("Yes")
    

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


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

    while (n)
    {
        int i = sqrt(n);
        if (i*i == n)
        {
            cout << n << endl;
            break;
        }
        n--;
    }


    return 0;
}


Measured memory_bytes: 256
(let ((n (read))
      (v nil))
  (loop :for i :from 1 :to n
        :do (push (read) v))
  (setf v (sort v #'<))
  (loop :with ans := (car v)
        :for x :in (cdr v)
        :do (setf ans (/ (+ ans x) 2))
        :finally (format t "~F~%" ans)))


Measured memory_bytes: 23884
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll n,q;
	cin>>n;
	ll fre[100001];
	for (int i = 0; i < 100001; ++i)
	{
		fre[i]=0;
	}
	ll s=0;
	for (int i = 0; i < n; ++i)
	{
		ll x;
		cin>>x;
		fre[x]++;
		s+=x;
	}
	cin>>q;
	while(q--)
	{
		ll b,c;
		cin>>b>>c;
		s-=b*fre[b];
		s+=c*fre[b];
		fre[c]+=fre[b];
		fre[b]=0;
		cout<<s<<endl;
	}
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 4436
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
    Integer[] A = new Integer[N];
    long number = 0l;
    Map<Integer, Long> map = new HashMap<>();
      for(int i = 0 ; i < N ; i++){
        A[i] = Integer.parseInt(sc.next());
        map.put(i + A[i] , map.getOrDefault(i + A[i] , 0L) + 1L);
      }
        for(int j = 0 ; j < N ; j++){
          number += map.getOrDefault(j - A[j] , 0L);
      }
      
	
	System.out.println(number);
	}
}

Measured memory_bytes: 73396
n,a,b = map(int, input().split())
rs = (b-a)//2

if (b-a) % 2 == 0:
    print(rs)
else:
    if a==1 and b==n:
        print(n//2)
    elif (a-1) > (n-b):
        print(rs+(n-b+1))
    else:
        print(rs+a)



Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace diverta20192_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToList();

            var numNeg = A.Where(x => x < 0).Count();

            long ans1 = 0;
            var ans2 = new List<Tuple<long, long>>();

            if (N == 2)
            {
                ans1 = A.Max() - A.Min();
                ans2.Add(new Tuple<long, long>(A.Max(), A.Min()));
            }
            else if (numNeg == 0)
            {
                var smallTwo = A.OrderBy(x => Math.Abs(x)).Take(2).ToList();
                ans1 = smallTwo[0] - smallTwo[1];
                ans2.Add(new Tuple<long, long>(smallTwo[0], smallTwo[1]));

                A.Remove(smallTwo[0]);
                A.Remove(smallTwo[1]);

                for (int i = 0; i < N - 3; i++)
                {
                    ans2.Add(new Tuple<long, long>(ans1, A[i]));
                    ans1 -= A[i];
                }

                ans2.Add(new Tuple<long, long>(A[N - 3], ans1));
                ans1 = A[N - 3] - ans1;
            }
            else if (numNeg == N)
            {
                var smallTwo = A.OrderBy(x => Math.Abs(x)).Take(2).ToList();
                ans1 = smallTwo[0] - smallTwo[1];
                ans2.Add(new Tuple<long, long>(smallTwo[0], smallTwo[1]));

                A.Remove(smallTwo[0]);
                A.Remove(smallTwo[1]);

                for (int i = 0; i < N - 3; i++)
                {
                    ans2.Add(new Tuple<long, long>(ans1, A[i]));
                    ans1 -= A[i];
                }

                ans2.Add(new Tuple<long, long>(ans1, A[N - 3]));
                ans1 -= A[N - 3];
            }
            else
            {
                var pos = A.Where(x => x >= 0).ToArray();
                var neg = A.Where(x => x < 0).ToArray();

                ans1 = pos[0];
                long temp = neg[0];
                for (var pIndex = 1; pIndex < pos.Length; pIndex++)
                {
                    ans2.Add(new Tuple<long, long>(temp, pos[pIndex]));
                    temp -= pos[pIndex];
                }

                for (var nIndex = 1; nIndex < neg.Length; nIndex++)
                {
                    ans2.Add(new Tuple<long, long>(ans1, neg[nIndex]));
                    ans1 -= neg[nIndex];
                }

                ans2.Add(new Tuple<long, long>(ans1, temp));
                ans1 -= temp;
            }

            Console.WriteLine(ans1);
            var sb = new StringBuilder();
            for (int i = 0; i < ans2.Count(); i++)
            {
                sb.AppendLine($"{ans2[i].Item1} {ans2[i].Item2}");
            }
            Console.WriteLine(sb.ToString());
        }
    }
}


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

#define ll long long
#define pb push_back


int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (char c : s){
		int ck = (int)c - '0';
		if (ans >= 9){
			ans += ck;
			ans -= 9;
		} else {
			ans +=ck;
		}
	}
	if (ans % 9 == 0){
		cout << "Yes";
	} else {
		cout << "No";
	}
}


Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
int a,b,c,x,y,z,ans;
scanf("%d%d%d",&a,&b,&c);
if(a>b)
x=a-b;
else
x=b-a;
if(b>c)
y=b-c;
else
y=c-b;
if(a>c)
z=a-c;
else
z=c-a;
if(x>=y && x>=z)ans=y+z;
else if(y>=x && y>=z)ans=x+z;
else if(z>=x && z>=y)ans=x+y;
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define Q int tt,qq; cin>>tt ;for(qq=1;qq<=tt;qq++)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
    int n;
    cin>>n;
    vector<ll>v(n+1),u(n);
    for(auto &it:v)    cin>>it;
    for(auto &it:u)    cin>>it;
    ll ans=0;
    for(int i=0;i<n;i++){
       if(v[i]>u[i]){
         ans+=u[i];
         u[i]=0;
       }
       else{
         ans+=v[i];
         u[i]-=v[i];
       }
       if(u[i]>0){
         if(v[i+1]>u[i]){
            ans+=u[i];
            v[i+1]-=u[i];
         }
         else{
            ans+=v[i+1];
            v[i+1]=0;
         }
       }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double INF = 1e17;
const double T_LIM = 1e9;

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

    double minX[2], maxX[2], minY[2], maxY[2];
    rep(i,2){
        minX[i] = minY[i] = INF;
        maxX[i] = maxY[i] = -INF;
    }

    double lx = INF, rx = -INF;
    double ly = INF, ry = -INF;

    rep(i,n){
        double x,y;
        char c;
        scanf(" %lf %lf %c", &x, &y, &c);
        if(c == 'L' || c == 'R'){
            int idx = 0;
            if(c == 'R') idx = 1;

            ly = min(ly, y);
            ry = max(ry, y);

            minX[idx] = min(minX[idx], x);
            maxX[idx] = max(maxX[idx], x);
        }
        else{
            int idx = 0;
            if(c == 'U') idx = 1;

            lx = min(lx, x);
            rx = max(rx, x);
        
            minY[idx] = min(minY[idx], y);
            maxY[idx] = max(maxY[idx], y);
        }
    }

    vector<double> cand;
    cand.pb(0);

    // X
    for(double X:{lx,rx}){
        rep(i,2){
            for(double m:{minX[i],maxX[i]}){
                double t = m-X;
                if(i) t = -t;
                if(0<=t && t<T_LIM) cand.pb(t);
            }
        }
    }
    for(double x0:{minX[0],maxX[0]})for(double x1:{minX[1],maxX[1]}){
        double t = (x0-x1)/2;
        if(0<=t && t<T_LIM) cand.pb(t);
    }

    // Y
    for(double Y:{ly,ry}){
        rep(i,2){
            for(double m:{minY[i],maxY[i]}){
                double t = m-Y;
                if(i) t = -t;
                if(0<=t && t<T_LIM) cand.pb(t);
            }
        }
    }
    for(double y0:{minY[0],maxY[0]})for(double y1:{minY[1],maxY[1]}){
        double t = (y0-y1)/2;
        if(0<=t && t<T_LIM) cand.pb(t);
    }

    double ans = INF;
    for(double t:cand){
        double X = max({rx, maxX[0]-t, maxX[1]+t}) - min({lx, minX[0]-t, minX[1]+t});
        double Y = max({ry, maxY[0]-t, maxY[1]+t}) - min({ly, minY[0]-t, minY[1]+t});
        ans = min(ans, X*Y);
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
using namespace std;
int compare(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}
int main(){
	int n,a[200][2],k=0,b[200],max=0,d=0,i;
	for(i=0;i<200;i++)
	a[i][1]=0;
	while(cin>>n){
		for(i=0;i<k;i++)
		if(a[i][0]==n){
			a[i][1]++;
			break;
		}
		if(i==k){
			a[k][0]=n;
			a[k++][1]++;
		}
	}
	for(i=0;i<k;i++)
		if(a[i][1]>max)
			max=a[i][1];
	for(i=0;i<k;i++)
		if(max==a[i][1])
			b[d++]=a[i][0];
	qsort(b,d,sizeof(int),compare);
	for(i=0;i<d;i++)
		cout<<b[i]<<endl;
	return 0;
}

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

using namespace std;

int main(){
   int ans[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 K;
   cin >> K;
   cout << ans[K-1] << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int x, a, b;

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

  cin >> x >> a >> b;

  if(abs(x-a) < abs(x-b)){
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }

  return 0;
}



Measured memory_bytes: 256