akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s = S()
a = s.count("A")
if a == 0 or a == 3:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 63468
#include<stdio.h>

int main () {
	int A, B, C;
	
	scanf("%d %d %d", &A, &B, &C);
	
	if (A == B && B != C) {
		printf ("Yes\n");
	}
	else if (A != B && A == C) {
		printf ("Yes\n");
	}
	else if (B == C && A != C) {
		printf ("Yes\n");
	}
	else {
		printf ("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 3160
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100005
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int a[3][N],b[N],vis[N];
int main(){
    //freopen("1.txt","w",stdout);
    //cout<<setprecision(3)<<fixed;
    int T,i,j,k,n,m=0,K=0;
    scanf("%d",&n);
    rep(i,0,n)scanf("%d",&a[0][i]),a[0][i]--;
    rep(i,0,n)scanf("%d",&a[1][i]),a[1][i]--;
    rep(i,0,n)scanf("%d",&a[2][i]),a[2][i]--;
    int e=0,o=0;
    rep(i,0,n){
        int x=a[1][i]/3;
        if(a[1][i]%3!=1||a[0][i]/3!=x||a[2][i]/3!=x||(i%2!=x%2)){puts("No");return 0;}
        if(a[0][i]>a[2][i]){
            if(i&1)e^=1;else o^=1;
        }
        b[i]=x;
    }
    int odd=0,even=0;
    for(i=0;i<n;i+=2)if(!vis[i]){
        int x=i;m=0;
        while(!vis[x])vis[x]=1,m++,x=b[x];
        odd+=m-1;
    }
    for(i=1;i<n;i+=2)if(!vis[i]){
        int x=i;m=0;
        while(!vis[x])vis[x]=1,m++,x=b[x];
        even+=m-1;
    }
    odd&=1,even&=1;
    if(e!=odd||o!=even)puts("No");
    else puts("Yes");
    return 0;
}

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

#define MAX 256

int main(void){
	
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	
	long a[n][m];
	long b[m][l];
	long c[n][l];

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

	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			b[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			c[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			scanf("%ld", &a[i][j]);
		}
	}

	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			scanf("%ld", &b[i][j]);
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
			if (j != l - 1)printf("%ld ", c[i][j]);
		}
		printf("%ld\n", c[i][l - 1]);
	}

	return 0;
}

Measured memory_bytes: 3436
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<tuple>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<fstream>


#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define foru(i , a , b) for(ll i = a ; i < b ; i++)
#define ford(i , a , b) for(ll i = a ; i >= b ; i--)
#define dbg(a) cerr << #a << ": " << a << "\n";
#define ain(a , n) for(ll i = 0 ; i < n ; i++) cin >> a[i]
#define aout(a , n) for(ll i = 0 ; i < n ; i++) cout << a[i] << " "
#define M 1000000007
#define mp make_pair
#define mt make_tuple
#define cend cout << "\n"
#define all(x) x.begin() , x.end()
#define aout2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cout << a[i][j] << " ";} cout << endl;}
#define ain2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cin >> a[i][j];}}
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}


/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

int main(){
    fastio;
#ifndef ONLINE_JUDGE
    freopen("testcase.txt" , "r" , stdin);
    freopen("error.txt" , "w" , stderr);
    freopen("output.txt" , "w" , stdout);
#endif
    ll n , k; cin >> n >> k; ll ans = 0;
    foru(i , k , n + 2){
        ans = (ans + ((((i)*(2*n + 1 - i))/2)%M - ((i*(i - 1))/2)%M + 1 + M)%M)%M;
    }
    cout << ans;
}
























Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, count=0;
  cin >> N;
  map<string, int> p;
  
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    if(p.count(s)) continue;
    else p[s] = 1;
  }
  for(auto x : p){
    count++;
  }
  cout << count << endl; 
}

