akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_135
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var S = ReadLine();
            var xor10 = new long[S.Length];
            var mod = 13L;
            long Mod = 1000000000 + 7;
            //10^n%13
            xor10[0] = 1;
            for (var i = 1; i < S.Length; ++i)
            { xor10[i] = xor10[i - 1] * 10 % mod; }
            var numxor = 0L;//?が0のときのmod
            var cnt = 0L;
            for (var i = S.Length - 1; 0 <= i; --i) 
            {
                if ('?' != S[i])
                {
                    var n = long.Parse(S[i].ToString());
                    numxor += xor10[cnt] * n;
                    numxor %= mod;
                }
                ++cnt;
            }
            var dp = new long[S.Length + 1, mod];
            for (var i = 1; i <= S.Length; ++i)
            {
                if ('?' != S[i - 1])//?ではない場合持ち越し
                {
                    for (var k = 0; k < mod; ++k)
                    { dp[i, k] = dp[i - 1, k]; }
                    continue;
                }
                var tmp = new long[mod];
                //i*10^n%modを計算。0は除く
                for (var j = 0; j < 10; ++j)
                { tmp[(xor10[S.Length - i] * j) % mod] = 1; }
                //上位桁で0位外を選んでる場合の遷移
                for (var j = 0; j < mod; ++j)
                {
                    for (var k = 0; k < mod; ++k)
                    { dp[i, (j + k) % mod] += dp[i - 1, j] * tmp[k]; }
                }
                //上位桁が0から遷移する場合
                for (var j = 1; j < mod; ++j)
                { dp[i, j] = (dp[i, j] + tmp[j]) % Mod; }
            }
            dp[S.Length, 0]++;//全て0の場合;
            WriteLine(dp[S.Length, (5 - numxor + mod) % mod] % Mod);
        }
    }
}

Measured memory_bytes: 26460
// Problem : H - Grid 1
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_h
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
	int h,w;
	cin >> h >> w;
	long long int dp[h][w];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			dp[i][j]=0;
			char t;
			cin >> t;
			if(t=='#')
			dp[i][j]=-1;
		}
	}
	dp[0][0]=1;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(i-1>=0 && dp[i][j]!=-1 && dp[i-1][j]!=-1)
			dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			if(j-1>=0 && dp[i][j]!=-1 && dp[i][j-1]!=-1)
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>

int N,M,m,i,t;
long long s;
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&t);
		s+=t;
		m=i&&m<t?m:t;
		M=i&&M>t?M:t;
	}
	printf("%d %d %lld\n",m,M,s);
	return 0;
}

Measured memory_bytes: 600
n = int(input())

def keta(r):
    cnt = 0
    while r:
        r//=10
        cnt+=1
    return cnt
ans = 1e10
for i in range (1,1000000000):
    if i * i > n :break
    if n%i !=0 :continue
    ans = min(ans,max(keta(n/i),keta(i)))
print(ans)



Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define SORT(v) sort((v).begin(),(v).end())
//#define scanf scanf_s

int ice[100005];

struct record
{
	int ac, pe, t;
};
bool comp(const record&  r1, const record& r2)
{
	if (r1.ac != r2.ac) return r1.ac > r2.ac;
	else if(r1.pe!=r2.pe) return r1.pe < r2.pe;
	else return r1.t>r2.t;
}

int main()
{
	int m, t, p, r;
	while (cin >> m >> t >> p >> r, (m || t || p || r))
	{
		int rec[55][11][2] = {};
		bool solved[55][11] = {};
		int a, b, c, d;
		REP(i, r)
		{
			cin >> a >> b >> c >> d;
			if (d == 0)
			{
				rec[b][c][0] = rec[b][c][1] + a;
				solved[b][c] = true;
			}
			else rec[b][c][1] += 20;
		}

		vector<record> v;
		FOR(i,1, t+1)
		{
			int ac = 0;
			int pe = 0;
			FOR(j,1, p+1)
			{
				if (solved[i][j] == true) ac++;
				pe += rec[i][j][0];
			}
			record r = { ac, pe, i };
			v.push_back(r);
		}

		sort(v.begin(), v.end(), comp);
		
		REP(i, v.size())
		{
			cout << v[i].t;
			if (i == v.size() - 1) cout << endl;
			else if (v[i].ac == v[i + 1].ac&&v[i].pe == v[i + 1].pe)cout << "=";
			else cout << ",";
		}

	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a+b+c>21?"bust":"win") << endl;
    return 0;
}


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

