akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

var (
	N, M int
)

// PriorityQueue is something.
type PriorityQueue struct {
	HeapSize int
	heap     []int
	size     int
	Reverse  bool
}

// Push pushs a number to queue
func (p *PriorityQueue) Push(x int) {

	// initialization
	if p.HeapSize == 0 {
		p.HeapSize = 100
	}
	if len(p.heap) == 0 && p.HeapSize > 0 {
		p.heap = make([]int, p.HeapSize)
	}
	i := p.size
	p.size++
	for i > 0 {
		n := (i - 1) / 2
		if p.Reverse {
			if p.heap[n] > x {
				break
			}
		} else {
			if p.heap[n] <= x {
				break
			}
		}

		p.heap[i] = p.heap[n]
		i = n
	}
	p.heap[i] = x
}

// Pop pops a number
func (p *PriorityQueue) Pop() int {
	ret := p.heap[0]
	p.size--
	x := p.heap[p.size]
	i := 0
	for (i*2 + 1) < p.size {
		a := i*2 + 1
		b := i*2 + 2
		if p.Reverse {
			if b < p.size && p.heap[b] >= p.heap[a] {
				a = b
			}
			if p.heap[a] < x {
				break
			}
		} else {
			if b < p.size && p.heap[b] < p.heap[a] {
				a = b
			}
			if p.heap[a] >= x {
				break
			}
		}

		p.heap[i] = p.heap[a]
		i = a
	}
	p.heap[i] = x
	return ret
}

func main() {

	fmt.Scan(&N, &M)
	pq := PriorityQueue{
		HeapSize: 1000*100 + 10,
		Reverse:  true,
	}

	var a int
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		pq.Push(a)
	}
	for i := 0; i < M; i++ {
		max := pq.Pop() / 2
		pq.Push(max)
	}

	ans := uint64(0)
	for i := 0; i < N; i++ {
		ans += uint64(pq.Pop())
	}
	fmt.Println(ans)
}


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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int Jank(char t, int r, int s, int p);

int main() {
  int n, r, s, p, k, ans = 0;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  //vector<int> v(n), c(n);
  for (int i = 0; i < n; i++){
    if(i < k) ans += Jank(t.at(i), r, s, p);
    else if(i >= k && t.at(i) != t.at(i - k)) ans += Jank(t.at(i), r, s, p);
    else t.at(i) = 'a';
  }
  //for(int i = 0; i < n; i++){}
  cout << ans << endl;
}

