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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int ui32;
const long long INFLL = 1e18;

using namespace std;

int get(int x) {
    int res = 0;
    while (x > 0) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("input.txt", "w", stdout);

    int n;
    cin >> n;
    int res = 1e9;
    for (int a = 1; a <= n - 1; a++) {
        int b = n - a;
        res = min(res, get(a) + get(b));
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 892
N,M = map(int,input().split())

lis = [False] * N
end = [False] * N
aft = []
for i in range(M):

    e = int(input())

    aft.append(e)
    lis[e-1] = True

aft.reverse()

for i in aft:

    if not end[i-1]:
        print (i)
        end[i-1] = True

for i in range(N):

    if not lis[i]:
        print (i+1)


Measured memory_bytes: 12936
program ABC168_A
  read(*,*)N
  M=mod(N,10)
  if(M==3)  write(*,*)'bon'
  if(M==0 .or. M==1 .or. M==6 .or. M==8) write(*,*)'pon'
  if(M==2 .or. M==4 .or. M==5 .or. M==7 .or. M==9) write(*,*)'hon'
end program ABC168_A

Measured memory_bytes: 2788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a[3];
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  int k;
  cin >> k;
  vector<long long> in[3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < a[i]; j++) {
      long long x;
      cin >> x;
      in[i].push_back(x);
    }
    sort(in[i].rbegin(), in[i].rend());
  }
  vector<long long> res1;
  for (int i = 0; i < (int) in[0].size(); i++) {
    for (int j = 0; j < (int) in[1].size(); j++) {
      res1.push_back(in[0][i] + in[1][j]);
    }
  }
  sort(res1.rbegin(), res1.rend());
  vector<long long> ans;
  for (int i = 0; i < min(k, (int) res1.size()); i++) {
    for (int j = 0; j < (int) in[2].size(); j++) {
      ans.push_back(res1[i] + in[2][j]);
    }
  }
  sort(ans.rbegin(), ans.rend());
  for (int i = 0; i < k; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin>>s;
	pair<char, int> a;
	pair<char, int> b;
	a.second=1;
	b.second=0;
	a.first=s[0];
	bool primer_diferente=false;
	for (int i=1; i<s.size(); i++)
	{
		if (s[i]==a.first)
			a.second++;
		else
		{
			if (!primer_diferente)
			{
				b.first=s[i];
				b.second++;
				primer_diferente=true;
			}
			else
			{
				if (s[i]==b.first)
				{
					b.second++;
				}
				else
				{
					cout<<"No\n";
					return 0;
				}
			}
		}
	}
	if (a.second==2&&b.second==2) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    int ARCmin = d.at(N/2);
    int ABCmax = d.at(N/2-1);
    if(ARCmin - ABCmax < 0){
        cout << 0;
    }else{
        cout << ARCmin - ABCmax;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num=0;
  string s;
  cin >>s;
  for(int i=0; i<3; i++){
    if(s[i]=='o') num +=100;
    if(s[i]=='x') num +=0;
  }
  cout << 700+num << endl;
}
  

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

using namespace std;

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

    vector<int> a(n), a_sort(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a_sort[i] = a[i];
    }

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

    for (int i = 0; i < n; i++) {
        if (a[i] == a_sort[n - 1]) {
            cout << a_sort[n - 2] << endl;
        } else {
            cout << a_sort[n - 1] << endl;
        }
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)

int main() {
    int n; cin >> n;
    vector<int> s(n);
    int sum = 0;
    rep(i, n) {
        cin >> s[i];
        sum += s[i];
    }
    if (sum%10) {
        cout << sum << endl;
        return 0;
    }
    sort(s.begin(), s.end());
    rep(i, n) {
        if (s[i]%10) {
            sum -= s[i];
            break;
        }
    }
    if (sum%10) {
        cout << sum << endl;
    } else {
        cout << 0 << endl;
    }
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
	int h, w;
	cin >> h >> w;
	vector< vector<char> > hyo(h, vector<char>(w));
	vector< vector<int> > hh(h, vector<int>(w, 1));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> hyo[i][j];
		}
	}
	queue<P> q;
	q.push(P(0, 0));
	hyo[0][0] = '.';

	while(!q.empty()) {
		P p = q.front();
		q.pop();
		if (p.first+1 < h) {
			if (p.second+1 < w) {
				if (hyo[p.first+1][p.second] == '#') {
					q.push(P(p.first+1, p.second));
					hyo[p.first+1][p.second] = '.';
				} else if (hyo[p.first][p.second+1] == '#') {
					q.push(P(p.first, p.second+1));
					hyo[p.first][p.second+1] = '.';
				}
			} else {
				if (hyo[p.first+1][p.second] == '#') {
					q.push(P(p.first+1, p.second));
					hyo[p.first+1][p.second] = '.';
				}
			}
		} else {
			if (p.second+1 < w) {
				if (hyo[p.first][p.second+1] == '#') {
					q.push(P(p.first, p.second+1));
					hyo[p.first][p.second+1] = '.';
				}
			} else {
			}
		}
	}
	bool hhh = true;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (hyo[i][j] == '#') {
				hhh = false;
				break;
			}
		}
	}
	if (hhh) {
		cout << "Possible" << endl;
	} else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;

