akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int nextInt();
char compare(int x, int y);
int med3(int x, int y, int z);
void quickSort(int *a, int left, int right);
void sort(int *a, int size);

int N, i;
int A[100000], B[100000], C[100000];
long long int a, b;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		A[i]=nextInt();
		B[i]=nextInt();
		C[i] = A[i] + B[i];
		b += B[i];
	}
	sort(C, N);
	for(i=0; i<N; i++){
		if(i%2 == 0){
			a += C[N-i-1];
		}
	}
	printf("%lld\n", a-b);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}

char compare(int x, int y){
	return x < y;
}

int med3(int x, int y, int z){
	if(compare(x, y)){
		if (compare(y, z)){return y;}else if(compare(z, x)){return x;}else{return z;}
	} else {
		if (compare(z, y)){return y;}else if(compare(x, z)){return x;}else{return z;}
	}
}

void quickSort(int *a, int left, int right){
	if(left >= right){return;}
	int pivot = med3(a[left], a[left+(right-left)/2], a[right]);
	int l=left, r=right;
	int t;
	while(1){
		while (compare(a[l], pivot)){l++;}
		while (compare(pivot, a[r])){r--;}
		if(l>=r){break;}
		t=a[l]; a[l]=a[r]; a[r]=t;
		l++; r--;
	}
	quickSort(a, left, l-1);
	quickSort(a, r+1, right);
}

void sort(int *a, int size){
	quickSort(a, 0, size-1);
}


Measured memory_bytes: 1280
s = input()
#文字の昇順に処理していきたいため、逆順にしておく
s = s[::-1]
mod = 7 + 10**9
keta = 1
dp = [[0 for i in range(13)] for j in range(len(s) + 1)]
dp[0][0] = 1
for i in range(len(s)):
    if s[i] != "?":
        k = (int(s[i]) * keta) % 13
        for j in range(13):
            dp[i + 1][(j + k) % 13] = dp[i][j]
    else:
        for j in range(13):
            for k in range(10):
                l = ( k * keta ) % 13
                dp[i + 1][(j + l) % 13] += dp[i][j] % mod
    keta = keta *10 % 13 
print(dp[-1][5] % mod)


Measured memory_bytes: 66140
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define RI register int
typedef long long LL;
const int MAXN = 1000005;
struct node{int from, to, w;} G[MAXN];
int dist[MAXN];
int head[MAXN];
bool vis[MAXN];
int cnt,k;
IL void add(int u, int v, int w)
{
    G[++cnt].to=v;
    G[cnt].w=w;
    G[cnt].from=head[u];
    head[u]=cnt;
}
IL void spfa(int s)
{
    memset(dist,127,sizeof(dist));
    memset(vis, false, sizeof(vis));
    queue<int> q;
    while(!q.empty())
        q.pop();
    vis[1]=true;
    q.push(s);
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(RI i=head[u]; i; i=G[i].from)
        {
            int v=G[i].to;
            if(dist[v]>dist[u]+G[i].w)
            {
                dist[v]=dist[u]+G[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    std::cin>>k;
    for(RI i=0; i<k; ++i)
    {
        add(i,(i+1)%k, 1);
        add(i, i*10%k, 0);
    }
    spfa(1);
    printf("%d\n", dist[0]+1);
    return 0;
}

Measured memory_bytes: 9984
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(2, n):
    if p[i - 2] < p[i - 1] < p[i]:
        cnt += 1
    if p[i - 2] > p[i - 1] > p[i]:
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	pair<int,int>p[10000],t;
	int n,a,b,c,i;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)scanf("%d%d%d",&a,&b,&c),p[i].first=b+c,p[i].second=a;
		t=*max_element(p,p+n);
		printf("%d %d\n",t.second,t.first);
	}
	return 0;
}

Measured memory_bytes: 844
#include <stdio.h>
int main(void){
    int SECOND;
    int hour,minute,second;
    
    scanf("%d\n",&SECOND);
    
    hour=SECOND/3600;
    minute=SECOND%3600/60;
    second=SECOND%3600%60;
    
    printf("%d:%d:%d\n",hour,minute,second);
    
    return 0;
    
}

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


//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int MOD2 = 998244353;
const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);
#define fi first
#define se second
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )

void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << endl;
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Fry my kartoshka
 */

const int MAXN = 2e5 + 3;
const int INF = 2e9;

ll dp[101][MAXN];
int a[MAXN];
ll pre[MAXN];

