akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 100 + 7;
const int mod = 1e9 + 7;

int a, b;
char s;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGm
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> a >> s >> b;
    if ( s == '-' ) a -= b;
    else a += b;
    cout << a;
}



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

const int INF = 100;

int A, B, C;
int ans = 0;

int main(){
    cin >> A >> B >> C;
    while(A!=B || A!=C) {
        if (A>B && A>C) {
            B++; C++;
        } else if (B>A && B>C) {
            A++; C++;
        } else if (C>A && C>B) {
            A++; B++;
        } else if (A==B) {
            C += 2;
        } else if (B==C) {
            A += 2;
        } else if (C==A) {
            B += 2;
        } 
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>

int main(){
  
  long long int N, tmp;
  std::vector<long long int> h;
  
  scanf("%lld", &N);
  for(int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    h.push_back(tmp);
  }
  
  // solve problem
  // min_cost[i] = minimum cost to reach i-th step
  std::vector<long long int> min_cost;
  for(int i = 0; i < N; i++){
    min_cost.push_back(0);
  }
  min_cost[1] = std::abs(h[0] - h[1]);
  
  for(int i = 2; i < N; i++){
    min_cost[i] = std::min(min_cost[i-2] + std::abs(h[i]-h[i-2]), min_cost[i-1] + std::abs(h[i]-h[i-1]));
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << min_cost[N-1] << std::endl;
  
  return 0;
}


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

int n;
vector<string> res;
vector<string> three = {"abb", "a.c", "ddc"};
vector<string> four = {"abcc", "abdd", "eefg", "hhfg"};
vector<string> five = {"abc..", "abc..", "deeff", "d.ghh", "iigjj"};
vector<string> six = {"abc...", "abc...", "d.eeff",
                      "dghh..", ".g.ijj", "kk.ill"};
vector<string> seven = {"abc....", "abc....", "def....", "def....",
                        "g..hhii", "g..jjkk", ".llmmnn"};
bool solve();

int main() {
  cin >> n;
  if (solve())
    for (int i = 0; i < n; ++i) cout << res[i] << endl;
  else
    cout << "-1" << endl;
  return 0;
}

bool solve() {
  if (n == 3) {
    res = three;
    return 1;
  } else if (n >= 4) {
    int now = 0;
    res.assign(n, string(n, '.'));
    vector<string> tmp;
    if (n % 4 == 0)
      tmp = four;
    else if (n % 4 == 1)
      tmp = five;
    else if (n % 4 == 2)
      tmp = six;
    else
      tmp = seven;
    for (int i = 0; i < tmp.size(); ++i)
      for (int j = 0; j < tmp[i].size(); ++j) res[i][j] = tmp[i][j];
    now += tmp.size();
    while (now < n) {
      for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j) res[i + now][j + now] = four[i][j];
      now += 4;
    }
    return 1;
  }
  return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;

int n;
vector<string> s;
vector<int> r, c;
vector<bool> ch;

void solve(int now);

int main() {
  cin >> n;
  s.assign(n, string(n, '.'));
  r.assign(n, 0);
  c.assign(n, 0);
  ch.assign(n + 1, 0);
  ch[0] = 1;
  solve(0);
  return 0;
}

void solve(int now) {
  if (now == n * n) {
    int num = r[0];
    if (ch[num]) return;
    for (int i = 0; i < n; ++i)
      if (num != r[i] || num != c[i]) return;
    cout << num << endl;
    ch[num] = 1;
    for (int i = 0; i < n; ++i) cout << s[i] << endl;
    return;
  }
  int x = now / n, y = now % n;
  if (x >= 1 && r[x - 1] != r[0]) return;
  if (x == n - 1 && y >= 1 && r[0] != c[y - 1]) return;
  if (s[x][y] == '.') {
    if (x < n - 1) {
      s[x][y] = s[x + 1][y] = '|';
      ++r[x], ++r[x + 1], ++c[y];
      solve(now + 1);
      s[x][y] = s[x + 1][y] = '.';
      --r[x], --r[x + 1], --c[y];
    }
    if (y < n - 1 && s[x][y + 1] == '.') {
      s[x][y] = s[x][y + 1] = '-';
      ++r[x], ++c[y], ++c[y + 1];
      solve(now + 1);
      s[x][y] = s[x][y + 1] = '.';
      --r[x], --c[y], --c[y + 1];
    }
  }
  solve(now + 1);
}
*/

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

int main()
{
	int x;
	int n = 1; 
	int d[10000]; 
	cin >> x;

	while (x != 0)
	{
		d[n] = x;
		n++;
		cin >> x;
	}


	for (int i = 1; i < n; i++)
	{
		cout << "Case" << " " << i << ":" << " " << d[i] << "\n";
	}

	return 0;
}

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

if L < 0 and N + L - 1 > 0:
    print(sum(range(L, N + L)))
else:
    if abs(L) > abs(N + L - 1):
        print(sum(range(L, N + L)) - (N + L - 1))
    else:
        print(sum(range(L, N + L)) - L)


Measured memory_bytes: 2940
def main():
	N = int(input())
	SE = [0]*(N)
	for i in range(N):
		SE[i] = list(map(int, input().split()))
	SE.sort(key=lambda x: (x[1], -x[0]))
	time_passsed = 0
	finish_possilbe = True
	for i in range(N):
		time_passsed += SE[i][0]
		if time_passsed > SE[i][1]:
			finish_possilbe = False
			break
	if finish_possilbe:
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()

Measured memory_bytes: 72500
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	string s , t;
	cin >> s >> t;
	priority_queue<char , vector<char> , greater<char> > q;
	priority_queue<char> q2;

	rep(i,0,s.size()){
		q.push(s[i]);
	}
	string s2 = "";
	while(!q.empty()){
		s2 += q.top();
		q.pop();
	}

	rep(i,0,t.size()){
		q2.push(t[i]);	
	}
	string t2 = "";
	while(!q2.empty()){
		t2 += q2.top();
		q2.pop();
	}
	
	if(s2 < t2 ){
		Yes;
	}
	else
		No;
	ret 0;

}

Measured memory_bytes: 256
import math
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
cnt1 = 0
cnt2 = 0
for i in range(n-1):
  cnt = 0
  for j in range(i+1,n):
    if p[i] > p[j]:
      cnt += 1
  cnt1 += cnt*math.factorial(n-(i+1))

for i in range(n-1):
  cnt = 0
  for j in range(i+1,n):
    if q[i] > q[j]:
      cnt += 1
  cnt2 += cnt*math.factorial(n-(i+1))

print(abs(cnt1 - cnt2))

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

using namespace std;

int main() {
    int N, K, Q, A;
    cin >> N >> K >> Q; cin.ignore();

    vector<int> points(N, K), deductions(N, 0);
    for(int i = 0; i < Q; i++) {
        cin >> A; cin.ignore();
        deductions[A-1]++;
    }

     for(int i = 0; i < N; i++) {
         if (points[i] - Q + deductions[i] > 0) {
             cout << "Yes" << endl;
         } else {
             cout << "No" << endl;
         }
     }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

struct train {
    int c,s,f;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<train> v(n-1);
    rep(i,n-1) cin >> v[i].c >> v[i].s >> v[i].f;
    rep(i,n) {
        int now = 0;
        rep2(j,i,n-1) {
            int dep;
            if(now <= v[j].s) {
                dep = v[j].s;
            } else {
                dep = (now+v[j].f-1)/v[j].f*v[j].f;
            }
            now = dep+v[j].c;
//            cout << dep << " " << now << endl;
        }
        cout << now << endl;
    }
}


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

ll C(ll n) {
  ll T = 1;
  int D = 0;
  while(T <= n) T *= 10, D++;
  ll ret = 0;
  for(int d=0; d<D; d++) {
    ll all = n - T / 10 + 1;
    ll fizz = n / 3 - (T / 10) / 3;
    ll buzz = n / 5 - (T / 10 - 1) / 5;
    ll fizzbuzz = n / 15 - (T / 10) / 15;
    ll sum = (all - fizz - buzz + fizzbuzz) * (D - d);
    sum += (fizz + buzz) * 4;
    ret += sum;
    T /= 10;
    n = T - 1;
  }

  return ret;
}

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

  ll L = 0, H = 1e17;
  while(L + 1 < H) {
    ll M = (L + H) / 2;
    (C(M) < n ? L : H) = M;
  }

  string res;
  for(ll i = L + 1; i < L + 22; i++) {
    if(i % 3 == 0) res += "Fizz";
    if(i % 5 == 0) res += "Buzz";
    if(i % 3 && i % 5) res += to_string(i);
  }

  ll p = C(L) + 1;

  for(int i=0;; i++) {
    assert(i < res.size());
    if(p >= n + 20LL) break;
    if(n <= p) cout << res[i];
    p ++;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3252
#include<stdio.h>

int main(){
  int i,k;
  int count = 0;
  int N;
  int H[22];
  scanf("%d",&N);
  for(i=0;i<=N-1;i++)
    scanf("%d",&H[i]);
  for(i=0;i<=N-1;i++){
    for(k=0;k<=i-1;k++){
      if(H[i] < H[k])
      goto not;
      };
    count++;
    not:;
    };
  printf("%d",count);
}

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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int xp = 0, xn = 0; 
  int idxp = 0, idxn = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > xp) {idxp = i; xp = x;}
    if (x < xn) {idxn = i; xn = x;}
  }
  cout << 2*n-1 << endl;
  int pivot  = idxn;
  if (xp > - xn) pivot = idxp;
  
  for (int i = 0; i < n; i++)  
    cout << pivot+1 << " " << i+1 << endl;
  
  if (pivot == idxp)  
  for (int i = 0; i < n-1; i++)
    cout << i+1 << " " << i+2 << endl;
  else
  for (int i = 0; i < n-1; i++)
    cout << n-i << " " << n-i-1 << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(m);
	vector<int> d(m);

	for(int i=0; i<n; i++){
		cin >> a.at(i) >> b.at(i);
	}
	for(int i=0; i<m; i++){
		cin >> c.at(i) >> d.at(i);
	}

	int ans=0;
	int dis;
	int mindis;
	for(int i=0; i<n; i++){
		ans=0;
		mindis=abs(c.at(0)-a.at(i))+abs(d.at(0)-b.at(i));
		for(int p=1; p<m; p++){
			dis=abs(c.at(p)-a.at(i))+abs(d.at(p)-b.at(i));
			if(dis<mindis){
				mindis=dis;
				ans=p;
			}
		}
		ans ++;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = ni()
li = make_divisors(n)
ans = 10000000000000000
for i in range(len(li) // 2):
    if li[i] * li[-(i+1)] == n:
        f = max(len(str(li[i])), len(str(li[-(i+1)])))
        ans = min(f, ans)
if len(li) % 2 != 0:
    if len(li) == 1:
        ans = 1
    else:
        print()
        ans = min(len(str(li[len(li)//2])), ans)
print(ans)


Measured memory_bytes: 3952
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

ll dp[2010][2010];
int main(){
	int n, m; cin >> n >> m;
	int s[2010], t[2010];
	for (int i = 1; i <= n; ++i)cin >> s[i];
	for (int i = 1; i <= m; ++i)cin >> t[i];
	for (int i = 0; i <= n; ++i)dp[i][0] = 1;
	for (int i = 0; i <= m; ++i)dp[0][i] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i] == t[j]) {
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			}
			else {
				dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1];
				dp[i][j] += INF;
			}
			dp[i][j] %= INF;
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    int cnt = 0;
    vi p(N);
    REP(i, N) {
        cin >> p[i];
        if (p[i] != i + 1) cnt++;
    }

    cout << (cnt > 2 ? "NO" : "YES") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] map = new char[H][W];
    for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();

    boolean[] emptyH = new boolean[H];
    boolean[] emptyW = new boolean[W];
    int newH = H;
    int newW = W;
    for (int i = 0; i < H; i++) {
      emptyH[i] = true;
      for (int j = 0; j < W; j++) emptyH[i] &= map[i][j] == '.';
      if (emptyH[i]) newH--;
    }
    for (int i = 0; i < W; i++) {
      emptyW[i] = true;
      for (int j = 0; j < H; j++) emptyW[i] &= map[j][i] == '.';
      if (emptyW[i]) newW--;
    }
    char[][] res = new char[newH][newW];
    int ii = 0;
    for (int i = 0; i < H; i++) {
      if (!emptyH[i]) {
        int jj = 0;
        for (int j = 0; j < W; j++) {
          if (!emptyW[j]) {
            res[ii][jj] = map[i][j];
            jj++;
          }
        }
        ii++;
      }
    }
    for (int i = 0; i < newH; i++) {
      for (int j = 0; j < newW; j++) System.out.print(res[i][j]);
      System.out.println();
    }
  }
}


Measured memory_bytes: 27432
#include<stdio.h>
int main(){
	int S,h,m,s,t;
	scanf("%d", &S);
	h = S / 3600;
	t = S % 3600;
	m = t / 60;
	s = t % 60;
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

Measured memory_bytes: 592
/*input
2 11 4
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=1e5+5;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(b/a,c);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int dx[] ={-1,0,1,-1,0,1,-1,0,1};
string str;
int check(int rl){
  int res = 0, t = str[0]-'1', x = dx[t];
  for(int i=1;i<str.size();i++){
    t = str[i]-'1';
    if((rl%2==0 && x<dx[t]) ||(rl%2==1 && x>dx[t]))res++,rl++;
    rl++,x = dx[t];
  }
  return res;
}

int main() {
  while(1){
    cin >> str;
    if(str == "#") break;
    cout << min(check(1),check(0)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007


int32_t main(){
    IOS;

int n,c;
cin>>n>>c;
int w[n],v[n];
for(int i=0;i<n;i++)
cin>>w[i]>>v[i];

int dp[n+1][c+1];
for(int i=0;i<=n;i++)
{
    for(int j=0;j<=c;j++)
    {
        if(i==0 || j==0)
        dp[i][j] = 0;

        else if(w[i-1] <= j)
        dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i-1]] + v[i-1]);

        else
        {
            dp[i][j] = dp[i-1][j];
        }
        
    }
}

cout<<dp[n][c]<<endl;

}


Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    int n = (int) s1.length();
    for(int i = 0; i < n; i++) {
        rotate(s1.begin(), s1.begin() + 1, s1.end());
        if(s1 == s2) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, a;
  cin >> n;
  vector<int> v(n);
  rep(i,n-1) {
    cin >> a;
    v[a-1]++;
  }
  rep(i,n) cout << v[i] << endl;
}

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

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

int x[510][510],rui[510][510];

int main(){
  int n,m,q;
  cin >> n >> m >> q;
  //vector<vector<int>> x(n,vector<int>(n+1,0));
  for(int i=0;i<m;++i){
    int l,r;
    cin >> l >> r;
    x[l][r]++;
  }
  //vector<vector<int>> rui(n+2,vector<int>(n+2,0));
  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j){
      rui[i][j]=rui[i][j-1]+x[i][j];
    }
  }
  vector<int> ans;
  for(int i=0;i<q;++i){
    int l,r;
    cin >> l >> r;
    int cal=0;
    for(int j=l;j<=r;++j){
      cal+=rui[j][r]-rui[j][l-1];
    }
    ans.push_back(cal);
  }
  int k=ans.size();
  for(int i=0;i<k;++i) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5784
main :: IO ()
main = do
  [n, k] <- map read.words <$> getLine :: IO [Int]
  if odd k
    then
      print $ (n `div` k) ^ 3
    else let m = (n `div` (k`div`2))
      in if odd m
        then print $ (m`div`2+1) ^ 3 + (m`div`2) ^ 3
        else print $ (m`div`2) ^ 3 + (m`div`2) ^ 3


Measured memory_bytes: 508
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,maxa;
  scanf("%d %d %d",&a,&b,&c);
  maxa=max(a,b);
  maxa=max(maxa,c);
  printf("%d\n",a+b+c+maxa*9);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,ans=LLONG_MAX;
  cin >>n;
  for(long long int i=1;i<=pow(n,0.5)+1;i++){
    if(n%i==0 && ans>i+(n/i)-2)ans=i+(n/i)-2;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    string s;
    cin >> s;
    ll cnt = 0;
    for (ll i=0;i<s.length();i++){
        if(s[i] == 'o'){
            cnt++;
        }
    }
    if(cnt + (15 - s.length()) >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = ['402351', '152304', '310542', '215043']   
t = []
t.append(a)
i = 0; j = 0
while True:
    if t[i][0] == b[0] and t[i][1] == b[1]:
        ans = "Yes" if t[i][2] == b[2] and t[i][3] == b[3] else "No"
        print(ans)
        break
    if i == len(t)-1: # add if it finishes searching all path
        for h in range(len(s)):
            t.append([ t[j][int(k)] for k in list(s[h]) ])
        j+=1
    i+=1


Measured memory_bytes: 5608
import math
input = raw_input

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

x = sum(B)
for i in range(1, N):
    if A[i] - A[i-1] == 1:
        x += C[A[i-1]-1]
print(x)


Measured memory_bytes: 27884
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    int a[n];
    int count = 0;
    for(auto &i:a) cin >> i;
    bool flag = true;
    while(flag){
        flag = false;
        for(int j=n-1;j>=1;j--){
            if(a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                flag = true;
                count++;
            }
        }
    }
    for(int i=0;i<n-1;i++) cout << a[i] << " ";
    cout << a[n-1] << endl << count << endl;
}


Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
const int INF = 1<<31;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int LL;

string s;

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

    cin >> s;

    /*int mx=0;

    FOR(i,0,(int)s.size()){
        FOR(j,i,(int)s.size()){
            FOR(k,0,(int)s.size()-i){
                string tmp=s.substr(j,k);
                int n=(int)tmp.size();

                if(tmp[0]=='A' && tmp[n-1]=='Z'){
                    mx=max(mx,n);
                }
            }
        }
    }
    cout << mx << endl;
    */
    int idx1=-1,idx2=0;
    FOR(i,0,(int)s.size()){
        if(s[i]=='A' && idx1==-1)
            idx1=i;
        if(s[i]=='Z')
            idx2=i;
    }

    cout << abs(idx2-idx1)+1 << endl;

    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<svec> sgrid;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef unordered_map<ull,ull> ullullhmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;
const unsigned LIMIT=1e3;
const unsigned M=1e9+7;
unsigned h,w;
svec matrix;
int dp[LIMIT+1][LIMIT+1];

ull calculate(unsigned row,unsigned col)
{
    ull res=0;
    if(dp[row][col]!=-1)
        return dp[row][col];
    if(row==h && col == w)
    {
        return 1;
    }
    if(row !=h && matrix[row+1-1][col-1]=='.')
    {
        // res=(res + calculate(row+1,col))%M;
        res += calculate(row+1,col);
        if(res>=M)
            res-=M;
        
    }
    if(col!=w && matrix[row-1][col+1-1]=='.')
    {
        // res=(res + calculate(row,col+1))%M;
        res+=calculate(row,col+1);
        if(res>=M)
            res-=M;
    }
    
    return dp[row][col]=res;
}
int main()
{
    cin>>h>>w;
    matrix.resize(h);
    for(unsigned i=0;i<h;++i)
    {
        cin>>matrix[i];
    }
    ull result=0;
    memset(dp,-1,sizeof dp);
    cout<<calculate(1,1);
}

Measured memory_bytes: 5376
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();	
		int sockets = 1;
		int count = 0;
		while(sockets<b) {
			sockets--;
			sockets+=a;
			count++;
		}
		System.out.println(count);

	}

}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(),a.end());
    ll ans = 0,b = a[n/2];
    for(int i = 0; i < n; i++){
        ans += abs(a[i]-b);
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)

print(ans)


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

using namespace std;
#define deb(x) cout << #x << ": " << x << endl
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fkn(i, k, n) for (i = k; i < n; i++)
#define ll long long
#define F first;
#define S second;
#define PB(x) push_back(x);
#define MP(x,y) make_pair(x,y);
typedef vector<ll> vll;

bool powerOfTwo(ll x)
{
    return !(x & (x - 1));
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    
    if(n%1000 == 0)
    {
        cout<<0<<endl;
    }
    else{
       ll ans =1000 - n%1000;
    cout <<ans;  
    }
     
    
}




Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 504
/*
ID: varunra2
LANG: C++
TASK: a
*/

#include<bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif

#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second

const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions


int main() {

  cin.sync_with_stdio(0); cin.tie(0);

  int n;
  cin >> n;

  ll d;
  cin >> d;
  d = d * d;
  int cnt = 0;

  for(int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    if(x*x + y*y <= d) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

struct Edge {
    int to, cost;
};

int main() {
    int s, d; // hot springs, districts
    while (cin >> s >> d, s || d) {
        vector<vector<Edge>> G(s+d);
        int t;

        // edge: hot springs -> districts
        for (int i=0; i<s; ++i) {
            for (int j=0; j<d; ++j) {
                cin >> t;
                if (t != 0) {
                    G[i].push_back((Edge){s+j, t});
                }
            }
        }
        // edge: districs <-> districts
        for (int i=0; i<d; ++i) {
            for (int j=i+1; j<d; ++j) {
                cin >> t;
                if (t != 0) {
                    G[s+i].push_back((Edge){s+j, t});
                    G[s+j].push_back((Edge){s+i, t});
                }
            }
        }

        // visited list & table
        vector<int> vpt;
        bool visited[200] = {false};
        for (int i=0; i<s; ++i) {
            vpt.push_back(i);
            visited[i] = true;
        }

        int res = 0;
        while ((int)vpt.size() < s+d) {
            int min_cost = INT_MAX;
            int to = -1;
            for (int i=0; i<(int)vpt.size(); ++i) {
                int from = vpt[i];
                for (int j=0; j<(int)G[from].size(); ++j) {
                    Edge e = G[from][j];
                    if ( ! visited[e.to] && e.cost < min_cost) {
                        min_cost = e.cost;
                        to = e.to;
                    }
                }
            }
            res += min_cost;
            vpt.push_back(to);
            visited[to] = true;
        }

        cout << res << endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans0 = 0;
  int ans1 = 0;
  int ans = 0;
  
  //0start
  string s0 = s;
  if (s0[0] == '1') ans0++;
  s0.replace(0, 1, "0");
  for (int i=1; i<s.size(); i++){
    if (s0[i-1] == s0[i]){
      ans0++;
      if(s0[i] == '0') {
        s0.replace(i, 1, "1");
      } else if (s0[i] == '1') {
        s0.replace(i, 1, "0");
      }
    }
  }
  
  //1start
  string s1 = s;
  if (s1[0] == '0') ans1++;
  s1.replace(0, 1, "1");
  for (int i=1; i<s.size(); i++){
    if (s1[i-1] == s1[i]){
      ans1++;
      if(s1[i] == '0') {
        s1.replace(i, 1, "1");
      } else if (s1[i] == '1') {
        s1.replace(i, 1, "0");
      }
    }
  }
  
  ans = min(ans0, ans1);
  cout << ans << endl;
  //cout << s << endl;
  //cout << s0 << endl;
  //cout << s1 << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n;
		double[] x = new double[111];
		double[] y = new double[111];
		double p, d;
		n = input.nextInt();
		for(int i = 0; i < n; i++)
		{
			x[i]=input.nextDouble();
		}
		for(int i = 0; i < n; i++)
		{
			y[i]=input.nextDouble();
		}
		p = 0;
		for(int i = 0; i < n; i++)
		{
			p += Math.abs(x[i] - y[i]);
		}
		System.out.println(p);
		
		p=0;
		for(int i = 0; i < n; i++)
		{
			p += Math.pow(x[i] - y[i], 2);
		}
		System.out.println(Math.sqrt(p));

		p=0;
		d=1.0/3;
		for(int i = 0; i < n; i++)
		{
			p += Math.pow(Math.abs(x[i] - y[i]), 3);
		}
		System.out.println(Math.pow(p, d));

		p = Math.abs(x[0] - y[0]);
		for(int i = 0; i < n; i++)
		{
			if(p < Math.abs(x[i] - y[i]))
			{
				p = Math.abs(x[i] - y[i]);
			}
		}
		System.out.println(p);
		input.close();
	}
}

Measured memory_bytes: 29040
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    set<int> D;
    REP(i, n){
        int tmp;cin >> tmp;
        D.insert(tmp);
    }
    cout << D.size() << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)
	s := make([]string, h)
	res := make([][]rune, h)
	for i := 0; i < h; i++ {
		res[i] = make([]rune, w)
		for j := 0; j < w; j++ {
			res[i][j] = '0'
		}
		fmt.Scanf("%s", &s[i])
	}
	for i, str := range s {
		for j, ch := range str {
			if ch == '#' {
				res[i][j] = '#'
				iG0 := i > 0
				iLh := i + 1 < h
				jG0 := j > 0
				jLw := j + 1 < w

				if iG0 && res[i-1][j] != '#' {
					res[i-1][j]++
				}
				if jG0 && res[i][j-1] != '#' {
					res[i][j-1]++
				}
				if iLh && res[i+1][j] != '#' {
					res[i+1][j]++
				}
				if jLw && res[i][j+1] != '#' {
					res[i][j+1]++
				}
				if iG0 && jG0 && res[i-1][j-1] != '#' {
					res[i-1][j-1]++
				}
				if iG0 && jLw && res[i-1][j+1] != '#' {
					res[i-1][j+1]++					
				}
				if iLh && jLw && res[i+1][j+1] != '#' {
					res[i+1][j+1]++
				}
				if iLh && jG0 && res[i+1][j-1] != '#' {
					res[i+1][j-1]++
				}
			}
		}
	}
	for _, str := range res {
		fmt.Println(string(str))
	}
}

Measured memory_bytes: 512
def resolve():
    N=int(input())
    T, X, Y = [0] *(N+1) , [0] *(N +1), [0] * (N+1)
    for i in range(N):
        T[i+1], X[i+1], Y[i+1] = map(int, input().split())

    def main():
        for i in range(N):
            if T[i+1]-T[i]==abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i]):
                continue
            else:
                if T[i + 1] - T[i] > abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])\
                and (T[i + 1] - T[i])%2==(abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i]))%2:

                    continue
                else:
                    return 'No'
        return 'Yes'

    print(main())