int Jank(char t, int r, int s, int p){
  if(t == 'r') return p;
  if(t == 's') return r;
  return s;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n + 1);
  rep(i, n) {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
  }

  ll ans = 0;
  map<ll, ll> mp;
  rep(i, n + 1) {
    ans += mp[b[i]];
    mp[b[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18624
#include<stdio.h>
int main(void)
{
	int a[4] = { 0 }, j, b, cnt, i, n, A = 0, B = 0, c, ruio;
	scanf("%d", &n);
	for (ruio = 0; ruio < n; ruio++) {
		scanf("%d %d %d", &a[0], &a[1], &a[2]);
		for (i = 0; i < 3; i++) {
			for (j = i; j < 3; j++) {
				if (a[i] < a[j]) {
					c = a[i];
					a[i] = a[j];
					a[j] = c;
				}
			}
		}
		if (a[0] * a[0] == a[1] * a[1] + a[2] * a[2]) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

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

ll modpow(ll a, ll n){
    ll res=1;
    while(n > 0){
        if(n & 1) res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}

int main(){
    ll N, K;
    cin >> N >> K;
    ll res=0;
    vector<ll> dp(K+1);
    for(ll i=K; i>=1; i--){
        ll a=K/i;
        dp[i]=modpow(a, N);
        for(int j=2; j<=a; j++){
            dp[i]=(dp[i]-dp[j*i])%MOD;
        }
        res=(res+i*dp[i]%MOD)%MOD;
    }
    if(res < 0) res+=MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4052
h,w=gets.split.map(&:to_i)
s=h.times.map{gets.chomp}
x=y=0
q=[[x,y]]
visited={}
visited[[x,y]]=1
while !q.empty?
  x,y=q.shift
  break if x==h-1&&y==w-1
  step=visited[[x,y]]
  [[0,1],[0,-1],[1,0],[-1,0]].each{|dx,dy|
    nx,ny=x+dx,y+dy
    next unless (0...h)===nx&&(0...w)===ny
    next if s[nx][ny]==?#
    next if visited[[nx,ny]]
    q.push [nx,ny]
    visited[[nx,ny]]=step+1
  }
end

white_num=s.map{|line|line.count(?.)}.inject(:+)
puts visited[[h-1,w-1]] ? white_num-visited[[h-1,w-1]] : -1

Measured memory_bytes: 2172
import sys

s = input()
def main():
    for i in range(2**3):
        localsum = s[0]
        for j in range(3):
            if (i >> j) & 1:
                localsum += "+"
            else:
                localsum += "-"
            localsum += s[j+1]
        sum = eval(localsum)
        if sum == 7:
            localsum += "=7"
            print(localsum)
            sys.exit()
main()

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

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = INT_MAX;
const LL INF = LLONG_MAX;

template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int maxn = 5e5 + 5;

int N;
char S[maxn];

int fail[maxn];
bool pre[maxn], suf[maxn];

inline void check (bool *rev)
{
	for (int i = 2, j = 0; i <= N; ++i)
	{
		while (j && S[j + 1] != S[i]) j = fail[j];
		if (S[j + 1] == S[i]) ++j;
		fail[i] = j;

		if (j && i % (i - j) == 0) rev[i] = 1;
	}
}

inline void solve ()
{
	bool flag = 1;
	for (int i = 2; i <= N; ++i) if (S[i] != S[i - 1]) flag = 0;
	if (flag) return (void) printf ("%d\n1\n", N);

	check (pre);
	if (!pre[N]) return (void) printf ("1\n1\n");

	reverse (S + 1, S + N + 1);
	check (suf);

	int ans = 0;
	for (int i = 1; i < N; ++i) if (!pre[i] && !suf[N - i]) ++ans;
	printf ("2\n%d\n", ans);
}

inline void input ()
{
	scanf ("%s", S + 1);
	N = strlen (S + 1);
}

int main ()
{

	input ();
    solve ();

    return 0;
}


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

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

    //ある整数が素数か否かを1から順に決定する（素数でなければtrue)
    vector<bool> notP(1001, false);
    notP[1] = true;
    for(int i=1; i<101; i++) {
        if(!notP[i]) {
            for(int j=i*2; j<=1000; j+=i) notP[j] = true;
        }
    }

    //N!に含まれる素因数をそれぞれ数える
    //一般に、n!に含まれる素因数pの個数はΣ(n/p^k)
    vector<int> cnt(101, 0);
    for(int i=2; i<=N; i++) {
        if(notP[i]) continue;
        int x = N;
        while(x) {
            cnt[i] += x/i;
            x /= i;
        }
    }

    
    //dp[i][j] ->　iの階乗の約数のうち、ちょうどj個の約数を持つ整数の数
    vector<vector<int>> dp(200, vector<int>(200, 0));
    dp[1][1] = 1;
    for(int i=1; i<=N; i++) {
        for(int j=0; j<=75; j++) {
            for(int k=1; k<=cnt[i]+1; k++) {
                if(j*k > 75) continue;

                //約数がj個の整数にk個の素因数が掛かると、約数の数はj*(k+1)個になる。
                //ここでは、kは1からcnt[i]+1までなので、cnt[i]が0(iが素因数でない)場合、
                //dp[i+1][j]にdp[i][j]の結果がそのまま代入される。
                dp[i+1][j*k] += dp[i][j];
            }
        }
    }

    cout << dp[N][75] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Edge { int to, cost; };
bool operator<(const Edge& e1, const Edge& e2) { return e1.cost < e2.cost; }
int N, M, Z, p, a, b, w, s[7], t[7], y[15], p1[7], p2[7], r[15], x[2][7], d[1111][1111]; vector<Edge> G[1111];
int main() {
	cin >> N >> M >> Z >> p; p--; r[0] = p;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> w; a--, b--;
		G[a].push_back(Edge{ b, w });
		G[b].push_back(Edge{ a, w });
	}
	for (int i = 0; i < Z; i++) {
		cin >> s[i] >> t[i]; s[i]--, t[i]--;
	}
	y[0] = p;
	for (int i = 0; i < Z; i++) y[i + 1] = s[i];
	for (int i = 0; i < Z; i++) y[i + Z + 1] = t[i];
	for (int g = 0; g < Z * 2 + 1; g++) {
		int i = y[g];
		priority_queue<Edge> que; que.push(Edge{ i, 0 });
		fill(d[i], d[i] + N, 999999999); d[i][i] = 0;
		while (!que.empty()) {
			int v = que.top().to; que.pop();
			for (auto &e : G[v]) {
				if (d[i][e.to] > d[i][v] + e.cost) {
					d[i][e.to] = d[i][v] + e.cost;
					que.push(Edge{ e.to, d[i][e.to] });
				}
			}
		}
	}
	long long ret = 999999999;
	for (int i = 0; i < (1 << (2 * Z)); i++) {
		int dep = 0; bool flag = true;
		for (int j = 0; j < 2 * Z; j++) {
			if (i & (1 << j)) dep--;
			else dep++;
			if (dep < 0) flag = false;
		}
		if (dep != 0) flag = false;
		if (!flag) continue;
		for (int j = 0; j < Z; j++) p1[j] = p2[j] = j;
		do {
			int cr1 = 0;
			for (int j = 0; j < 2 * Z; j++) {
				if (!(i & (1 << j))) {
					x[0][p1[cr1]] = j;
					r[j + 1] = s[p1[cr1++]];
				}
			}
			do {
				int cr2 = 0;
				for (int j = 0; j < 2 * Z; j++) {
					if (i & (1 << j)) {
						x[1][p2[cr2]] = j;
						r[j + 1] = t[p2[cr2++]];
					}
				}
				bool e = true;
				for (int j = 0; j < Z; j++) {
					if (x[0][j] > x[1][j]) {
						e = false;
						break;
					}
				}
				if (!e) continue;
				bool ok = true;
				long long res = 0;
				for (int j = 0; j < 2 * Z; j++) {
					if (d[r[j]][r[j] + 1] == 999999999) ok = false;
					res += d[r[j]][r[j + 1]];
				}
				ret = min(ret, res);
			} while (next_permutation(p2, p2 + Z));
		} while (next_permutation(p1, p1 + Z));
	}
	if (ret == 999999999) cout << "Cannot deliver" << endl;
	else cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long x,k,d,s,l,p,q;
    cin>>x>>k>>d;
    s=x;
    if(x<0)
    {
        s=(-1)*x;
    }
    l=s/d;
    if(l>=k)
    {
        cout<<s-(k*d)<<endl;
    }
    else
    {
        p=s-(l*d);
        q=k-l;
        if(q%2==0)
        {
           cout<<p<<endl;
        }
        else
        {
            cout<<(-1)*(p-d)<<endl;
        }
    }
    return 0;
}

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

class Slimes
{
	public:
		int merged(string &slimes)
		{
			int ans=0,i,size=slimes.size();
			while(i<size)
			{
				ans++;
				char temp=slimes[i];
				while(i<size and slimes[i]==temp)
					i++;
}
return ans;
}
};
int main()
{
	int n;
cin>>n;
string slimes;
cin>>slimes;
Slimes slime;
cout<<slime.merged(slimes);
}


Measured memory_bytes: 512
N = int(input())
CSF = [list(map(int,input().split())) for _ in range(N-1)]

res = [0]*N
for i in range(N-1):
    t = 0
    for j in range(i,N-1):
        c = CSF[j][0]
        s = CSF[j][1]
        f = CSF[j][2]
        if t <= s:
            t = s+c
        else:
            if t%f == 0:
                t += c
            else:
                m = t%f
                t += ((f-m)+c)
    res[i] = t
print("\n".join(map(str,res)))

Measured memory_bytes: 3064
using System;

namespace ITP1_6_C
{
    class Program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int[,] a = new int[n, m];
            int[] c = new int[n];

            for (int i = 0; i < n; i++)
            {
                c[i] = 0;
                string[] ele = Console.ReadLine().Split(' ');

                for (int j = 0; j < m; j++) a[i, j] = int.Parse(ele[j]);
            }
            for (int i = 0; i < m; i++)
            {
                int b = int.Parse(Console.ReadLine());

                for (int j = 0; j < n; j++) c[j] += a[j, i] * b;
            }
            for (int i = 0; i < n; i++) Console.WriteLine(c[i]);
        }
    }
}

Measured memory_bytes: 9420
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll a[305][305];

int main(){
	ll n,m; cin >> n >> m;
	rep(i,n) rep(j,m) cin >> a[i][j], a[i][j]--;

	ll ok = n, ng = 0;
	while(ok-ng > 1){
		ll mid = (ok+ng) / 2;
		vb use(m,true);
		vl id(n,0);
		vl v(m,0);
		bool flag = true;
		vb renew(n,true);
		while(1){
			bool cont = false;
			rep(i,n){
				if(id[i] == m){
					flag = false;
					break;
				}
			}
			if(!flag) break;
			rep(i,n) if(renew[i]) v[a[i][id[i]]]++, renew[i] = false;
			rep(i,m) if(v[i] > mid) use[i] = false;
			rep(i,n){
				if(!use[a[i][id[i]]]){
					id[i]++; cont = true; renew[i] = true;
				}
			}
			if(!cont) break;
		}
		if(flag) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int sudapon=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a%2==0){
            sudapon++;
        }
        else{
        }
    }
    cout<<sudapon<<endl;
}



Measured memory_bytes: 3108
import java.util.*;
import java.util.Scanner;

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

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

        int[] candles = new int[N];
        for (int i = 0; i < N; i++) {
            candles[i] = sc.nextInt();
        }

        int numWindows = N - K + 1;

        int minDist = -1;
        for (int i = 0; i < numWindows; i++) {
            int min = candles[i];
            int max = candles[i + K - 1];

            int dist = -1;
            if ((min < 0) && (max < 0)) {
                dist = -min;
            } else if ((min >= 0) && (max >= 0)) {
                dist = max;
            } else {
                if (max > -min) {
                    dist = max - min * 2;
                } else {
                    dist = max * 2 - min;
                }
            }

            if ((minDist == -1) || (dist < minDist)) {
                minDist = dist;
            }

        }

        System.out.println(minDist);
    }
}

Measured memory_bytes: 50496
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int k,n=s.size(); cin>>k;
    rep(i,n){
        if(('z'-s[i]+1)%26<=k){
            k-=('z'-s[i]+1)%26;
            s[i]='a';
        }
    }
    s.back()=(s.back()-'a'+k)%26+'a';
    cout<<s<<endl;
}

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




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


            //int n = int.Parse(Console.ReadLine());
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();


            string s = Console.ReadLine();
            int len = s.Length;
            int count = int.MaxValue;

            int wCount = 0;
            int bCount = 0;
            bool w = false;
            bool b = false;
            for(int i =0; i<len; i++)
            {
                if (i == 0 && s[0] == 'W')
                {
                    w = true;
                }
                else if(i == 0 && s[0] == 'B') b = true;

                if(s[i]=='W' && !w)
                {
                    wCount++;
                    w = true;
                    b = false;
                }
                else if(s[i] == 'B' && !b)
                {
                    bCount++;
                    b = true;
                    w = false; 
                }

            }
            count = Math.Min(count,(wCount+bCount));

            wCount = 0;
            bCount = 0;
            w = false;
            b = false;
            for (int i = len-1; i >=0; i--)
            {
                if (i == len-1 && s[len-1] == 'W')
                {
                    w = true;
                }
                else if (i == len-1 && s[len-1] == 'B') b = true;


                if (s[i] == 'W' && !w)
                {
                    wCount++;
                    w = true;
                    b = false;
                }
                else if (s[i] == 'B' && !b)
                {
                    bCount++;
                    b = true;
                    w = false;
                }

            }
            count = Math.Min(count, (wCount + bCount));


            Console.WriteLine(count);
            


        

        }

        

    }


}