int main() {

    vector<int> A(3);
    for(int i = 0; i < 3; i++)
        cin >> A[i];

    int i;
    int sum = 0;

    for(i = 0; i < 3; i++) {
        if(!(A[i] == 5 || A[i] == 7)) {
            cout << "NO" << endl;
            return 150;
        }

        sum += A[i];

        if(i == 2) {
            if(sum == 17) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(b)   sort(b.begin(), b.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    ll n, k; cin >> n >> k;

    vector<int> x(n);
    for(int i = 0; i < n; ++i) cin >> x[i];

    gSort(x);

    if(n <= k) {
        cout << 0;
        return 0;
    }

    ll ans = 0;
    for(int i = k; i < n; ++i) {
        ans += x[i];
    }

    cout << ans;
}

Measured memory_bytes: 1024
N,M=map(int,input().split())
P=[0]+list(map(int,input().split()))

#Union-find
U=[i for i in range(N+1)] #根の頂点

#根を与える関数
def root(x):
    global U
    if x==U[x]:
        return x
    else:
        U[x]=root(U[x])  #経路圧縮
        return U[x]

#併合関数
def unite(x,y):
    global U
    if root(x)!=root(y):
        U[root(x)]=root(y)

#判定関数
def same(x,y):
    global U
    if root(x)==root(y):
        return 1
    else:
        return 0

for j in range(M):
    X,Y=map(int,input().split())
    unite(X,Y)

ans=0
for k in range(1,N+1):
    ans+=same(k,P[k])

print(ans)
    



Measured memory_bytes: 13812
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    
    for(int i=n-1;i>=0;i--) {
        cout << a[i];
        if(i==0)cout << endl;
        else cout << " ";
    }
    return 0;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include<bits/stdc++.h>
typedef long long int ll;
const int maxn=1e6+7;
using namespace std;
//四步走，
//确定状态 1、最后一步2、化成子问题
//转移方程
//初始条件和边界情况
//计算顺序，确保要用到的都算过
int main()
{
    char ch[200005];
    cin>>ch;
    int sum=0;
    for(int i=0;i<strlen(ch);i++)
    {
        sum+=ch[i]-'0';
    }
    if(sum%9==0)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,mod=1e9+7,inf=1e9+10;
int a[M];
int cnt[M];
main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)cin>>a[i],cnt[a[i]]=1;
	for(int i=1;i<=100;i++)ans+=cnt[i];
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;

int main()
{
    int n; cin >> n;
    int d = n % 10;

    if (d == 3) {
        cout << "bon" << endl;
    }
    else if (d == 0 ||
             d == 1 ||
             d == 6 ||
             d == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N, M;

struct WeightedUnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> diff_weight;

    WeightedUnionFind(int N) : par(N), rank(N), diff_weight(N) {
        for(int i = 0; i < N; i++) {
            par[i] = i;
            rank[i] = 0;
            diff_weight[i] = 0;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = root(par[x]);
        }
    }

    int weight(int x) {
        root(x);
        return diff_weight[x];
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }

    void merge(int x, int y, int w) {
        w -= diff(x, y);
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            swap(rx, ry);
            w = -w;
        }
        if (rank[rx] == rank[ry]) rank[rx]++;
        par[ry] = rx;
        diff_weight[ry] = w;
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }    
};

int main() {
    cin >> N >> M;
    WeightedUnionFind tree(N);
    bool f = true;
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        if (tree.is_same(l-1, r-1)) {
            int diff = tree.diff(l-1, r-1);
            if (diff != d) {
                f = false;
                break;
            }
        }
        else {
            tree.merge(l-1, r-1, d);
        }
    }
    cout << (f ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define allr(x) (x.rbegin()),(x.rend())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif	

const int maxn = 1e3;
const int inf = 1e6;
struct Edge{
	pair<int,int> from,to;
	int wt;
	Edge(pair<int,int> f,pair<int,int> t,int w): from(f),to(t),wt(w) {}
	bool operator < (const Edge & e ) const{
		return wt > e.wt;
	}
};
  
int Dijkstra(vector<vector<vector<Edge>>> & adj,pair<int,int> src,pair<int,int> dest){
	vector<vector<int>> dist(maxn,vector<int>(maxn,inf));
	dist[src.first][src.second] = 0;
	priority_queue<Edge> q;
	q.push(Edge(make_pair(-1,-1),src,0));
	
	while(!q.empty()){
		Edge node = q.top(); q.pop();
		//debug() << owo(node.to);
		if(dist[node.to.first][node.to.second] < node.wt) continue; // some other state reached better
		// performing relaxation using used nodes..
		for(Edge el : adj[node.to.first][node.to.second]){
			if(dist[el.to.first][el.to.second] > dist[el.from.first][el.from.second] + el.wt){
				dist[el.to.first][el.to.second] = dist[el.from.first][el.from.second] + el.wt;
				q.push(Edge(el.from,el.to,dist[el.to.first][el.to.second]));
			}
		}
			
	}
	return dist[dest.first][dest.second];
}

int N , M;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
char grid[maxn][maxn];

bool is_valid(int x,int y){
	if(x < 0 || y < 0 || x >= N || y >= M || grid[x][y] != '.')
		return false;
	return true;
}
void solve(){
	cin >> N >> M;
	pair<int,int> src,dest;
	cin >> src.first >> src.second;
	cin >> dest.first >> dest.second;
	--src.first,--src.second,--dest.first,--dest.second;
	vector<vector<vector<Edge>>> adj(maxn,vector<vector<Edge>>(maxn));

	for(int i = 0;i<N;++i){
		for(int j = 0;j<M;++j){
			cin >> grid[i][j];
		}
	}
	
	for(int i = 0;i<N;++i)
		for(int j = 0;j<M;++j){
			if(is_valid(i,j)){
				for(int k = 0;k<4;++k){
					int RR = i + dx[k];
					int CC = j + dy[k];
					if(is_valid(RR,CC))
						adj[i][j].push_back(Edge(make_pair(i,j),make_pair(RR,CC),0));
				}
				for(int a = i-2;a <= i+2;++a)
					for(int b = j-2; b <= j+2;++b)
						if(is_valid(a,b))
							adj[i][j].push_back(Edge(make_pair(i,j),make_pair(a,b),1));
			}
		}
	
	int ans =  (Dijkstra(adj,src,dest));
	cout << (ans == inf?-1:ans);
}
	

int main(){
	FAST_IO;
	int tt;
	//cin >> tt;
	tt = 1;
	for(int i = 0;i<tt;++i){
		solve();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 242496
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author izban
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;

#ifdef HOME
#define db(x) { cerr << #x << " = " << x << endl; }
#define db2(x, y) { cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl; }
#define db3(x, y, z) { cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl; }
#define dbv(a) { cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl; }
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

#define sz(a)  (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x)  (1LL << (x))


class C {
public:
    void solve(std::istream &in, std::ostream &out) {
        ios_base::sync_with_stdio(0);
        in.tie(0);

        int n;
        in >> n;
        vector<vector<int>> e(n);
        for (int i = 0; i < n - 1; i++) {
            int u, v;
            in >> u >> v;
            u--;
            v--;
            e[u].push_back(v);
            e[v].push_back(u);
        }

        vector<int> h(n);
        function<void(int, int, int)> dfs = [&](int v, int pr, int ch) {
            h[v] = ch;
            for (int to : e[v]) {
                if (to == pr) continue;
                dfs(to, v, ch + 1);
            }
        };
        dfs(0, -1, 0);
        int v = 0;
        for (int i = 0; i < n; i++) if (h[i] > h[v]) v = i;
        dfs(v, -1, 0);
        for (int i = 0; i < n; i++) if (h[i] > h[v]) v = i;

        vector<int> dp(n + 1);
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            if (i >= 1) dp[i] |= !dp[i - 1];
            if (i > 2) dp[i] |= !dp[i - 2];
        }
//        dbv(dp);

        string res = dp[h[v] + 1] ? "First" : "Second";
        out << res << endl;
    }
};


int main() {
    C solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define rep(i,n) for(int i=0; i <(n); i++)

using namespace std;

int main(void){

    //input
    int N;
    cin >> N;

    //output
    long int sum = 0;

    rep(i, N+1){
        //cout << i;
        //FizzBuzz
        if( (i%3 ==0) || (i%5 ==0)){
           //cout << "FizzBuzz or Fizz or Buzz" << endl;
        }else{
            sum += i;
        }
    }
    //output
    cout << sum;

    return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!
l = list(map(int,input().split()))	
K = l[0]
S = l[1]
count = 0
for i in range(K + 1):
    X = i
    if X > S:
        break
    for j in range(K + 1):
        Y = j
        if X + Y > S:
            break
        else:
            Z = S - (X + Y)
            if Z <= K:
                count += 1

print(count)

Measured memory_bytes: 41052
from collections import defaultdict
from itertools import permutations as p

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
xy = [readInts() for i in range(n)]
l = list(p(list(range(0,n))))
length = len(l)
sumDis = 0
for i in l:
	for j in range(n-1):
		sumDis += ((xy[i[j+1]][0]-xy[i[j]][0])**2+(xy[i[j+1]][1]-xy[i[j]][1])**2)**0.5

print(sumDis/length)

Measured memory_bytes: 14032
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll a, b, v, w, T;
	cin >> a >> v >> b >> w >> T;
	if(a == b){
		cout << "YES" << endl;
		return 0;
	}
	if(v <= w || T * (v - w) < abs(a - b)){
		cout << "NO" << endl;
		return 0;
	} 
	cout << "YES" << endl; 
	return 0;
}

Measured memory_bytes: 3640
import math
a, b, x = map(int, input().split())
if (2 * x > a * a * b):
    #空の部分から
    h = 2 * (x-a*a*b) / (a*a)
    print(-math.degrees(math.atan(h/a)))
else:
    #水の部分から
    print(90-math.degrees(math.atan(2*x/(a*b*b))))


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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    ll u, v;
    vvi ed(n+1);
    vi val(n+1, 0), c(n);
    REP(i, 0, n-1) {
        cin >> u >> v;
        ed[u].pb(v);
        ed[v].pb(u);
    }
    REP(i, 0, n)
        cin >> c[i];
    sort(all(c), greater<ll>());
    queue<ll> q;
    ll p = 0;
    q.push(1);
    val[1] = c[p];
    p = 1;
    while (!q.empty()) {
        auto cr = q.front();
        q.pop();
        REP(i, 0, ed[cr].size()) {
            if (val[ed[cr][i]] == 0) {
                val[ed[cr][i]] = c[p];
                p++;
                q.push(ed[cr][i]);
            }
        }
    }
    ll sm = 0;
    REP(i, 1, n)
        sm += c[i];
    cout << sm << endl;
    REP(i, 1, n+1)
        cout << val[i] << " ";
    cout << endl;
    return 0;
}


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

using namespace std;

#define CVector CPoint
typedef long long LL;
typedef unsigned long long ULL;

const LL mod=1e9+7;
const double PI=acos(-1);
const double EPS=1e-6;
const int INF=0x3f3f3f3f;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}


vector<int> E[100005];
bool v[100005];

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    int cnt1=0,cnt2=0;
    queue<int> s1,s2;
    s1.push(1);
    s2.push(n);
    v[1]=v[n]=true;
    while(!s1.empty()||!s2.empty()){
        int c1=s1.size();
        if(c1){
            while(c1--){
                int d=s1.front();
                s1.pop();
                for(int i=0;i<E[d].size();i++){
                    if(!v[E[d][i]]){
                        v[E[d][i]]=true;
                        cnt1++;
                        s1.push(E[d][i]);
                    }
                }
            }
        }
        int c2=s2.size();
        if(c2){
            while(c2--){
                int d=s2.front();
                s2.pop();
                for(int i=0;i<E[d].size();i++){
                    if(!v[E[d][i]]){
                        v[E[d][i]]=true;
                        cnt2++;
                        s2.push(E[d][i]);
                    }
                }
            }
        }
    }
    cout<<(cnt1>cnt2? "Fennec":"Snuke")<<endl;
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
bool cmp(pint a, pint b) {return a.second < b.second;}

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

    vector<P> a(n);
    rep(i, n) {
        int x, l;
        cin >> x >> l;
        a[i] = make_pair(x - l, x + l);
    } 
    sort(all(a), cmp);

    int ans = 0;
    int end = -1e9;
    rep(i, n) {
        if(a[i].first >= end) {
            ans++;
            end = a[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  vector<long>b(n);
  int i,j;
  long sumA = 0;
  long sumB = 0;
  vector<long>sa(n);
  for(i=0;i<n;i++){
    cin >> a[i];
    sumA += a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
    sa[i] = a[i]-b[i];
    sumB += b[i];
  }
  if(sumB > sumA)cout << -1 << endl;
  else{
    sort(sa.begin(),sa.end());
    i=0;
    j = n-1;
    long tmp = 0;
    while(sa[i]<0){
      tmp = -sa[i];
      i++;
      while(sa[j]<tmp){
        tmp -= sa[j];
        j--;
      }
      sa[j]-=tmp;
    }

    if(sa[0]>=0)cout << 0 << endl;
    else cout << i + (n-j) << endl;
  }


}


Measured memory_bytes: 2560
import numpy as np
n,d = map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]
X = np.array(X)
#print(X)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        #print(i,j)
        sq = np.sqrt(sum((X[j]-X[i])**2))
        #print(sq)
        if sq == int(sq):
            ans += 1
print(ans)

Measured memory_bytes: 21772
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    cout << max(0LL, c - (a - b)) << endl;

    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
int max(int a,int b){
	return a>b?a:b;
}
const int Maxn=200000;
const int Inf=0x3f3f3f3f;
int head[Maxn+5],arrive[Maxn<<1|5],nxt[Maxn<<1|5],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int a[Maxn+5];
int n;
int d[Maxn+5],d_len;
int len[Maxn+5];
void work_dfs(int u,int fa){
	int c_len=0,c_pos=-1,c_val=-1;
	if(a[u]>d[d_len]){
		d_len++;
		d[d_len]=a[u];
		c_len=1;
	}
	else{
		int left=1,right=d_len;
		while(left<right){
			int mid=(left+right)>>1;
			if(d[mid]<a[u]){
				left=mid+1;
			}
			else{
				right=mid;
			}
		}
		c_pos=left;
		c_val=d[left];
		d[left]=a[u];
	}
	len[u]=d_len;
	for(int i=head[u];i;i=nxt[i]){
		int v=arrive[i];
		if(v==fa){
			continue;
		}
		work_dfs(v,u);
	}
	if(c_len!=0){
		d_len-=c_len;
	}
	else{
		d[c_pos]=c_val;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	work_dfs(1,0);
	for(int i=1;i<=n;i++){
		printf("%d\n",len[i]);
	}
	return 0;
}


Measured memory_bytes: 21592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        System.out.println(arr[n - 1]);
    }
}


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

int main(){
  int N;
  cin >> N;
  int x = N%10;
  int z = N%100;
  int y = z%10;
  double a = N/10;
  double b = N/100;
  if(a < 1){
    if(N == 2){
      cout << "hon" << endl;
    }
    else if(N == 4){
      cout << "hon" << endl;
    }
    else if(N == 5){
      cout << "hon" << endl;
    }
    else if(N == 7){
      cout << "hon" << endl;
    }
    else if(N == 9){
      cout << "hon" << endl;
    }
    else if(N == 0){
      cout << "pon" << endl;
    }
    else if(N == 1){
      cout << "pon" << endl;
    }
    else if(N == 6){
      cout << "pon" << endl;
    }
    else if(N == 8){
      cout << "pon" << endl;
    }
    else if(N == 3){
      cout << "bon" << endl;
    }
  }
  else if(b < 1){
    if(x == 2){
      cout << "hon" << endl;
    }
    else if(x == 4){
      cout << "hon" << endl;
    }
    else if(x == 5){
      cout << "hon" << endl;
    }
    else if(x == 7){
      cout << "hon" << endl;
    }
    else if(x == 9){
      cout << "hon" << endl;
    }
    else if(x == 0){
      cout << "pon" << endl;
    }
    else if(x == 1){
      cout << "pon" << endl;
    }
    else if(x == 6){
      cout << "pon" << endl;
    }
    else if(x == 8){
      cout << "pon" << endl;
    }
    else if(x == 3){
      cout << "bon" << endl;
    }
  }
  else{
    if(y == 2){
      cout << "hon" << endl;
    }
    else if(y == 4){
      cout << "hon" << endl;
    }
    else if(y == 5){
      cout << "hon" << endl;
    }
    else if(y == 7){
      cout << "hon" << endl;
    }
    else if(y == 9){
      cout << "hon" << endl;
    }
    else if(y == 0){
      cout << "pon" << endl;
    }
    else if(y == 1){
      cout << "pon" << endl;
    }
    else if(y == 6){
      cout << "pon" << endl;
    }
    else if(y == 8){
      cout << "pon" << endl;
    }
    else if(y == 3){
      cout << "bon" << endl;
    }
  }
}

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

typedef long long ll;
ll n, a, b;
int main()
{
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2;
	} else {
		cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2;
	}
    return 0;
}

Measured memory_bytes: 256
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Measured memory_bytes: 34428
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
tot = abs(A[1])+abs(A[N])
for i in range(2,N+1):
    tot += abs(A[i]-A[i-1])
for i in range(1,N+1):
    if i==1:
        print(tot-abs(A[1])-abs(A[2]-A[1])+abs(A[2]))
    elif i==N:
        print(tot-abs(A[N])-abs(A[N]-A[N-1])+abs(A[N-1]))
    else:
        print(tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000;

int n, m, x, y, z;

vector<int> graph[N];
bitset<N> used;

void dfs(int v) {
	used[v] = 1;
	for (auto& u : graph[v]) {
		if (!used[u]) dfs(u);
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
		cin >> x >> y >> z;
		x--; y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	
	used.reset();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			dfs(i);
			ans++;
		}
	}
	cout << ans;
    return 0;
}


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

int main() {
    int N, Q; cin >> N >> Q;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    reverse(A.begin(), A.end()); // 考えやすいように左右反転

    vector<long long> sum(N+1), evensum(N+1); // 累積和、偶数番目累積和
    for (int i = 0; i < N; ++i) {
        sum[i+1] = sum[i] + A[i];
        evensum[i+1] = evensum[i] + (i % 2 == 0 ? A[i] : 0);
    }

    vector<long long> ths, vals; // ths: L の値が変化する x の境目、vals: またそのときの先手のスコア
    for (int i = 0; i < (N-1)/2; ++i) {
        long long th = (A[i+1] + A[i*2+2])/2 + 1;
        long long val = (sum[i+1] - sum[0]) + (evensum[N] - evensum[i*2+2]);
        ths.push_back(th); vals.push_back(val);
    }
    reverse(ths.begin(), ths.end()); reverse(vals.begin(), vals.end());
    for (int _ = 0; _ < Q; ++_) {
        long long x; cin >> x;
        int it = upper_bound(ths.begin(), ths.end(), x) - ths.begin(); // L の値が何かを求める
        if (it == 0) cout << sum[(N+1)/2] - sum[0] << endl;
        else cout << vals[it-1] << endl;
    }
}


Measured memory_bytes: 5108
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0;i < 3;++i) {
		if (s[i] == 'o') {
			++cnt;
		}
	}
	cout << 700 + 100 * cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pr(a) printf("%lld\n",a)

int main()
{
    ll n,m,i,j,k,l,t,x,y,z;

    cin>>x>>n;

    ll a[n+5];

    map<ll,ll>mx;

    for(i=0; i<n; i++)
    {

        cin>>a[i];

        mx[a[i]]=1;
    }

    vector<pair<ll,ll>>v;

    for(i=0; i<=101; i++)
    {

        if(mx[i]==0)
        {

            k=abs(x-i);

            v.pb(mp(k,i));
        }
    }

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

    cout<<v[0].second<<endl;


}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n; cin >> n;
	cout << n * 800 - (n/15) * 200 << endl;
	
	return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//cout<<fixed<<setprecision(10);

	int N=in();
	string S=in<string>();
	int sum=0;
	REP(i,1000){
		char str[8];
		sprintf(str,"%03d",i);
		int index=0;
		REP(j,N){
			if(str[index]==S[j]){
				index++;
			}
			if(index==3) break;
		}
		if(index==3) sum++;
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int n,s[3][105],x,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
            cin>>x,s[i][j]=s[i][j-1]+x;
    for(int i=1;i<=n;i++)
        ans=max(ans,s[1][i]+s[2][n]-s[2][i-1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define O 0
#define I 1
#define E 8

typedef struct node{
  int key;
  int priority;
  struct node *left;
  struct node *right;
}node;


node * Delete(node **,int);
node * _delete(node **,int);

int find(node *p,int x){
  while(p!=NULL){
    if(p->key==x){
      return I;
    }
    else if(p->key > x){
      p=p->left;
    }
    else{
      p=p->right;
    }
  }
  return O;
}

void inorder(node *p){

  if(p->left!=NULL){
    inorder(p->left);
  }
  printf(" %d",p->key);
  if(p->right!=NULL){
    inorder(p->right);
  }
  return;
}

void preorder(node *p){
  printf(" %d",p->key);
  if(p->left!=NULL){
    preorder(p->left);
  }
  if(p->right!=NULL){
    preorder(p->right);
  }
  return;
}

void print(node *p){
  inorder(p);
  printf("\n");
  preorder(p);
  printf("\n");
  return;
}

node * makenode(int x,int y){
  node *new=malloc(sizeof(node));
  new->key=x;
  new->priority=y;
  new->left=NULL;
  new->right=NULL;
  return new;
}

node *rightRotate(node *p){
  node *q=p->left;
  p->left=q->right;
  q->right=p;
  return q;
}

node *leftRotate(node *p){
  node *q=p->right;
  p->right=q->left;
  q->left=p;
  return q;
}

node* insert(node **t,int key,int priority){
  node *new;
  if((*t)==NULL){
  return new=makenode(key,priority);
  }
  if((*t)->key==key){
  return *t;
  }
  if(key < (*t)->key){
    (*t)->left=insert(&(*t)->left,key,priority);
    if((*t)->priority < (*t)->left->priority){
    (*t)=rightRotate((*t));
    }
  }
  else{
    (*t)->right=insert(&(*t)->right,key,priority);
    if((*t)->priority < (*t)->right->priority){
    (*t)=leftRotate((*t));
    }
  }
  return *t;
}

node * Delete(node **t,int key){
  if((*t)==NULL)
  return NULL;
  if(key < (*t)->key){
  (*t)->left=Delete(&((*t)->left),key);
  }
  else if(key > (*t)->key){
  (*t)->right=Delete(&((*t)->right),key);
  }
  else{
    return _delete(t,key);
  }
  return *t;
}

node * _delete(node **t,int key){
  if((*t)->left==NULL && (*t)->right==NULL){
  return NULL;
  }
  else if((*t)->left==NULL){
  (*t)=leftRotate(*t);
  }
  else if((*t)->right==NULL){
  (*t)=rightRotate(*t);
  }
  else{
    if((*t)->left->priority > (*t)->right->priority){
    (*t)=rightRotate(*t);
    }
    else{
    (*t)=leftRotate(*t);
    }
  }
  return Delete(t,key);
}

int main(){
  int i,n,x,y;
  char com[E];
  node *root=NULL;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    switch(com[O]){
      case 'i':scanf("%d %d",&x,&y);
      root=insert(&root,x,y);
      break;
      case 'd':scanf("%d",&x);
      root=Delete(&root,x);
      break;
      case 'f':scanf("%d",&x);
	if(find(root,x)){
	  printf("yes\n");
	}
	else{
	  printf("no\n");
	}
      break;
      case 'p':print(root);
      break;
    }
  }
  return O;
}



Measured memory_bytes: 7920
/*
    Created by vasu090 on 19 Apr, 2020
*/
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    int n,d; cin >> n >> d;
    int cur = 2*d+1;
    cout << ceil((double)n/cur) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(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; }

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

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

  if (n >= 0) {
    cout << n << endl;
  } else {
    cout << -1 << endl;
  }


  return 0;
}


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

int distRobot(int, vector<int>);

int main()
{
  int N, K;
  cin>>N>>K;
  vector<int> x(N);
  for(int i=0; i<N; i++)
    cin>>x[i];

  cout<<distRobot(K, x)<<endl;

  return 0;
}

int distRobot(int K, vector<int> x)
{
  int count = 0;
  for(int xi: x) {
    if(xi > K/2)
      count += (K-xi)*2;
    else
      count += xi*2;
  }
  return count;
}


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

int main(){

    int a,b,acard,bcard,match;

    while(1){

      a = b = 0;

      cin >> match;

      if(match == 0){
        break;
      }



      for(int i=0;i < match; i++){
        cin >> acard >> bcard;
        if(acard > bcard){
          a += acard+bcard;
        }
        else if(acard < bcard){
          b += acard+bcard;
        }
        else{
          a += acard;
          b += bcard;
        }
      }

      cout << a << ' ' << b << endl;

    }


    return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    long long int N;
    long long int X;
    long long int count = 0;
    scanf("%lld",&N);
    long long int A[300000];
    long long int counter_minus[300000];
    long long int counter_plus[300000];

    for(int i = 0; i < 300000; ++i){
        counter_minus[i] = 0;
        counter_plus[i] = 0;
        A[i] = 0;
    }

    for(int i = 1; i <= N; ++i) {
        scanf("%lld", &A[i]);
        if(abs(A[i] + i) < 300000 ) {
            counter_plus[A[i] + i]++;

        }
        if(i - A[i]  >= 0){
            counter_minus[i - A[i]]++;
        }
    }


    for(long long int i = 0; i < 300000; ++i){
        count += counter_minus[i]*counter_plus[i];
    }
    printf("%lld",count);



}

int D(){
    long long int A,B;
    long long int X;
    scanf("%lld",&X);
    for(long long int i = -1000; i <= 1000;++i){
        A = pow(i,5);
        for(long long int j = -1000; j <= 1000; ++j){

            B = pow(j,5);
            if(A-B == X){
                printf("%d %d",i,j);
                return 0;
            }
        }
    }

    printf("A");


}


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

int main() {
  string s; cin >> s;
  int a = s.find('A');
  reverse(s.begin(), s.end());
  int z = (int)s.size() - s.find('Z');
  cout << z - a << endl;

  return 0;
}

Measured memory_bytes: 3752
/* C program for Merge Sort */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long dp[100][100000];
long long int v[100];
int w[100];
int n;
long long int mod=1000000007;
long long int max_q(int i,int weight){
    if(i>=n){
        return 0;
    }
    if(weight==0){
        return 1;
    }
    if(dp[i][weight]!=-1){
        return dp[i][weight] ;
    }
    if(w[i]<=weight ){
        dp[i][weight]=max(v[i]+max_q(i+1,weight-w[i]),max_q(i+1,weight));
        return dp[i][weight];
    }
    else dp[i][weight]=max_q(i+1,weight);
    
    return dp[i][weight];
}
int main() 
{ 
    int weight;
    cin>>n>>weight;
    //cout<<weight;
    for(int i=0;i<100;i++){
        for(int j=0;j<100000;j++){
            dp[i][j]=-1;
            }
    }
    for(int i =0;i<n; i++){
        cin>>w[i]>>v[i];
    }
    cout<<max_q(0,weight)<<endl;

	return 0; 
} 


Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int X,Y,S;
int solve()
{
	int maxinum = 0;
	int i,j;
	for (i = 1; i<S; i++)
	{
		for (j = i; j<S; j++)
		{
			if(i*(100+X)/100+j*(100+X)/100 == S)
			{
				int S0= i*(100+Y)/100+j*(100+Y)/100;
				maxinum = max(maxinum,S0);
			}
		}
	}
	return maxinum;
};
int main()
{
	int A[100000];
	int k = 0;
    while(cin>>X>>Y>>S && X>0)
	{
		A[k]=solve();
		k++;
	}
	for(int l = 0;l < k; l++)
	{
		cout<<A[l]<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s[n], x;
    int t[n];
    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i];
    }
    cin >> x;
    bool f = 0;
    int r = 0;
    for(int i = 0; i < n; i++){
        if(f) r += t[i];
        if(s[i] == x) f = 1;
    }
    cout << r << '\n';
}


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void read(T &x)
{
    x=0; char c=getchar();  int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
int main()
{
	int n,k;
	read(n),read(k);
	if(2*k-1<=n) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
 
ll go(ll n,ll k,ll arr[])
{
    ll aa[n];
    ll i,j,ans;
    aa[0] = 0;
    aa[1] = abs(arr[1]-arr[0]);
    //cout << aa[0] << " " << aa[1] << endl;
    
    for(i=2;i<n;i++)
    {
        ans = abs(arr[i]-arr[i-1])+aa[i-1];
        //cout << i << "*\n";
        for(j=2;j<=k;j++)
        {
            //cout << i << " " << ans << endl; 
            if(i-j>=0)
                ans = min(ans,(abs(arr[i]-arr[i-j])+aa[i-j]));
        }
        aa[i] = ans;
        //aa[i] = min(abs(arr[i]-arr[i-1])+aa[i-1],abs(arr[i]-arr[i-2])+aa[i-2]);
        //cout << aa[i] << endl;
    }
    
    /*for(i=0;i<n;i++)
    {
        cout << aa[i] << endl;
    }*/
    return aa[n-1];
}
 
int main(void){
    // Your code here!
    ll n,k,i;
    
    cin >> n >> k;
    
    ll arr[n];
    
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    
    ll ans = go(n,k,arr);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main(void){
    char c[10000];
    int a[2000];
    int i=0,j=0;
    while(scanf("%s",c) != EOF){
        switch(c[0]){
        case '%':
        a[i-2]=a[i-1]/a[i-2];
        i--;
        break;
        case '*':
        a[i-2]=a[i-1]*a[i-2];
        i--;
        break;
        case '+':
        a[i-2]=a[i-1]+a[i-2];
        i--;
        break;
        case '-':
        a[i-2]=a[i-2]-a[i-1];
        i--;
        break;
        default:
        a[i]=atoi(c);
        i++;
        break;
}
    }
    printf("%d\n",a[i-1]);
    return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);

    for (int i=0; i<H; i++){
        cin >> a.at(i);
    }

    for (int i=0; i<W+2; i++){
        cout << '#';
    }
    cout << endl;

    for (int i=0; i<H; i++){
        cout << '#' << a.at(i) << '#' << endl;
    }

    for (int i=0; i<W+2; i++){
        cout << '#';
    }
    cout << endl;

}

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

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

  if(k<=a){
      cout << k << endl;
  }

  else if(k>a && k<=a+b){
      cout << a << endl;
  }

  else if(k > a+b){
      cout << a - (k-(a+b)) << endl;
  }


}

Measured memory_bytes: 3676
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);
  int shou1;
  int amari;
  int shou2;
  shou1 = N / 100;
  amari = N % 100;
  shou2 = amari / 10;
  amari = amari % 10;
  if (shou1 == 7 || shou2 == 7 || amari == 7) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1604