resolve()

Measured memory_bytes: 47448
/*program from Wolfycz*/
#include<map>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e5,p=1e9+7;
const int A[4][4]={
	{1,1,1,1},
	{0,1,0,1},
	{0,0,1,1},
	{1,1,1,2},
};
const int B[4][4]={
	{1,1,1,1},
	{0,1,0,1},
	{0,0,1,1},
	{0,0,0,1},
};
struct Matrix{
	int v[4][4];
	Matrix(){memset(v,0,sizeof(v));}
	void clear(){memset(v,0,sizeof(v));}
	void init(){for (int i=0;i<4;i++)	v[i][i]=1;}
}trans,Ans,T;
Matrix operator *(const Matrix &x,const Matrix &y){
	Matrix z;
	for (int i=0;i<4;i++)
		for (int j=0;j<4;j++)
			for (int k=0;k<4;k++)
				z.v[i][k]=(z.v[i][k]+1ll*x.v[i][j]*y.v[j][k])%p;
	return z;
}
Matrix mlt(Matrix a,int b){
	Matrix res; res.init();
	for (;b;b>>=1,a=a*a)	if (b&1)	res=res*a;
	return res;
}
int val[N+10];
int main(){
	int n=read(),m=read(),Last=0;
	memcpy(T.v,B,sizeof(B));
	memcpy(trans.v,A,sizeof(A));
	Ans.v[0][0]=1;
	Ans=Ans*trans,Last=1;
	for (int i=1;i<=m;i++){
		int x=read();
		Ans=Ans*mlt(trans,x-Last);
		Ans=Ans*T,Last=x+1;
	}
	Ans=Ans*mlt(trans,n-Last);
	printf("%d\n",Ans.v[0][3]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using vi = vector<int>;

 int main() {
   int n; cin >> n;
   vi a(n);
   int x = 0;
   rep(i, 0, n) {
     cin >> a[i];
     x = max(x, a[i]);
   }
   int y;
   int d_min = 1 << 29;
   rep(i, 0, n) {
     if (a[i] == x) continue;
     int d = abs(a[i] - x / 2);
     if (d < d_min) {
       d_min = d;
       y = a[i];
     }
   }
   cout << x << " " << y << endl;
 }

Measured memory_bytes: 640
N=int(input())
A=list(map(int,input().split()))
B=set(A)
A.sort()
S=max(A)
ans=[1]*S
for i in range(len(A)):
  if ans[A[i]-1]!=0:
    if i>0 and A[i]==A[i-1]:
      ans[A[i]-1]=0
    for j in range(A[i]*2,S+1,A[i]):
      ans[j-1]=0
k=0
for i in A:
  if ans[i-1]==1:
    k+=1
print(k)

Measured memory_bytes: 35276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int K = scan.nextInt();

		int[] P = new int[N];
		double[] e = new double[N];

		for (int i = 0; i < N; i++) {
			P[i] = scan.nextInt();
			e[i] = (double) (P[i] + 1) / 2;
		}

		double expect = 0;

		for (int i = 0; i < K; i++) {
			expect += e[i];
		}

		double max = expect;

		int left = 0;
		int right = K;

		for (int i = 0; i < N - K; i++) {
			expect = expect - e[left] + e[right];
			if (max < expect) {
				max = expect;
			}
			left++;
			right++;
		}

		System.out.println(max);
	}

}