Measured memory_bytes: 3160
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x, n, p[100] = {};
	int i = 0, j = 0,k = 0;//ループ用配列
	int sa[101] = {};
	int ans = 0;

	cin >> x >> n;
	rep(i, n) {
		cin >> p[i];
	}

	rep(i, n) {
		sa[abs(x - p[i])]++;
	}
	if(sa[0] == 0){
		cout << x << "\n";
		return 0;
	}
	else
	{
		for(i = 1;i <= 100;i++){
			if (sa[i] == 0) {
				cout << x - i << "\n";
				return 0;
			}
			else if (sa[i] == 1) {
				rep(j, n) {
					if (p[j] == x + i) {
						cout << x - i << "\n";
						return 0;
					}
					else if (p[j] == x - i) {
						cout << x + i << "\n";
						return 0;

					}
				}

			}
			else;
		}
	
	}


}


Measured memory_bytes: 3648
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a == 2 || b == 2){
      System.out.println(0);
    }else if(a == 1 && b == 1){
      System.out.println(1);
    }else if(a == 1 || b == 1){
      System.out.println(a * b - 2);
    }else{
      System.out.println(((long)a-2) * (b-2));
    }
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int k;
int cnt[110];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		cnt[x]++;
		k=max(k,x);
	}
	for(int i=(k+1)/2+1;i<=k;i++)
	{
		if(cnt[i]<2)
		{
			printf("Impossible");
			return 0;
		}
		cnt[i]-=2;
	}
	if(k&1)
	{
		if(cnt[(k+1)/2]<2)
		{
			printf("Impossible");
			return 0;
		}
		cnt[(k+1)/2]-=2;
	}
	else
	{
		if(!cnt[k/2])
		{
			printf("Impossible");
			return 0;
		}
		cnt[k/2]--;
	}
	for(int i=1;i<=n;i++)
	{
		if(cnt[i] && i<(k+1)/2+1)
		{
			printf("Impossible");
			return 0;
		}
	}
	printf("Possible");
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <list>