int main(){
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	int n, k;
	cin >> n >> k;

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


	for(int i = k; i >= 0; i--){
		if(k - i > a[0]) break;
		dp[0][i] = 1;

		dp[0][i] = dp[0][i];
		pre[i] = dp[0][i];
	}
	for(int j = 0; j <= k; j++){
		pre[j] = dp[0][j];

		if(j != 0){
			pre[j] = (pre[j] + pre[j - 1]) % MOD;
		}
	}
	for(int i = 1; i < n; i++){
		for(int j = k; j >= 0; j--){
			dp[i][j] = (pre[min(k, j + a[i])] - (j > 0 ? pre[j - 1] : 0) + MOD) % MOD;
		}

		for(int j = 0; j <= k; j++){
			pre[j] = dp[i][j];

			if(j != 0){
				pre[j] = (pre[j] + pre[j - 1]) % MOD;
			}
		}
	}

	cout << dp[n - 1][0];
}


Measured memory_bytes: 158720
N, A, B, C, D = map(int, input().split())
S = input()

needOver = False
if C > D:
    needOver = True

ans = 'Yes'
overPos = 0
if needOver:
    canOver = False
    for i in range(B-1, D):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            canOver = True
            break
    if not canOver:
        ans = 'No'

for i in range(A+1-1, C):
    if S[i-1] == '#' and S[i] == '#':
        ans = 'No'
        break

for i in range(B+1-1, D):
    if S[i-1] == '#' and S[i] == '#':
        ans = 'No'
        break

print(ans)


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

using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
    }

    int res = 0;
    for (int i = 0; i < (1 << (h + w)); i++) {
        int r = 0;
        for (int j = 0; j < h * w; j++) {
            if ((i & (1 << (j / w))) == 0 && (i & (1 << (h + j % w))) == 0 && c[j / w][j % w] == '#') {
                r++;
            }
        }

        if (r == k) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int a, b;
	cin >> a >> b;
	if(a<=b){println(a);}
	else {println(a-1);}

	return 0;

}


Measured memory_bytes: 256
// Apna Time Aayega :)
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define vpi vector<pair<int, int>>
#define ll long long int
#define MAX 1000000
#define inf 1000000000


int solve(string x, int n, int k)
{
    double kd = k;
    int arrayLength = ceil(kd/2);
    int grid[arrayLength][26];
    for(int i=0; i<arrayLength; ++i)
    {
        for(int j=0; j<26; j++) 
            grid[i][j] = 0;
    }
    for(int i=0; i<arrayLength; i++)
    {
        int firstPosition = i, lastPosition = k-1-i;
        while(lastPosition<n)
        {
            grid[i][x[firstPosition]-'a']++;
            if(firstPosition!=lastPosition)
            grid[i][x[lastPosition]-'a']++;
            firstPosition+=k;
            lastPosition+=k;
        }
    }
    // for(int i=0; i<arrayLength; ++i)
    // {
    //     for(int j=0; j<26; j++)
    //     {
    //         cout<<grid[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    if(k%2==0)
    {
        int answer = 0;
        for(int i=0; i<arrayLength; ++i)
        {
            int maximum = grid[i][0];
            for(int j=0; j<26; j++)
            {
                if(grid[i][j]>maximum) maximum = grid[i][j];
            }
            answer+= 2*(n/k) - maximum;
            // cout<<"ArrayLength -> "<<i<<" maximum -> "<<maximum<<" answer -> "<<answer<<endl;
        }
        return answer;
    }
    else
    {
        int answer = 0;
        for(int i=0; i<arrayLength-1; ++i)
        {
            int maximum = grid[i][0];
            for(int j=0; j<26; j++)
            {
                if(grid[i][j]>maximum) maximum = grid[i][j];
            }
            answer+= 2*(n/k) - maximum;
        }
        int maximum = grid[arrayLength-1][0];
        for(int i=0; i<26; i++)
        {
            if(grid[arrayLength-1][i]>maximum) maximum = grid[arrayLength-1][i];    
        }
        answer += (n/k)-maximum;
        return answer;
    }
    return -1;
}

int length(int number)
{
    int count = 0;
    while(number>0){
        number = number/10;
        count++;
    }
    return count;
}



int overlaps(int* S, int* E, int N){
    sort(S, S+N);
    sort(E, E+N);
    int counter = 0;
    int maximumValue = -1;
    int startPointer = 0, endPointer = 0;
    while(startPointer<N && endPointer<N){
        if(S[startPointer]<E[endPointer]) {counter++; startPointer++;}
        else {counter--; endPointer++;}
        if(counter>maximumValue) maximumValue = counter;
    }
    while(startPointer<N){
        counter++; startPointer++;
        if(counter>maximumValue) maximumValue = counter;
    }
    while(endPointer<N){
        counter--; endPointer++;
        if(counter>maximumValue) maximumValue = counter;
    }
    return maximumValue;
}