Measured memory_bytes: 76328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define pb push_back
#define mp make_pair
#define se second
#define fi first
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int maxn = 500005;
const ll mod = 1000000007;
const ll inf = 0x7f7f7f7f;
//int edgenum, head[maxn], vet[maxn*2], nxt[maxn * 2], wt[maxn * 2];
//void add(int u,int v){edgenum++;vet[edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;}
//void add(int u,int v,int w){edgenum++;vet[edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;wt[edgenum]=w;}
//ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
/********HEAD********/
int main() {
	int n;
	cin >> n;
	cout << 2 * 3.1415 * n;
	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;


int main() {
    
    int K;
    string S;
    cin >> K;
    cin >> S;
    
    for(int i=0;i<K&&i<S.size();i++){
        cout << S[i];
    }
    if(S.size()>K){
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
    int n;
    int m;
    int a[128];
    int score[128] = {0};
    int i, j;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++){
        scanf("%d", a + i);
    }

    for (i = 0; i < m; i++){
        for (j = 0; j < n; j++){
            int b;

            scanf("%d", &b);
            if (b == a[i]) score[j]++;
            else score[a[i] - 1]++;
        }
    }

    for (i = 0; i < n; i++) printf("%d\n", score[i]);

    return 0;
}

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

int main() {
    int n=0;
    scanf("%d", &n);
    int ue = n / 100;
    int sita = n % 100;
    if ((ue <= 12) && (ue >= 1)) {
        if ((sita <= 12) && (sita >= 1)) printf("AMBIGUOUS\n");
        else printf("MMYY\n");
    }
    else {
        if ((sita <= 12) && (sita >= 1)) printf("YYMM\n");
        else printf("NA\n");
    }
    return 0;
}


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


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

    int targetVal = -100;
    int costMin = 1e9;
    for (targetVal = -100; targetVal <= 100; targetVal++)
    {
        int cost = 0;
        for (int i = 0; i < n; i++)
        {
            cost += (a[i] - targetVal) * (a[i] - targetVal);
        }
        if(cost < costMin) costMin = cost;
    }
    
    cout << costMin << endl;
    
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[100][5],u[100][5];
vector<int> ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  cin >>a>>b;
  for(int n=0;n<a;n++){
    cin >>i[n][0]>>i[n][1];
  }
  for(int n=0;n<b;n++){
    cin >>u[n][0]>>u[n][1];
  }
  for(int n=0;n<a;n++){
    d=0,e=INF;
    for(int m=0;m<b;m++){
      f=abs(i[n][0],u[m][0])+abs(i[n][1],u[m][1]);
      if(f<e) d=m+1,e=f;
    }
    ii.push_back(d);
  }
  for(int n=0;n<a;n++) cout <<ii[n]<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const ll Max=1e18+100;
const int sz=310;
ll dist[2][sz][sz];
void Floyad(ll n,ll l,ll tar)
{
     for(int k=1;k<=n;k++)
     {
         for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++)
                {
                    if(dist[tar][i][k]+dist[tar][k][j]<dist[tar][i][j]) dist[tar][i][j]=dist[tar][i][k]+dist[tar][k][j];
                }
         }
     }
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    int t,cs;
    cin>>n>>m>>l;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++){
           if(i==j) dist[0][i][j]=dist[1][i][j]=0;
           else dist[0][i][j]=dist[1][i][j]=Max;
        }
    }

    for(i=1;i<=m;i++){
        cin>>p>>q>>c;
        dist[0][p][q]=dist[0][q][p]=c;
    }
    Floyad(n,l,0ll);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++){
            if(i==j) dist[1][i][j]=0;
            else dist[1][i][j]=dist[1][j][i]=((dist[0][i][j]<=l) ? 1ll: Max);
        }
    }
    Floyad(n,l,1ll);

    cin>>x;
    while(x--)
    {
        cin>>p>>q;
        if(dist[1][p][q]>=Max) cout<<"-1"<<endl;
        else{
            cout<<dist[1][p][q]-1<<endl;
        }
    }


}