using System.Linq;

using System.Collections.Generic;

using System.Numerics;



namespace hello_cs

{

    class Program

    {

        static void Main(string[] args)

        {

            var blank = " ";

            var ipt = System.Console.ReadLine().Split(blank.ToCharArray()).Select(a => int.Parse(a)).ToArray();



            var n = ipt[0];

            var x = ipt[1];

            var y = ipt[2];

            //   var com = new List<int>();

            var com = new int[n - 1];



            for (var i = 1; i < n; i++)

            {

                for (var j = i + 1; j <= n; j++)

                {

                    var dis = 0;



                    // 前同士 or 後ろ同士

                    if (i >= y || j <= x)

                    {

                        dis = j - i;

                    }

                    // 前後の組み合わせ

                    else if (i <= x && j >= y)

                    {

                        dis = x - i + j - y + 1;

                    }

                    // 中同士

                    else if (i >= x && j <= y)

                    {

                        var rdis = j - i;

                        var ldis = i + (y - x + 1) - j;

                        dis = rdis <= ldis ? rdis : ldis;

                    }

                    // 前中の組み合わせ

                    else if (j <= y)

                    {

                        var rdis = j - x;

                        var ldis = x + (y - x + 1) - j;

                        dis = rdis <= ldis ? rdis : ldis;

                        dis += i < x ? x - i : 0;

                    }

                    // 中後の組み合わせ

                    else

                    {

                        var rdis = y - i;

                        var ldis = i + (y - x + 1) - y;

                        dis = rdis <= ldis ? rdis : ldis;

                        dis += j > y ? j - y : 0;

                    }

                    //com.Add(dis);

                    com[dis - 1] += 1;

                }

            }





            for (var i = 1; i < n; i++)

            {

                System.Console.WriteLine(com[i - 1]);

            }



        }

    }

}



Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string s;

int main(void){
	cin >> s;
	lli r = 0;
	for(int i = 0; i < s.size(); i++){
		r += s[i]-'0';
		r%=9;
	}
	if(r == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e5 + 9;
int par[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  for(int i = 1; i <= n; i ++ )
    cin >> par[i];
  int ans = 0;
  for(int i = 1; i <= n; i ++ )
    ans += (par[par[i]] == i);
  cout << ans/2 << "\n";
  return 0;
}


Measured memory_bytes: 640
MOVE_LIST = [
    [1, 4],
    [0, 2, 5],
    [1, 3, 6],
    [2, 7],
    [0, 5],
    [1, 4, 6],
    [2, 5, 7],
    [3, 6]
]

def swap(str, a, b)
  tmp = str.dup
  tmp[a], tmp[b] = tmp[b], tmp[a]
  tmp
end

def haba_search(answer, queue)
  loop do
    move_num, search = queue.shift
    break unless search

    a = search.index('0')
    MOVE_LIST[a].each do |b|
      next_str = swap(search, a, b)
      next if answer[next_str]
      answer[next_str] = move_num + 1
      queue.push([move_num + 1, next_str])
    end
  end
  answer
end

goal = '01234567'
answers = { goal => 0 }
queue = [[0, goal]]
answers = haba_search(answers, queue)

while str = gets
  str = str.chomp.gsub(' ', '')
  break if str.length <= 7
  puts answers[str]
end

Measured memory_bytes: 11992
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Integer> plusSet = new TreeSet<>();
        TreeSet<Integer> minusOneSet = new TreeSet<>();
        TreeMap<Integer, Integer> minusMap = new TreeMap<>();
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            if (x > 1) {
                plusSet.add(i);
            } else if (x == -1) {
                minusOneSet.add(i);
            } else if (x < -1) {
                minusMap.put(i, x);
            }
        }
        if (minusMap.size() % 2 == 1) {
            if (minusOneSet.size() > 0) {
                plusSet.addAll(minusMap.keySet());
                plusSet.add(minusOneSet.first());
            } else {
                int min = Integer.MAX_VALUE;
                int minIdx = 0;
                for (Map.Entry<Integer, Integer> entry : minusMap.entrySet()) {
                    if (min >= entry.getValue()) {
                        min = entry.getValue();
                        minIdx = entry.getKey();
                    }
               }
                minusMap.remove(minIdx);
                plusSet.addAll(minusMap.keySet());
            }
        } else {
            plusSet.addAll(minusMap.keySet());
        }
        StringBuilder sb = new StringBuilder();
        sb.append(plusSet.size()).append("\n");
        for (int x : plusSet) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
}



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