Measured memory_bytes: 19232
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		execute5_2();
	}
	
	private static void execute5_2() {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int K = sc.nextInt();
			
			long[] a = new long[N];
			
			for(int i=0; i<N;i++) {
				a[i] = sc.nextLong();
			}
			
			Arrays.sort(a);
			
			long ans =0;
			for(int i=N-1;i>=0;i--) {
				if(0<K) {
					K--;
					continue;
				}
				ans+=a[i];
			}
			System.out.println(ans);
		}
	}
}

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

int main(void)
{

	int N,x,i;

	string S;

	cin >> N >> S;

	size_t size = S.size();

	for(i=0;i<size;i++)
	{
		x=S[i]-'A';

		x=(x+N)%26;

		S[i]='A'+x;

		cout << S[i];
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
/**
 *  Kaiwen Zhou,
 *  CUHK
**/
#include <bits/stdc++.h>
using namespace std;
#define INS ios::sync_with_stdio(false);cin.tie(0)
typedef long long LINT;
#define INF 1000000000000
vector<int> dp(100001, -1);
vector<vector<int>> prev_map(100001);
int N, M;

int msearch(int i) {
    if(dp[i] != -1) return dp[i];
    int maxi = 0;
    for(auto u : prev_map[i]) {
        maxi = max(maxi, msearch(u) + 1);
    }
    dp[i] = maxi;
    return maxi;
}

int main(void) {
    INS;
    cin >> N >> M;
    for(int i = 0; i < M; i ++) {
        int x, y;
        cin >> x >> y;
        prev_map[y].push_back(x);
    }
    int ans = -1;
    for(int i = 1; i <= N; i ++) {
        ans = max(ans, msearch(i));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 10624
#include <stdio.h>

int main(int argc, char const* argv[])
{
	int n;
	char s[256];
	int i;

	while (1){

		scanf("%d", &n);
		if (n == 0){
			break;
		}

		sprintf(s, "%o", n);

		for (i = 0; s[i] != '\0'; i++){
			if (s[i] >= '4'){
				s[i]++;
			}
			if (s[i] >= '6'){
				s[i]++;
			}
			printf("%c", s[i]);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 624
#include<stdio.h>
int main(){
    int n,k,q;
    scanf("%d %d %d", &n, &k, &q);
    
    int correct[q];
    int person[n];

    for(int i;i<n;i++){
        person[i] = 0;
    }

    for(int i = 0;i<q;i++){
        scanf("%d",&correct[i]);
        person[(correct[i] -1)]++;
    }

    for(int i = 0;i< n;i++){
        if(q - person[i] >= k){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }
   
    return 0;
}

Measured memory_bytes: 1280
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int L = sc.nextInt();
        int T = sc.nextInt();
        int[] X = new int[N];
        int[] W = new int[N];
        for (int i = 0; i < N; ++i) {
            X[i] = sc.nextInt();
            W[i] = sc.nextInt();
        }

        int[] p = new int[N];
        int x0 = 0;
        for (int i = 0; i < N; ++i) {
            if (W[i] == 1) {
                p[i] = (X[i] + T) % L;
                x0 += (X[i] + T) / L;
            } else {
                p[i] = (X[i] - T) % L;
                x0 += (X[i] - T) / L;
                if (p[i] < 0) {
                    p[i] += L;
                    --x0;
                }
            }
        }
        Arrays.sort(p);
        x0 %= N;
        if (x0 < 0) {
            x0 += N;
        }
        for (int i = 0; i < N; ++i) {
            _out.println(p[(i + x0) % N]);
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 93124
#include <iostream>

using namespace std;

int main()
{
    char a;
    cin>>a;
    switch(a)
    {
        case 'A':cout<<"T";break;
        case 'T':cout<<"A";break;
        case 'C':cout<<"G";break;
        case 'G':cout<<"C";break;
    }
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
    freopen("input.in" , "r" , stdin);
#endif
    int n , m;
    cin >> n >> m;

    vector<int> adj[m + 1];
    for (int i = 1 ;i <= n ;i++) {
        int time , reward;
        cin >> time >> reward;
        if (time <= m)
            adj[time].push_back(reward);
    }

    int ans = 0;

    priority_queue<int> pq;
    for (int i = 1 ;i <= m ;i++) {
        for (int x : adj[i])
            pq.push(x);

        if (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
    }

    cout << ans;
}


Measured memory_bytes: 8892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;



int main() {
	int N, L; cin >> N >> L;
	vector<string> s(N);
	for (int i = 0; i < N; i++) cin >> s[i];
	sort(s.begin(), s.end());
	for (auto t : s) cout << t; cout << endl;
	return 0;
}

Measured memory_bytes: 256
# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False


def eratosthenes(n):
    s = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if s[x]: mark(s, x)
    return s

Q = int(input())
LR = [list(map(int, input().split())) for i in range(Q)]

primes = eratosthenes(10 ** 5+1)
primes[0] = False
primes[1] = False

ruiseki = [0] * (10**5 + 1)
for i in range(3, 10**5 + 1, 2):
    if (primes[i]) and (primes[int((i+1)/2)]):
        ruiseki[i] = ruiseki[i-2] + 1
    else:
        ruiseki[i] = ruiseki[i-2]

for l, r in LR:
    print(ruiseki[r] - ruiseki[l-2])




Measured memory_bytes: 29804
import sys
import copy
sys.setrecursionlimit(10000)

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def unite(x, y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        par[rx] = ry

def same(x, y):
    return root(x) == root(y)


n, m = map(int, input().split())

par = [i for i in range(n)]

a = [0] * m
b = [0] * m

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

ans = 0

for i in range(m):
    c = copy.deepcopy(a)
    d = copy.deepcopy(b)
    c = c[:i] + c[i+1:]
    d = d[:i] + d[i+1:]
    par = [i for i in range(n)]
    for j in range(m-1):
        unite(c[j]-1, d[j]-1)
    if not same(a[i]-1, b[i]-1):
        ans += 1

print(ans)

Measured memory_bytes: 9356
from collections import deque

queue = deque()

for _ in range(int(input())):
    commands = input().split(" ")
    if commands[0] == "insert":
        queue.appendleft(commands[1])
    elif commands[0] == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif commands[0] == "deleteFirst":
        queue.popleft()
    elif commands[0] == "deleteLast":
        queue.pop()

print(" ".join(queue))

Measured memory_bytes: 71924
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read():
    N, K = map(int, input().strip().split())
    G = [[] for i in range(N+1)]
    for i in range(N-1):
        a, b = map(int, input().strip().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    return N, K, G


def permute_init(n, MOD):
    factorial = [1 for i in range(n+1)]
    for i in range(1, n+1):
        factorial[i] = factorial[i-1] * i
        factorial[i] %= MOD
    return factorial


def permute(n, r, factorial, MOD):
    """nPr = n! / (n-r)!"""
    if n < 0 or r < 0 or n < r:
        return 0
    return factorial[n] * pow(factorial[n-r], MOD-2, MOD) % MOD


def solve(N, K, G, MOD=10**9+7):
    factorial = permute_init(K, MOD)

    visited = [False for i in range(N)]
    
    def dfs(a=0):
        f = 1
        if a == 0:
            f = permute(K-1, len(G[a]), factorial, MOD)
        else:
            f = permute(K-2, len(G[a])-1, factorial, MOD)
        for b in G[a]:
            if not visited[b]:
                visited[b] = True
                f *= dfs(b)
                f %= MOD
        return f
    
    visited[0] = True
    ans = K * dfs(0) % MOD

    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 111764
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int  a[N],flag[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	long long n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		n-=x;
	}
	if(n>=0)cout<<n;
	else cout<<"-1";
}


Measured memory_bytes: 3648
#include <stdio.h>
#define MAX 2000000000
void maxHeapify(int);
int A[MAX+1];
int H;
 
int main(void)
{
    int i,j;
 
    scanf("%d",&H);
     
    for(i=1;i<H+1;i++){
    scanf("%d", &A[i]);
    }
     
    for(i=H/2;i>=1;i--){
    maxHeapify(i);
    //printf("max-heapifing...\n");
    }
     
    for(i=1;i<H+1;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
     
}
 
void maxHeapify(int i){
    int tmp;
    int max;
    if(i*2<H+1 && A[i] < A[i*2]){
        max = i*2;
        //printf("left is largest\n");
    }
     
    else {
        max = i;
    //  printf("i is largest\n");
    }
    if(i*2+1 < H+1 && A[max] < A[i*2+1]){
        max = i*2+1;
    //  printf("right is largest\n");
    }
     
    if(max != i ){
        tmp  = A[max];
        A[max] = A[i];
        A[i] = tmp; 
        maxHeapify(max);
    }
}


Measured memory_bytes: 3688
h, w, k = map(int,input().split())
ans = 0
c = [list(input()) for _ in range(h)]

for p_h in range(2**h):
    for p_w in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (p_h >> i)&1 == 0 and (p_w >> j)&1 == 0:
                    if c[i][j] == "#":
                        cnt += 1
        
        if cnt == k:
            ans += 1

print(ans)

Measured memory_bytes: 73764
def main():
    import sys
    N = int(input())
    left = 0
    right = N
    table = ["?"]*N
    print(left)
    sys.stdin.flush()
    le = input()
    if le == "Vacant":
        return
    table[left] = le

    for i in range(20):
        c = (left + right) // 2
        print(c)
        sys.stdin.flush()
        s = input()
        if s == "Vacant":
            return
        table[c] = s
        if (c - left) % 2 == 0 and table[left] == table[c]:
            left = c
        elif (c - left) % 2 == 1 and table[left] != table[c]:
            left = c
        else:
            right = c


if __name__ == '__main__':
    main()


Measured memory_bytes: 4424
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstdint>
using namespace std;

const uint64_t kP = 1000000007;

int main()
{
  string s;
  uint64_t dp[100100][13];

  cin >> s;
  const uint64_t n = s.size();

  dp[0][0] = 1;
  for (uint64_t i = 0; i < n; ++i) {
    const uint64_t c = (s[i] == '?') ? 100 : s[i] - '0';
    for (uint64_t k = 0; k < 13; ++k) {
      dp[i+1][k] = 0;
    }
    for (uint64_t j = 0; j < 10; ++j) {
      if (c != 100 && c != j) continue;
      for (uint64_t k = 0; k < 13; ++k) {
        dp[i+1][(10 * k + j) % 13] += dp[i][k];
        dp[i+1][(10 * k + j) % 13] %= kP;
      }
    }
  }

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

  return 0;
}




Measured memory_bytes: 10624
n, a, b = map(int, input().split())


def modpow(a, b, mod=10 ** 9 + 7):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


def modcomb(n, c, mod=10 ** 9 + 7):
    if c > n - c:
        c = n - c
    u, d = 1, 1
    for i in range(c):
        u = u * (n - i) % mod
        d = d * (i + 1) % mod
    return u * modpow(d, mod - 2) % mod


print((modpow(2, n) - modcomb(n, a) - modcomb(n, b)) % (10 ** 9 + 7) - 1)


Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int n = sc.NextInt(), m = sc.NextInt();
        var points = new int[n];
        var targets = new int[m];
        for (int i = 0; i < m; i++)
        {
            targets[i] = sc.NextInt() - 1;
        }

        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                int a = sc.NextInt() - 1;
                points[targets[i] == a ? j : targets[i]]++;
            }
        }
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(points[i]);
        }
    }

    static void Main()
    {
        byte[] inputBuffer = new byte[1024];
        Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 9252
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let x = scan!(usize);
    if x < 1200 {
        println!("ABC")
    } else {
        println!("ARC")
    }
}


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

string convert(string pre) {
    int pos = 0;
    int num = 0;
    char chr = '\0';
    string ret;

    while (pos < pre.size()) {
        if (chr == pre[pos]) {
            ++num;
        } else {
            if (num){
                stringstream ll;
                ll << num;
                ret += ll.str() + chr;
            }
            chr = pre[pos];
            num = 1;
        }
        ++pos;
    }

    stringstream ll;
    ll << num;
    ret += ll.str() + chr;

    return ret;
}

int main() {
    int n;
    string s;
    while (1) {
        cin >> n;
        if (!n) {
            return 0;
        }
        cin >> s;
        for (int i=0;i<n;i++) s = convert(s);
        cout << s + "\n";
    }
}

Measured memory_bytes: 1360
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <ctime>
#include <random>

#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
//ifstream cin("input.txt"); ofstream cout("output.txt");
//ifstream cin("umbrella.in"); ofstream cout("umbrella.out");

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	vector<int> A(16);
	if (a < b) swap(a, b);
	for (int i = 0; i < 16; i += 2) {
		if (a == 0) break;
		else {
			a--;
			A[i] = 1;
		}
	}
	for (int i = 1; i < 16; i += 2) {
		if (b == 0) break;
		else {
			b--;
			A[i] = 2;
		}
	}
	for (int i = 1; i < 16; i++) {
		if (A[i] && A[i - 1] == A[i]) {
			cout << ":(";
			return 0;
		}
	}
	if (A[0] == A[15] && A[0] || a || b) {
		cout << ":(";
	}
	else {
		cout << "Yay!";
	}
	return 0;
}

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


using namespace std;
using ll = long long;

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

int main(){
    int n,x,ans=0;
    cin >> n >> x;
    vector<int> m(n);

    rep(i,n){ cin >> m[i];
        x -= m[i];
    }
    ans += n;
    sort(m.begin(),m.end(), less<int>());
    ans += (x / m[0]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

 int main(void){
   int A,B,C,check=0;
   cin >> A >> B >> C;
   for(int i=1;i<=B;i++){
     if((A*i)%B==C) check=1;
   }
   if(check==0) cout << "NO" << endl;
   else cout << "YES" << endl;
 }

Measured memory_bytes: 256
a = int(input())
L0 =2
L1 =1
if a==0:
    print(L0)
elif a==1:
    print(L1)
else:
    for i in range(2, a+1):
        temp = L1
        L1 = L1 +L0
        L0 = temp

    print(L1)

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

map<int,int>f;
int n, m, a[101000], b[101000];
map<int,set<int,greater<int> > >S;

void add(int x,int v){
  for (;x<=mod;x+=x&-x)
    f[x]=(f[x]+v)%mod;
}
int que(int x){
  int t=0;
  for (;x;x-=x&-x)
    t=(t+f[x])%mod;
  return t;
}

int main(){
  cin>>n>>m;
  for (int i=1;i<=n;++i) cin>>a[i];
  for (int i=1;i<=m;++i) cin>>b[i];
  for (int i=1;i<=n;++i){
    int p=lower_bound(b+1,b+m+1,a[i])-b;
    if (p>=2&&p<=m) S[a[i]-b[p-1]].insert(b[p]-a[i]);
  }
  add(1,1);
  for (auto it:S)
    for (auto o:it.second)
      add(o+1,que(o));
  cout<<que(mod);
}


Measured memory_bytes: 68096
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <cassert>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll a[100];
ll ans = 0;
ll tmp[100];
int main(){
  cin >> N;
  rep(i,N){
    cin >> a[i];
    if(a[i] == 0){
      cout << "0" << endl;
      return 0;
    }
  }
  if(N >= 24){
    cout << "0" << endl;
    return 0;
  }
  rep(i,(1 << N)){
    //cerr << i << endl;
    rep(j,25){
      tmp[j] = 0;
    }
    rep(j,N){
      if(i & (1 << j)){
        tmp[a[j]]++;
      }
      else{
        tmp[24-a[j]]++;
      }
    }
    /*
    rep(j,24){
      cerr << tmp[j] << " ";
    }
    cerr << endl;
    */
    ll prev = 0;
    ll tmp_ans = 100;
    rep(j,24){
      if(tmp[j] > 1){
        tmp_ans = 0;
        break;
      }
      else if(tmp[j] == 1){
        tmp_ans = min(tmp_ans, abs(prev-j));
        prev = j;
      }
    }
    tmp_ans = min(tmp_ans, abs(24-prev));
    if(tmp_ans > ans) ans = tmp_ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;


int main(){
   string day[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
   string s;
   cin >> s;
   rep(i, 7){
       if(s == day[i]){
           if(i != 6)cout << 6 - i << endl;
           else cout << 7;
           return 0;
       }
   }
}



Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int N, M;

int main(void)
{
    cin >> N >> M;
    int out = 0;
    for (int i = M / N; i > 0; i--)
    {
        if (M % i == 0)
        {
            out = i;
            break;
        }
    }
    cout << out;

    return 0;
}

Measured memory_bytes: 256
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const LL inf=1e9;
template <class T>
struct segment_tree_min
{
    #define chl (k<<1)
    #define chr (k<<1|1)
    #define mid ((l+r)>>1)
    T *t,*tag;
    int n;

    segment_tree_min(int n) {t=new T[n<<2](); tag=new T[n<<2](); this->n=n;}

    void push_up(int k) {t[k]=min(t[chl],t[chr]);}

    void push_down(int k,int l,int r)
    {
        if(!tag[k]) return;
        t[chl]+=tag[k]; t[chr]+=tag[k];
        tag[chl]+=tag[k]; tag[chr]+=tag[k]; tag[k]=0;
    }

    void build(int k,int l,int r,T *a)
    {
        if(l>r) return;
        if(l==r) {t[k]=a[l]; return;}
        build(chl,l,mid,a); build(chr,mid+1,r,a);
        push_up(k);
    }
    void build(T *a) {build(1,1,n,a);}

    void update_add(int k,int l,int r,int ll,int rr,T x)
    {
        if(l>rr || ll>r) return;
        if(l>=ll && r<=rr) {t[k]+=x; tag[k]+=x; return;}
        push_down(k,l,r);
        update_add(chl,l,mid,ll,rr,x); update_add(chr,mid+1,r,ll,rr,x);
        push_up(k);
    }
    void update_add(int ll,int rr,T x) {update_add(1,1,n,ll,rr,x);}

    T query(int k,int l,int r,int ll,int rr)
    {
        if(l>rr || ll>r) return inf*10000;  // attention!
        if(l>=ll && r<=rr) return t[k];
        push_down(k,l,r);
        return min(query(chl,l,mid,ll,rr),query(chr,mid+1,r,ll,rr));
    }
    T query(int ll,int rr) {return query(1,1,n,ll,rr);}
};

const int maxn=2e5+5;
int H,W,A[maxn],B[maxn];

int main()
{
    H=read(),W=read();
    REP(i,1,H) A[i]=read(),B[i]=read();
    segment_tree_min<LL> t1(W),t2(W);
    REP(i,1,W) t2.update_add(i,i,-i);

    REP(i,1,H)
    {
        int r=B[i]+1;
        if(r<=W)
        {
            LL minx=t2.query(1,B[i]);
            LL now=t1.query(r,r);
            if(now>minx+r)
            {
                t1.update_add(r,r,minx+r-now);
                t2.update_add(r,r,minx-t2.query(r,r));
            }
        }
        t1.update_add(A[i],B[i],inf);
        t2.update_add(A[i],B[i],inf);
        t1.update_add(1,W,1);
        t2.update_add(1,W,1);

        LL x=t1.query(1,W);
        if(x>=inf) puts("-1");
        else printf("%lld\n",x);
    }

    return 0;
}


Measured memory_bytes: 30356
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    ll N,K,S;
    cin >> N >> K >> S;
    if(N==K){
        for(int i=0; i<N-1; i++){
            cout << S << ' ';
        }
        cout << S << endl;
        return 0;
    }
    if(S!=1000000000){
        for(int i=0; i<K; i++){
            cout << S << ' ';
        }
        for(int i=K; i<N-1; i++){
            cout << 1000000000 << ' ';
        }
        cout << 1000000000 << endl;
        return 0;
    }
    for(int i=0; i<K; i++){
        cout << 1000000000 << ' ';
    }
    for(int i=K; i<N-1; i++){
        cout << 1 << ' ';
    }
    cout << 1 << endl;
    

    

    return 0;
}

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


typedef long long LL;

int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    LL ans = 0;
    LL last = 0;
    vector<pair<LL,LL>> v;
    for(int i = 0; i < n; i++) {
        LL a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    reverse(v.begin(), v.end());
    for(auto t : v) {
        LL a = t.first, b = t.second;
        LL lo = 0, hi = 1e18/b;
        while(hi > lo) {
            LL mid = lo+hi>>1;
            if(b * mid >= a + last) hi = mid;
            else lo = mid+1;
        }
        last = lo*b-a;
//        debug(), dbg(last);
    }
    cout << last << endl;
}





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

int main(){
	ll k,x; cin >> k >> x;
	if(k*500 >= x)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::string S; std::cin >> S;

  int ans = 0;
  for(int i=0; i<N; i++) {
    if ( S.substr(i,3) == "ABC" ) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    ans = 0
    # 隣り合うものを比較する
    for i in range(1,n):
        if A[i] == A[i-1]:
            ans += 1
            A[i] = -1
    print(ans)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, K; cin >> N >> K;
    int sum = 0;
    rep(i,N) {
        int H;
        cin >> H;
        if (H >= K) sum++;
    }
    cout << sum << endl;
}


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


int main() {
    int N;
    cin >> N;
    int ans = 0;
    while (N > 0) {
        if (N % 10 == 2) ++ans;
        N /= 10;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
from itertools import accumulate
from bisect import bisect_right
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M,K = map(int, readline().split())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]

    acc_A = [0] + list(accumulate(A))
    acc_B = [0] + list(accumulate(B))

    ans = 0
    for i, a in enumerate(acc_A):
        tmp = i
        rest = K - a
        if rest < 0:
            ans = max(ans, bisect_right(acc_B, K) - 1)
            break
        b_ind = bisect_right(acc_B, rest) - 1
        tmp += b_ind

        ans = max(ans, tmp)
   
    print(ans)
       


if __name__ == "__main__":
    main()


Measured memory_bytes: 49200
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;


long long int n,m,a,b,c,res=0;
int main() {
    int count=0;
    string str,str2;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i<=9||100<=i&&i<=999||10000<=i&&i<=99999){
            res++;
        }
    }
    cout<<res;
    
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,ll> p1,pair<ll,ll> p2){
return p1.se>p2.se;
}
void solve(){
  ll n,m,a,sum=0;
  cin>>n>>m;
  fr(i,0,m){
  cin>>a;
  sum+=a;
  }
  if(sum>n) cout<<-1<<endl;
    else cout<<n-sum<<endl;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
solve();
    }
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N)
  {
    cin >> A[i];
    A[i] -= i + 1;
  }

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

  // rep(i, N) cout << A[i] << endl;
  int b = A[A.size() / 2];
  ll ans = 0;
  rep(i, N)
  {
    ans += abs(A[i] - b);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
ab = []
array1 = [[] for _ in range(N+1)]
result = 0

for _ in range(M):
    a, b = map(int, input().split())
    ab.append([a, b])
    array1[a].append(b)
    array1[b].append(a)

for i in ab:
    array2 = [j[:] for j in array1]
    array2[i[0]].remove(i[1])
    array2[i[1]].remove(i[0])
    L = []
    save = []
    x = 1
    
    while True:
        if not x in L:
            L.append(x)
            save.append(x)

        if len(L) == N:
            break

        flag = True
        for j in array2[x]:
            if not j in L:
                x = j
                flag = False
                break

        if flag:
            del save[-1]
            if not save:
                result += 1
                break

            x = save[-1]

print(result)


Measured memory_bytes: 3064
#include <cstdio>
#include <utility>
#include <algorithm>

std::pair<int, int> order[100000];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", &order[i].first);
    order[i].second = i + 1;
  }
  
  std::sort(order, order + n);
  printf("%d", order[0].second);
  for (int i = 1; i < n; ++i)
  {
    printf(" %d", order[i].second);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdlib>
#include<string>
#include<stack>
using namespace std;



int main()
{
	stack<int> my_stack;
	string str;
	while (cin >> str) {
		if (str[0] == '+') {
			int a1 = my_stack.top();
			my_stack.pop();
			int a2 = my_stack.top();
			my_stack.pop();
			my_stack.push(a1 + a2);
		}
		else if (str[0] == '-') {
			int a1 = my_stack.top();
			my_stack.pop();
			int a2 = my_stack.top();
			my_stack.pop();
			my_stack.push(a2 - a1);
		}
		else if (str[0] == '*') {
			int a1 = my_stack.top();
			my_stack.pop();
			int a2 = my_stack.top();
			my_stack.pop();
			my_stack.push(a1*a2);
		}
		else {
			my_stack.push(atoi(str.c_str()));
		}
	}

	cout << my_stack.top() << endl;
    return 0;
}


Measured memory_bytes: 3212
#mapってそんなに速ないんけ？
#for 文と勝負や
iN = int(input())
aA = [0] + [int(_) for _ in input().split()] + [0]
#iAll = sum(map(lambda i :abs(aA[i+1]-aA[i]),range(iN+1)))
iAll = sum([abs(aA[i+1]-aA[i]) for i in range(iN+1)])
#print("\n".join(map(str,map(lambda i:iAll - abs(aA[i-1]-aA[i]) - abs(aA[i]-aA[i+1]) + abs(aA[i-1]-aA[i+1]), range(1,iN+1)))))
print("\n".join(map(str,[iAll - abs(aA[i-1]-aA[i]) - abs(aA[i]-aA[i+1]) + abs(aA[i-1]-aA[i+1]) for i in range(1,iN+1)])))


Measured memory_bytes: 18424
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

moduloN = 10 ^ 9 + 7
modN = flip mod moduloN
mulMod x y = modN $ x * y

main = do
    [n, m] <- getIntList
    as <- replicateM m getInt
    print . foldl' mulMod 1 $ zipWith (\x y -> modN (mf (x - y - 2))) (as ++ [n+1]) ((-1) : as)

mf x | x < 0 = 0
     | otherwise = fib' !! x

fib' = 1 : 1 : zipWith' (+) fib' (tail fib') 

zipWith' f (x:xs) (y:ys) = let z = f x y
                           in z `seq` (z : zipWith' f xs ys)

Measured memory_bytes: 21500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << x << '\n';
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, n, cnt = 1;
  cin >> a >> b;
  n = __gcd(a, b);
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      cnt++;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n != 1) cnt++;
  cout << cnt << '\n';
}


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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

ll dp[55];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    if (s[0] == t[0]) {
        dp[0] = 3;
    } else {
        dp[1] = 6;
    }
    for (int i = 1; i < n; ++i) {
        if (dp[i]) {
            continue;
        }
        if (s[i - 1] == t[i - 1] && s[i] == t[i]) {
            dp[i] = dp[i - 1] * 2 % M;
        }
        if (s[i - 1] == t[i - 1] && s[i] != t[i]) {
            dp[i + 1] = dp[i - 1] * 2 % M;
        }
        if (s[i - 1] != t[i - 1] && s[i] == t[i]) {
            dp[i] = dp[i - 1];
        }
        if (s[i - 1] != t[i - 1] && s[i] != t[i]) {
            dp[i + 1] = dp[i - 1] * 3 % M;
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 256
#![allow(dead_code, unused_imports, deprecated)]
 
use std::collections::HashMap;
use std::cmp::Reverse;
 
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

use maplit::*;

#[fastout]
fn main() {
  input!{
    n: usize,
  };

  let res = (1..=n).filter(|i| i % 3 != 0 && i % 5 != 0).sum::<usize>();
  println!("{}", res);
}

Measured memory_bytes: 2152
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

V = Counter(S[0])
for s in S:
    cntS = Counter(s)
    for t in S[0]:
        V[t] = min(V[t], cntS[t])

ans = []
for s in sorted(V.keys()):
    ans += [s] * V[s]
print(''.join(ans))

Measured memory_bytes: 3316