akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N - 1);
  for (int i = 0; i < N - 1; i++)
  {
    int a;
    cin >> a;
    a--;
    A[i] = a;
  }
  vector<int> ans(N);
  for (auto &a : A)
    ans[a]++;
  for (auto a : ans)
    cout << a << endl;
  return 0;
}


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

int main(){
    int N,M,C;
    cin>>N>>M>>C;
    int B[M];
    rep(i, M) cin>>B[i];
    int count = 0;
    rep(i, N){
        long score = C;
        rep(j, M){
            int A;
            cin>>A;
            score += A*B[j];
        }
        if(score > 0) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
dic=defaultdict(int)
for i in range(N):
  key=input()
  dic[key] += 1

print("AC x {}".format(dic["AC"]))
print("WA x {}".format(dic["WA"]))
print("TLE x {}".format(dic["TLE"]))
print("RE x {}".format(dic["RE"]))

Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,c=0,flag=0;
cin>>n;
int arr[n][2];
for(int i=0;i<n;i++)
for(int j=0;j<2;j++)
cin>>arr[i][j];
for(int i=0;i<n;i++){
if(arr[i][0]==arr[i][1])
c++;
else
c=0;
if(c==3){
cout<<"Yes";
flag=1;
}
}
if(flag==0)
cout<<"No";

return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

ll A,B,C,N,W,H,ans = 0,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	ans = (N/11)*2;
	if(N%11 > 6){
		ans += 2;
	}else if(N%11 > 0){
		ans++;
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

Measured memory_bytes: 5180
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

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

  vector<pair<int, int>> t(N);
  for (int i = 0; i < N; ++i)
    t[i] = make_pair(x[i], y[i]);

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

  int u = 1;
  for (int i = 1; i <= N; ++i)
    u *= i;

  double ans = 0;
  do {
    for (int i = 0; i < N - 1; ++i)
      ans += sqrt(abs(t[i].first - t[i + 1].first) *
                      abs(t[i].first - t[i + 1].first) +
                  abs(t[i].second - t[i + 1].second) *
                      abs(t[i].second - t[i + 1].second));
  } while (next_permutation(t.begin(), t.end()));
  ans /= u;

  cout << fixed << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n, mn=2e9, cnt, c[100005];
pair<ll, ll> a[100005];
int main() {
	ll i;
	scanf("%lld", &n);
	for(i=1; i<=n; i++) scanf("%lld", &a[i].F), a[i].S=i;
	sort(a+1, a+n+1);
	for(i=n; i; i--) {
		mn = min(mn, a[i].S);
		cnt++;
		if(a[i].F!=a[i-1].F) c[mn] += (a[i].F - a[i-1].F) * cnt;
	}
	for(i=1; i<=n; i++) printf("%lld\n", c[i]);
	return 0;
}

Measured memory_bytes: 3456
function main (input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const t = input[1].split(" ").map(n => Number(n));
  const m = Number(input[2]);
  const px = input.slice(3).map(n => n.split(" ").map(m => Number(m));
  const sum = t.reduce((a, b) => a + b));
  for (let i = 0; i < m; i++) {
    const [p, x] = px[i];
    console.log(sum - t[p-1] + x);
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8140
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 500
#define MOD 1000000007
#define M 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define endl "\n"
#define eps 1e-9
#define PI 3.141592653589793
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
#define debug(x) cout<<#x<<"="<<x<<endl;
vl ans(INF,0);
vl siz(INF,0);
vl g[INF];
void dfs(lo node,lo par){
    siz[node]=1;
    lo other=0;
    lo temp=1;
    TRV(g[node])if(it!=par){
        dfs(it,node);
        temp*=ans[it];
        other+=siz[it];
    }
    ans[node]=temp;
    TRV(g[node])if(it!=par){
        if(ans[node]<(siz[it]+1)*(temp/siz[it])){
            ans[node]=(temp/siz[it])*(siz[it]+1);
            siz[node]=siz[it]+1;
        }
    }
    if(ans[node]<other+1){
        ans[node]=siz[node]=other+1;
    }
}
int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
	string a;
	cin>>a;
	if(a.find("AC")==string::npos)cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
   int N,K;
   cin>>N>>K;
   int l[N];
   for(int i=0;i<N;i++){
       cin>>l[i];
   }
   sort(l,l+N);
reverse(l,l+N);
   long long sum=0;
   for(int i=0;i<K;i++){
        sum+=l[i];
   }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using std::cin; using std::cout;
using std::endl;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::stringstream; using std::vector;
using std::pair; using std::make_pair;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<ULL, ULL> puu;
#ifdef DEBUG
using std::cerr;
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)                                                     \
  {                                                                            \
    cerr << #a << " = {";                                                      \
    for (int qwq = (st); qwq <= (n); ++qwq)                                    \
      if (qwq == (st))                                                         \
        cerr << a[qwq];                                                        \
      else                                                                     \
        cerr << ", " << a[qwq];                                                \
    cerr << "}" << endl;                                                       \
  }
#define displayv(a) displaya(a, 0, (int)(a.size() - 1))
#include <ctime>
class MyTimer {
    clock_t st;
public:
    MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
    ~MyTimer() { report(); }
    void reset() { st = clock_t(); }
    void report() {  cerr << "Time consumed: " << (clock() - st) * 1e3 / CLOCKS_PER_SEC << "ms" << endl; }
} myTimer;
#else
#define cerr if(false) std::cout
#define pass ;
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(a) ;
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename A, typename B>
std::ostream& operator << (std::ostream &cout, const pair<A, B> &x) {
    return cout << "(" << x.first << ", " << x.second << ")";
}
template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }

const int maxN = 200000 + 233;
char s[maxN];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    LL ans = 0, cnt = 0;
    for(int i = n - 1; i >= 0; --i) {
        if(s[i] == 'W') ++cnt;
        else ans += cnt;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    long long ans = 0;
    int suf[4002][3] {};
    for (int i = n-1; i >= 0; --i) {
        if (s[i] == 'R')
            suf[i][0] += 1;
        if (s[i] == 'G')
            suf[i][1] += 1;
        if (s[i] == 'B')
            suf[i][2] += 1;

        suf[i][0] += suf[i+1][0];
        suf[i][1] += suf[i+1][1];
        suf[i][2] += suf[i+1][2];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (s[i] != s[j]) {
                if (j+j-i < n && s[j+j-i] != s[i] && s[j+j-i] != s[j]) --ans;
                bool c = 0, d = 0, t = 0;
                if (s[i] == 'R' || s[j] == 'R') c = 1;
                if (s[i] == 'G' || s[j] == 'G') d = 1;
                if (s[i] == 'B' || s[j] == 'B') t = 1;

                if (!c) 
                    ans += suf[j+1][0];
                if (!d) 
                    ans += suf[j+1][1];
                if (!t) 
                    ans += suf[j+1][2];
            }
        }
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3688
h, w = map(int, input().split())
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    # pattern1は縦or横にぶった切るパターン
    pattern1 = min(w, h)
    # pattern2は縦と横に切るパターン(pattern2にも2パターンある)
    # (a, b)のセットと, cのブロックで考える
    a_w = w // 2
    b_w = w - a_w
    c_w = w
    pattern2_1 = float("inf")
    for tmp_h in range(1, h + 1):
        tmp_diff = max(abs(c_w * tmp_h - a_w * (h - tmp_h)), abs(c_w * tmp_h - b_w * (h - tmp_h)))
        if tmp_diff < pattern2_1:
            pattern2_1 = tmp_diff
        else:
            break
    a_h = h // 2
    b_h = h - a_h
    c_h = h
    pattern2_2 = float("inf")
    for tmp_w in range(1, w + 1):
        tmp_diff = max(abs(c_h * tmp_w - a_h * (w - tmp_w)), abs(c_h * tmp_w - b_h * (w - tmp_w)))
        if tmp_diff < pattern2_2:
            pattern2_2 = tmp_diff
        else:
            break
    print(min(pattern1, pattern2_1, pattern2_2))

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

    #define ll long long
    #define pb push_back
    #define mod 1000000007
    #define mk make_pair


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

      ll a,b;
      cin>>a>>b;
      a--; b--;
      cout<<(b%a!=0)+b/a;

      return 0;
      
      }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7||a==5&&b==7&&c==5||a==7&&b==5&&c==5) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
	return 0;
	}
	


Measured memory_bytes: 256
using System;
class AtCoder
{
    static void Main(string[] args)
    {
      	var str = Console.ReadLine();
      	if( 
          str[0] != str[1] || 
          str[1] != str[0] ||
          str[0] != str[2] )
        {
          Console.WriteLine("Yes");
        }
      else{
        Console.WriteLine("No");
      }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace::std;
using ll =long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define INF (1LL<<60)
template<class T> using V=vector<T>;

vector<int> finddivisor(int x){
  vector<int> d;
  for(int i=1;i*i<=x;i++){
    if(x%i==0){
      d.push_back(i);
      if(i*i!=x)d.push_back(x/i);
    }
  }
  return d;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  V<int> cnt(100010,0),d;
  rep(i,2,100010){
    ll pro=1;
    d=finddivisor(i);
    rep(j,0,(int)d.size()){
      if(d[j]!=i)pro*=d[j];

      if(2*i<=pro){
        cnt[i]++;
        break;
      }
    }
  }

  rep(i,1,100010){
    cnt[i]+=cnt[i-1];
  }

  int qq;cin>>qq;
  while(qq--){
    int x;cin>>x;
    cout<<cnt[x]<<'\n';
  }
}


Measured memory_bytes: 3272
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

class BCollatzProblem {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        using namespace std;
        vector<bool> hash(1000001, false);
        ll s;
        cin >> s;
        ll cnt = 1;
        while(!hash[s]) {
            cnt++;
            hash[s] = true;
            if(s %2) s = 3*s+1;
            else s= s/2;
        }
        cout << cnt << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BCollatzProblem solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#define mod 1000000007;
#define SIZE_INT sizeof(int) * 8
#define ll long long int 
using namespace std;

int main()
{
	ll n,wa=0,ac=0,tle=0,re=0;
	string t;
	cin>>n;
	while(n--)
	{
		cin>>t;
		if(t == "AC")
			ac++;
		else if(t == "RE")
			re++;
		else if(t == "TLE")
			tle++;
		else
			wa++;
	}
	cout<<"AC "<<"x "<<ac<<"\n";
	cout<<"WA "<<"x "<<wa<<"\n";
	cout<<"TLE "<<"x "<<tle<<"\n";
	cout<<"RE "<<"x "<<re<<"\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int num_use[10] = {6,2,5,5,4,5,6,3,7,6};
int use_pos[10][7] = {{0,1,2,4,5,6},{2,5},{0,2,3,4,6},{0,2,3,5,6},{1,2,3,5},{0,1,3,5,6},{0,1,3,4,5,6},{0,2,5},{0,1,2,3,4,5,6},{0,1,2,3,5,6}};
int shine_num[14][10];
int num_day[13] = {0,31,0,31,30,31,30,31,31,30,31,30,31};
ll num_HMS[43],num_YMD[57];
bool is_ok[14][7];

bool is_leap_year(int year){

	if(year%400 == 0)return true;
	if(year%100 == 0)return false;
	return year%4 == 0;
}

int main(){

	int N;
	scanf("%d",&N);

	int K;
	scanf("%d",&K);

	for(int i = 0; i <= 13; i++){
		for(int k = 0; k <= 6; k++)is_ok[i][k] = true; //各桁の各棒が光るか
	}

	int digit,pos;
	for(int loop = 0; loop < K; loop++){
		scanf("%d %d",&digit,&pos);
		is_ok[digit][pos] = false;
	}

	//各桁の各数字が、実際に何文字棒を光らせるか計算
	int count;
	for(int i = 0; i <= 13; i++){
		for(int k = 0; k <= 9; k++){
			count = 0;
			for(int a = 0; a < num_use[k]; a++){
				if(is_ok[i][use_pos[k][a]]){
					count++;
				}
			}
			shine_num[i][k] = count;
		}
	}

	int work[14];
	int tmp_sum;

	for(int i = 0; i <= 42; i++)num_HMS[i] = 0;

	//時分秒を全探索
	for(int hour = 0; hour <= 23; hour++){

		work[8] = shine_num[8][hour/10];
		work[9] = shine_num[9][hour%10];

		for(int minute = 0; minute <= 59; minute++){

			work[10] = shine_num[10][minute/10];
			work[11] = shine_num[11][minute%10];

			for(int second = 0; second <= 59; second++){

				work[12] = shine_num[12][second/10];
				work[13] = shine_num[13][second%10];

				tmp_sum = 0;

				for(int a = 8; a <= 13; a++)tmp_sum += work[a];

				num_HMS[tmp_sum]++;
			}
		}
	}

	int tmp,limit;
	for(int i = 0; i <= 56; i++)num_YMD[i] = 0;

	//年月日を全探索
	for(int year = 0; year <= 9999; year++){

		tmp = year;

		work[0] = shine_num[0][tmp/1000];
		tmp %= 1000;
		work[1] = shine_num[1][tmp/100];
		tmp %= 100;
		work[2] = shine_num[2][tmp/10];
		work[3] = shine_num[3][tmp%10];

		for(int month = 1; month <= 12; month++){

			work[4] = shine_num[4][month/10];
			work[5] = shine_num[5][month%10];

			if(month != 2){
				limit = num_day[month];
			}else{
				if(is_leap_year(year)){
					limit = 29;
				}else{
					limit = 28;
				}
			}

			for(int day = 1; day <= limit; day++){

				work[6] = shine_num[6][day/10];
				work[7] = shine_num[7][day%10];

				tmp_sum = 0;

				for(int a = 0; a <= 7; a++)tmp_sum += work[a];

				num_YMD[tmp_sum]++;
			}
		}
	}

	ll ans = 0;
	for(int i = 0; i <= min(42,N); i++){
		if(N-i > 56)continue;
		ans += num_HMS[i]*num_YMD[N-i];
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;
int main(){
    int k, s;
    int ans = 0;
    cin >> k >> s;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            if(s - i - j <= k && s >= i + j){
                // cout << i << j  << endl;
                ans++;
            }  
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
const ll INF = 1e18;
using namespace std;
// using namespace atcoder;


void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    map<ll, ll> cnt;
    ll res = 0;
    rep(i, n) {
        ll ref = 1+i - A[i];
        ll c = cnt.count(ref) ? cnt[ref] : 0;
        res += c;

        ll v = 1+i + A[i];
        cnt[v]++;
    }
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 17136
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 333

int n, m, i, j, ans;
int ord[maxN][maxN], pos[maxN];
bool dead[maxN];

int cnt[maxN];

int main()
{
 //   freopen("test.in","r",stdin);

    cin >> n >> m; ans = n;
    for (i = 1; i <= n; i++) {
        pos[i] = 1;
        for (j = 1; j <= m; j++) cin >> ord[i][j];
    }

    for (int step = 1; step < m; step++) {
        for (i = 1; i <= m; i++) cnt[i] = 0;
        for (i = 1; i <= n; i++) {
            while (dead[ord[i][ pos[i] ]]) pos[i]++;
            cnt[ord[i][ pos[i] ]]++;
        }

        int bg = 1;
        for (i = 1; i <= m; i++)
            if (cnt[i] > cnt[bg])
                bg = i;

        ans = min(ans, cnt[bg]);
        dead[bg] = true;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 640
c = [list(map(int, input().split())) for i in range(3)]
x = [0 for i in range(len(c))]
for i, line in enumerate(c):
    for j in range(len(c)):
            x[j] += line[(i+j) % len(c)]
print('Yes' if all(x[i] == x[0] for i in range(len(c))) else 'No')

Measured memory_bytes: 3060
require 'set'

n = gets.to_i

n.times do
  s = gets.chomp
  ans = Set.new
  ans << s
  (1..s.size-1).each do |i|
    ox, oy = s[0...i], s[i..-1]
    rx, ry = ox.reverse, oy.reverse
    ans << ox + oy << rx + oy << ox + ry << rx + ry <<
           oy + ox << oy + rx << ry + ox << ry + rx
  end
  puts ans.size
end


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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "No" << endl;
    }else if(a == b || b == c || c == a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main(){
  int a[10],i,n,c=0,j,b=0,jud=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    jud=1;
    b=0;
    c=0;
    for(j=0;j<10;j++){
      scanf("%d",&a[j]);
	}
    for(j=0;j<10;j++){
      if(b>a[j]&&c<a[j]) c=a[j];
      else if(b>a[j]&&c>a[j]){
	jud=0;
	break;
      }
      else if(b<a[j]&&c<a[j]&&b<c) c=a[j];
      else b=a[j];
    }
    if(jud==0) printf("NO\n");
    else printf ("YES\n");
  }
  return 0; 
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

int city[50];
int main(){
    int n,m,x,y;
    cin>>n>>m;
    for(int i;i<m;i++){
        cin>>x>>y;
        city[x-1]++;
        city[y-1]++;
    }
    for(int j;j<n;j++){
        cout<<city[j]<<endl;
    }
}



Measured memory_bytes: 256
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sortva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll mod=1e9+7;
ll const maxn=1e5+5;
ll const inf=1e18;
bool ss(const pair<ll,ll> &a, const pair<ll,ll> &b) { 
    return a.first*b.second+a.second<b.first*a.second+b.second;
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {     
    bool prim[n+1]; 
    memset(prim, true, sizeof(prim)); 
  
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) { 
            for (int i=p*p; i<=n; i += p) 
                prim[i] = false; 
        } 
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v; 
}
bool check(string s){
    ll l=0,r=sz(s)-1;
    while(l<=r){
        if(s[l]!=s[r])return false;
        l++;
        r--;
    }
    return true;
}
int main(){

    fio;
    ll n,k;
    cin>>n>>k;
    string dp[maxn];
    vi a(n);
    fr1(i,n)cin>>a[i];
    sortva(a);
    fr(i,0,k)dp[i]="Second";
    fr(i,a[0],k){
        fr1(j,n){
            if(i>=a[j])
            if(dp[i-a[j]]=="Second"){dp[i]="First";break;}
        }
    }
    cout<<dp[k];
    return 0;
}

Measured memory_bytes: 5760
N=int(input())
H=list(map(int,input().split()))
ans=[]
count = 0
for i in range(N-1):
    if H[i]>=H[i+1]:
        count+=1
    else:
        ans.append(count)
        count=0
else:
    ans.append(count)
print(max(ans))

Measured memory_bytes: 15020
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
struct node {
	int parent, left, right;
};
void setDepth(int i, int d, vector<int>& D, vector<node>& A) {
	D[i] = d;
	if (A[i].left != -1)setDepth(A[i].left, d + 1, D,A);
	if (A[i].right != -1)setDepth(A[i].right, d + 1, D,A);
}
int setHeight(int i , vector<int>& H, vector<node>& A) {
	int h1 = 0;
	int h2 = 0;
	if (A[i].left != -1) h1=setHeight(A[i].left, H, A)+1;
	if (A[i].right != -1)h2=setHeight(A[i].right, H, A)+1;
	return H[i]=max(h1,h2);
}
int main() {
	int N;
	cin >> N;
	vector<node> A(N);
	vector<int> D(N);
	vector<int> H(N);
	for (int i = 0; i < N; i++)A[i].parent = A[i].left = A[i].right = -1;
	for (int i = 0; i < N; i++)
	{
		int id;
		cin >> id;
		cin >> A[id].left;
		cin >> A[id].right;
		if (A[id].left != -1)A[A[id].left].parent = id;
		if (A[id].right != -1)A[A[id].right].parent = id;
	}
	int root = 0;
	for (int i = 0; i < N; i++)
	{
		if (A[i].parent == -1)root = i;
	}
	setDepth(root, 0, D, A);
	setHeight(root,  H,A);
	int height = *max_element(D.begin(),D.end());
	for (int i = 0; i < N; i++)
	{
		string type;
		if (A[i].parent == -1)type = "root";
		else if (A[i].left == -1 && A[i].right == -1)type = "leaf";
		else type = "internal node";

		int sibling;
		if (type == "root")sibling = -1;
		else{
			if (i == A[A[i].parent].left)sibling = A[A[i].parent].right;
			else if (i == A[A[i].parent].right)sibling = A[A[i].parent].left;
			else sibling = -1;
		}
		cout<< "node "<<i<<": parent = "<<A[i].parent<<", sibling = "<< sibling <<", degree = "<<((A[i].left!=-1)+(A[i].right!=-1))<<", depth = "<<D[i]<<", height = "<<H[i]<<", "<<type<<endl;
	}

};


Measured memory_bytes: 3212
import java.lang.Math;
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        int inf = 1000000000;

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();

        String[] meiro = new String[h];

        for(int i = 0; i < h; i++){
            meiro[i] = sc.next();
        }

        int[][] grh = mapping(h,w,meiro);
        int size = grh[0].length;

        // grh[0] = daik(grh,0);

        System.out.print(war(grh));
    }

    static int war(int[][] map){
        int inf = 1000000000;
        int ans = 0;
        int n = map[0].length;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                for(int k = 0; k < n; k++){
                    map[j][k] = Math.min(map[j][k],map[j][i]+map[i][k]);
                }
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ans = Math.max(ans,map[i][j]);
            }
        }
        return ans;
    }

    static int[][] mapping(int h,int w,String[] meiro){
        int inf = 1000000000;

        char[][] Meiro = new char[h][w];
        int size = 0;
        int[] ichi = new int[h*w];
        for(int i = 0; i < h; i++){
            Meiro[i] = meiro[i].toCharArray();

            for(int j = 0; j < w; j++){
                if(Meiro[i][j] == '.'){
                    ichi[size] = i*w + j;
                    size++;
                }
            }
        }
        System.out.print("\n\n");

        int[][] grh = new int[size][size];
        for(int i = 0; i < size; i++){
            for(int j = 0; j < size; j++){
                grh[i][j] = inf;
            }
        }

        for(int i = 0; i < size; i++){
            grh[i][i] = 0;
        }

        for(int i = 0; i < size; i++){
            for(int j = 0; j < i; j++){
                if(ichi[j]/w==ichi[i]/w && Math.abs(ichi[j]-ichi[i]) == 1){
                    grh[i][j] = 1;
                    grh[j][i] = 1;
                }
                if(ichi[j] % w == ichi[i] % w && Math.abs(ichi[j] / w - ichi[i] / w ) == 1){
                    grh[i][j] = 1;
                    grh[j][i] = 1;
                }
                
            }
        }
        return grh;
    }
}

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

typedef long long ll;

const int MOD = 1000000007;

int main() {
    ll X;
    cin >> X;
    ll total;
    for (int i = -200; i <= 200; i++) {
        for (int j = -200; j <= 200; j++) {
            ll a, b;
            a = pow(i, 5);
            b = pow(j, 5);
            total = a - b;
            if (X == total) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
const long long md=998244353;
long long n,s,a[3333],dp[6666],ans;
int main()
{
	cin>>n>>s;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==s)
		{
			ans+=i*(n-i+1);
			ans%=md;
		}
		else if(a[i]<s)
		{
			ans+=dp[s-a[i]]*(n-i+1);
			ans%=md;
		}
		for(int j=s;j>=0;j--)
		{
			if(j+a[i]>s)
			{
				continue;
			}
			dp[j+a[i]]+=dp[j];
			dp[j+a[i]]%=md;
		}
		dp[a[i]]+=i;
		dp[a[i]]%=md;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f(int a){
  if (a < 0) return 0;
  return 1LL * a * (a - 1) / 2;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n), cnt(n + 1);
  vector<long long> com(n + 1);
  for (auto& x : a) cin >> x, cnt[x]++;
  long long sum = 0;
  for (int i = 0; i <= n; i++) com[i] = f(cnt[i]), sum += com[i];
   for (int k = 0; k < n; k++) {
    long long ans = sum - f(cnt[a[k]]);
    ans += f(cnt[a[k]] - 1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,a[100001]; long long f[100001];
    cin >> n >> a[1];
    a[0]=f[0]=1000000001; f[1]=0;
    for (int i=2 ;i <= n; i++)
    {
        cin>>a[i];
        f[i]=min(f[i-1]+abs(a[i-1]-a[i]),f[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<f[n];
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  int ans = 0;
  FORS(i, K + 1, N) {
    int remain = (N % i == 0) ? -1 : N % i;
    ans += N / i * (i - K);
    ans += max(0ll, remain - (K == 0 ? 0 : (K - 1)));
    // if (i < K + 10)
    //   DEBUG(ans);
  }
  print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

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

    int N;cin >> N;
    int K;cin >> K;
    vector<int> vec;
  //  vec.push_back(0);
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
    }
  //  vec.push_back(0);
    LL ans = -1e9;
    for(int a = 0;a <= N;a++){
        for(int b = 0;b <= N;b++){
            if(a + b > K)break;
            if(a + b > N)break;
            LL calc = 0;
            vector<int> q;
            for(int c = 0;c < a;c++){
                calc += vec.at(c);
                if(vec.at(c) < 0)q.push_back(vec.at(c));
            }
            //cout<<calc<<endl;
            for(int d = 0;d < b;d++){
                calc += vec.at(N-d-1);
                if(vec.at(N-d-1) < 0)q.push_back(vec.at(N-d-1));
            }
            //cout<<calc<<endl;
            sort(q.begin(),q.end());
    //        cout<<calc<<endl;
            for(int i = 0;i < min((int)q.size(), K - a - b);i++){
                calc -= q.at(i);
            }
            ans = max(ans, calc);
          //  cout<<calc<<" "<<a<<" "<<b<<endl;
            //cout<<ans<<endl;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
b_1 = []
a_N = []
ab = []
for i in range(M):
    a,b = map(int, input().split())
    if a == 1:
        b_1.append(b)
    if b == N:
        a_N.append(a)
    ab.append((a,b))
    
if len(set(b_1) & set(a_N)) >= 1:
    print('POSSIBLE')
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 39252
import heapq


def main():
    _ = input()
    v = [int(x) for x in input().split()]
    heapq.heapify(v)

    while len(v) >= 2:
        x = heapq.heappop(v)
        y = heapq.heappop(v)
        z = (x+y)/2
        heapq.heappush(v, z)
    print(v[0])


if __name__ == '__main__':
    main()

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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    if (n % 2 == 1){
        cout << "No";
        return 0;
    }
    for (int i = 0; i < n / 2; i++){
        if (s[i] != s[i + n/2]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a*b%2==1) co("Odd");
  else co("Even");
  
  return 0;
}


Measured memory_bytes: 256
using System;
 
class Program{
	public static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			int[] n = Array.ConvertAll(s.Split(' '), int.Parse);

			int a = GCD(n[0], n[1]);
			Console.WriteLine(a + " " + n[0]/a*n[1]);
		}
	}

	static int GCD(int x, int y) {
		if(y == 0) return x;
		return GCD(y, x % y);
	}
}

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

char x;

int main() {
  cin >> x;
  if (x <= 'Z') cout << "A" << endl; 
  else cout << "a" << endl;
  return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

typedef long long ll;

const int MAXN = 2e5 + 10;

int n;
ll ans;

int main() {
    IO::read(n);
    rep(i, 1, n) ans += 1ll * (n - i + 2) * (n - i + 1) / 2;
    rep(i, 1, n - 1) {
        int a, b;
        IO::read(a), IO::read(b);
        if (a > b) swap(a, b);
        ans -= 1ll * a * (n - b + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3764
import math
ndev2 = 0

while True:
    n = int(input())
    if n == 0:
        break
    scores = list(map(int, input().split()))
    avg = sum(scores) / len(scores)
    for i in range(n):
        ndev2 += (scores[i] - avg) ** 2

    dev2 = ndev2 / len(scores)
    dev = math.sqrt(dev2)
    print(dev)
    ndev2 = 0


Measured memory_bytes: 5704
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}


int main() {
	//file();
	fast();
	int n; cin >> n;
	vi v1(n);
	map<int, ll> mp;
	for (auto& it : v1) {
		cin >> it;
		mp[it]++;
	}
	vi Give(n);
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans += mp[v1[i]] - 1LL;
	for (int i = 0; i < n; i++)
		cout << (ans - (mp[v1[i]] - 1) * 2LL) / 2 << endl;
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main()
{
	char n[5];
	cin>>n;
	if(n[0]==n[1]&&n[0]==n[2])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(n[1]==n[2]&&n[1]==n[3])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(n[2]==n[3]&&n[2]==n[4])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(n[0]==n[1]&&n[0]==n[2]&&n[0]==n[3]&&n[0]==n[4])
	{
		cout<<"Yes"<<endl;
		return 0;
	}	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;

#define M 1000001
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }
int h(int key, int i){ return (h1(key) + i*(h2(key))) % M; }

int find(char str[]){
    long long key;
    long long i = 0;
    key = getKey(str);
    while(i < M){
        int j = h(key, i);
        if(strcmp(H[j], str) == 0) return 1;
        else if (strlen(H[j]) == 0) return 0;
        else i++;
        
    }
    return 0;

}

int insert(char str[]){
    long long key;
    key = getKey(str);
    long long i = 0;
    while(i < M){
        int j = h(key, i);
        if(strlen(H[j]) == 0){
            strcpy(H[j], str);
            return 0;
        } else i++;
        
    }
    return 0;

}

int main(){
    int i, n;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16832
# 初期入力 readlineだけで1950ms⇒1234ms
#                           PyPy   ⇒867ms
from collections import defaultdict
from collections import deque
import sys
input = sys.stdin.readline
N,Q = (int(x) for x in input().split())

connection ={i:set() for i in range(1,N+1)}
for i in range(1,N):
    a,b = (int(i) for i in input().split())
    connection[a].add(b)
    connection[b].add(a)
nord_point = defaultdict(lambda: 0)
for i in range(1,Q+1):
    a,b = (int(i) for i in input().split())
    nord_point[a] +=b

#BSF

dq =deque()
start =1
dq.append(start)
passed =set()
counter_dic ={i:0 for i in range(1,N+1)}
counter_dic[start] =nord_point[start]
while len(dq) >0:
    now =dq.popleft()
    passed.add(now)
    for next in connection[now]:
        if next not in passed:
            #頂点のカウンター＝親のカウンター ＋ 頂点のポイント
            counter_dic[next] =counter_dic[now] +nord_point[next]
            dq.append(next)
#出力
print(*counter_dic.values())

Measured memory_bytes: 227992
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=(n+1)/2;
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++) {
		cin>>a[i];
	}
	vector<ll> money(n + 1,1000);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < i; j++) {
			money[i] = max(money[i],money[j] - ((money[j] / a[j]) * a[j]) + ((money[j] / a[j]) * a[i]));
		}
		money[i] = max(money[i],money[i - 1]);
	}
	ll res = 1000;
	for(int i = 0; i < n; i++) {
		// cout << money[i] << endl;
		res = max(res,money[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  long double l;
  cin >> l;
  l /= 3;
  printf("%.6Lf\n", l * l * l);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MAXN 1000
//const double INF=;
using namespace std;
double sx,sy,tx,ty;
struct Circle
{
	double x,y,r;
}C[MAXN+5];
bool vis[MAXN+5];
double G[MAXN+5][MAXN+5];
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		for(int j=0;j<=MAXN+3;j++)
			G[i][j]=-1.0;
}
double Getlen(double x1,double y1,double x2,double y2)
{
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
bool Intersect(int a,int b)
{
	double len=Getlen(C[a].x,C[a].y,C[b].x,C[b].y);
	double totr=C[a].r+C[b].r;
	if(len<=totr)
		return true;
	return false;
}
int n;
double dist[MAXN+5];
double Dijkstra(int s)
{
	memset(vis,0,sizeof(vis));
	for(int i=0;i<=MAXN+3;i++)
		dist[i]=-1;
	dist[s]=0;
	vis[s]=true;
	int u=s,nu,cnt=1;
	for(int i=1;i<=n+2;i++)
	{
		double mindist=-1;
		for(int v=0;v<=n;v++)
		{
			if(G[u][v]==-1)
				continue;
			if(dist[v]>dist[u]+G[u][v]||dist[v]==-1)
				dist[v]=dist[u]+G[u][v];
			if((mindist==-1||dist[v]<mindist)&&vis[v]==false)
			{
				mindist=dist[v];
				nu=v;
			}
		}
		vis[nu]=true;
		u=nu;
	}
	return dist[n];
}
int main()
{
	Init();
	scanf("%lf %lf %lf %lf",&sx,&sy,&tx,&ty);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lf %lf %lf",&C[i].x,&C[i].y,&C[i].r);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			double len=max(Getlen(C[i].x,C[i].y,C[j].x,C[j].y)-C[i].r-C[j].r,0.0);
			if(G[i][j]==-1||len<G[i][j])
				G[i][j]=len;
		}
	for(int i=1;i<=n;i++)
	{
		double len=max(Getlen(sx,sy,C[i].x,C[i].y)-C[i].r,0.0);
		if(G[i][0]==-1||len<G[0][i])
			G[i][0]=G[0][i]=len;
		len=max(Getlen(tx,ty,C[i].x,C[i].y)-C[i].r,0.0);
		if(G[i][n+1]==-1||len<G[i][n+1])
			G[i][n+1]=G[n+1][i]=len;
	}
	n++;
	G[0][n]=G[n][0]=Getlen(sx,sy,tx,ty);
	double ans=Dijkstra(0);
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public final class Main {
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		long k = scan.nextLong();
		System.out.println(k % 2 == 0 ? a - b : b - a);
	}
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
#毎日全売り
#あとに今日より大きいがあるか　ある：買い　ない：やめ
#今日より大きいがくるまでに今日より安いがあるならスルー、ないなら買い

m = 1000
k = 0
flag = False
for i in range(N):

    m += k*A[i]
    k = 0
    low = False
    high = False
    for j in range(i+1, N):
        if A[i] < A[j]:
            high = True
            break
        elif A[i] >= A[j]:
            low = True
    if not low and high:
        k = m // A[i]
        m -= k*A[i]

print(m)

Measured memory_bytes: 9200