using namespace std;

void solve()
{
	string str;
	while(cin >> str, str != "0")
	{
		int pointA = 0;
		int pointB = 0;
		for(int i = 1; i < str.size(); ++i)
		{
			if(str[i] == 'A')
			{
				++pointA;
			}
			else
			{
				++pointB;
			}
		}
		if(pointA > pointB)
		{
			++pointA;
		}
		else
		{
			++pointB;
		}
		cout << pointA << " " << pointB << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int M;
    while(cin >> M, M){
        int n;
        cin >> n;
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        vector<int> to(n+2);
        to.back() = n+1;
        for (int i = 0; i < n; ++i) {
            if(v[i] < 0) to[i+1] = max(0, i+1+v[i]);
            else to[i+1] = min(n+1, i+1+v[i]);
        }
        vector<vector<int>> dp(n+2, vector<int>(n+2, INF<int>));
        for (int i = 0; i <= n; ++i) {
            for (int j = 1; j <= M; ++j) {
                int t = to[min(n+1, i+j)];
                dp[i][t] = 1;
            }
        }
        for (int k = 0; k <= n+1; ++k) {
            for (int i = 0; i <= n+1; ++i) {
                for (int j = 0; j <= n+1; ++j) {
                    dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
                }
            }
        }
        int ok = 1;
        for (int i = 0; i <= n; ++i) {
            if(dp[0][i] != INF<int> && dp[i][n+1] == INF<int>){
                ok = 0;
            }
        }
        puts(ok ? "OK" : "NG");
    }
    return 0;
}


Measured memory_bytes: 3248
INF = 10 ** 10
def min(a, b)
  a < b ? a : b
end
n, m = gets.split.map(&:to_i)
bin_memo = [1]
1.upto(n - 1) do |i|
  bin_memo[i] = bin_memo[i - 1] * 2
end
costs = []
keys = []
m.times do
  costs << gets.to_i
  keys << gets.split.map(&:to_i).inject(0) { |res, num| res | bin_memo[num - 1] }
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each_with_index do |key, i|
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | key)
    dp[next_opened] = min(dp[next_opened], cost + costs[i])
  end
end
puts dp.last == INF ? - 1 : dp.last


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair


void disp(vi const& v){
    rep(i,v.size()){
        cout << v[i] << " ";
    }
    cout << endl;
}

int main(){
    vvi G;
    string s;
    while(cin>>s){
        replace(all(s), ',', ' ');
        vi v;
        stringstream ss(s);
        int i=0;
        while(ss>>i) v.push_back(i);

        G.push_back(v);
        // disp(v);
    }

    rep(i,G.size()-1){
        vi & next=G[i+1];
        vi & cur=G[i];

        if(next.size() > cur.size()){
            rep(j,next.size()){
                if(j==0) next[j] += cur[j];
                else if(j==next.size()-1) next[j] += cur[j-1];
                else next[j] += max(cur[j], cur[j-1]);
            }
        } else {
            rep(j,next.size()){
                next[j] += max(cur[j], cur[j+1]);
            }
        }
        // <disp(next);
    }

    cout << G.back().back() << endl;
}

Measured memory_bytes: 1256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;
// #define int long long
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)


