akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include <vector>
#include<list>

using namespace std;


int main() {

	int x, n;

	int ans, temp, check;

	cin >> x >> n;

	vector<int> p(n);
	vector<int> comp(102);

	for (int i = 0; i <= 101; i++) {
		comp[i] = i;
	}

	check = 5000;


	for (int i = 0; i < n; i++) {
		cin >> p[i];
		comp[p[i]] = 500;
	}

	for (int i = 101; i >= 0; i--) {

		if (comp[i] >= x) {
			temp = comp[i] - x;
		}
		if (x >= comp[i]) {
			temp = x - comp[i];
		}
		if (temp <= check) {

			ans = comp[i];
			check = temp;
		}

	}

	cout << ans;
}

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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int cnt = 0,a,b,c;
    cin >> a >> b >> c;
    
    rep(i,a,b+1){
        if(c % i == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3172
class Dice:
    def __init__(self, label: list):
        self.top, self.front, self.right, self.left, self.back, self.bottom = label

    def roll(self, direction: str):
        if direction == "N":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.front,
                self.bottom,
                self.right,
                self.left,
                self.top,
                self.back,
            )
        elif direction == "W":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.right,
                self.front,
                self.bottom,
                self.top,
                self.back,
                self.left,
            )
        elif direction == "S":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.back,
                self.top,
                self.right,
                self.left,
                self.bottom,
                self.front,
            )
        elif direction == "E":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.left,
                self.front,
                self.top,
                self.bottom,
                self.back,
                self.right,
            )

    def output_top(self):
        print(self.top)


(*label,) = map(int, input().split())
dice = Dice(label)
for i in input():
    dice.roll(i)
dice.output_top()


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

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

    long long n;
    cin >> n;

    long long ng = 1, ok = n;
    while(ok - ng > 1){
        long long mid = (ok + ng) / 2;
        long long t = mid * (1 + mid) / 2;
        if(t < n) ng = mid;
        else ok = mid;
    }

    vector<long long> Ans;
    long long k = n;
    for(long long i = ok; i >= 1; i--){
        if(k - i >= 0){
            k -= i;
            Ans.push_back(i);
        }
    }

    sort(Ans.begin(), Ans.end());
    
    for(auto x : Ans){
        cout << x << endl;
    }

    return 0;
}

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

#define MAX_N 200010
#define MAX_Q 1010

struct Node {
  int prev, next;
  bool dead;
};

int N, M, Q;
Node S[MAX_N];

int main() {
  cin >> N >> M >> Q;
  for (int i=0; i<N; i++) {
    S[i].prev = (i-1+N) % N;
    S[i].next = (i+1  ) % N;
  }

  int head = 0;
  for (int i=0; i<M; i++) {
    int a;
    cin >> a;
    for (int j=0; j<a; j++) {
      if (a % 2 == 0) head = S[head].next;
      else            head = S[head].prev;
    }
    S[head].dead = true;
    S[S[head].prev].next = S[head].next;
    S[S[head].next].prev = S[head].prev;
    head = S[head].next;
  }
  for (int i=0; i<Q; i++) {
    int q;
    cin >> q;
    cout << (S[q].dead ? 0 : 1) << "\n";
  }
  return 0;
}

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

int main(){
    int x, n;
    int min, k; 
    int count, m, r;
    
    min = 200;
    r = 100;

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

    int p[n+1];

    for(int i=1; i<n+1; i++){
         scanf("%d", &p[i]);
    }   
    
    
    for(int i=-1; i<=101; i++){

        m = 0;
        count = 0;

            for(int j=1; j<n+1; j++){
                if(i != p[j]){
                    m += 1;   
                }
                count += 1;
            }

            if(count == m){
                k = abs(i - x);
                if(min > k){
                     min = k;
                     r = i;
                }
            }
        
    }   

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

return 0;

}

Measured memory_bytes: 1716
import java.util.*;

