akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cassert>
#include <complex>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define EPS 1e-10

typedef complex<double> P;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

double dist2(P& a, P& b)
{
	return (a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag());
}

class XP
{
public:
	int cg;
	double dist;
	XP(int cg, double dist)
	:cg(cg),dist(dist)
	{}
	
	bool operator<(const XP& a) const
	{
		return dist<a.dist;
	}
};

int main()
{
	int N,M;
	scanf("%d", &N);
	while(N--)
	{
		int xa,ya,xb,yb;
		scanf("%d%d%d%d", &xa,&ya,&xb,&yb);
		L line=L(P(xa,ya),P(xb,yb));
		
		scanf("%d", &M);
		vector<XP> xp;
		while(M--)
		{
			int xs,ys,xt,yt,o,l;
			scanf("%d%d%d%d%d%d",&xs,&ys,&xt,&yt,&o,&l);
			L road=L(P(xs,ys),P(xt,yt));
			
			if(intersectSS(line, road))
			{
				int cg=(o==l?1:0);
				P p=crosspoint(line, road);
				xp.push_back(XP(cg, dist2(line[0], p)));
			}
		}
		
		int cnt=0;
		sort(xp.begin(), xp.end());
		if(xp.size()>0)
		{
			int ps=xp[0].cg;
			for(int i=1; i<xp.size(); i++)
			{
				if(xp[i].cg!=ps)
				{
					cnt++;
					ps=xp[i].cg;
				}
			}
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 840
def create_sum(N):
    list_align = [2 for _ in range(N)]
    for i in range(N):
        if i % 2 == 0:
            list_align[i] *= -1
    list_align[0] //= 2
    list_align[N-1] //= 2
    list_align.sort()
    return list_align

def solve(N, Array):
    sum1 = 0
    sum2 = 0
    arr = create_sum(N)
    for i in range(N):
        sum1 += arr[i] * Array[i]
        sum2 += arr[i] * Array[N-1-i]
    print(max(abs(sum1), abs(sum2)))
    
if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    solve(N, A)

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin >> a[i];
    int ct=0;
    int min_n=abs(a[0]);
    for(int i=0;i<n;++i){
        if(a[i]<0) ct++;
        int res = abs(a[i]);
        if(res<min_n) min_n=res;
    }
    long long ans = 0;
    for(int i=0;i<n;++i){
       ans += abs(a[i]);
    }
    if(ct%2==1){
        ans -= 2*min_n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
fn main() {
    let v = read_vec::<usize>();

    println!("{} {} {}", v[2], v[0], v[1]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);p[i]--;
	}
	for(int i=0;i<a;i++)p[i]=(p[i]==i);
	int ret=0;
	for(int i=0;i<a;i++){
		if(p[i]+p[i+1]==2){
			ret++;p[i]=p[i+1]=0;
		}else if(p[i])ret++;
	}
	printf("%d\n",ret);
}

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

using namespace std;

const int N = 1e6 + 10;

int n, m, siz, num;
int w[N], cnt[N], belong[N];
int now, ans[N];

struct query{
	int l, r, id;
}q[N];

//bool cmp(query a, query b)
//{
//	return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.l] & 1) ? a.r < b.r : a.r > b.r);
//}
bool cmp(query a, query b) {
    return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.l] & 1) ? a.r < b.r : a.r > b.r);
}

void add(int pos)
{
	if(!cnt[w[pos]]) ++now;
	++cnt[w[pos]];
}

void del(int pos)
{
	--cnt[w[pos]];
	if(!cnt[w[pos]]) --now;
}

int main()
{
	scanf("%d%d", &n, &m);
	siz = sqrt(n);
	num = ceil((double) n / siz);
//	cout << num << endl;
	for (int i = 1; i <= num; i ++)
	{
		for (int j = (i - 1) * siz + 1; j <= i * siz; j ++)
		{
			belong[j] = i;
		}
	}
	for (int i = 1; i <= n; i ++) scanf("%d", &w[i]);
	for (int i = 1; i <= m; i ++)
	{
		q[i].id = i;
		scanf("%d%d", &q[i].l, &q[i].r);
	}
	sort(q + 1, q + m + 1, cmp);
	int l = 1, r = 0;
	for (int i = 1; i <= m; i ++)
	{
		int ql = q[i].l, qr = q[i].r;
		while(l < ql) del(l ++);
		while(l > ql) add(-- l);
		while(r < qr) add(++ r);
		while(r > qr) del(r --);
		ans[q[i].id] = now;
	}
	for (int i = 1; i <= m; i ++)
		printf("%d\n", ans[i]);
}

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