Measured memory_bytes: 2048
N = int(input())
A = [int(x) for x in input().split()]
A = [0] + A + [0]

S = 0
for i in range(len(A) - 1):
    S += abs(A[i] - A[i+1])
for i in range(1, len(A)-1):
    reg = S - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1])
    print(reg)

Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int n; cin>>n; P a[n],b[n];
    for (int i = 0; i < n; i++)cin>>a[i].first>>a[i].second;
    for (int i = 0; i < n; i++)cin>>b[i].first>>b[i].second;
    sort(b,b+n); int ans=0; bool used[n]={};
    for (int i = 0; i < n; i++){
        P key=P(-1,-1);
        for (int j = 0; j < n; j++){
            if(b[i].first>a[j].first&&b[i].second>a[j].second&&!used[j]){
                if(key.first<a[j].second)key=P(a[j].second,j);
            }
        }
        if(key.second!=-1){
            ans++; used[key.second]=true;
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
public static void main(String [] args)throws Exception{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  StringTokenizer st = new StringTokenizer(br.readLine());
  int n = Integer.parseInt(st.nextToken());
  int x = Integer.parseInt(st.nextToken());
  int array[] = new int[n + 1];
  st = new StringTokenizer(br.readLine());
  long tot = 0;
  for(int i = 1;i <= n;i++){
  	array[i] = Integer.parseInt(st.nextToken());
  	tot += array[i];
  }
  for(int i = 2;i <= n;i++){
  	if(array[i] + array[i - 1] <= x)continue;
  	int diff = array[i] + array[i - 1] - x;
  	if(array[i] >= diff) array[i] -= diff;
  	else{
  		array[i - 1] -= (diff - array[i]);
  		array[i] = 0;
  	}
  }
  long ans = 0;
  for(int i = 1;i <= n;i++)
  	ans += array[i];
  System.out.println(tot - ans);
}
}


Measured memory_bytes: 28544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n;
  cin >> n;
  vll c(n), s(n), f(n);
  for (ll i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];
  for (ll i = 0; i < n - 1; i++) {
    ll t = 0;
    for (ll j = i; j < n - 1; j++) {
      if (t < s[j]) t = s[j];
      else if ((t - s[j]) % f[j] != 0) {
        t += f[j] - (t - s[j]) % f[j];
      }
      t += c[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256