int main() {
    int X, Y, Z; cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<endl;
}


Measured memory_bytes: 256
import re

S = input()

R = [
    "^.*keyence$",
    "^k.*eyence$",
    "^ke.*yence$",
    "^key.*ence$",
    "^keye.*nce$",
    "^keyen.*ce$",
    "^keyenc.*e$",
    "^keyence.*$",
]

for ri in R:
    if re.match(ri, S):
        print("YES")
        exit(0)
print("NO")


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long LL;
const int Mod = 1e9 + 7;
int n;
LL ans = 1;
int main(){
	while(~scanf("%d", &n)){
		ans = 1;
		for(int i = 1; i <= n; i++)
			ans = ans * i % Mod;
		printf("%lld\n", ans);
	}
	return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
  int x, y;
  cin >> x >> y;
  int a, b, c;
  a = max(x, y);
  b = min(x, y);
  c = max(a-1, b);
  cout << a + c << endl;
  return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

int main(){
  int n, m; cin >> n >> m;
  vector<llP> h(n), c(m);
  rep(i, n) cin >> h[i].first >> h[i].second;
  rep(i, m) cin >> c[i].first >> c[i].second;

  rep(i, n) {
    int ans;
    ll dist = INF64;
    rep(j, m) {
      if(chmin(dist, abs(h[i].first-c[j].first)+abs(h[i].second-c[j].second))) ans = j+1;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    ll cnt = abs(x) / d;
    if(k <= cnt) cout<<abs(x)-d*k<<endl;
    else{
        ll now=abs(x)-d*cnt;
        if((k-cnt)&1) cout<<abs(now-d)<<endl;
        else cout<<now<<endl;
    }

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct edge {
    int from;
    int to;
    ll w;

    bool operator<(const edge& other) const {
        if (w < other.w) return true;
        else return false;
    }
};

class UnionFind {
public:
    vector <int> par; // 各元の親を表す配列
    vector <int> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(int sz_): par(sz_), siz(sz_, 1) {
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);  // resize だとなぜか初期化されなかった
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    int root(int x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y) { // 連結判定
        return root(x) == root(y);
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    // vector< vector<edge> > edges(N, vector<edge>());
    vector<edge> edges;

    REP(i, M) {
        int s, t;
        int w;
        cin >> s >> t >> w;
        edge e = {s, t, w};
        edges.push_back(e);
    } 

    sort(ALL(edges));

    UnionFind uf = UnionFind(N);
    set<int> U;
    vector<edge> tree;

    for(edge e: edges) {
        int v1 = e.from;
        int v2 = e.to;
        if(!uf.issame(v1, v2)) {
            uf.merge(v1, v2);
            tree.push_back(e);
        }
    }

    int ans = 0;
    for(edge e: tree)
        ans += e.w;
    cout << ans << endl;
    // printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4876
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        int result = Math.max(A+B,Math.max(A-B,A*B));
        System.out.println(result);

    }
}

Measured memory_bytes: 21844
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

void fileIO()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int32_t main()
{
	IOS;
	fileIO();
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n,k,i;
		cin>>n>>k;
		VI64 v(n);
		for(auto &x:v)
		{
			cin>>x;
		}
		while(k--)
		{
			int cnt=0;
			VI64 vv(n+1,0);
			for(i=0;i<n;i++)
			{
				cnt+= v[i]==n;
				int l=max(i-v[i],(int)0);
				int r=min(i+v[i]+1,n);
				vv[r]--;
				vv[l]++;
			}
			if(cnt==n)
				break;
			v[0]=vv[0];
			for(i=1;i<n;i++)
			{
				vv[i]+=vv[i-1];
				v[i]=vv[i];
			}
			
			
		}
		for(auto x:v)
			cout<<x<<" ";
		
	}
	
	return 0;
}

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

#define ll long long

map<string,ll> mp;

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

	string s;
	ll t;

	vector<ll> time;
	for(int i=0;i<n;i++)
	{
		cin >> s >> t;
		time.push_back(t);
		mp[s]=i;
	}

	cin >> s;

	ll ans=0;
	for(int i=mp[s]+1;i<n;i++) ans+=time[i];

	cout << ans << endl;


	return 0;
}


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

int main(){
  int n,m;
  int t,r;
  int cnt = 0;
  int i,j;
  int a[101];
  int k;
  int sum = 0;

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

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

  for(i = 0;i < n - 1;i++){
    for(j = n - 1;j > i;j--){
      if(a[j] < a[j - 1]){
        t = a[j]; a[j] = a[j - 1]; a[j - 1] = t;
      }
    }
  }

  k = n - 1;

  while(1){
    if(4*m*a[k] >= sum) cnt++;

    else break;

    k--;
  }

  if(cnt >= m) printf("Yes\n");

  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
eval"N,K,*A="+`dd`.split*?,
s,*l=eval A*?+
1.upto(3e4){|j|s%j<1&&l<<j<<s/j}
p l.select{|h|t=0
K>=A.map{|x|x%h}.sort.map{|x|t+=x}[~t/h]}.max

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

int n, x, tab[200010], maks;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
    for (int a = 1; a <= n; a++) {
        cin >> x;
        tab[x] = max(tab[x - 1] + 1, tab[x]);
        maks = max(maks, tab[x]);
    }
    cout << n - maks << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//code
	long long int n;
	cin>>n;
	long long int s=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
			s+=i;
	}
	cout<<s<<endl;
 	return 0;
}


Measured memory_bytes: 3628
package main

import (
  "fmt"
  "bufio"
  "strconv"
  "os"
)

// var memo = make([]int, 100005)

func main() {

	// var N, M int
	// fmt.Scan(&N, &M)
	// a := make([]int, M)
  sc := bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)
    sc.Scan()
    N, _ := strconv.Atoi(sc.Text())
    sc.Scan()
    M, _ := strconv.Atoi(sc.Text())

  steps := make([]int, N+1)
  for i := range steps{
    steps[i] =1
  }
	for i := 0; i < M; i++ {
		sc.Scan()
    a, _ := strconv.Atoi(sc.Text())
    steps[a] = 0
	}

  for i := 2; i<=N; i++{
    steps[i] *= (steps[i-1] + steps[i-2]) %1000000007
  }
  fmt.Println(steps[N])

	// fmt.Println(a)

	// result := 1
	// for i := 0; i <= M; i++ {
	// 	if i == 0 {
	// 		result *= conb(a[0] - 1)
	// 	} else if i == M {
	// 		result *= conb(N - a[i-1] - 1)
	// 	} else {
	// 		result *= conb(a[i] - a[i-1] - 2)
	// 	}
	// 	// result *= conb(a[i]-a[i-1])
	// }
	// fmt.Println(result%1000000007)
}

