akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

bool chkmin(int &x,int y){return x>y?x=y,1:0;}
bool chkmax(int &x,int y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n;
int a[205];

int main(){
	n=readint();
	for(int i=1;i<=n+n;i++) a[i]=readint();
	sort(a+1,a+n+n+1);
	int ans=0;
	for(int i=1;i<=n+n;i+=2) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int N, K, C, now = 0;
    string S;
    cin >> N >> K >> C >> S;
    vector<int> A(K), B(K);
    for (int i = 0; i < N; i++){
        if (S.at(i) == 'o'){
            A.at(now) = i + 1;
            now++;
            i += C;
        }
        if (now == K){
            break;
        }
    }
    now = 0;
    for (int i = 0; i < N; i++){
        if (S.at(N - i - 1) == 'o'){
            B.at(K - 1 - now) = N - i;
            now++;
            i += C;
        }
        if (now == K){
            break;
        }
    }
    for (int i = 0; i < K; i++){
        if (A.at(i) == B.at(i)){
            cout << A.at(i) << endl;
        }
    }
}

Measured memory_bytes: 3332
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

int F(int a, int b, int c){
	return (a*c+b) % 26;
}

int main(){
	int n;
	string str1;
	getline(cin,str1);

	n = atoi(str1.c_str());
	for(int i=0;i<n;i++){
		string str2;
		getline(cin,str2);

		for(int a=0;a<100;a++){
			for(int b=0;b<100;b++){
				string tmp = str2;
				for(int i=0;i<str2.size();i++){
					if(tmp[i]=='.') continue;
					if(tmp[i]==' ') continue;
					if(isdigit(tmp[i])) continue;
					tmp[i] = F(a,b,str2[i]-'a') + 'a';
				}

				if(tmp.find("that") != string::npos
					|| tmp.find("this") != string::npos){
						cout << tmp << endl;
						goto found;
				}
			}
		}
found:;
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	std::vector<int > a(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2==1)cnt++;
	}
	cout << (cnt%2==0?"YES":"NO") << endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e3;
bool ans[nsz + 5][nsz + 5];
int n, m, a, b;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> b >> a;
    cont (i, n) {
        circ (j, b + 1, m) {
            ans[i][j] ^= 1;
        }
    }
    circ (i, a + 1, n) {
        cont (j, m) {
            ans[i][j] ^= 1;
        }
    }
    cont (i, n) {
        cont (j, m) {
            cout << ans[i][j];
        }
        cout << ln;
    }
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int n;
int a[1000];
int a1[1000];
int a2[1000];
void dfs(int s,int s1, int s2){
    if(s==10){
        return ;
    }
    if(s1==0 && s2==0){
        a1[s1]=a[s];
        dfs(s+1,s1+1,s2);
    }else{
        if(s1==0){
            if(a2[s2-1]<a[s]){
                a2[s2] = a[s];
                dfs(s+1,s1,s2+1);
            }else{
                a1[s1] = a[s];
                dfs(s+1,s1+1,s2);
            }
        }else if(s2==0){
            if(a1[s1-1]<a[s]){
                a1[s1] = a[s];
                dfs(s+1,s1+1,s2);
            }else{
                a2[s2] = a[s];
                dfs(s+1,s1,s2+1);
            }
        }else{
            if(a1[s1-1]<a[s]){
                a1[s1] = a[s];
                dfs(s+1,s1+1,s2);
            }else if(a2[s2-1]<a[s]){
                a2[s2] = a[s];
                dfs(s+1,s1,s2+1);
            }else{
                return ;
            }
        }
    }
}
int main(){
    while(~scanf("%d",&n)){
        while(n--){
            for(int i=0;i<10;i++){
                scanf("%d",&a[i]);
            }
            memset(a1,-1,sizeof(a1));
            memset(a2,-1,sizeof(a2));
            dfs(0,0,0);
            int i=0,j=0;
            for(;;i++){
                if(a1[i]==-1){
                    break;
                }
            }
            for(;;j++){
                if(a2[j]==-1){
                    break;
                }
            }
            if(i+j==10){
                printf("YES\n");
            }else{
                printf("NO\n");
            }
        }
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    {
        cout<<"1"<<endl;
    }
    else if(b==0)
    {
        cout<<"2"<<endl;
    }
    else if(c==0)
    {
        cout<<"3"<<endl;
    }
    else if(d==0)

    {
        cout<<"4"<<endl;
    }
    else if(e==0)
    {
        cout<<"5"<<endl;
    }
}







Measured memory_bytes: 3556
import sys

def main(inp):
    a,b,c=map(int,next(inp).split())
    
    for i in range(min(a,b),0,-1):
        if(a%i == 0 and b%i == 0):
            c-=1
        if(c==0):
            return i
            break
  
print(main(sys.stdin))

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

LL N;
LL T[3];
LL L[10];

LL CalcMp(int i, vector<LL> stack) {
	if (i >= N) {
		LL sum[3] = {};
		LL useCount[3] = {};
		for (int s = 0; s < stack.size(); ++s) {
			if (stack[s] < 3) {
				sum[stack[s]] += L[s];
				useCount[stack[s]]++;
			}
		}

		LL mp = 0;
		REP(d, 3) {
			if (useCount[d] == 0) {
				return -1;
			}

			mp += (useCount[d] - 1) * 10;
			mp += abs(T[d] - sum[d]);
		}

		return mp;
	}
	
	LL minMp = -1;
	REP(n, 4) {
		vector<LL> next = stack;
		next.push_back(n);
		LL mp = CalcMp(i + 1, next);

		if (mp >= 0) {
			if (minMp < 0) {
				minMp = mp;
			}
			else {
				if (mp < minMp) {
					minMp = mp;
				}
			}
		}
	}

	return minMp;
}

int main()
{
	cin >> N >> T[0] >> T[1] >> T[2];
	REP(i, N) {
		cin >> L[i];
	}

	vector<LL> stack;
	LL mp = CalcMp(0, stack);

	cout << mp << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
	double a,b;
	

	double table1[] = {35.5,37.5,40.0,43.0,50.0,55.0,70.0};
	double table2[] = {71.0,77.0,83.0,89.0,105.0,116.0,148.0};
	string rank[] = {"AAA","AA","A","B","C","D","E","NA"};

	while(~scanf("%lf %lf",&a,&b)){
		int c=7,d=7;
		for(int i=0;i<sizeof(table1)/sizeof(double);i++){
			if(a < table1[i]) { c = i; break; }
		}

		for(int i=0;i<sizeof(table2)/sizeof(double);i++){
			if(b < table2[i]) { d = i; break; }
		}

		cout << rank[max(c,d)] << endl;

	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

using namespace std;

#define MOD 1000000007
#define INF 100000000000000000
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ALL(x) ((x).begin(), (x).end())
#define sync(); ios_base::sync_with_stdio(0);

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


ll ex_euclid(ll a, ll b, ll &x, ll &y){
  ll xx,yy;
  x = yy = 1;
  xx = y = 0;
  while(b){
    ll m = a / b;
    ll t = xx;
    xx = x - m * xx;
    x = t;
    t = yy;
    yy = y - m * yy;
    y = t;
    t = b;
    b = a % b;
    a = t;
  }

  return a;
}

ll inverse(ll a){
  pair<ll,ll> p {MOD,a};
  pair<pair<ll,ll>,pair<ll,ll>> k {{1,0}, {0,1}};
  while(1){
    if(p.second == 1){
      return k.second.second;
    }
    ll temp = p.second;
    pair<ll,ll> tempp = k.second;
    k.second.first = k.first.first - (p.first / p.second) * k.second.first;
    k.second.second = k.first.second - (p.first / p.second) * k.second.second;
    p.second = p.first % p.second;
    p.first = temp;
    k.first = tempp;
  }
}

ll pw(ll a, ll b){
  ll ans = 1;
  ll mul = a;
  
  while(b){
    if((b & 1ll) == 1){
      ans *= mul;
      ans %= MOD;
    }
    mul = mul * mul;
    mul %= MOD;
    b = (b >> 1);
  }
  return ans;
}



int main(){
  sync();
  ll m,n;
  cin >> m >> n;
  cout << pw(m,n) << endl;
  return 0;
}

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

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        double a = Double.parseDouble(in.readLine());
        double b = 3;
        System.out.println((int) Math.pow(a, b));
    }
}

Measured memory_bytes: 24228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll n, m, a, sum;
int main() {
	scanf("%lld%lld", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%lld", &a);
		sum += a;
	}
	printf("%lld\n", max(-1ll, n - sum));
	return 0;
}

Measured memory_bytes: 3828
# frozen_string_literal: true
n, a, b = gets.split.map(&:to_i)
sum = 0
1.upto(n) do |i|
  digitsum = i.to_s.split('').map { |e| e.to_i }.reduce(:+)
  sum += i if digitsum >= a && digitsum <= b
end
puts sum


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

int main() {
  string a;
  cin >> a;
  if(a=="a"||a=="i"||a=="u"||a=="e"||a=="o"){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> t(n), d(n);
    rep(i, n) {
        cin >> t[i] >> d[i];
        --t[i];
    }
    
    vector<int> nums(n);
    rep(i, n) nums[i] = i;
    sort(all(nums), [&](int x, int y) -> bool {return d[x] > d[y];});
    ll sum = 0;
    vector<int> cnt(n, 0);
    vector<vector<int>> vec(n);
    ll x = 0;
    rep(i, k) {
        sum += d[nums[i]];
        if (!cnt[t[nums[i]]]) ++x;
        ++cnt[t[nums[i]]];
        vec[t[nums[i]]].emplace_back(d[nums[i]]);
    }
    rep(i, n) sort(all(vec[i]));
    
    vector<int> yobun;
    rep(i, n) rep(j, (int)vec[i].size() - 1) yobun.emplace_back(vec[i][j]);
    sort(all(yobun));
    int now = 0;
    
    ll ans = sum + x * x;
    rep(i, k, n) {
        if (now == yobun.size()) break;
        if (cnt[t[nums[i]]]) continue;
        ++x;
        ++cnt[t[nums[i]]];
        sum -= yobun[now];
        sum += d[nums[i]];
        ++now;
        chmax(ans, sum + x * x);
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 9360
import sys

K = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip('\n')

# ## COMBINATION (MOD) ###
N_MAX = 10**6  # 問題サイズに合わせて変えておく
MOD = 10**9 + 7

inv = [0] * (N_MAX + 2)
inv[0] = 0  # 逆元テーブル計算用テーブル
inv[1] = 1

for i in range(2, N_MAX + 2):
    q, r = divmod(MOD, i)
    inv[i] = -inv[r] * q % MOD


# K 文字追加
ans = 0

ln = len(S)

p = pow(26, K, MOD)

for i in range(1, K + 2):

    ans += p % MOD
    ans %= MOD

    # pre
    p = p * (ln + i - 1) * inv[i] * 25 * inv[26] % MOD

    # suf
    # s2 = (s2 * inv[26]) % MOD

print(ans)


Measured memory_bytes: 49396
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s,t = input().split()
    a,b = readInts()
    u = input()
    if u == s:
        a -=1
    else:
        b -=1
    print(a,b)
if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    stick = list(map(int, input().split()))

    total = sum(stick)
    mid = total // 2

    cum = 0
    midi = 0
    for i, block in enumerate(stick):
        cum += block
        if cum >= mid:
            midi = i
            break

    l1 = sum(stick[:midi])
    r1 = sum(stick[midi:])
    diff1 = abs(l1 - r1)
    
    l2 = l1 + stick[midi]
    r2 = r1 - stick[midi]
    diff2 = abs(l2 - r2)
    
    print(min(diff1, diff2))

main()

Measured memory_bytes: 26216
// D - Coloring Dominoes

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const ll MOD = 1e9 + 7;

int N;
string S1, S2;

char dir(int i) {
	if (S1[i] == S2[i]) return 'v';
	else return 'h';
}

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

	ll ans;
	char prev_dir;
	int i;

	if (dir(0) == 'v') {
		ans = 3;
		prev_dir = 'v';
		i = 1;
	} else {
		ans = 6;
		prev_dir = 'h';
		i = 2;
	}

	while(i < S1.size()) {
		if (prev_dir == 'v' && dir(i) == 'v') {
			ans = (ans * 2) % MOD;
			prev_dir = 'v';
			i += 1;
		} else if (prev_dir == 'v' && dir(i) == 'h') {
			ans = (ans * 2) % MOD;
			prev_dir = 'h';
			i += 2;
		} else if (prev_dir == 'h' && dir(i) == 'v') {
			ans = ans;
			prev_dir = 'v';
			i += 1;
		} else {
			ans = (ans * 3) % MOD;
			prev_dir = 'h';
			i += 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout<<"Alice"<<endl;
    else if(a<b)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  int h, w, k;
  std::cin >> h >> w >> k;
  std::vector<string> s(h);
  for(int i=0;i<h;i++) std::cin >> s[i];
  std::vector<set<ll> > t(h);
  int l = -1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#') {
        if(l==-1) l = i;
        t[i].insert(j);
      }
    }
  }
  vvl ans = vv(h, w, 0, ll);
  std::vector<ll> data;
  // init
  int now = 0;
  for(int i=0;i<w;i++){
    if(t[l].find(i)!=t[l].end()) now++;
    data.push_back(max(1, now));
  }
  for(int i=0;i<=l;i++){
    for(int j=0;j<w;j++){
      ans[i][j] = data[j];
    }
  }
  for(int i=l+1;i<h;i++){
    if(t[i].size()==0){
      for(int j=0;j<w;j++){
        ans[i][j] = ans[i-1][j];
      }
    }else{
      for(int j=0;j<(*t[i].begin());j++) ans[i][j] = now+1;
      for(int j=(*t[i].begin());j<w;j++){
        if(t[i].find(j)!=t[i].end()) now++;
        ans[i][j] = max(1, now);
      }
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      std::cout <<  ans[i][j] << " ";
    }
    std::cout << '\n';
  }
  return 0;
}


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

int ketasum5(int a){
  int ret=0;
  for(int i=0; i<5; i++){
    ret += a%10;
    a /= 10;
  }
  return ret;
}

int main(){
  int n, a, b, ret=0;
  cin >> n >> a >> b;
  for(int i=1; i<=n; i++){
    int s=ketasum5(i);
    if(a<=s && s<=b)ret+=i; 
  }
  cout << ret;
  return 0;
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;
  vi A(N);
  unordered_multiset<i64> As;
  REP(0, N, i) {
    cin >> A[i];
    As.insert(A[i]);
  }

  i64 ans = 0;
  REP(0, N, i) {
    As.erase(As.find(A[i]));
    bool valid = true;
    i64 p = 1;
    while(p*p <= A[i]) {
      if(A[i] % p == 0) {
	i64 q = A[i] / p;
	if(As.find(p) != As.end() || As.find(q) != As.end()) {
	  valid = false;
	  break;
	}
      }
      ++p;
    }
    if(valid) {
      ans++;
    }
    As.insert(A[i]);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 12960
#include <bits/stdc++.h>
using namespace std;
string A, B;
int n;
const int N = 100000;
int L[N], R[N], mx[N];
int ans = N;
int main()
{
    cin >> A >> B;
    n = A.size();
    int G = 0;
    for (int i = 0; i < n; ++ i)
        if (B[i] == '1') G = 1;
    if (!G && A != B)
    {
        cout << -1 << endl;
        return 0;
    }
    A = A + A + A;
    B = B + B + B;
    for (int i = 0; i < n * 3; ++ i)
        if (B[i] == '1' || i == 0) L[i] = i;
        else L[i] = L[i - 1];
    for (int i = n * 3 - 1; ~i; -- i)
        if (B[i] == '1' || i == n * 3 - 1) R[i] = i;
        else R[i] = R[i + 1];
    for (int i = -n + 1; i <= n - 1; ++ i)
    {
        int cnt = 0;
        for (int j = 0; j <= n; ++ j) mx[j] = 0;
        for (int j = 0; j < n; ++ j)
            if (A[j] != B[n + j + i])
            {
                cnt ++;
                int ll = max(n + j - L[n + j] + min(0, i), 0);
                int rr = max(R[n + j] - n - j - max(0, i), 0);
                mx[ll] = max(mx[ll], rr);
            }
        for (int j = n; j >= 0; -- j) mx[j] = max(mx[j], mx[j + 1]);
        for (int j = 0; j <= n; ++ j)
            ans = min(ans, abs(i) + j * 2 + mx[j + 1] * 2 + cnt);
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

int main() {
	int N;
	cin >> N;
	vector<ll> A(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	map<ll, ll> ma;
	ll ans = 0;

	for (int i = 1; i <= N; i++) {
		ma[i + A[i]]++;
		ans += ma[i - A[i]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 27420
#include <bits/stdc++.h>
using namespace std;
#define my_all(v) v.begin(),v.end()
#define my_un(v) v.erase(unique(ALL(v)),v.end())
#define my_each(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,m,k,sx,sy,ans=INT_MAX;
bool vis[805][805],b[805][805];
int dist[805][805];
char t;
void swap_int(int &a,int &b)
{
	a^=b;
	b^=a;
	a^=b;
}
bool inrange(int x,int y)
{
	return x>0&&x<=n&&y>0&&y<=m;
}
queue<pii> q,ostep;
int main()
{
	memset(dist,-1,sizeof(dist));
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			t=getchar();
			while(t!='#'&&t!='S'&&t!='.')
			{
				t=getchar();
			}
			b[i][j]=(t=='#');
			if(t=='S')
			{
				sx=i,sy=j;
			}
		}
	}
	q.push(pii(sx,sy));
	while(!q.empty())
	{
		pii fr=q.front();
		q.pop();
		int x=fr.first,y=fr.second;
		if(dist[x][y]<k)
		{
			ostep.push(fr);
		}
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir],ny=y+dy[dir];
			if(inrange(nx,ny))
			{
				if(dist[nx][ny]==-1&&!b[nx][ny])
				{
					dist[nx][ny]=dist[x][y]+1;
					q.push(pii(nx,ny));
				}
			}
		}
	}
	memset(dist,-1,sizeof(dist));
	while(!ostep.empty())
	{
		pii p=ostep.front();
		ostep.pop();
		q.push(p);
		dist[p.first][p.second]=0;
	}
	while(!q.empty())
	{
		pii fr=q.front();
		q.pop();
		int x=fr.first,y=fr.second;
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir],ny=y+dy[dir];
			if(inrange(nx,ny))
			{
				if(dist[nx][ny]==-1)
				{
					dist[nx][ny]=dist[x][y]+1;
					q.push(pii(nx,ny));
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(i==n||j==m||i==1||j==1)
			{
				ans=min(ans,dist[i][j]);
			}
		}
	}
	ans=(ans+k-1)/k+1;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 8704
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int INF = 1001001001;
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, l;
    cin >> n >> m >> l;
 
    vector<vi> dist(n, vi(n, INF));
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    rep(i, n) dist[i][i] = 0;
    rep(k, n) rep(i, n) rep(j, n){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    vector<vi> dist2(n, vi(n, INF));
    rep(i, n) rep(j, n){
        if (dist[i][j] <= l){
            dist2[i][j] = 1;
        }
    }
    rep(k, n) rep(i, n) rep(j, n){
        dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
    }
 
    int q;
    cin >> q;
    vi s(q), t(q);
    rep(i, q) {
        cin >> s[i] >> t[i];
    }
    rep(i, q){
        s[i]--;t[i]--;
        if (dist2[s[i]][t[i]] != INF){
            cout << dist2[s[i]][t[i]] - 1 << endl;
        }else{
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 2048
N, L = map(int, input().split())

# 元々の味（等差数列の和の公式より）
s = N*(2*L+N-1) // 2
# 味の差の絶対値=リンゴiの味の絶対値
l = [abs(L+i) for i in range(N)]
 
# 味の絶対値が最小になるリンゴのindexを求め、sからその味を引けばよい
print(s - (L+l.index(min(l))))

Measured memory_bytes: 9064
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

int main() 
{
    vector<int> a(3);
    rep(i,3) { cin >> a[i]; }
    sort(a.begin(), a.end());

    int ans = 0;
    
    while(a[0] < a[1]) {
        a[0] += 2;
        ans++;
    }

    if(a[0] == a[1]) {
        while(a[1] < a[2]) {
            a[1]++;
            a[0]++;
            ans++;
        }
    } else {
    
        a[1]++; a[2]++;
        ans++;
        while(a[1] < a[2]) {
            a[1]++;
            a[0]++;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}
    



Measured memory_bytes: 256
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
i, = I()
if i == 0:
    print(1)
else:
    print(0)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    ll dp[2]={};
    int n,p;
    cin>>n>>p;
    dp[0]=1;
    REP(i,n){
        int a;
        cin>>a;
        if(a%2){
            dp[1]=(dp[0]+=dp[1]);
        }else{
            dp[0]<<=1;
            dp[1]<<=1;

        }
    }
    cout<<dp[p]<<endl;
    return 0;
}


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

int main() {
  int x;
  cin>>x;
  
  if(x>=400 &&x<=599){
    cout<<8<<endl;
  }
  else if(x>=600 &&x<=799){
    cout<<7<<endl;
  }
  else if(x>=800 &&x<=999){
    cout<<6<<endl;
  }
  else if(x>=1000 &&x<=1199){
    cout<<5<<endl;
  }
    else if(x>=1200 &&x<=1399){
    cout<<4<<endl;
  }
    else if(x>=1400 &&x<=1599){
    cout<<3<<endl;
  }
    else if(x>=1600 &&x<=1799){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
}



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    bool a[n+1];
    memset(a,false, sizeof a);
    int ans[n+1];
    memset(ans,0,sizeof ans);
    int sum=0,sum1=0;
    for(int i=0;i<m;i++)
    {
        int c;
        string s;
        cin>>c>>s;
        if(s[0]=='A' && !a[c])
        {
            sum++;
            a[c]=true;
        }
        if(s[0]=='W' && !a[c])
            ans[c]++;
    }
    for(int i=1;i<=n;i++)
        if(a[i])
            sum1+=ans[i];
    cout<<sum<<" "<<sum1;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k,l;
	cin>>n>>k;
	vi v(n);
	rep(i,n)
		cin>>v[i];
	int dp[n+1];
	rep(i,n){
		dp[i]=Max;
	}
	dp[0]=0;
	loop(i,1,n){
		int temp=min(i,k);
		while(temp>0){
			dp[i]=min(dp[i],dp[i-temp]+abs(v[i]-v[i-temp]));
			temp--;
		}
	}
	cout<<dp[n-1]<<endl;
}
int  main() 
{
	fast_io;
	/*#ifndef ONLINE_JUDGE
	freopen("/home/sid/Documents/output.txt","w",stdout);
    freopen("/home/sid/Documents/input.txt","r",stdin);
 	#endif*/
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
	return 0; 
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef pair<int,int>p;
#define ll long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(long long int i=a;i<=b;i++)
#define FOR(i,a,b) for(int i=a;i>b;--i)
#define FORE(i,a,b) for(int i=a;i>=b;--i)
#define f first
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
/*note
*/



int main()
{

int a,b;
cin>>a>>b;
cout<<a*b<<endl;


}








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

const int MAX = 100010;
int A[MAX][3];
int dp[MAX][3];

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

    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue; // 前日と同じ
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[i][k]);
            }
        }
    }

    int maxi = -1e9;
    for(int i = 0; i < 3; i++){
        maxi = max(maxi, dp[n][i]);
    }

    cout << maxi << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  while(1) {
    bool isok = true;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) isok = false;
    }
    if (!isok) break;
    for (int i = 0; i < N; i++) {
      A[i] /= 2;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std ;

int a[4] ;

int main ( )
{
	while ( scanf ( "%d" , &a[0] ) == 1 ) {
		for ( int i = 1 ; i < 5 ; i++ ) {
			scanf ( "%d" , &a[i] ) ;
		}
		sort ( a , a + 5 ) ;
		for ( int i = 4 ; i >= 0 ; i-- ) {
			if ( i != 4 ) putchar ( ' ' ) ;
			printf ( "%d" , a[i] ) ;
		}
		putchar ( '\n' ) ;
	}
	return 0 ;
}

Measured memory_bytes: 1048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e9 + 7ll ;
int main() {
    ll n, k;
    cin >> n >> k;
    ll h[n];
    for(ll i = 0; i < n; ++i ) cin >> h[i] ;
    ll dp[n] = {0};
    for(ll i=1; i<n; ++i ) 
        dp[i] = inf ;
    for(ll i = 1; i < n; ++i ) {
      for(ll j = max(i-k, 0ll ) ; j< i; ++j ) {
         dp[i] = min( dp[i] , dp[j] + abs(h[i]- h[j]) ) ;        
      }          
    }  cout << dp[n-1 ] ;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  ll c = k - a;
  if(c <= 0) cout << 1 << endl;
  else if(a <= b) cout << -1 << endl;
  else {
    if(c % (a - b) == 0LL) cout << c / (a - b) * 2LL + 1LL << endl;
    else cout << (c / (a - b) + 1LL) * 2LL + 1LL << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll a,b;
  	ci(a>>b);
  ll s=0;
  ll t=0;
  ll u=0;
  FOR(i,0,n){
    ll A;
    	ci(A);
    if(A<=a){
		s++;
    }
    else if(A<=b){
      	t++;
    }
    else{
      u++;
    }
  }
  co(min({s,t,u}))
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char s[100000];
    cin>>s;
    int ln,i;
    ln= strlen(s);
    for(i=0;i<ln;i+=2){
        cout<<s[i];
    }
    cout<<endl;
    return 0;

}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans  = 0;
    int N;
    cin >> N;
    int n[N];
    for(int i = 0;i < N;i++){
        cin >> n[i];
    }
    stable_sort(n,n+N,greater<int>());
    int a = 0;
    int b = 0;
    for(int i = 0;i < N;i+= 2){
        a += n[i];
    }
    for(int i = 1;i < N;i+= 2){
        b += n[i];
    }
    ans = a - b;

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  Int n;cin >> n;
  Int ans=0;
  vector<Int> a(n+1),b(n);
  for(auto &i:a) cin >> i;
  for(auto &i:b) cin >> i;
  for(Int i=0;i<n;i++){
    if(a[i]>=b[i]){ans+=b[i];a[i]-=b[i];b[i]=0;}
    else{
      ans+=a[i];
      b[i]-=a[i];
      a[i] = 0;
      if(a[i+1]>=b[i]){a[i+1]-=b[i];ans+=b[i];b[i]=0;}
      else{ans+=a[i+1];a[i+1]=0;b[i]=0;}
    }
  }
  cout << ans << endl;
  /*cout << ans << endl;
  for(auto &i:a) cout << i;
  cout << endl;
  for(auto &i:b) cout << i;
  cout << endl;*/
}


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



int main() {
	ll N;
	cin >> N;
	char tmp;
	vector<char> S;
	int j = 0;
	for (int i = 0; i < N;i++) {
		cin >> tmp;
		
		if (j != 0) {
			if (S[j - 1] != tmp) {
				S.push_back(tmp);
				j++;
			}
			else { continue; }
		}
		else {
			S.push_back(tmp);
			j++;
		}
	}
	
	
		cout <<endl<< S.size()<< endl;
	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

int32_t main(){ fast;
	ll n, answer = 0, d; cin>>n>>d;
	while(n--){
		ll x, y; cin>>x>>y;
		if( x * x + y * y - d * d <= 0){
			answer++;
		}
	}
	cout<<answer<<endl;
	
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin >> N >> S >> K;
  char s = S[K-1];
  for (int i = 0; i < N ; i++){
    if (S[i] != s){
      S[i] = '*';
    }
  }
cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,i,res;
   cin>>n;
   int a[n];
   for(i=0;i<n;i++) cin>>a[i];
   sort(a,a+n);
   res=(a[n/2]-a[(n/2)-1]);
   cout<<res;
   return 0;
}

Measured memory_bytes: 640
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
X = ri()
ans = 0
for b in range(1, 1001):
    for p in range(2, 11):
        tmp = b ** p
        if tmp <= X:
            ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 64748
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back
typedef pair<LL, double> P;
typedef pair<P, P> PP;

LL a[2020];

int main() {
	LL n, z, w;
	cin >> n >> z >> w;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	cout << max(abs(a[n - 1] - w), (n == 1 ? 0 : abs(a[n - 1] - a[n - 2]))) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return -par[root(x)]; }
};

struct WeightedEdge {
  const int a;
  const int b;
  const ll c;
  WeightedEdge(int a, int b, ll c) : a(a), b(b), c(c) {};
  WeightedEdge(WeightedEdge&& a) = default;
};

bool comp(const WeightedEdge& a, const WeightedEdge& b) {return a.c<b.c;}



signed main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  using Node = pair<ll, ll>;
  vector<Node> v;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v.emplace_back(b, a);
  }
  sort(all(v), [](auto &a, auto& b) {return a.second < b.second;});
  priority_queue<Node> q;
  ll ans = 0;
  int index = 0;
  REP(day, m+1) {
    while(index < n && v[index].second <= day) {
      q.push(v[index]);
      index++;
    }
    if(q.size()) {
      auto c = q.top();q.pop();
      ans += c.first;
    }
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vll a(n); for(auto& e : a) cin >> e;
    sort(_all(a));
    a.emplace_back(INF);

    using CB = tuple<ll, int>;
    vector<CB> cb(m);
    for(auto& e : cb){
        int b; ll c; cin >> b >> c;
        e = CB(c, b);
    }
    sort(_all(cb), greater<CB>());

    int l = 0;
    for(auto& e : cb){
        int b; ll c; tie(c, b) = e;
        while(b > 0 and a[l] < c){
            a[l] = c;
            b--;
            l++;
        }
    }

    ll res = 0LL;
    rep(i, n) res += a[i];

    cout << res << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

const string YES = "Yes";
const string NO = "No";

void func(std::string S){
    string ret = YES;
    if (S=="AAA" || S=="BBB") {
        ret = NO;
    }
    cout << ret << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    func(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }   
}

int main(){
    int x;
    cin >> x;
    print_ans(x < 1200);
    return 0;
}


Measured memory_bytes: 256