int n;
string s;

void rec(int pos) {
    if (pos == n) {
        printf("%s\n", s.c_str());
        return;
    }
    char max_c = 'a'-1;
    rep(i,pos){
        if (s[i] > max_c) max_c = s[i];
    }
    max_c++;
    for (char c = 'a'; c <= max_c; c++){
        s[pos] = c;
        rec(pos+1);
    }
}

int main(void){
    scanf("%d", &n);
    s = string(n, ' ');
    rec(0);
    return 0;
}


Measured memory_bytes: 1536
import fractions

n, X = map(int, input().split())
x = list(map(int, input().split()))

for i in range(n):
  x[i] = abs(x[i] - X)
  
ans = x[0]

for i in range(1, n):
  ans = fractions.gcd(ans, x[i])
  
print(ans)

Measured memory_bytes: 16240
import numpy as np
import numba
import sys
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


@njit((i8, i8, i8[:]), cache=True)
def main(Height, Width, XY):
    UP = 300010
    row = np.zeros(UP, np.int64)
    col = np.zeros(UP, np.int64)
    
    for i in range(0, len(XY), 2):
        x, y = XY[i:i + 2] - 1
        row[x] += 1
        col[y] += 1
    
    row_max = row.max()
    col_max = col.max()

    judge = np.sum(row == row_max) * np.sum(col == col_max)

    for i in range(0, len(XY), 2):
        x, y = XY[i:i + 2] - 1
        
        if (row[x] == row_max and col[y] == col_max):
            judge -= 1
    
    summ = row_max + col_max
    
    return (summ if judge else summ - 1)


Height, Width, M_ko = map(int, readline().split())
XY = np.array(read().split(), np.int64)

ans = main(Height, Width, XY)
print(ans)


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

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


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

string query(int n) {
	cout << n << '\n' << flush;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (true) {
		int m = (l + r) / 2;
		R = query(m);
		if (L == R) {
			if (m % 2) r = m;
			else l = m;
		} else {
			if (m % 2) l = m;
			else r = m;
		}
	}
	return 0;
}

Measured memory_bytes: 3860
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

static bool comparator(pair<int32_t, int32_t> left, pair<int32_t, int32_t> right) {
	return left.first < right.first;
}