// func conb(d int) int { //d段まで何通りあるか　0スタート
// 	if memo[d] != 0 {
// 		return memo[d]
// 	} else if d == 2 {
// 		memo[d] = 2
// 		return memo[d]
// 	} else if d == 1 {
// 		memo[d] = 1
// 		return memo[d]
// 	} else if d == 0 {
// 		memo[d] = 1
// 		return memo[d]
// 	} else {
// 		memo[d] = conb(d-1) + conb(d-2)
// 		return memo[d]
// 	}
// }


Measured memory_bytes: 1920
#include <stdio.h>

void trace(int a[], int size) {
    for (int i = 0; i < size; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

void InsertionSort(int A[], int N) {
    int j = 0;
    for (int i = 1; i < N; ++i) {
        trace(A, N);
        int key = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > key) {
            A[j+1] = A[j];
            --j;
        }
        A[j+1] = key;
    }
    trace(A, N);
}

int main() {
    int N;
    int A[100];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    InsertionSort(A, N);
    return 0;
}

Measured memory_bytes: 2744
### constant

MAX_TIME = 1 << 31 - 1

### main

while true
  n = gets.strip.to_i
  break if n == 0

  times = [MAX_TIME] * 4
  cs = [nil] * 4

  (1..4).each do
    c, m1, s1, m2, s2, m3, s3, m4, s4 = gets.strip.split(' ').map{|s| s.to_i}
    time = (m1 + m2 + m3 + m4) * 60 + (s1 + s2 + s3 + s4)

    for i in (0..3)
      if times[i] > time
        times[i + 1, 3 - i] = times[i, 3 - i]
        cs[i + 1, 3 - i] = cs[i, 3 - i]
        times[i] = time
        cs[i] = c
        break
      end
    end
  end

  (5..n).each do
    c, m1, s1, m2, s2, m3, s3, m4, s4 = gets.strip.split(' ').map{|s| s.to_i}
    time = (m1 + m2 + m3 + m4) * 60 + (s1 + s2 + s3 + s4)

    if times[0] > time
      times[1] = times[0]
      cs[1] = cs[0]
      times[0] = time
      cs[0] = c
    elsif times[1] > time
      times[1] = time
      cs[1] = c
    elsif times[3] < time
      times[2] = times[3]
      cs[2] = cs[3]
      times[3] = time
      cs[3] = c
    elsif times[2] < time
      times[2] = time
      cs[2] = c
    end
  end

  (0..2).each{|i| puts cs[i]}
end

Measured memory_bytes: 6140
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi t(n);
    rep(i,n) cin >> t.at(i);
    int64_t m;
    cin >> m;
    vi p(m),x(m);
    rep(i,m) cin >> p.at(i) >> x.at(i);
    int64_t sum = 0;
    for(int i=0; i<n; i++){
        sum += t.at(i);
    }
    for(int i=0; i<m; i++){
        cout << sum - t.at(p.at(i)-1) + x.at(i) << endl;
    }
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;

int main() {
  int N;
  cin>>N;
  ll A[N],B[N];
  for(int i=0;i<=N;i++){
    cin>>A[i];
    }
    for(int i=0;i<N;i++){
    cin>>B[i];
    }
    ll count=0;
    for(int i=0;i<N;i++){
      ll c;
      c=min(A[i],B[i]);
      count+=c;
      A[i]-=c;
      B[i]-=c;
      c=min(A[i+1],B[i]);
      count+=c;
      A[i+1]-=c;
    }
    cout<<count<<endl;
    return 0;
    }

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  loop {
    Real v; cin >> v;
    if (!cin) break;
    for (int n=1;;++n) {
      Real y = 5 * n - 5;
      Real v2 = 2.0 * 9.8 * y;
      if (v2 >= v * v) {
        cout << n << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

void bfs(const vector<int>& vec, map<vector<int>, int>& m) {
	const int len = vec.size();
	queue<pair<int, vector<int> > > que;
	que.push(make_pair(0, vec));
	m[vec] = 0;

	while(!que.empty()) {
		const int cnt = que.front().first;
		const vector<int> state = que.front().second;
		que.pop();

		if(cnt == 4)
			break;

		for(int l = 0; l < len; ++l) {
			for(int r = l + 1; r < len; ++r) {
				vector<int> tmp(state);
				reverse(tmp.begin() + l, tmp.begin() + r + 1);
				if(!m.count(tmp)) {
					m[tmp] = cnt + 1;
					que.push(make_pair(cnt + 1, tmp));
				}
			}
		}
	}
}

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

	int n;
	cin >> n;

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

	map<vector<int>, int> a, b;
	bfs(vec, a);
	sort(vec.begin(), vec.end());
	bfs(vec, b);

	int ans = 9;
	FOR(it, a) {
		map<vector<int>, int>::const_iterator it2 = b.find(it->first);
		if(it2 != b.end())
			chmin(ans, it->second + it2->second);
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 83268
#include<stdio.h>

int search(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(){
  int i,n,A[10000+1],q,key,sum = 0;

  scanf("%d",&n);
  for(i = 0; i<n; i++) scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i = 0; i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key)) sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
using namespace std;
int n,k,s;
int total;
void solve(int i,int knum,int res){
	for(int j = i;j <= n;j++){
		if(j+res > s)break;
		if(knum == k && res + j == s)total++;
		else if(knum < k && res + j < s)solve(j+1,knum+1,res+j);
	}
}

int main(){
	while(1){
		cin >> n >> k >> s;
		if(n == 0)break;
		total = 0;
		solve(1,1,0);
		cout << total << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

struct UnionFind {  // UnionFind uni(N);
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化、頂点数N
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry] += siz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int n,q;cin >> n >> q;
    UnionFind uni(n);
    rep(i,q){
        int t;cin >> t;
        int a,b;cin >> a >> b;
        if(t){
            cout << uni.same(a,b) << endl;
        }
        else uni.unite(a,b);
    }

}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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 under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	VL a(n);
	VL A(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		A[i] = 2 * a[i];
	}
	VL ans(n);
	ans[0] = sum;
	for (int i = 1; i <= n - 2; i += 2) {
		ans[0] -= A[i];
	}
	rep1(i, n - 1) {
		ans[i] = A[i - 1] - ans[i - 1];
	}
	rep(i, n) cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=4e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;


int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int& x:a) cin>>x;
	auto check=[&](int x){
		int cur=0;
		for(int v:a){
			cur+=(v-x)*(v-x);
		}
		return cur;
	};
	int ans=INF;
	for(int i=1;i<=100;++i) ans=min(ans,check(i));
	cout<<ans;
	return 0;	
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//System.out.println();
public class Main{
   String op(int n){

      if(n%10==3){
         return "bon";
      }else if(n%10==0||n%10==1||n%10==6||n%10==8){
         return "pon";
      }else{
         return "hon";
      }
   }




   public static void main(String[] args)  throws IOException {
      // Use the Scanner class
      
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  
          
        while(br.ready()){
int t = Integer.parseInt(br.readLine());  
          
        // String Buffer to store answer 
        StringBuffer sb = new StringBuffer(); 
       Main obj = new Main();
        // One by one run for all input test cases  
        
          
        System.out.println(obj.op(t)); 
       }
return;
}
}

Measured memory_bytes: 32460
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>

const int Max_size=100005;
std::vector<std::vector<long> > piece(3, std::vector<long>(Max_size));
std::vector<std::vector<long> > memo(3, std::vector<long>(Max_size));

int binary_search(int key, std::vector<long> &p, int s, int t){
    int ss=s, tt=t;
    while(true){
        if(p[(ss+tt)/2] <= key) ss=(ss+tt)/2;
        else tt=(ss+tt)/2;

        while((ss>=0)&&(ss<t-1)){
            if(p[ss]==p[ss+1]) ss++; 
            else break;
        }
        while((tt<=t)&&(tt>0)){
            if(p[tt]==p[tt-1]) tt--;
            else break;
        }

        if( (ss+1) == tt) return tt;
    }
}
int main(){
    int n=0;
    std::cin >> n;
    for(int j=0; j<3; j++){
        for(int i=0; i<n; i++){
            std::cin >> piece[j][i];
        }
    }

    for(int i=0;i<3;i++) std::sort(piece[i].begin(), piece[i].begin()+n);

    int s=-1, t=n;
    memo[1][n]=0;
    for(int i=n-1; i>=0; i--){
        //t = binary_search(piece[1][i], piece[2], -1, t);
        auto tmp = std::upper_bound(piece[2].begin(), piece[2].begin()+n, piece[1][i]);
        t = std::distance(piece[2].begin(), tmp);
        //std::cout << i << ", " << t << std::endl;
        memo[1][i] = n-t+memo[1][i+1];
    }
    s=-1; t=n;
    long sum=0;
    for(int i=n-1; i>=0; i--){
        //s = binary_search(piece[0][i], piece[1], -1, n);
        auto tmp = std::upper_bound(piece[1].begin(), piece[1].begin()+n, piece[0][i]);
        s = std::distance(piece[1].begin(), tmp);
        sum += memo[1][s];
    }
    std::cout << sum << std::endl;    
    return 0;

}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const ll MAX = 3510;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N;cin >> N;
  //4nhw/(nh+hw+wn) == N
  repp(h,1,MAX)repp(n,1,MAX){
    ll l = 0, r = MAX;
    if(4*n*h*r < N*(n*h + r*n + h*r))continue;
    while(r-l>1){
      ll w = (l+r)/2;
      if(4*n*h*w == N*(n*h + w*n + h*w)){
        cout << n SP h SP w << endl;
        return 0;
      }
      if(4*n*h*w < N*(n*h + w*n + h*w)) l = w;
      else r = w;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        String S=scan.next();
        char[] s=S.toCharArray();
        int k;
        if(S.length()<4){
            System.out.println("No");
        }


        else if(S.charAt(0)!='Y'){
            System.out.println("No");

            }
        else if(S.charAt(1)!='A'){
            System.out.println("No");

        }
        else if(S.charAt(2)!='K'){
            System.out.println("No");


        }
        else if(S.charAt(3)!='I'){
            System.out.println("No");

        }else{

            System.out.println("Yes");
            }


    }
}






Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  	int n;
  	cin>>n;
  	vector<int> v(n);
  	int sum = 0;
  	for(int i = 0; i < n; i++)
    {
    	cin>>v[i];
      	sum += v[i];
    }
  	int tr = round(double(sum) / double(n));
  	int res = 0;
  	for(int i = 0; i < n; i++)
    {
    	int d = v[i]-tr;
      	res += d*d;
    }
  	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 384
/**********************************************************
* @Author: 			   .Sunbeam
* @Date:   			   2020-03-22 20:09:35
* @Last Modified by:   .Sunbeam
* @Last Modified time: 2020-03-22 20:12:56
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn=1000;
char str[maxn];

bool palindrome(int l,int r){
	for(int i=0;i<(r-l);i++){
		if(str[l+i]!=str[r-1-i])
			return false;
	}
	return true;
}

int main()
{
	cin>>str;
	int n=strlen(str);
	if(palindrome(0,n)&&palindrome(0,(n-1/2))&&palindrome((n+1)/2,n))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
module ABC085

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public :: ABC085_A


	! constants for this <module>
	integer( kind=INT32 ), parameter, private :: len_TargetString = 10


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC085_A

		! variables for this <subroutine>
		character( len=len_TargetString, kind=1 ) :: buffer

		! STEP.01
		! read out the the date
		read( unit=INPUT_UNIT, fmt='(A)' ) buffer

		! STEP.02
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(A10)', advance='yes' ) '2018' // buffer(5:10)

		! STEP.END
		return

	end subroutine ABC085_A

end module ABC085


program main

	! <module>s to import
	use, non_intrinsic :: ABC085

	! require all variables to be explicitly declared
	implicit none

	call ABC085_A

end program main


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

int n;
ll cnt[N], a[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		cnt[a[i]]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) ans += cnt[i] * (cnt[i] - 1) / 2;
	for (int i = 1; i <= n; i++) printf("%lld\n", ans - cnt[a[i]] + 1);
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string s,t;
    cin >> s >> t;;
int count = 0;
    for(int i = 0; i < 3; ++i){
        if(s.at(i) == t.at(i))++count;
    }

    cout << count << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,i,r,b;
char s;
int main()
{
    cin>>n;
    r=0;b=0;
    for (i=0;i<=n-1;i++)
    {
        cin>>s;
        if (s=='R') r++;
         else b++;
    }
    if (r>b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

struct Edge {
  int to;
  int id;
  Edge(int t, int i) : to(t), id(i) {}
};

vector<vector<Edge>> g;
vector<bool> seen;
vector<int> ans;

void dfs(const vector<vector<Edge>> &g, int vertex, int c = -1) {
  seen.at(vertex) = true;
  int color = 1;

  for (int i = 0; i < g.at(vertex).size(); i++) {
    int next_v = g.at(vertex).at(i).to, edge_id = g.at(vertex).at(i).id;

    if (seen.at(next_v)) continue;
    if (color == c) color++; // avoid color duplication
    ans.at(edge_id) = color;
    color++;
    dfs(g, next_v, ans.at(edge_id));
  }
}

int main() {
  int N;
  cin >> N;
  int edge_num = N - 1;
  int from, to;
  g.resize(N);
  seen.assign(N, false);
  ans.resize(edge_num);
  for (int i = 0; i < edge_num; i++) {
    cin >> from >> to;
    from--; to--;
    g.at(from).push_back(Edge(to, i));
    g.at(to).push_back(Edge(from, i));
  }
  dfs(g, 0);

  int color_max = 0;
  for (int i = 0; i < N; i++) {
    color_max = max(color_max, static_cast<int>(g.at(i).size()));
  }
  cout << color_max << endl;
  for (int i = 0; i < edge_num; i++) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 8320
s=list(input())
out=[]
for i in range(len(s)):
    if s[i]=="B" and out==[]:
        out=[]
    elif s[i]=="B":
        del(out[-1])
    else:
        out.append(s[i])
for i in range(len(out)):
    print(out[i],end="")

Measured memory_bytes: 3060
def solve():
    H, W = map(int, input().split())
    l = [list(input()) for _ in range(H)]
    q = [(0, 0)]
    sc = [[H*W]*W for _ in range(H)]
    sc[0][0] = 0 if l[0][0]=="." else 1

    while q:
        y, x = q.pop()
        for y1, x1 in [(y+1, x), (y, x+1)]:
            if not (0<=x1<W and 0<=y1<H):continue
            if l[y][x]=="#":
                if sc[y1][x1] > sc[y][x]:
                    sc[y1][x1] = sc[y][x]
                    q.append((y1, x1))
            else:
                v = sc[y][x]+1 if l[y1][x1]=="#" else sc[y][x]
                if sc[y1][x1] > v:
                    sc[y1][x1] = v
                    q.append((y1, x1))

    print(sc[-1][-1])


if __name__ == "__main__":
    solve()

Measured memory_bytes: 43116
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,i;
	cin >> N;
	ll A;
	ll ans[N];
	for(i=0;i<N;i++){
		cin >> A;
		ans[A-1]=i+1;
	}
	for(i=0;i<N;i++){
		cout << ans[i]<< " ";
	}
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define sf(n) scanf("%lld",&n)
#define pf(n) printf("%lld\n",n)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define pff(x,y) printf("%lld %lld\n",x,y)
#define REP(I,N) for(I=0;I<N;I++)
#define REPP(I,A,B) for(I=A;I<=B;I++)
#define MS0(X) memset(X,0,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define F first
#define S second
#define Mod 1000000007
#define pb push_back
#define RF freopen("riyad.txt","r",stdin)
#define WF freopen("out.txt","w",stdout)
#define YES printf("YES\n")
#define NO printf("NO\n")

using namespace std;

typedef unsigned long long Ull;
typedef pair < int , int > Pii;
typedef pair < ll , ll > Pll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //RF;
    //WF;
    ll i,tc,cs=1,n,m,k,cnt=0,j,q;
    cin>>n>>m;
    cout<<(n*(n-1))/2 + (m*(m-1))/2<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define IsDigit(x) ((x) >= '0' && (x) <= '9')
using namespace std;

int n, m;
int b[201][5001], in_r[201][5001], in_l[201][5001];
long long dist[5001], d[5002][5002];
struct Elem{
    int b, id;
    Elem() {}
    Elem(int x, int y)
        : b(x), id(y)
    {}
}s[5000];


int Read(void)
{
    int c, ret(0);
    
    c = getchar();
    while (!IsDigit(c))
        c = getchar();
    do
        ret = ret * 10 + c - '0';
    while ((c = getchar()) && IsDigit(c));
    return ret;
}


int main()
{
    int pos, l, r;
    long long ans(0), t;
    
    n = Read();
    m = Read();
    for (int i = 2; i <= n; ++i)
        dist[i] = Read() + dist[i - 1];
    for (int j = 1; j <= n; ++j)
        for (int i = 1; i <= m; ++i)
            b[i][j] = Read();
    for (int i = 1; i <= m; ++i) {
        pos = 0;
        s[pos++] = Elem(b[i][1], 1);
        for (int j = 2; j <= n; ++j) {
            while (pos && b[i][j] >= s[pos - 1].b) {
                in_r[i][s[pos - 1].id] = j - 1;
                --pos;
            }
            s[pos++] = Elem(b[i][j], j);
        }
        while (pos) {
            in_r[i][s[pos - 1].id] = n;
            --pos;
        }
        s[pos++] = Elem(b[i][n], n);
        for (int j = n - 1; j; --j) {
            while (pos && b[i][j] >= s[pos - 1].b) {
                in_l[i][s[pos - 1].id] = j + 1;
                --pos;
            }
            s[pos++] = Elem(b[i][j], j);
        }
        while (pos) {
            in_l[i][s[pos - 1].id] = 1;
            --pos;
        }
    }
    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= n; ++j) {
            l = in_l[i][j];
            r = in_r[i][j];
            t = b[i][j];
            d[l][j] += t;
            d[l][r + 1] -= t;
            d[j + 1][j] -= t;
            d[j + 1][r + 1] += t;
        }
    for (int i = 1; i <= n + 1; ++i)
        for (int j = 1; j <= n + 1; ++j)
            d[i][j] += d[i - 1][j];
    for (int i = 1; i <= n + 1; ++i)
        for (int j = 1; j <= n + 1; ++j)
            d[i][j] += d[i][j - 1];
    for (int i = 1; i <= n; ++i)
        for (int j = i; j <= n; ++j)
            ans < (t = d[i][j] - dist[j] + dist[i]) && (ans = t);
    printf("%lld\n", ans);
    return 0;
}



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

#define f first
#define s second
#define pb push_back

using namespace std;

typedef unsigned long long int lli;
typedef vector<int> vi;

vi c;

int recur(int l,int r){

    
    int m = 0;    
    
    for(int i = 0;i<r;++i){
        
       m = max(m,c[r]-c[i]);   
        
    }
    
    for(int i = r;i>l;--i){
       m = max(m,c[l]-c[i]);
    }
    
    return m;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int k,ci;
    
    for(int i = 0;i<5;++i){
        
        cin>>ci;
        c.pb(ci);      
        
    }
    cin>>k;
    
    
    if(recur(0,c.size()-1)>k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

template<typename T>
T calc_mod(string s, T d) {
    T r = 0;
    int n = sz(s);
    REP(i, n) r = (r * 10 + (s[i] - '0')) % d;
    return r;
}

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


Measured memory_bytes: 256