using namespace std;

const int mod = int(1e9) + 7;
//const int SZ = 10100;
//const int MX = 210500;
#define pii pair<int,int>
#define ll long long
#define sqr(x) (x)*(x)


void solve();
int main(int argc, char** argv)
{
#ifdef LOCAL
    freopen("../in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
//-----------------------------------------------------------------------------

//const int MX = 100500;
const int SZ = 3010;

int a[2][SZ][SZ];
int k;

int get_cnt(int c, int x, int y) {
    int ans = a[c][x + k][y + k] - a[c][x][y + k] - a[c][x + k][y] + a[c][x][y];
    ans += a[c][x + k][y - k] - a[c][x][y - k];
    ans += a[c][x - k][y + k] - a[c][x - k][y];
    ans += a[c][x][y] - a[c][x][y - k] - a[c][x - k][y] + 2 * a[c][x - k][y - k];
    return ans;
}

pair<int,int> get_ans(int x, int y) {
    return make_pair(get_cnt(0, x, y), get_cnt(1, x, y));
}

int cnt[2];

void solve(){
    int n;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        char cc;
        int x, y;
        cin >> x >> y >> cc;
        x %= (2 * k);
        y %= (2 * k);
        a[cc == 'B'][x + 1][y + 1]++;
        cnt[ cc == 'B' ]++;
    }
    for (int c = 0; c < 2; c++) {
        for (int i = 1; i < SZ; i++) {
            for (int j = 1; j < SZ; j++) {
                a[c][i][j] += a[c][i - 1][j] + a[c][i][j - 1] - a[c][i - 1][j - 1];
            }
        }
    }
    int ans = 0;
    for(int x = k; x <= 2 * k; x++) {
        for (int y = k; y <= 2 * k; y++) {
            auto p = get_ans(x, y);
            ans = max(ans, p.first + cnt[1] - p.second);
            ans = max(ans, cnt[0] - p.first + p.second);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  string aa, bb;
  for (int i = 0; i < a; i++) {
    aa += to_string(b);
  }
  for (int i = 0; i < b; i++) {
    bb += to_string(a);
  }
  cout << min(aa, bb) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	unordered_map<string, bool>z;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (z.find(s) == z.end()) {
			z.insert(make_pair(s, true));
		}
	}
	cout << z.size() << endl;
}

Measured memory_bytes: 17788
#include<bits/stdc++.h>
#define N 1500005

using namespace std;
typedef long long int ll;
typedef pair<int, int> pi;

int n;

vector<int> gr[N];

int cnt[N];
int input[1005][1005];

int main(){
	scanf("%d", &n);
	int x1, x2;
	int mn, mx;
	for(int i=1;i<=n;i++){
		for(int j=0;j<n-1;j++){
			scanf("%d", input[i]+j);
			x1=x2;
			mn=min(i, input[i][j]);
			mx=max(i, input[i][j]);
			x2=mn*(n+1)+mx;
			if(j){
				gr[x1].push_back(x2);
				cnt[x2]++;
			}
		}
	}
	queue<pi> q;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int x=i*(n+1)+j;
			if(!cnt[x]) q.push(pi(x, 1));
		}
	}
	int c=0;
	int ans=0;
	while(!q.empty()){
		pi t=q.front();
		q.pop();
		c++;
		ans=max(t.second, ans);
		for(auto &j : gr[t.first]){
			cnt[j]--;
			if(!cnt[j]) q.push(pi(j, t.second+1));
		}
	}
	if(c!=n*(n-1)/2){
		printf("-1\n");
	}
	else{
		printf("%d\n", ans);
	}
	return 0;
}

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

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


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
long long t[100005],dp[100005];
main()
{
	int p,k;
	scanf("%d",&p);
	for(int i = 1;i <= p;i++)
	{
		scanf("%lld",&dp[i]);
	}
	k=2;
	
	for(int i = 0;i <= 100003;i++)
	t[i]=1e15;
	t[1]=0;
	for(int i = 1;i <= p;i++)
	{
		for(int j = 1;j <= k && i+j <= p;j++)
		{
			t[i+j]=min(t[i]+abs(dp[i]-dp[i+j]),t[i+j]);
		}
	}
	printf("%lld",t[p]);
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int man[100005],ic[100005],icm[100005];
int day[100005];int n,m;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> m >> n;
    rep(i,0,100005){
        day[i]=0;
    }
    int x=0;cin >> x;
    rep(i,1,n){
        int y;
        cin >> y;
        int a=max(x,y);int b=min(x,y);
        day[b]++;day[a]--;
        x=y;
    }
    rep(i,1,m){
        day[i]+=day[i-1];
       // cout << day[i] << " ";
    }
    //cout << endl;
    rep(i,1,m){
        cin >> man[i] >> icm[i] >> ic[i];
    }
    int ans=0;
    rep(i,0,m){
        int res=0;
        res=min((man[i]*day[i]),(ic[i]+icm[i]*day[i]));
        ans+=res;
    }
    cout << ans << endl;
    return 0;
}

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