int main()
{
	int32_t N;
	int64_t K;
	cin >> N >> K;

	vector<pair<int32_t, int32_t>> val(N);
	for (int32_t i = 0; i < N; i++) {
		int32_t a, b;
		cin >> a >> b;
		val[i] = make_pair(a, b);
	}
	sort(val.begin(), val.end(), comparator);

	for (int32_t i = 0; i < N; i++) {
		K -= val[i].second;
		if (K <= 0) {
			cout << val[i].first << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int n, m, nn[100100], dp[100801];
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
	{
		dp[i] = 0;
		nn[i] = 100000000;
	}
	for (int i = 0; i < m; i++)
	{
		cin >> nn[i];
	}
	dp[0] = 1;
	if (nn[0] != 1)
	{
		dp[1] = 1;
	}
	int c = 0;
	for (int i = 2; i <= n; i++)
	{
		if (nn[c] == i - 2)
		{
			if (nn[c + 1] == i - 1)
			{
				if (nn[c + 2] == i)
				{
					c += 3;
				}
				else
				{
					c += 2;
				}
			}
			else
			{
				if (nn[c + 1] == i)
				{
					c += 2;
				}
				else
				{
					dp[i] = dp[i - 1];
					c++;
				}
			}
		}
		else
		{
			if (nn[c] == i - 1)
			{
				if (nn[c + 1] == i)
				{
					c += 2;
				}
				else
				{
					c += 1;
					dp[i] = dp[i - 2];
				}
			}
			else
			{
				if (nn[c] == i)
				{
					c += 1;
				}
				else
				{
					dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
				}
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    static String [][] dp; static String s; static String t;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.next(); t = sc.next();
        int n = s.length(); int m = t.length();
        dp = new String[n+1][m+1];
        lcs(s, t, n, m);
    }

    static void lcs(String X, String Y, int m, int n)
    {
        int[][] L = new int[m+1][n+1];

        // Following steps build L[m+1][n+1] in bottom up fashion. Note
        // that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1]
        for (int i=0; i<=m; i++)
        {
            for (int j=0; j<=n; j++)
            {
                if (i == 0 || j == 0)
                    L[i][j] = 0;
                else if (X.charAt(i-1) == Y.charAt(j-1))
                    L[i][j] = L[i-1][j-1] + 1;
                else
                    L[i][j] = Math.max(L[i-1][j], L[i][j-1]);
            }
        }

        // Following code is used to print LCS
        int index = L[m][n];
        int temp = index;

        // Create a character array to store the lcs string
        char[] lcs = new char[index+1];
        lcs[index] = '\u0000'; // Set the terminating character

        // Start from the right-most-bottom-most corner and
        // one by one store characters in lcs[]
        int i = m;
        int j = n;
        while (i > 0 && j > 0)
        {
            // If current character in X[] and Y are same, then
            // current character is part of LCS
            if (X.charAt(i-1) == Y.charAt(j-1))
            {
                // Put current character in result
                lcs[index-1] = X.charAt(i-1);

                // reduce values of i, j and index
                i--;
                j--;
                index--;
            }

            // If not same, then find the larger of two and
            // go in the direction of larger value
            else if (L[i-1][j] > L[i][j-1])
                i--;
            else
                j--;
        }

        // Print the lcs
        for(int k=0;k<temp;k++)
            System.out.print(lcs[k]);
    }


}


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

int main(void){
	char s[13];
	char b[7];
	std::set<string> m;
	int a;
	scanf("%d",&a);
	while(a--){
		scanf("%s %s",b,s);
		if(b[0]=='i')m.insert(s);
		else{
			if(m.find(s)!=m.end())cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 29112
#include <iostream>

using namespace std;

const int MAXN=1e4+4,MAXH=1e2+2;

int H,W;
int N;
int a[MAXN],c[MAXH][MAXH];

int main() {
        cin >> H >> W >> N;
        for (int i=0; i<N; i++)
                cin >> a[i];

        int curx=0,cury=0;
        for (int i=0; i<N; i++) {
                for (int rep=0; rep<a[i]; rep++) {
                        c[curx][cury] = i+1;
                        if (curx%2 == 0) {
                                if (cury == W-1)
                                        curx++;
                                else
                                        cury++;
                        } else {
                                if (cury == 0)
                                        curx++;
                                else
                                        cury--;
                        }
                }
        }

        for (int i=0; i<H; i++) {
                for (int j=0; j<W; j++)
                        cout << c[i][j] << " ";
                cout << "\n";
        }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;

    return 0;
}

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

using namespace std;

const int N = 1000 + 5;
const int M = 2000 + 5;

int n;
int m;

vector <int> g[N];

void add(int u, int v) {
  g[u].push_back(v);
}

bool instk[N];

bool vis[N];
bool del[N];

bool dfs(int u) {
  vis[u] = 1;
  if (instk[u] == 1) {
    add(0, u);
    return 1;
  } else {
    instk[u] = 1;
  }

  for (int o = 0; o < (int) g[u].size(); ++o) {
    int v = g[u][o];
    if (!del[v] && dfs(v)) {
      add(0, u);
      return 1;
    }
  }
  instk[u] = 0;
  return 0;
}

bool dfs2(int u) {
  vis[u] = 1;
  if (instk[u] == 1) {
    return 1;
  } else {
    instk[u] = 1;
  }

  for (int o = 0; o < (int) g[u].size(); ++o) {
    int v = g[u][o];
    if (!del[v] && dfs2(v)) {
      return 1;
    }
  }
  instk[u] = 0;
  return 0;
}

/*

        
*/

bool get() {
  memset(vis, 0, sizeof(vis));
  memset(instk, 0, sizeof(instk));
  for (int i = 1; i <= n; ++i) {
    if (!vis[i] && !del[i]) {
      if (dfs2(i)) {
        return 1;
      }
    }
  }
  return 0;
}

int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    add(u, v);
  }

  for (int i = 1; i <= n; ++i) {
    del[i] = 1;
    if (get()) {
      continue;
    }
    del[i] = 0;
    
  }

  memset(instk, 0, sizeof(instk));
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i) {
    if (!vis[i] && !del[i]) {
      if (dfs(i)) {
        int ans = (int) g[0].size() - 1;
        cout << ans << endl;
        reverse(g[0].begin(), g[0].end());
        for (int i = 1; i <= ans; ++i) {
          cout << g[0][i] << endl;
    
        }
        return 0;
      }
    }
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int[] divisors = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= n; j += i) {
                divisors[j]++;
            }
        }

        long answer = 0;
        for (int i = 1; i <= n; i++) {
            answer += (long) i * divisors[i];
        }
        out.println(answer);
    }
}


Measured memory_bytes: 72580
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	unordered_map<int,int> ma;
	while(n--) {
		int s;
		cin>>s;
		ma[s]++;
	}
	int cnt = 0;
	for(auto p:ma) {
		if(p.F>p.S) {
			cnt+=p.S;
		} else if(p.F<p.S) {
			cnt+=p.S-p.F;
		}
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 7292
import bisect

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

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    ans += a*(N-c)

print(ans)

Measured memory_bytes: 23360
N,M,*abs=$<.read.split.map(&:to_i)

arr = Array.new(N+1) { Array.new(N+1, 0)}
abs.each_slice(2) do |a,b|
    arr[a][b] = arr[b][a] = 1
end

puts (2..N).to_a.permutation.count { |ls|
    ([1]+ls).each_cons(2).all? { |a,b| arr[a][b] == 1 }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[9] = { 0,0, 0, 1, -1, 1, 1, -1, -1 };    int DY[9] = { 0,1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 061_arc_b / Link: https://abc045.contest.atcoder.jp/tasks/arc061_b?lang=en_  ----- */
/* ------問題------

縦 H 行、横 W 列のマス目からなる盤があります。最初、どのマス目も白く塗られています。
すぬけ君が、このうち N マスを黒く塗りつぶしました。i 回目 ( 1≤i≤N ) に塗りつぶしたのは、 上から ai 行目で左から bi 列目のマスでした。
すぬけ君がマス目を塗りつぶした後の盤の状態について、以下のものの個数を計算してください。
各整数 j ( 0≤j≤9 ) について、盤の中に完全に含まれるすべての 3 行 3 列の連続するマス目のうち、黒いマスがちょうど j 個あるもの。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL H, W, N;

LL ans = 0LL;

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

	cin >> H >> W >> N;
	map<PII, int>Map;
	FOR(i, 0, N) {
		int a, b; cin >> a >> b;
		a--, b--;
		FOR(k, 0, 9) {
			int ny = a + DY[k], nx = b + DX[k];
			if (1 <= ny&&ny < H-1 && 1 <= nx&&nx < W-1) {
				Map[PII(ny, nx)]++;
			}
		}
	}
	VL cnt(10, 0);
	int sum = 0;
	for (auto it = Map.begin(); it != Map.end(); it++) {
		cnt[(*it).second]++;
		sum++;
	}
	cnt[0] = (H-2)*(W-2) - sum;
	FOR(i, 0, 10) {
		cout << cnt[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}
const ll inf = 99999999999;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m; cin >> n >> m;
    vec<ll> pow2(14); pow2[0] = 1;
    rep(i,13)pow2[i+1] = pow2[i] * 2; 
    ll t = pow2[n];
    vec<ll> dp(5000,inf);
    dp[0] = 0;
    rep(i,m){
        ll a,b; cin >> a >> b;
        ll bit = 0;
        rep(i,b){
            ll c; cin >> c; --c;
            bit += pow2[c];
        }
        rep(i,t){
            ll s = i|bit;
            dp[s] = min(dp[s],dp[i]+a);
        }
    }
    ll ans = dp[t-1] == inf ? -1 : dp[t-1];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main() {
	long long X;
	scanf("%lld", &X);
    long long Y = 100;
    int count = 0;
    while(Y < X) {
        Y += Y * 0.01;
        count++;
    }
    printf("%d\n", count);
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N;
int sx, sy;
typedef long long ll;
typedef pair<ll,ll> P;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first > b.first;
    }
}
int main(){
    vector<P> data;
    cin >> N;
    for(int i=0;i<N;i++){
        ll tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        data.push_back(P(tmp1,tmp2));
    }
    sort(data.begin(),data.end(),compare_by_b);
    ll nowt=0;
    // for(int i=0;i<N;i++){
    //     cout << data[i].first <<" " <<data[i].second << endl;
    // }
    for(int i=0;i<N;i++){
        nowt += data[i].first;
        if(nowt > data[i].second){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  int n;

  cin >> n;

  int a, b, sum;
  a = 0;
  b = 0;
  while (true) {
    while (true) {
      if (4*a + 7*b == n) {
        cout << "Yes" << endl;
        return 0;
      }
      if (4*a + 7*b > n) {
        break;
      }
      b++;
    }
    b = 0;
    if (4*a > n) {
      break;
    }
    a++;
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := Scan()
	ans := 1
	for i := 1; i < n; i++ {
		if s[i] != s[i-1] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int cn;
char t[51];
string s;

int main(){
	cin>>cn;
	while(cin>>s){
		fill(t,t+51,0);
		int cur=0,n=25;
		while(1){
			t[n]=s[cur++];
			if(cur==s.size())break;
			if(s[cur]=='-')n++;
			else n--;
			cur+=2;
		}
		for(int i=0;i<51;i++)if(t[i])cout<<t[i];
		cout<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define dst distance
#define INF 1000000000
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define MAXN 310
ll MOD = 1e9+7;

ll N,M,a,b,c;
vpi V[MAXN];
ll dp[MAXN][MAXN][MAXN];

ll ask(ll n, ll a, ll b){
	if (dp[n][a][b] != -1)return dp[n][a][b];
	if (n == N){
		if(a==b){
			assert(a==0);
			return dp[n][a][b] = 3;
		}
		return dp[n][a][b] = 6;
	}
	if(a!=b)return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a) + ask(n+1,n,b))%MOD;
	else return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a))%MOD;
}

int main(){
	cin>>N>>M;
	ll samework = 1;
	for (ll i=0;i<M;++i){
		cin>>a>>b>>c;
		if (c>1)samework = 0;
		V[b].pb(a,c);
	}
	memset(dp,-1,sizeof(dp));
	for (ll b=0;b<=N;++b){
		for (ll a=b;a<=N;++a){
			for (ll i=a+1;i<=N;++i){
				for (auto v:V[i]){
					ll has_b = (b>=v.f);
					ll has_a = (a>=v.f);
					ll t = has_a+has_b+1;
					if (t != v.s){dp[i][a][b] = 0;break;}
				}
			}
		}
	}
	cout<<ask(1,0,0);
	// for (ll i=0;i<=N;++i){
	// 	for (ll j=0;j<=N;++j){
	// 		for (ll k=0;k<=N;++k)cout<<dp[i][j][k]<<' ';cout<<'\n';
	// 	}
	// 	cout<<'\n';
	// }
}

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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

int d[105][100013],p[105][100013];

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int a[n+1];
    a[0]=0;
    for(int i=1;i<n+1;i++)
    {
        cin >> a[i];
        a[i]+=a[i-1];
    }
    int dp[n][n];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            if(i==j)
                dp[i][j]=0;
            else
                dp[i][j]=INF;
        }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<n-i;j++)
        {
            for(int k=j;k<j+i;k++)
            {
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][i+j]);
            }
            dp[j][j+i]+=a[j+1+i]-a[j];
        }
    }
    cout << dp[0][n-1];
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
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){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[2000], sum[2000], f[2000000];
signed main(){
  int n, k;
  scanf("%lld%lld", &n, &k);
  rrep(i,n)scanf("%lld", &a[i]);
  rrep(i,n)sum[i] = sum[i-1]+a[i];
  vector<int> vec;
  rrep(i,n)rrep(j,n){
    if(i > j)continue;
    vec.pb(sum[j]-sum[i-1]);
  }
  sort(all(vec), greater<int>());
  fill(f, f+2000000, 1);

  n = vec.size();
  drep(i,60,0){
    int cnt = 0;
    rep(j,n){
      if(f[j] == 0)continue;
      if(vec[j] & (1LL<<i))cnt++;
    }
    if(cnt < k)continue;
    rep(j,n){
      if(!(vec[j] & (1LL<<i)))f[j] = 0;
    }
  }

  int ans = 0, cnt = 0;
  rep(i,n){
    if(cnt >= k)break;
    if(f[i] == 0)continue;
    if(cnt == 0)ans = vec[i];
    else ans &= vec[i];
    cnt++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 20076
#[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 s = scan!();

    let mut num = 0;
    for c in s.chars() {
        if c == 'p' {
            num += 1;
        }
    }

    println!("{}", s.chars().count() / 2 - num);
}


Measured memory_bytes: 4352
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l=[abs(i-k) for i in l]
def gcd(a,b):
    if b==0: 
        return a 
    return gcd(b,a%b)
g=0 
for i in l: 
    g=gcd(g,i)
print(g)

Measured memory_bytes: 14224
#ifdef ONLINE_JUDGE
  #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define mtr vector<vector<int>>

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

int dp[1000010], n, k;
vector<int> v;

int solve(int x) {
  if (dp[x]) return dp[x];
  for (int i = 0; i < n; i ++) {
    if (v[i] <= x) {
      if (solve(x - v[i]) == 2) {
        return dp[x] = 1;
      }
    }
  }
  return dp[x] = 2;
}

signed main() {
  #ifndef ONLINE_JUDGE
    ifstream cin("in");
  #endif
  ios_base::sync_with_stdio(0); cin.tie(0); // harris leung ioi gold calling it 18.09

  cin >> n >> k;
  for (int i = 0; i < n; i ++) {
    int l; cin >> l; v.push_back(l);
  }
  dp[0] = 2;
  cout << (solve(k) == 1 ? "First" : "Second") << endl;
}

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

}
int main(){

    fio;
    clock_t zzzz = clock();
    ll T;
    T=1;
    // cin>>T;
    while(T--){
        solve();
    } 
    debug("Total Time: %.3f\n", (double)(clock() - zzzz) / CLOCKS_PER_SEC);
   return 0;
}




Measured memory_bytes: 11124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int l,r;
    cin>>l>>r;
    long long ans=3000;
    if(r-l>=2200)cout<<0<<endl;
    else{
        for(long long i=l;i<=r-1;i++){
            for(long long j=i+1;j<=r;j++){
                long long tmp=(i*j)%2019;
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f;
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt, a[5100];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	while (true) {
		sum = 0;
		rep(i, n) sum += a[i] / n;
		rep(i, n) {
			ans += a[i] / n;
			LL cur = sum - a[i] / n;
			a[i] -= (a[i] / n)*n;
			a[i] += cur;
		}
		if (sum == 0)break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ilis =[]
check = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        ilis.append(True)
    else:
        ilis.append(False)

for i in range(n-2):
    if ilis[i] == True and ilis[i+1] == True and ilis[i+2] == True:
        print("Yes")
        check = 1
        break
    else:
        pass
if check == 0:
    print("No")

Measured memory_bytes: 9192
#include<iostream>
#include<fstream>
using namespace std;
int main(){
	int a,s=0,t=0;
	for(int i=0;i<4;i++){
		cin>>a;
		s+=a;
	}
	for(int i=0;i<4;i++){
		cin>>a;
		t+=a;
	}
	cout<<max(s,t)<<endl;
	
	return 0;
}

Measured memory_bytes: 1160
let split target =
  Str.split (Str.regexp " ") target
  |> List.map int_of_string


let rec gcd x y =
  match (x, y) with
  | (_, 0) -> x
  | (_, _) -> gcd y (x mod y)


let () =
  let nums =
    read_line ()
    |> split in
  Printf.printf "%d\n" (gcd (List.nth nums 0) (List.nth nums 1))

Measured memory_bytes: 2272
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}

int n;
vector<int> p;
void input(){
    cin>>n;
    p.resize(n);
    rep(i,n) cin>>p[i];
}
void src(){
    int c=0;
    repi(i,1,n-1){
        ll imin=(ll)distance(p.begin(),min_element(p.begin()+i-1,p.begin()+i+2));
        ll imax=(ll)distance(p.begin(),max_element(p.begin()+i-1,p.begin()+i+2));
        if(i!=imin and i!=imax){ c++;}
    }
    cout<<c;
    return;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	char op;
	int a, b;

	cin >> a >> op >> b;

	if (op == '+')
		cout << a + b << endl;
	else
		cout << a - b << endl;

	return 0;
}

Measured memory_bytes: 256
str = gets
num = str.split(" ")

if num[0] > num[1] then
  temp = num[0]
  num[0] = num[1]
  num[1] = temp
end

if num[1] > num[2] then
  temp = num[1]
  num[1] = num[2]
  num[2] = temp
end

if num[0] > num[1] then
  temp = num[0]
  num[0] = num[1]
  num[1] = temp
end

print num[0]," ",num[1]," ",num[2],"\n"

Measured memory_bytes: 8656
#include <iostream>

using namespace std;
int n;
int main(){
    cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i!=0)continue;
        if(n/i<10){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

def solve(n, ps):
    pmin = ps[0]
    c = 0
    for i in range(0, len(ps)):
        if ps[i] <= pmin:
            pmin = ps[i]
            c += 1
    return c

def main():
    n = int(sys.stdin.readline().strip())
    nstr = sys.stdin.readline().strip()

    ps = []
    i = 0
    for c in range(0, n):
        iend = nstr.find(" ", i)
        if iend < 0:
            iend = len(nstr)
        ps.append(int(nstr[i:iend]))
        i = iend + 1

    ans = solve(n, ps)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14356
#include<iostream>

int main(){
 int a, b;

 while(1){
  std::cin>>a>>b;
  if(a==0 && b==0 ) break;

  if(a<b){
   std::cout<<a<<" "<<b<<"\n";
  } else {
   std::cout<<b<<" "<<a<<"\n";
  }
 }
 return 0;
}

Measured memory_bytes: 2996
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            long N = long.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var dict = new Dictionary<long,long>();
            for(var i=0;i<N;i++){
                if(!dict.ContainsKey(a[i]))dict[a[i]]=0;
                dict[a[i]]++;
            }
            long result = 0;
            foreach(var key in dict.Keys){
                if(dict[key]>=key){
                    result += dict[key] - key;
                }else{
                    result += dict[key];
                }
            }
            Console.WriteLine(result);
        }
    } 
}

Measured memory_bytes: 27488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
       int n;
       scanf("%d",&n);
       int squ[3][110];
       for(int i=1;i<=2;i++){
              for(int j=1;j<=n;j++){
                     scanf("%d",&squ[i][j]);
              }
       }
       for(int i=1;i<=2;i++){
              for(int j=1;j<=n;j++){
                     if(i==1&&j==1){
                            continue;
                     }
                     if(i==2&&j!=1){
                            squ[i][j]+=(squ[i-1][j]>squ[i][j-1]?squ[i-1][j]:squ[i][j-1]);
                     }
                     if(i==1){
                            squ[i][j]+=squ[i][j-1];
                     }
                     if(j==1){
                            squ[i][j]+=squ[i-1][j];
                     }
              }
       }
       printf("%d",squ[2][n]);
       return 0;
}



Measured memory_bytes: 256
class Combination:
    def __init__(self, max_n, _mod):
        self.mod = _mod

        self.fac = [0 for _ in range(max_n + 10)]
        self.finv = [0 for _ in range(max_n + 10)]
        self.inv = [0 for _ in range(max_n + 10)]

        self.fac[0], self.fac[1] = 1, 1
        self.finv[0], self.finv[1] = 1, 1
        self.inv[1] = 1

        for i in range(2, max_n + 10):
            self.fac[i] = self.fac[i - 1] * i % self.mod
            self.inv[i] = self.mod
            self.inv[i] -= self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod

    def mod_comb(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0

        res = self.fac[n] * (self.finv[k] * self.finv[n - k] % self.mod)
        res %= self.mod

        return res


def main():
    max_n = 2000
    mod = 10**9 + 7
    comb = Combination(max_n, mod)

    N, K = map(int, input().split())
    for i in range(1, K + 1):
        a = comb.mod_comb(N - K + 1, i)
        b = comb.mod_comb(K - 1, i - 1)
        print(a * b % mod)


main()

Measured memory_bytes: 3572