public class Main{
    public static void main(String[]args){
	int black;
	Scanner sc = new Scanner(System.in);
	int H = sc.nextInt();
	int W = sc.nextInt();
	int K = sc.nextInt();
	sc.nextLine();
	
	String str ="";
	String c[][]= new String[H][W];
	//String d[]= new String[W];
        int ans=0;
	
	for(int i=0; i<H; i++){
	    str = sc.next();
	    String d[] = str.split("");
	    for(int j=0; j<W; j++){
		c[i][j]=d[j];
	    }
	}

	for(byte maskR=0; maskR<(1<<H); maskR++){
	    for(byte maskC=0; maskC<(1<<W); maskC++){
		black=0;
		for(int i=0; i<H; i++){
		    for(int j=0; j<W; j++){
			if(((maskR>>i)&1)==0 &&
			   ((maskC>>j)&1)==0 &&
			   (c[i][j].equals("#"))){
			    black++;
			}
		    }
		}
		if(black==K){
		    ans++;
		}
	    }
	}
	System.out.println(ans);
    }
}


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

int main() {
  string a,b;
  cin >> a >> b;
  int lon,lon2;
  lon = a.size();
  lon2 = b.size();


  if(lon>lon2){
      cout << "GREATER" << endl;
      return 0;
  }else if(lon<lon2){
      cout << "LESS" << endl;
      return 0;
  }

  for(int i=0;i<lon+1;i++){
      if(a[i]>b[i]){
          cout << "GREATER" << endl;
          return 0;
      }else if(a[i]==b[i]){
          continue;
      }else{
          cout << "LESS" << endl;
          return 0;
      }
  }
    cout << "EQUAL" << endl;
}

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