int compare_ints(const void* a, const void* b)
{
    int arg1 = *(const int*)a;
    int arg2 = *(const int*)b;
 
    if (arg1 < arg2) return -1;
    if (arg1 > arg2) return 1;
    return 0;
}

int	main(void)
{
  	int	N;
  	int	K;
  	int	*H;
  	long long int	sum;
  	int	num;
  	int i;
  
  	num = scanf("%d %d", &N, &K);
  	if (num != 2)
      	return (0);
  
  	H = (int *)malloc(sizeof(int) * N);
  	for (i=0; i<N; i++)
    {
      	num = scanf("%d", &H[i]);
      	if (num != 1)
          	return (0);
    }
  
  	qsort(H, N, sizeof(int), compare_ints);
  
  	sum = 0;
  	for (i=0; i<N-K; i++)
    {
      	sum += H[i];
    }
  
  	printf("%lld", sum);
  	return (0);
}

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

string s;
long long n, p, t = 0, m = 0, w = 1;
long long a[10000];

int main()
{
	cin >> n >> p >> s;

	if (p == 2 || p == 5) {
		for (long long i = 0; i < n; i++) {
			t = s[i] - '0';

			if (t % p == 0)
				m += i + 1;
		}

		cout << m << endl;
	}
	else {
		memset(a, 0, sizeof(a));

		for (long long i = 0; i < n; i++) {
			t = (t + (s[n - 1 - i] - '0') * w) % p;
			w = w * 10 % p;
			a[t]++;
		}

		m = a[0] * (a[0] + 1) / 2;

		for (long long i = 1; i < p; i++)
			m += a[i] * (a[i] - 1) / 2;

		cout << m << endl;
	}
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N, W;
    cin >> N >> W;

    vl v[4];
    ll w1, vv;
    cin >> w1 >> vv;
    v[0].PB(vv);
    rep(i, N-1) {
        ll w;
        cin >> w >> vv;
        v[w - w1].PB(vv);
    }

    rep(i, 4) {
        sortdown(v[i]);
        ll n=v[i].size();
        rep(j, n) if(j) v[i][j] += v[i][j-1];
    }

    ll n0=v[0].size(), n1=v[1].size(), n2=v[2].size(), n3=v[3].size();
    ll ans=0;
    rep(i, n0+1) {
        rep(j, n1+1) {
            rep(k, n2+1) {
                rep(l, n3+1) {
                    if(i*w1 + j*(w1+1) + k*(w1+2) + l*(w1+3) <= W){
                        ll val=0;
                        if(i) val += v[0][i-1];
                        if(j) val += v[1][j-1];
                        if(k) val += v[2][k-1];
                        if(l) val += v[3][l-1];
                        chmax(ans, val);
                    }
                }
            }
        }
    }

    cout << ans << nl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) {
        cin >> b[i];
    }
    int ans = b[0] + b[n - 2];
    rep(i, n - 2) {
        ans += min(b[i], b[i + 1]);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a; cin >> a;
	if (a == 25)cout << "Christmas" << endl;
	else if (a == 24)cout << "Christmas Eve" << endl;
	else if (a == 23)cout << "Christmas Eve Eve" << endl;
	else if (a == 22)cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
(* O(n log n) *)
let n = read_int () in
let rec count c m = if m mod 2 = 1 then c else count (c + 1) (m / 2) in
let counts = Array.init n @@ fun i -> i + 1, count 0 @@ i + 1 in
let max (x1, c1) (x2, c2) = if c1 < c2 then x2, c2 else x1, c1 in
Array.fold_left max (1, 0) counts |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

char S[SIZE], T[SIZE];
ll dp1[SIZE][2], dp2[SIZE][2];

int main(){
  int N;

  scanf("%s%s", S, T);

  N = strlen(S);

  dp1[0][1] = 1;

  for(int i=0; i<N; i++) {
    if (T[i] == '?') {
      dp1[i+1][0] = (dp1[i][0] * 10 + dp1[i][1] * (S[i] - '0')) % mod;
      dp1[i+1][1] = dp1[i][1] % mod;
      dp2[i+1][0] = (dp2[i][1] * 10 * (S[i] - '0') + dp2[i][0] * 10 * 10 + dp1[i][0] * 45 + dp1[i][1] * ((S[i] - '0') * (S[i] - '0' - 1) / 2)) % mod;
      dp2[i+1][1] = (dp2[i][1] * 10 + dp1[i][1] * (S[i] - '0')) % mod;
    } else {
      if(S[i] < T[i]) {
        dp1[i+1][0] = (dp1[i+1][0] + dp1[i][0]) % mod;
        dp2[i+1][0] = (dp2[i][0] * 10 + dp1[i][0] * (T[i] - '0')) % mod;
      } else if (S[i] == T[i]) {
        dp1[i+1][0] = (dp1[i+1][0] + dp1[i][0]) % mod;
        dp1[i+1][1] = (dp1[i+1][1] + dp1[i][1]) % mod;
        dp2[i+1][0] = (dp2[i][0] * 10 + dp1[i][0] * (T[i] - '0')) % mod;
        dp2[i+1][1] = (dp2[i][1] * 10 + dp1[i][1] * (T[i] - '0')) % mod;
      } else {
        dp1[i+1][0] = (dp1[i][0] + dp1[i][1]) % mod;
        dp2[i+1][0] = (dp2[i][0] * 10 + dp2[i][1] * 10 + (dp1[i][0] + dp1[i][1]) * (T[i] - '0')) % mod;
      }
    }
  }

  cout << (dp2[N][0] + dp2[N][1]) % mod << endl;

  return 0;
}



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

int main(){
    int x;
    cin >> x;
    for(int a = 1;a < 1000;a++){
        ll a5 = 1;
        for(int i = 0;i < 5;i++) a5 *= a;
        for(int b = -1000;b < 1000;b++){
            ll b5 = 1;
            for(int i = 0;i < 5;i++) b5 *= b;
            if(a5 - b5 == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 2000005;
array<ll, MAX_SIZE> fac, inv, finv;
void finit() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[MAX_SIZE - 1] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    for(ll i = MAX_SIZE - 1; i > 0; i--) finv[i - 1] = finv[i] * i % MOD;
    
    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }


int main() {
    init();
    finit();
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = S.size();

    ll ans = 0;
    repe(i, N, N + K + 1){
        (ans += modpow(25, N + K - i, MOD) * comb(N + K, i)) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 51136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
#include <string>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;

    ll ans;
    if (a - b > c) ans = 0;
    else ans = c - (a - b);

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    string A, B, C, ans = "";
    cin >> A >> B >> C;

    ans += A[0] - 0x20;
    ans += B[0] - 0x20;
    ans += C[0] - 0x20;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	const i = parseInt(input[0], 10);
    const s = input[1]
    if (s.length > i) {
        console.log(`${s.slice(0, i)}...`)
    } else {
        console.log(s)
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30104
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = float('inf')


def LI(): return list(map(int, sys.stdin.readline().split()))


def I(): return int(sys.stdin.readline())


def LS(): return sys.stdin.readline().split()


def S(): return sys.stdin.readline().strip()


def IR(n): return [I() for i in range(n)]


def LIR(n): return [LI() for i in range(n)]


def SR(n): return [S() for i in range(n)]


def LSR(n): return [LS() for i in range(n)]


def SRL(n): return [list(S()) for i in range(n)]


def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


mod = 10 ** 9 + 7

h, w = LI()
sy, sx = LI()
gy, gx = LI()
sy -= 1
sx -= 1
gy -= 1
gx -= 1
grid = SR(h)
dp = [[INF] * w for _ in range(h)]
q = deque([(sy, sx)])
dp[sy][sx] = 0
while q:
    uy, ux = q.popleft()
    for i, j in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        ny = uy + i
        nx = ux + j
        if 0 <= ny < h and 0 <= nx < w and grid[ny][nx] == "." and dp[ny][nx] > dp[uy][ux]:
            dp[ny][nx] = dp[uy][ux]
            q.appendleft((ny,nx))
    for i in range(-2, 3):
        for j in range(-2, 3):
            ny = uy + i
            nx = ux + j
            if 0 <= ny < h and 0 <= nx < w and grid[ny][nx] == "." and dp[ny][nx] > dp[uy][ux] + 1:
                dp[ny][nx] = dp[uy][ux] + 1
                q.append((ny, nx))


print(dp[gy][gx] if dp[gy][gx] != INF else -1)


Measured memory_bytes: 108160
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
int p[6000006];
int main(){
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                p[i*i+j*j+k*k+i*j+i*k+k*j]++;
            }
        }
    }
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cout<<p[i]<<endl;
    }
}

Measured memory_bytes: 3812
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M 1000000007
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
bool x[101];
int main()
{
    int n;
    cin>>n;
    string S;
    cin>>S;

    int i,ans=0;
    for(i=0;i<n-2;i++)
    {
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
        {
            ans++;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
inf = 10**7
dp = [0]
dp[0] = 0
for i in range(1,n):
    dp.append(min(dp[i-1] + abs(h[i] - h[i-1]), float("inf") if i < 2 else dp[i-2] + abs(h[i] - h[i-2])))
print(dp[-1])

Measured memory_bytes: 13924
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int x,y;
int main(){
	int A=0,B=0,C=0;
	cin>>x;
	if(x==1)A+=1;
	if(x==2)C+=1;
	if(x==3)A+=1;
	if(x==4)B+=1;
	if(x==5)A+=1;
	if(x==6)B+=1;
	if(x==7)A+=1;
	if(x==8)A+=1;
	if(x==9)B+=1;
	if(x==10)A+=1;
	if(x==11)B+=1;
	if(x==12)A+=1;
	cin>>y;
	if(y==1)A+=1;
	if(y==2)C+=1;
	if(y==3)A+=1;
	if(y==4)B+=1;
	if(y==5)A+=1;
	if(y==6)B+=1;
	if(y==7)A+=1;
	if(y==8)A+=1;
	if(y==9)B+=1;
	if(y==10)A+=1;
	if(y==11)B+=1;
	if(y==12)A+=1;


	if(A==2 && B==0 && C==0)cout<<"Yes"<<endl;
	if(A==0 && B==2 && C==0)cout<<"Yes"<<endl;
	if(A==0 && B==0 && C==2)cout<<"Yes"<<endl;
	if(A!=2 && B!=2 && C!=2)cout<<"No"<<endl;



	return 0;
}


Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = K*(K-1)**(N-1)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
   string s;
   cin >> s;
   if(s=="ABC"){
       cout << "ARC" << endl;
   } else{
       
       cout << "ABC" << endl;
   }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

int main() {
    long long int n, a;
    scanf("%lld", &n);
    vector<long long int> v;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a);
        v.push_back(a - i);
    }

    sort(v.begin(), v.end());
    long long int size = v.size();
    long long int m = v[size / 2];
    long long int sad = 0;
    for (long long int e: v) sad += abs(e - m);

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

    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define sonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define fi first
#define se second
#define pb push_back
using namespace std;

const ll INF=1e18;
const int N=1e5+17;
int ans,cal,sum,cnt;

int main(){
	sonic
	ll a;
	cin>>a;
	cout<<a+a*a+a*a*a;
}


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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;


signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N;
    cin >> N;
    cout << N * N * N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
vector<PII> v[55];
bool visit[55];
int res=0;
int t;
inline void dfs(int x)
{
	visit[x]=1;
	for (int i=0;i<v[x].size();i++)
	{
		int xi=v[x][i].F;
		int yi=v[x][i].S;
		if (yi==t || visit[xi]) continue;
		dfs(xi);
	}
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		v[x].push_back(MP(y,i));
		v[y].push_back(MP(x,i));
	}
	for (int i=0;i<m;i++)
	{
		fill(visit,visit+n,0);
		t=i;
		dfs(0);
		if (count(visit,visit+n,0)) res++;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(br.readLine());

            br.lines().forEach(s -> {
                List<String> list = Arrays.asList(s.split(" "));

                Collections.reverse(list);

                String answer = String.join(" ", list);

                System.out.println(answer);
            });
        }
    }
}

Measured memory_bytes: 30852
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
char c;
int main()
{
    int ans=700;
    for (int i=0; i<3; ++i)
    {
        cin>>c;
        if (c=='o') ans+=100;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<iostream>
using namespace std;
typedef long long ll;

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

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

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

    ll ans = abs(y[0] - x);


    for(int i = 1; i < n; i++){
        if(ans == 1){
            break;
        }else{
            ans = gcd(ans, abs(y[i] - y[i - 1]));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024