int main(int argc, const char * argv[]) {

    int N;
    cin >> N;
    cout << (N-2)*180 << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdlib>
#include<complex>
#define EPS 1e-10
using namespace std;

typedef complex<double> Po;
Po p[3],o;

double dot(Po x, Po y){return x.real()*y.real()+x.imag()*y.imag();}

double cross(Po x, Po y){return x.real()*y.imag() - x.imag()*y.real();}

double area(Po a, Po b, Po c){return abs(cross(b-a,c-a))/2;}

bool inter(Po a, Po b, Po c, Po x){
  return (fabs(area(a,b,x)+area(b,c,x)+area(c,a,x)-area(a,b,c)) < EPS);
}

double seg_dis(Po a, Po b, Po c){
  if(dot(b-a,c-a)<EPS)return abs(c-a);
  if(dot(a-b,c-b)<EPS)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

int main(){
  double x[4],y[4],r;

  for(;;){
    cin >> x[0] >> y[0];
    if(!x[0] && !y[0])break;

    for(int i=1;i<4;i++)cin >> x[i] >> y[i];
    cin >> r;

    for(int i=0;i<3;i++)p[i] = Po(x[i],y[i]);
    o = Po(x[3],y[3]);


    bool f = true;;
    for(int i=0;i<3;i++)f &= !(abs(o-p[i])>r);
    if(f)cout << "b\n";
    else if(inter(p[0],p[1],p[2],o)){
      f = true;
      for(int i=0;i<3;i++)f &= !(seg_dis(p[i],p[(i+1)%3],o)<r);
      if(f)cout << "a\n";
      else cout << "c\n";
    }else{
      for(int i=0;i<3;i++)f |= !(seg_dis(p[i],p[(i+1)%3],o)>r);
      if(f)cout << "c\n";
      else cout << "d\n";
    }
  }
}

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

int main(void){
    int N,M;
  	scanf("%d %d", &N,&M);
    int l, i=0, a[M];
    while(cin>>l){
        a[i] = l;
        i++;
    }
  	int sum = 0;
  	for(i=0;i<M;i++){
      sum = sum+a[i];
    }
  	int ans = N-sum;
 	 if(ans<0){
		ans =-1;
     }
  	printf("%d",ans);
	}
 

Measured memory_bytes: 3284
w, h, n = map(int, raw_input().split())
a, b = map(int, raw_input().split())
ans = 0
for i in xrange(n-1):
    x, y = map(int, raw_input().split())
    ans += min(abs(y-x + a-b) + min(abs(y-b),abs(x-a)), abs(x-a) + abs(y-b))
    a, b = x, y
print ans

Measured memory_bytes: 4224
e=enumerate
n,a=open(0)
n=int(n)
d=[0]+[-2**64]*n
for j,(a,i)in e(sorted((-int(a),i)for i,a in e(a.split()))):d=[max(t-a*(~i-j+k+n),d[k-1]-a*abs(~i+k))for k,t in e(d)]
print(max(d))

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//---------------------------------------------------------------
//---------------------------------------------------------------

string S;
int64 K;
//int64 X[10] = { 1,	100000000000000000, 150000000000000000, 
//					200000000000000000, 250000000000000000, 
//					300000000000000000, 350000000000000000, 
//					400000000000000000, 450000000000000000 };

signed main(){
	cin >> S;
	cin >> K;
	
	int64 wk = 0;
	int ans;
	REP(i, 0, S.size()) {
		ans = S[i] - '0';
		if(ans == 1) {
			wk += 1;
		} else {
			wk = K + 1;
		}
//		wk += X[ans - 1];
//		cout << ans << " [" << X[ans - 1] << "] --> [" << wk << "]" << endl;
		if(wk >= K) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << wk << " < " << K << endl;
	return 0;
}


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

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

    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    for (int i = 0; i < s.size() - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n,k;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  multiset<int> s;
  multiset<int,greater<int>> s1;
  rep(i,0,k) {s.insert(a[i]); s1.insert(a[i]);}
  int ans= *s1.begin()-*s.begin();
  rep(i,k,n){
    s.erase(a[i-k]);
    s1.erase(a[i-k]);
    s.insert(a[i]);
    s1.insert(a[i]);
    ans=min(ans,*s1.begin()- *s.begin());
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod int(1e9+7)
#define hmod 1223334444555553LL
using namespace std;

ll n,fv,tw,ct;
int main(){
	scanf("%lld",&n);
	if (n%2 == 1)
	printf("0\n");
	else
	{
		for (ll i=10;i<=n;i*=5){
			fv+=(n/i);
		}	
		for (ll i=2;i<=n;i*=2){
			tw+=(n/i);
		}
		printf("%lld\n",min(fv,tw));
	}
	return 0;
} 

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

int main(){
  long long A, B, C;
  cin >> A >> B >>C;
  int ans=0;
  long long ab=abs(A-B);
  long long ac=abs(A-C);
  if(A*B*C%2!=0) ans=0;
  else if(A==B && B==C) ans=-1;
  else{
    int j=0; int k=0;
    while(ab%2==0){
      ab=ab/2;
      j++;
    }
    while(ac%2==0){
      ac=ac/2;
      k++;
    }
    ans=min(j, k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
  int n,i,j,c=0,a,k;

  scanf("%d",&n);

  if(n < 1 || n > 10000) return 0;

  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d",&a);
      
      if(a < 2 || a > 100000000) return 0;

      if( a == 2 ) c++; /* aが2だったら素数 */
      if( a%2 == 0 ) continue; /* 偶数だったらスキップ */

      k = 0;
      
      for(j = 3 ; j <= sqrt(a) ; j += 2)
	{
	  if(a%j == 0)
	    {
	      k++;
	      break;
	    }
	}
      
      if(k == 0) c++;
        
    }

  printf("%d\n",c);
  
  return 0;
}



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

int n;
deque<int> b;
vector<int> ans;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        int a; cin >> a;
        if (i%2==0) b.pb(a);
        else b.push_front(a);
    }
    if (n%2==0) {
        while (b.size()) {
            int v = b.front(); b.pop_front();
            ans.pb(v);
        }
    }
    else {
        while (b.size()) {
            int v = b.back(); b.pop_back();
            ans.pb(v);
        }
    }
    rep(i, n) {
        if (i<n-1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
}

Measured memory_bytes: 6004
loop do
  n, l, r = gets.split.map(&:to_i)
  break if n == 0
  a = (1..n).map { gets.to_i }
  leap = 0
  (l..r).each do |x|
    i = a.index {|y| x % y == 0}
    if i
      leap += 1 if i.even?
    else
      leap += 1 if n.even?
    end
  end
  p leap
end


Measured memory_bytes: 6876
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
  /* your code */
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev =x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32972
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;
int MOD = 1e9 + 7;

int N;
vector<long long> A;

vector<vector<long long>> DP;
vector<long long> AA;

int main() {
	cin >> N;
	A.resize(N);
	for (int n = 0; n < N; n++) {
		cin >> A[n];
	}
	AA.resize(N+1);
	DP.resize(N, vector<long long>(N, LLONG_MAX));
	for (int n = 1; n <= N; n++) {
		AA[n] = AA[n - 1] + A[n - 1];
		DP[n - 1][n - 1] = 0;
	}
	for (int n = 0; n < N - 1; n++) {
		DP[n][n + 1] = A[n] + A[n + 1];
	}
	for (int k = 2; k < N; k++) {
		for (int left = 0; left < N; left++) {
			int right = left + k;
			if (right >= N)continue;
			for (int mid = left; mid < right; mid++) {
				DP[left][right] = min(DP[left][right] ,DP[left][mid]+DP[mid+1][right]+ AA[right + 1] - AA[left]);
			}
		}
	}
	cout << DP[0][N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
ll fun(ll n)
{
    if(n<2)
        return 1;
    return n*fun(n-2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    ll n;
    while(cin>>n)
    {
        if(n%2==1)
            cout<<0<<endl;
        else
        {
            ll five=0;
            ll cnt=1LL;
            ll ans=0;
            while(n>0)
            {
                ans += (n/5LL)/2LL;
                n=n/5LL;
            }
            cout<<ans<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 150

int stringJudge(char s[],char t[])
{
  int i,flag=1;
  for(i=0;;i++)
  {
    if(s[i]!=t[i])
    {
      flag=0;
    }
    if(s[i]==0 || t[i]==0)
    {
      break;
    }
  }
  return flag;
}

int main(void)
{
  int n,i,j,flag=1,flag2=0;
  char s[N][N]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%s",s[i]);
  }
  for(i=1;i<n;i++)
  {
    for(j=0;;j++)
    {
      if(s[i-1][j]==0)
      {
        if(s[i-1][j-1]!=s[i][0])
        {
          flag=0;
        }
        break;
      }
    }
    if(flag==0){
      break;
    }

    for(j=0;j<i;j++)
    {
      flag2=stringJudge(s[i],s[j]);
      if(flag2==1)
      {
        break;
      }
    }
    if(flag2==1)
    {
      break;
    }
  }

  if(flag==1 && flag2==0)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  //printf("f1:%d f2:%d\n",flag,flag2);
  return 0;
}


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

using namespace std;

typedef long long int ll;

const ll MAXN = 2e5 + 5;

vector < ll > a;

ll n, k;

void pwr(ll k){
  vector < ll > res(n + 1);
  for(int i = 1; i <= n; i++) res[i] = i;
  while(k > 0){
    if(k & 1){
      vector < ll > tmp = res;
      for(int i = 1; i <= n; i++) tmp[i] = res[a[i]];
      res = tmp;
    }
    vector < ll > tmp = a;
    for(int i = 1; i <= n; i++) tmp[i] = a[a[i]];
    a = tmp;
    k >>= 1;
  }

  cout << res[1] << '\n';
  exit(0);
}

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

  cin >> n >> k;
  a.resize(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  pwr(k);
}


Measured memory_bytes: 7956
#include<iostream>
using namespace std;
int main()
{
 string S;
  cin >> S;
  if(S=="Sunny"){
    cout << "Cloudy";
  } else if(S=="Cloudy"){
    cout << "Rainy";
  }  if(S=="Rainy"){
    cout << "Sunny";
  }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, count=0;
    
    cin >> a >> b >> c;
    
    for(int i=a; i <= b; i++){
        if(c%i == 0)
            count++;
        else;
    }
    cout << count << endl;
    
    return 0;
}



Measured memory_bytes: 3092
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = list(input())

    i = 0
    j = n
    ans = 0

    while i < n:
        if s[i] == "W":
            while j > i:
                j -= 1
                if s[j] == "R":
                    s[i], s[j] = s[j], s[i]
                    ans += 1
                    break
        i += 1


    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77284
#include<bits/stdc++.h>
#include<chrono>
 
using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
//ll mod=1000000007;
const int MX=0x3f3f3f;

const int Maxn = 1e5+1, Mod = 1e9 + 7;
    ll fact[Maxn];

    template<typename T, typename T1>
    T mod(T x, T1 p) {
        x %= p;
        if (x < 0)
            x += p;
        return x;
    }
    // x must be relatively prime to p
    ll inv[Maxn], ifact[Maxn];
     
    // x must be relatively prime to p
    template<typename T>
    T inverse(T x, T p) {
        x = mod(x, p);
        if (x == 1)
            return x;
        return mod((1LL * (-p / x) * (inv[p % x] % p)) , p); 
        // Since inverse of p % x is already calculated.
    }
    ll NcR(int n, int r) {
        int ret = (1LL * ifact[n - r] * ifact[r]) % Mod ;
    	ret = (1LL * ret * fact[n]) % Mod;
        return ret;
    }

int main(){
	IOS;
    fact[0] = 1;
    for(int i = 1; i < Maxn; i++) {
    	fact[i] = 1LL * fact[i - 1] * i % Mod;
    }
    ifact[0] = 1;
    for(int i = 1; i < Maxn; i++) {
    	inv[i] = inverse(i, Mod);
    	ifact[i] = (1LL * ifact[i - 1] * inv[i]) % Mod;
    }
	int n,k,i,j;
    cin>>n>>k;
    int a[n];
    REP(i,0,n-1) cin>>a[i];
    ll maxS=0,minS=0;
    sort(a,a+n);
    REP(i,k-1,n-1) maxS+=a[i]*NcR(i,k-1),maxS%=Mod;
    REP(i,0,n-k) minS+=a[i]*NcR(n-i-1,k-1),minS%=Mod;
    cout<<(maxS-minS+Mod)%Mod;
	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>

#include <string>
#include <cmath>

using namespace std;


int main() {
  int n, k;

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

  if(n % k == 0){
    printf("0");
  }else{
    printf("1");
  }

  return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int hash[10001]={};
	int sum = 0;
	for(int i = 1; i< 100 ; i++){
		for(int j = 1; j < 100 ; j++){
			for(int k = 1 ; k < 100 ; k++){
				sum = i*i+j*j+k*k + i*j + j*k + i*k;
				if(sum >10000){
					break;
				}
				hash[sum]++;
			}
		}
	}
	for(int i = 1; i<=n;i++) cout << hash[i] << endl;
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
struct edge
{
	int v, nxt;
}e[N * 2];
int p[N], eid;
int ans[N], d[N];

void bfs(int s)
{
	memset(d, 0x3f, sizeof(d));
	queue<int> q;
	q.push(s);
	d[s] = 0;
	while (q.size())
	{
		int u = q.front(); q.pop();
		for (int i = p[u]; ~i; i = e[i].nxt)
		{
			int v = e[i].v;
			if(d[u] + 1 < d[v])
			{
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
}

int main()
{
	int n, x, y; cin >> n >> x >> y;
	memset(p, -1, sizeof(p));
	for (int i = 2; i <= n; ++ i)
	{
		e[eid] = edge{i - 1, p[i]}; p[i] = eid ++;
		e[eid] = edge{i, p[i - 1]}; p[i - 1] = eid ++;
	}
	e[eid] = edge{y, p[x]}; p[x] = eid ++;
	e[eid] = edge{x, p[y]}; p[y] = eid ++;
	for (int i = 1; i <= n; ++ i)
	{
		bfs(i);
		for (int i = 1; i <= n; ++ i) ans[d[i]] ++;
	}
	for (int i = 1; i < n; ++ i) cout << ans[i] / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>

int main(){
  int n,t,Ci,Ti;
  cin >> n >> t;
  
  int min_cost = 10000;
  for(int i = 0; i < n; i++){
    cin >> Ci >> Ti;
    if(min_cost > Ci && Ti <= t)
      min_cost = Ci;
  }
  
  if(min_cost == 10000)
    cout << "TLE" << endl;
  else
    cout << min_cost << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c,d;
   ll mod =1e9+7;
   string s1,s2;
   stack<ll>stck1;
   stack<ll>stck2;

   set<ll>st;
   map<string,ll>mp;
   cin>>n;
   cin>>s1;
   ll cnt=0;
   for(ll i=0;i<s1.length()-2;i++){
    if(s1[i]=='A' && s1[i+1]=='B' && s1[i+2]=='C'){
        cnt++;
    }
   }
   cout<<cnt<<endl;
}


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

int n;
long a[100010], x;

int main(){
	cin >> n;
	x = 0;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		x += (2*(1-i%2)-1)*a[i];
	}
	printf("%d ", x);
	for (int i = 0; i < n-1; ++i){
		x = 2*a[i] - x;
		printf("%d ", x);
	}
}

Measured memory_bytes: 2048
#0:上面　1:S 2:E 3:W 4:N 5:下
class Dice:
    def __init__(self):#クラス内で用いる変数の定義（クラス作成時に代入しなくてよい）
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    #サイコロの目の数を設定
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
        
    #サイコロを転がせ，それぞれのいちを追跡
    def roll(self, loc):#loc:
    #初期位置
        for i in range(6):
            self.work[i] = self.number[i]
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        else:
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
            
    def get_Top(self):
        return self.number[0]

dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])#init
loc_array=str(input())

for tmp_loc in loc_array:
    dice.roll(tmp_loc)
print(dice.get_Top())
        
        
        


Measured memory_bytes: 5616
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
var n=Arr.shift()-0;
var ans=[];
for(var i=0;i<n;i++)ans[i]=0;
var m=Arr.shift()-0;
var t=Arr.shift().split(" ").map(function(v){return ~~v-1;});
for(var I=0;I<m;I++){
   var arr=Arr[I].split(" ").map(function(v){return ~~v-1;});
   var target=t[I];
   var bad=0;
   arr.forEach(function(v,i){
      (v==target)?ans[i]++:bad++;
   });
   ans[target]+=bad;
}
console.log(ans.join("\n"));

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[55] = {}, z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    while (1) {
        for (int i = 0; i < n; i++) if (a[i] >= n) {
            for (int j = 0; j < n; j++) if (j != i) a[j] += a[i] / n;
            z += a[i] / n;
            a[i] %= n;
        }
        bool y = 0;
        for (int i = 0; i < n; i++) if (a[i] >= n) y = 1;
        if (!y) break;
    }
    cout << z;
}


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

using namespace std;

const int MAX_N = 1e5 + 5, MOD = 1e9 + 7;

int n, k;
int dp[MAX_N];

int add(int x, int y) {
	return x + y >= MOD ? x + y - MOD : x + y;
}

int sub(int x, int y) {
	return x - y < 0 ? x - y + MOD : x - y;
}

int mul(int x, int y) {
	return 1ll * x * y % MOD;
}

int deg(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		y >>= 1, x = mul(x, x);
	}
	return res;
}

int main() {
	cin >> n >> k;
	int ans = 0;
	for (int i = k; i >= 1; --i) {
		int cnt = 0;
		for (int j = i; j <= k; j += i) {
			dp[i] = sub(dp[i], dp[j]);
			++cnt;
		}
		dp[i] = add(dp[i], deg(cnt, n));
		ans = add(ans, mul(dp[i], i));
	}
	cout << ans << "\n";
	// for (int i = 1; i <= k; ++i) {
	// 	cerr << dp[i] << " ";
	// }
	// cerr << "\n";
	return 0;
}

Measured memory_bytes: 4020
import numpy as np
N, M, Q = map(int, input().split())
table = [[0] * N for _ in range(N)]
for _ in range(M):
    L, R = map(lambda n: int(n) - 1, input().split())
    table[L][R] += 1
table = np.rot90(np.rot90(table, k=-1).cumsum(axis=0).cumsum(axis=1), k=1).tolist()
for _ in range(Q):
    p, q = map(lambda n: int(n) - 1, input().split())
    print(table[p][q])

Measured memory_bytes: 22312
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


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

    vl a(n);
    rep (i, n) cin >> a[i];

    map<int, int> mp;
    rep (i, n) {
        mp[i - a[i]]++;
    }

    ll ans = 0;
    rep (i, n) {
        int x = a[i] + i;
        ans += mp[x];
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> a(n);

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

    vector <vector <long long int> > dp(n, vector <long long int> (n, 0));
    dp[n - 1][n - 1] = a[n - 1];

    for (int l = n - 2; l >= 0; l--) {
        for (int r = l; r < n; r++) {
            dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
        }
    }
    
    cout << dp[0][n - 1] << '\n';

    return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>

int main(){
    int n;
    int d[200];

    scanf("%d", &n);
    int cnt = 0;
    int flag = 1;
    for(int i = 0; i < n; ++i){
        scanf("%d", &d[i]);
        for(int j = 0; j < i; ++j){
            if(d[i] == d[j]) flag = 0;
        }
        if(flag == 1) cnt++;
        flag = 1;
    }

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

    return 0;
}

Measured memory_bytes: 1704
#include <stdio.h>
void main(void)
{      
     int K,N,max,i;
 scanf("%d %d",&K,&N);
  
  int A[N+1];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  A[N]=A[0]+K;



     max=A[1]-A[0];
  for(i=0;i<N-1;i++){
   if(max<(A[i+2]-A[i+1]))
     max=A[i+2]-A[i+1];
  }


  
  printf("%d",K-max);
}

Measured memory_bytes: 896
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	for (int n; (n = in());) {
		vector<vector<int>> s(30);
		vector<long> v(n);
		for (int i: range(n)) {
			for (int j {in()}; j; j--)
				s[in() - 1].push_back(i);
			v[i] = 1L << i;
		}
		outl([&] {
			 long e = {(1L << n) - 1};
			 for (int i: range(30)) {
				long r {};
				for (int j: s[i])
					r |= v[j];
				if (r == e)
					return i + 1;
				for (int j: s[i])
					v[j] = r;
			}
			return -1;}());
	}
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;
string s;

int main() {
  cin >> n >> s;
  vector<vector<int>> g(n);
  range(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> dep(n);
  vector<int> w(n);
  vector<int> total(n);
  function<void(int, int)> dfs = [&](int v, int p) {
    dep[v] = total[v] = w[v] = 0;
    if(~p) dep[v] = dep[p] + 1;
    if(s[v] == '1') {
      w[v] = 1;
    }
    for(int u : g[v]) {
      if(u == p) continue;
      dfs(u, v);
      w[v] += w[u];
      total[v] += total[u] + w[u];
    }
  };
  int res = INT_MAX;
  for(int v = 0; v < n; v++) {
    dfs(v, -1);
    if(total[v] & 1) continue;
    int cur = v;
    int par = -1;
    int ans = total[v] / 2;
    int ps = 0;
    while(true) {
      int p = -1;
      for(int u : g[cur]) {
        if(u == par) continue;
        if(p == -1 || total[p] + w[p] < total[u] + w[u]) p = u;
      }
      if(p == -1) {
        ans = INT_MAX;
        break;
      }
      int c = total[cur] + ps - total[p] - w[p];
      if(total[p] + w[p] <= c) break;
      if(w[p] > c) {
        ans = INT_MAX;
        break;
      }
      par = cur; cur = p; ps = c - w[p];
    }
    res = min(res, ans);
  }
  if(res == INT_MAX) res = -1;
  cout << res;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*float n乗*/ll floatpow(float x,ll n){ll i;float ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll sub=0;
 ll a[n+10],s[n+10];
 a[0]=0;a[n+1]=0;
 rep(i,1,n+1){sc(a[i]);s[i]=a[i];}
 rep(i,0,n+1)sub+=abs(a[i]-a[i+1]);
 rep(i,1,n+1){
  ans=sub;
  ans-=abs(a[i]-a[i-1])+abs(a[i]-a[i+1]);
  ans+=abs(a[i+1]-a[i-1]);
  pr(ans);  
 }
  
return 0;}

Measured memory_bytes: 5192
#include <stdio.h>

int main(void){
  int x, y;

  while(1){
    scanf("%d %d", &x, &y);
    if(x == 0 && y ==0){
      break;
    }
    if(x > y){
      printf("%d %d\n", y, x);
    } else {
      printf("%d %d\n", x, y);
    }
  }
  return 0;
}



Measured memory_bytes: 2044
#include<stdio.h>
int main(void)
{
	int n,sum,x,m,i;
	while(1){
		sum=1150;
		scanf("%d",&n);
		if(n<0)break;
		m=n;
		if(m>10){
			for(i=0;i<10;i++){
				if(n-10==0)break;
				sum+=125;
				n-=1;
			}
		}
		if(m>20){
			for(i=0;i<10;i++){
				if(n-10==0)break;
				sum+=140;
				n-=1;
			}
		}
		if(m>30){
			m=n;
			for(i=0;i<m-10;i++){
				if(n-10==0)break;
				sum+=160;
				n-=1;
			}
		}
		x=4280-sum;
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 1028