using namespace std;

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

    vector<int> vt[2];
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            int a;
            cin >> a;
            vt[i].push_back(a);
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int tmp = accumulate(vt[0].begin(), vt[0].begin() + i + 1, 0) +
                  accumulate(vt[1].begin() + i, vt[1].end(), 0);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N, x; cin >> N >> x;
    V<ll> a = V<ll>(N+1); REP(i,1,N+1) cin >> a[i];
    sort(a.begin()+1,a.end());
    REP(i,2,N+1) a[i] += a[i-1];

    if(x == a[N]) {
        cout << N << endl;
        return 0;
    }

    int k = 0;
    REP(i,1,N+1) {
        if(x >= a[i]) k = i;
    }

    if(k == N) {
        cout << N-1 << endl;
    } else {
        cout << k << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool rev = false;
    string Fr, Ba;
    rep(i, 0, Q){
        int T;
        cin >> T;
        if (T == 1){
            if (rev) rev = false;
            else rev = true;
        }
        if (T == 2){
            int F;
            char C;
            cin >> F >> C;
            if (F == 1){
                if (rev) Ba += C;
                else Fr += C;
            }
            if (F == 2){
                if (rev) Fr += C;
                else Ba += C;
            }
        }
    }
    reverse(all(Fr));
    //cout << Fr << " " << S << " " << Ba << endl;
    S = Fr + S + Ba;
    if (rev) reverse(all(S));
    cout << S << endl;
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  if(a<=b){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N;
ll T[MAX_N];

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  ll r = a % b;
  if (r == 0) return b;
  return gcd(b, r);
}

void solve() {
  ll ans = 1;
  for (int i = 0; i < N; i++) {
    ll g = gcd(ans, T[i]);
    ans = (ans / g) * T[i];
  }
  cout << ans << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> T[i];

  solve();

  return 0;
}


Measured memory_bytes: 256
R,G,B,N = map(int,input().split())

cnt = 0
for r in range(N//R+1):
    totalR = r * R
    excess = N - totalR
    for g in range(excess//G+1):
        totalRG = totalR + g * G
        if (N - totalRG) % B == 0:
            cnt += 1
            
print(cnt)

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


int main()
{
    char s[10000];
    while(scanf("%s",s)!=EOF)
    {
        int a;
        scanf("%d",&a);
        for(int i=0;i<strlen(s);i++)
        {
            if(i%a==0)
            {
                printf("%c",s[i]);
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void){
 	int index[26] = {0};
  	string s;	
  	int cnt = 0;
  	
  	cin >> s;
  	
  	for(int i = 0; i < 4; i++){
     	index[s[i] - 'A']++; 
    }
  
  	for(int i = 0; i < 26; i++){
     	if(index[i] == 2){
         	cnt++; 
        }
    }
  	
  	cout << (cnt == 2 ? "Yes" : "No") << endl;
  
	return 0;
}

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


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B,C,K,tmp;
  cin>>A>>B>>C>>K;
  if(B<C){
    tmp=B;
    B=C;
    C=tmp;
  }
  if(A<B){
    tmp=A;
    A=B;
    B=tmp;
  }
  if(B<C){
    tmp=B;
    B=C;
    C=tmp;
  }
  for(int i=0;i<K;i++){
    A=A*2;
  }
  int ans=A+B+C;
  cout<<ans;




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
int main(){
    int a, b, c;
    scanf("%d%d%d" ,&a, &b, &c);
    c = c-a-b;
    if(c < 0) printf("No\n");
    else{
        long long e = c*1ll*c;
        long long d = 4*1ll*a*b;
        if(d < e) printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

template<typename T> class segtree {
private:
    int n,sz,h;
    vector<T> node, lazy;
    void eval(int k) {
        if(lazy[k]){
            node[k] += lazy[k];
            if(k < n) {
                lazy[k*2] += lazy[k] / 2, lazy[k*2+1] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0) {
        while(n < sz) n *= 2, h++;
        node.resize(2*n, 0), lazy.resize(2*n, 0);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n-1; i >= 1; i--) node[i] = node[2*i] + node[2*i+1];
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a){
            return;
        }
        if(a <= l && r <= b){
            lazy[k] += (r-l)*x;
            eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = node[2*k] + node[2*k+1];
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = 0, res2 = 0;
        while(a < b) {
            if(a & 1) eval(a), res1 += node[a++];
            if(b & 1) eval(--b), res2 += node[b];
            a >>= 1, b >>= 1;
        }
        return res1 + res2;
    }
    void _print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<vector<ll>> g(n);
    
    zep(i, 0, n - 1){
    	ll u, v; cin >> u >> v; u--; v--;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    
    //ll c[n], cnt[n];
    //memset(c, -1, sizeof(c));
    //memset(cnt, 0, sizeof(cnt));
    
    /*zep(i, 0, n){
    	zep(j, 0, g[i].size()){
    		if(g[i][j] < i){
    			c[i] = max(c[i], g[i][j]);
    			cnt[i]++;
    		}
    	}
    }*/
    //printa(c, 0, n - 1)
    
    vector<ll> v(n, 0);
    segtree<ll> sg(v);
    
    ll ans = 0;
    zep(i, 0, n){
    	sg.range(0, i + 1, 1);
        zep(j, 0, g[i].size()){
            if(g[i][j] < i){
                sg.range(0, g[i][j] + 1, -1);
            }
        }

        ans += sg.query(0, i + 1);
    }
    print(ans)
    
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        c: chars,
    }

    let ans = (c[0] as u8 + 1) as char;

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


Measured memory_bytes: 4352
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e6+5;
int fac[N],ifac[N];
void init(int n=2e6){
	fac[0]=ifac[0]=1;fp(i,1,n)fac[i]=mul(fac[i-1],i);
	ifac[n]=ksm(fac[n],P-2);fd(i,n-1,1)ifac[i]=mul(ifac[i+1],i+1);
}
inline int C(R int n,R int m){return m>n?0:1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
inline int calc(R int x,R int y,R int xx,R int yy){
	R int res=C(x+y,x);
	upd(res,C(xx+1+yy+1,xx+1));
	upd(res,P-C(x+yy+1,x));
	upd(res,P-C(y+xx+1,y));
	return res;
}
int x[15],y[15],res;
inline int t1(R int xx,R int yy){
	return calc(xx-x[2],yy-y[2],xx-x[1],yy-y[1]);
}
inline int t2(R int xx,R int yy){
	return calc(x[5]-xx,y[5]-yy,x[6]-xx,y[6]-yy);
}
int main(){
//	freopen("testdata.in","r",stdin);
	init();
	fp(i,1,6)scanf("%d",&x[i]);
	fp(i,1,6)scanf("%d",&y[i]);
	fp(i,x[3],x[4]){
		upd(res,1ll*(P-y[3]-i)*t1(i,y[3]-1)%P*t2(i,y[3])%P);
		upd(res,1ll*(y[4]+1+i)*t1(i,y[4])%P*t2(i,y[4]+1)%P);
	}
	fp(j,y[3],y[4]){
		upd(res,1ll*(P-x[3]-j)*t1(x[3]-1,j)%P*t2(x[3],j)%P);
		upd(res,1ll*(x[4]+1+j)*t1(x[4],j)%P*t2(x[4]+1,j)%P);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 15872
s=input()
for i in range(0,len(s),2):
    if s[i]=='R' or s[i]=='U' or s[i]=='D':
        continue
    else:
        print('No')
        exit()
for i in range(1,len(s),2):
    if s[i]=='L' or s[i]=='U' or s[i]=='D':
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

B = [0]*N
for i in range(N):
    B[i] = i - A[i]

C = Counter(B)

ans = 0
for j in range(N-1):
    d = A[j]+j
    ans += C[d]
    C[B[j]] -= 1

print(ans)

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

int main(){
	int N;
	cin >> N;
	string W[N];
	//入力
	for(int i = 0; i < N; i++) cin >> W[i];
	//繋がりのチェック
	for(int i = 0; i < N - 1; i++){
		if(W[i].at(W[i].size()-1) != W[i+1].at(0)){
			cout << "No" << endl;
			return 0;
		}
	}
	//重複のチェック
	for(int i = 0; i < N - 1; i++) for(int j = i + 1; j < N; j++){
		if(W[i] == W[j]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI a(n);
    REP(i,n){
        cin >> a[i];
    }

    VI map(100001,0);
    REP(i,n){
        map[a[i]]++;
    }

    int m = *max_element(ALL(map));
    int t = 0;
    FOR(i,1,100001){
        t += max(map[i]-1,0LL);
    }
    cout << n - (t/2*2+t%2*2) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define reps(i,b,n) for(int i = b ; i < (int)n ; ++i )
#define rep(i,n) reps(i,0,n)
#define fr first
#define sc second
map<int,int> used;
void solve(int a,int b,int now){
  int r = a % b;
  if(used[r] != 0){
    cout << ( a / b ) << endl;
    used[r]-- , now++ ;
    rep(i,used[r]) cout << ' ';
    reps(i,used[r],now) cout << '^';
    cout << endl;
  }else{
    used[r] = now + 2;
    cout << ( a / b );
    if(r != 0) solve(r*10,b,now+1);
    else cout << endl;
  }
}
int main(){
  int p,q;
  while(cin >> p >> q){
    used[p%q] = 1;
    solve(p*10,q,0);
    used.clear();
  }
}

Measured memory_bytes: 1200
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = - a[i]
heapq.heapify(a)
for i in range(m):
    h = heapq.heappop(a)
    h = - h
    h = h // 2
    h = - h
    heapq.heappush(a,h)
g = 0
for j in range(n):
    g += heapq.heappop(a)
print(0-g)

Measured memory_bytes: 14180
n=int(input())
a=list(map(int,input().split()))

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)

Measured memory_bytes: 84660
function Main(input) {
  input=input.split("\n");
  var L=input[0]-0;
  console.log((L/3)**3);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29524
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N, K;
double ki[200010];

signed main()
{
	cin >> N >> K;
	REP(i, N)
	{
		int p;
		cin >> p;
		int sum = p * (p + 1) / 2;
		ki[i] = sum / (double)p;
	}

	
	double sum = 0;
	for (int i = 0; i < K; i++)
	{
		sum += ki[i];
	}
	double mx = sum;

	for (int i = K; i < N; i++)
	{
		sum -= ki[i - K];
		sum += ki[i];
		mx = max(mx, sum);
	}

	cout << fixed << setprecision(10) << mx << endl;
}




Measured memory_bytes: 1792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int c = cin.ReadInt;
            int x = cin.ReadInt;
            int cnt = 0;

            for (int i = 0; i <= a; i++)
                for (int j = 0; j <= b; j++)
                    for (int k = 0; k <= c; k++)
                        if (i * 500 + j * 100 + k * 50 == x) cnt++;

            Console.WriteLine(cnt);

        }

        bool IsOK(ref int[] a)
        {
            foreach (int i in a)
            {
                if (i % 2 != 0) return false;
            }

            for(int i = 0; i < a.Length; i++)
            {
                a[i] = a[i] / 2;
            }
            return true;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <iostream>
typedef long double ld;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    if (n == 1)
    {
        cout << 1.00000 << endl;
        return (0);
    }
    if (n % 2 == 0)
    {
        cout << 0.5000000000 << endl;

    }
    else
    {
        cout << (n / 2 + 1)/double(n) << endl;
    }
    return (0);
}

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

using namespace std;

class Item {
public:
	int id;
	int p, q, r;
	Item(int id, int p, int q, int r) :
		id(id), p(p), q(q), r(r){}

	bool operator<(const Item &t)const{
		if (id != t.id)return id < t.id;
		if (p != t.p)return p < t.p;
		if (q != t.q)return q < t.q;
		if (r != t.r)return r < t.r;
		return false;
	}
};

int main()
{
	while (true) {
		int n;
		int P, Q, R, C;
		vector<Item> items;
		bool output = false;

		cin >> n;

		if (n == 0) {
			break;
		}

		for (int i = 0; i < n; ++i) {
			int id, p, q, r;
			cin >> id >> p >> q >> r;
			items.push_back(Item(id, p, q, r));
		}

		cin >> P >> Q >> R >> C;
		
		// sort(items.begin(), items.end());

		for (int i = 0; i < items.size(); ++i) {
			int cal = items[i].p * 4 + items[i].q * 9 + items[i].r * 4;
			if ( items[i].p <= P && items[i].q <= Q && items[i].r <= R && cal <= C ) {
				cout << items[i].id << endl;
				output = true;
			}
		}

		if ( !output ) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(void){

  int in[5]={0};
  while(scanf("%d,",&in[0])!=EOF){
    scanf("%d,%d,%d,%d",&in[1],&in[2],&in[3],&in[4]);

    int sort[5]={0};
    int i,j;
    int datesu=0;

    for(i=0;i<5;i++){    
      for(j=datesu-1;j>=0;j--){
	if(in[i]>sort[j])
	  sort[j+1]=sort[j];
	else{
	  sort[j+1]=in[i];
	  break;
	}
      }
      if(j==-1)
	sort[0]=in[i];
      datesu++;
    }
    
    
    if(sort[0]==sort[3]||sort[1]==sort[4]){
      puts("four card");
    }else if(sort[0]==sort[2]){
      if(sort[3]==sort[4])
	puts("full house");
      else
	puts("three card");
    }else if(sort[2]==sort[4]){
      if(sort[0]==sort[1])
	puts("full house");
      else
	puts("three card");
    }else if(sort[1]==sort[3]){
      puts("three card");
    }else if((sort[0]==sort[1]&&sort[2]==sort[3])||(sort[0]==sort[1]&&sort[3]==sort[4])||(sort[1]==sort[2]&&sort[3]==sort[4])){
      puts("two pair");
    }else if(sort[0]==sort[1]||sort[1]==sort[2]||sort[2]==sort[3]||sort[3]==sort[4]){
      puts("one pair");
    }else if(sort[4]==1&&sort[3]==10){
      puts("straight");
    }else if(sort[4]-sort[0]==-4){
      puts("straight");
    }else
      puts("null");
  }

  return 0;
}

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

#define all(a) (a).begin(),(a).end()

using namespace std;

int c[2001],res[4001];

int main(void){

  for(int i=0;i<1001;i++)
    for(int j=0;j<1001;j++)
      c[i+j]++;

  for(int i=0;i<2001;i++)
    for(int j=0;j<2001;j++)
      res[i+j]+=c[i]*c[j];

  int n;
  while(cin >> n)cout << res[n] << endl; 
  

  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool ans1 = true; 
    bool ans2 = true;
    bool ans3 = true;
    for(int i = 0; i < n; i++) {
        if(s.at(i) != s.at(n - i - 1)) ans1 = false;
    }
    for(int j = 0; j < (n-1)/2; j++) {
        if(s.at(j) != s.at((n-1)/2 - j - 1)) ans2 = false;
    }
    for(int k = 0; k < (n-1)/2; k++) {
        if(s.at((n+3)/2 - 1 + k) != s.at(n - 1 - k)) ans3 = false;
    }
    if(ans1 && ans2 && ans3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000 + 1)

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

maxDist = [0 for i in range(N+1)]
in_degree = [0 for i in range(N+1)]
adj_list = [[] for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    adj_list[x].append(y)
    in_degree[y] += 1

for node in range(1, N+1):
    adj_list[0].append(node)
    in_degree[node] += 1

# dp[i] = maximum length of path ending at i
flattenedNodes = []
def dfs(node):
    for child in adj_list[node]:
        maxDist[child] = max(maxDist[child], 1 + maxDist[node])
        in_degree[child] -= 1
        if in_degree[child] == 0:
            dfs(child)
            
dfs(0)
print(max(maxDist) - 1)


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  map<string,int> m;

  rep(i, n) {
    string s; cin >> s;
    sort(all(s));

    ++m[s];
  }

  int ans = 0;
  for (auto e : m) ans += e.se * (e.se-1) / 2;

  cout << ans << endl;
}


Measured memory_bytes: 11344
using System;
using System.Collections.Generic;
class Program
{	
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long x1 = long.Parse(str[0]);
		long y1 = long.Parse(str[1]);
		long x2 = long.Parse(str[2]);
		long y2 = long.Parse(str[3]);
		long x3 = x2 - (y2-y1);
		long y3 = y2 - (x1-x2);
		long x4 = x3 - (y3-y2);
		long y4 = y3 - (x2-x3);
		Console.WriteLine(x3+" "+y3+" "+x4+" "+y4);
	}
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

#define lint long long int

int main()
{
    char s[11], t[11];
    scanf("%s %s", s, t);
    
    int l = strlen(t);
    t[l-1] = '\0';
    
    if (strcmp(s,t)) cout << "No";
    else cout << "Yes";
    cout << endl;
}


Measured memory_bytes: 3764
main=getLine>>=print.solve.map read.words
solve[h,w]
 |h*w`mod`3==0 = 0
 |otherwise=minimum$concatMap f [[h,w],[w,h]] where
  f[h,w]=[h,cx*h-(w-cx)*fy,(w-fx)*cy-fx*h] where
   (cx,fx,cy,fy)=((w+2)`div`3, w`div`3, (h+1)`div`2, h`div`2)


Measured memory_bytes: 508
#include <stdio.h>
#include <stdbool.h>

int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    char a[h][w];
    bool b[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("\n%c",&a[i][j]);
            b[i][j] = true;
        }
    }

    int count_a_r;
    int count_b_r;
    for(int j = 0; j < h; j++){
        count_a_r = 0;
        count_b_r = 0;
        for(int k = 0; k < w; k++){
            if(b[j][k] == true){
                count_b_r++;
                if(a[j][k] == '.'){
                    count_a_r++;
                    continue;
                }else if(a[j][k] == '#'){
                    break;
                }
            }
        }
        if(count_a_r == count_b_r){
            for(int l = 0; l < w; l++){
                b[j][l] = false;
            }
        }
    }

    int W = w;
    int count_a_c;
    int count_b_c;
    for(int j = 0; j < w; j++){
        count_a_c = 0;
        count_b_c = 0;
        for(int k = 0; k < h; k++){
            if(b[k][j] == true){
                count_b_c++;
                if(a[k][j] == '.'){
                    count_a_c++;
                    continue;
                }else if(a[k][j] == '#'){
                    break;
                }
            }
        }
        if(count_a_c == count_b_c){
            for(int l = 0; l < h; l++){
                b[l][j] = false;
            }
            W--;
        }
    }

    int count_w = 0;
    for(int i = 0; i < h; i++){
        count_w = 0;
        for(int j = 0; j < w; j++){
            if(b[i][j]){
                printf("%c",a[i][j]);
                count_w++;
            }
            if(count_w == W){
                printf("\n");
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var (D,X) = readLine()!!.split(" ").map(String::toInt)
    (1..N).map{
        var a = readLine()!!.toInt()
        if(D%a == 0) (D/a).toInt()
        else (D/a).toInt() + 1
    }.sum().let{
        println(it+X)
    }
}


Measured memory_bytes: 37928
// https://beta.atcoder.jp/contests/abc106

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define debug(x) cout<< #x <<": "<<x<<endl
#define debug2(x,y) cout<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

int main() {
  vi a(31, 0);
  a[0] = 1;
  a[1] = 1;
  a[2] = 2;
  for (int i = 3; i <= 30; ++i) {
    a[i] = a[i-1]+a[i-2]+a[i-3];
  }
  const int try_per_year = 365*10;
  while (true) {
    int steps;
    cin >> steps;
    if (steps == 0) { break; }
    printf("%d\n", (a[steps]+try_per_year-1)/try_per_year);
  }

  return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n<105){
    cout << 0 << endl;
  }else if(105<=n&&n<135){
    cout << 1 << endl;
      }else if(135<=n&&n<165){
    cout << 2 << endl;
      }else if(165<=n&&n<189){
    cout << 3 << endl;
      }else if(189<=n&&n<195){
    cout << 4 << endl;
      }else if(195<=n){
    cout << 5 << endl;
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;

    REP(i, s.length() - 1) {
        if (s.at(i) == 'A' && s.at(i + 1) == 'C') {
            MSG("Yes")
            exit(0);
        }
    }

    MSG("No")
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n; // scanf("%d", &n);
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    // what is the minimum possible number of elements
    // changed in such a way that no two adjacent elements
    // are equal
    int answer = 0;
    for(int i = 0; i < n; ++i) {
        const int x = a[i];
        int group_size = 1;
        while(i + 1 < n && a[i+1] == x) {
            ++i;
            ++group_size;
        }
        answer += group_size / 2;
    }
    cout << answer << endl;
}
    


Measured memory_bytes: 256
#include <stdio.h>
 int main(void){
    int r,c,a[101][101]={0},i,j;
    scanf("%d%d",&r,&c);
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
            a[i][c]+=a[i][j];
        }
    }
    for(i=0;i<c;i++){
        for(j=0;j<r;j++)a[r][i]+=a[j][i];
        a[r][c]+=a[r][i];
    }
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            if(j!=0)printf(" ");
            printf("%d",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2064
#include<stdio.h>
long a, b,c;
long count = 0;
int main() {
	scanf("%ld %ld", &a, &b);
	for (a; a <= b; a++) {
		c = (a % 10) * 10 + ((a % 100) / 10);
			if (a / 1000 == c) count++;
	}
	printf("%ld", count);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] kokuban = new int[N];
		int counter = 0;

//		for (int i = 0; i < N; i++) {
//			kokuban[i] = sc.nextInt();
//		}
		for (int i = 0; i < N; i++) {
			if (sc.nextInt() % 2 == 1) {
				counter++;
			}
		}
		if (counter % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

int main(){
    string s,ans;
    cin>>s;
    rep(i,s.size()){
        if(s[i]!='B')ans+=s[i];
        else{
            if(!ans.empty()){
                ans.erase(ans.size()-1);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
// #define mp make_pair
#define ss second
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repp(i,a,b) for(int i = a; i <= b; i++)
#define endl '\n'
#define mod 1000000007
#define mod_in(a) bin(a, mod - 2)
#define ncr(n, r) (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n)-(r)]) % mod)) % mod) : (int)0)
#define pi 3.14159265358979323
#define INF 1e15
#define lb(v, a) lower_bound(v.begin(), v.end(), a)
#define ub(v, a) upper_bound(v.begin(), v.end(), a)

int power(int x, int n){
    int res=1;
    while(n>0){
        if(n&1)
            res=res*x;
        x*=x;
        n>>=1;
    }
    return res;
}

int bin(int x, int n){
    int res=1; x%=mod;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res%mod;
}
// vector<int> ft;

// int ncr(int n, int r){
//     if(n>=r){
//         return (ft[n] * mod_in((ft[r] * ft[(n)-(r)]) % mod)) % mod;
//     }
//     else return 0;
// }

bool prime(int n){
    if(n==3)return 1;
    repp(i,2,sqrt(n)){
        if(n%i==0)return 0;
    }
    return 1;
}

// vector<int> adj[100001];
// int flag=0, x, y, f=0;
// int vis[100001]={0}, par[200001]={0}, top[500001], pop[100001]={0}, g[100001], b[100001];
// int p[100001], h[100001];

// void dfs(int n){
//     vis[n] = 1;
//     pop[n]=p[n];
//     for(auto i: adj[n]){
//         if(!vis[i]){ 
//             dfs(i);
//             pop[n] += pop[i];
//         }
//     }
// }


// vector<int> pr(2000005, 1), xx[2000005];
// void sieve(int n){ 
//     for(int p=2; p<n; p++){ 
//         if(pr[p]){ 
//             for(int i=p; i<n; i += p){
//                 pr[i]=0;
//                 xx[i].pb(p);
//             }
//         } 
//     } 
// }  

void solve(){
    int x, k, d, ans=1e18; cin>>x>>k>>d;
    if(x >=0){int f = x/d;
    f = min(f, k);
    k-=f;
    x-=f*d;
    ans = x;
    if(k%2){
        ans= abs(x-d);
    }
    else ans=x;}
    else{ x= abs(x); int f = x/d;
    f = min(f, k);
    k-=f;
    x-=f*d;
    ans = x;
    if(k%2){
        ans= abs(x-d);
    }
    else ans=x;}
    cout<<ans<<endl;
}

signed main(){
    fast
    // ft.pb(1);
    // rep(i,1,2000005) ft.pb((ft[i-1]*i)%mod);
    int t=1;
    // cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3692
class Dice2():

    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        self.view = v
        self.dTFR = {}
        for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in  range(6)):
            self.dTFR[self.view[i]]=[self.view[v] for v in (j, k, 5-j, 5-k, j)]


d2, q = Dice2(list(map(int, input().split()))), int(input())
for i in range(q):
    t, f = map(int, input().split())
    print(d2.dTFR[t][d2.dTFR[t].index(f)+1] )

Measured memory_bytes: 7788
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] A = new int[N];

		int c = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if (A[i] < 0) {
				c++;
			}
		}

		for (int i = 0; i < N; i++) {
			A[i] = Math.abs(A[i]);
		}
		Arrays.sort(A);

		long ans;
		if (c % 2 == 0) {
			ans = 0;
			for (int i = 0; i < N; i++) {
				ans += A[i];
			}
		} else {
			ans = -A[0];
			for (int i = 1; i < N; i++) {
				ans += A[i];
			}

		}
		out.println(ans);

		sc.close();

	}

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

}


Measured memory_bytes: 52680
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int a,b,o,ab,jad2;
  char jad[2];
  a=0,b=0,o=0,ab=0;
  while(scanf("%d,%s",&jad2,jad)!=EOF){
    if(0==strcmp(jad,"A")){
      a++;
    }if(0==strcmp(jad,"B")){
      b++;
    }if(0==strcmp(jad,"O")){
      o++;
    }if(0==strcmp(jad,"AB")){
      ab++;
    }
  }
  cout<<a<<endl;
  cout<<b<<endl;
  cout<<ab<<endl;
  cout<<o<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
 
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
 
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}


void solve()

{
int n;
cin>>n;
string str;
cin>>str;
int ans = 0;
FOR(i,0,n-2)
{
    if(str.substr(i,3)=="ABC")ans++;
}
cout<<ans<<endl;
                                                                                           
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    // ll t;
    //cout<<"Y"<<endl;
    //cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256