akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define NMAX 200100
#define INF 2000000000

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

typedef unsigned long long ull;
typedef long long int lli;

using namespace std;

// std::ifstream cin("f.in");
// std::ofstream cout("f.out");

int boxes[NMAX];
int a[NMAX];
int n;

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

    int count = 0;
    for(int i = n / 2 + 1; i <= n; i++)
        if(a[i])
        {
            boxes[i] = 1;
            count++;
        }
    for(int i = n / 2; i >= 1; i--)
    {
        int sumInd = 0;
        for(int j = i + i; j <= n; j += i)
            sumInd += boxes[j];
        
        if(sumInd % 2 != a[i])
        {
            count++;
            boxes[i] = 1;
        }
    }

    cout << count << '\n';
    for(int i = 1; i <= n; i++)
        if(boxes[i])
            cout << i << ' ';

    return 0;
}   

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
using namespace std;
typedef long long int llint;
int main() {
	int a, n, b;
	cin >> n >> a >> b;
	if (a*n < b) {
		cout << a*n << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, B, C, K = map(int, input().split())

    ans = 0
    if A >= K:
        print(K)
        exit()
    ans += A
    K -= A
    if B >= K:
        print(ans)
        exit()
    K -= B
    if C >= K:
        ans -= K
    else:
        ans -= C
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	static int[] dx = { 1, 0, -1, 0 };
	static int[] dy = { 0, 1, 0, -1 };
	static int h, w;
	static int[][] d;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		h = sc.nextInt();
		w = sc.nextInt();
		int x = 0, y = 0;
		char[][] map = new char[h][w];
		d = new int[h][w];
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
			Arrays.fill(d[i], Integer.MAX_VALUE);
		}
		map[0][0] = 'f';

		d[0][0] = 1;
		solve(map, x, y);
		int score;
		if (d[h - 1][w - 1] != Integer.MAX_VALUE) {
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (map[i][j] == '#') {
						cnt++;
					}
				}
			}
			score = h * w - cnt - d[h - 1][w - 1];
		} else {
			score = -1;
		}
		System.out.println(score);
	}

	private static void solve(char[][] map, int x, int y) {
		Deque<P> deque = new ArrayDeque<>();
		deque.add(new P(x, y));
		while (!deque.isEmpty()) {
			P p = deque.poll();
			if (p.x == w && p.y == h) {
				break;
			}
			for (int i = 0; i < 4; i++) {
				int xx = p.x + dx[i];
				int yy = p.y + dy[i];
				if (xx >= 0 && xx < w && yy >= 0 && yy < h && map[yy][xx] == '.' && d[yy][xx] == Integer.MAX_VALUE) {
					deque.add(new P(xx, yy));
					d[yy][xx] = d[p.y][p.x] + 1;
				}
			}
		}
	}
}

class P {
	int x;
	int y;

	public P(int x, int y) {
		this.x = x;
		this.y = y;
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+10;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y;
    cin>>y;
    ll sum=0,op;
    for (int i=0;i<y;i++)
    {
        cin>>op;
        sum+=op;
    }
    if (sum>=x)
        cout<<"Yes\n";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val out = new java.io.PrintWriter(System.out)
  val Array(r, d, x2000) = in.readLine.split(" ").map(_.toInt)

  (1 to 10).scanLeft(x2000) {(acc, _) =>
    r * acc -d
  }.tail.foreach(out.println)

  out.flush
}

Measured memory_bytes: 25544
#include<stdio.h>
int main()
{
  int a,b,res;
  char c;
  scanf ("%d %c %d",&a, &c, &b);
  switch(c)
  {
    case '+': res=a+b;
    printf("%d",res);
    break;
    case '-': res=a-b;
    printf("%d",res);
    break;
  }
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	int temp = (n+999) / 1000;
	int ans = temp * 1000 - n;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

double mink(long long p, vector<long long> d)
{
    double result = 0;
    if (p >= INF)
    {
        long long m = d.at(0);
        for (size_t i = 1; i < d.size(); i++)
        {
            if (m < d.at(i))
            {
                m = d.at(i);
            }
        }
        result = m;
        return result;
    }
    for (size_t i = 0; i < d.size(); i++)
    {
        result += (double)pow(d.at(i), p);
    }
    result = (double)pow(result, (double)1 / p);

    return result;
}

int main()
{
    long long n;
    cin >> n;
    vector<long long> x(n);
    vector<long long> y(n);
    for (long long i = 0; i < n; i++)
    {
        cin >> x.at(i);
    }
    for (long long i = 0; i < n; i++)
    {
        cin >> y.at(i);
    }
    vector<long long> d(n);
    for (long long i = 0; i < n; i++)
    {
        d.at(i) = x.at(i) - y.at(i);
        if (d.at(i) < 0)
        {
            d.at(i) = -1 * d.at(i);
        }
    }
    vector<double> ans(4);
    ans.at(0) = mink(1, d);
    ans.at(1) = mink(2, d);
    ans.at(2) = mink(3, d);
    ans.at(3) = mink(INF, d);
    for (int i = 0; i < 4; i++)
    {
        cout << std::fixed << std::setprecision(10) << ans.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 3420
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] arrs){
		
		Scanner sc = new Scanner(System.in);
		
		
		ArrayList<Integer> pollock = new ArrayList<Integer>();
		ArrayList<Integer> pollockk = new ArrayList<Integer>();

		int pollocknum = 0;
		int[] pollocktrue = new int[1000000 + 1];
		int[] pollocktrue2 = new int[1000001];
		Arrays.fill(pollocktrue, Integer.MAX_VALUE/2);
		Arrays.fill(pollocktrue2, Integer.MAX_VALUE/2);
		
		for(int i = 1; pollocknum <= 1000000 - 1; i++){
			pollock.add(pollocknum); 
			pollocktrue2[pollocknum] = 1;
			if(pollocknum%2 != 0){
				pollocktrue[pollocknum] = 1;
				pollockk.add(pollocknum);
			}
			pollocknum = (i * (i + 1) * (i + 2)) / 6;
		}
		
		for(int i = 0; i < pollockk.size();i++){
			for(int j = 0 ; j < pollocktrue.length; j++){
				if(j + pollockk.get(i) <= 1000000){
					pollocktrue[j + pollockk.get(i)] = Math.min(pollocktrue[j + pollockk.get(i)], pollocktrue[j] + 1); 
				}
			}
			
		}
		for(int i = 0; i < pollock.size();i++){
			for(int j = 0 ; j < pollocktrue2.length; j++){
				if(j + pollock.get(i) <= 1000000){
					pollocktrue2[j + pollock.get(i)] = Math.min(pollocktrue2[j + pollock.get(i)], pollocktrue2[j] + 1); 
				}
			}
			
		}
		
		while(true){
			
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			
			System.out.println(pollocktrue2[n]+ " "+ pollocktrue[n]);
		}
		
	}

}

Measured memory_bytes: 20000
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii>
using vec = vector<T>;

const ll INF = 1e18, MOD = 1e9 + 7;

const int MAX = 2e5;

vec<> divisors(MAX + 1, {1});
void sieve() {
    divisors[1].clear();
    for (int i = 2; i <= MAX; i++) {
        for (int j = 2 * i; j <= MAX; j += i) {
            divisors[j].push_back(i);
        }
    }
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    sieve();

    int n;
    cin >> n;
    vii v(n);
    for (auto &e : v) {
        cin >> e;
    }
    vii res;
    for (int x = n; x > 0; x--) {
        for (int d : divisors[x]) {
            v[d - 1] ^= v[x - 1];
        }
        if (v[x - 1]) res.push_back(x);
    }
    cout << res.size() << '\n';
    for (auto e : res) {
        cout << e << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 24672
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> point;
typedef pair<point, point> line;
double cross(point a, point b){
  return imag(conj(a) * b);
}


point cross_point(line a, line b){
  double d1 = cross(b.second - b.first,
                    b.first - a.first);
  double d2 = cross(b.second - b.first,
                    a.second - a.first);
  return a.first + (a.second - a.first) * (d1/d2);
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    point x[3];
    for (int j = 0; j < 3; j++) {
      double real, imag;
      cin >> real >> imag;
      x[j] = point(real, imag);
    }
    point m1 = (x[0] - x[1]), m2 = (x[1] - x[2]);
    m1 = point(m1.real()/2, m1.imag()/2);
    m2 = point(m2.real()/2, m2.imag()/2);
    line n1 = line(m1*point(0, 1), m1*point(0, -1)),
      n2 = line(m2*point(0, 1), m2*point(0, -1));
    n1.first += m1 + x[1];
    n1.second += m1 + x[1];
    n2.first += m2 + x[2];
    n2.second += m2 + x[2];
    point center = cross_point(n1, n2);
    printf("%.3lf %.3lf %.3lf\n", center.real(), center.imag(),
           abs(center - x[0]));
  }
  return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
int n,K,dp[5][105][3];
char str[105];
int dfs(int m,int use,int limit) {
    if(use>K){
    	return 0;
	}
    if(m>n){
    	return use==K;
	}
    if(dp[use][m][limit] != -1){
    	return dp[use][m][limit];
	}
    int up=limit==1?str[m]-'0':9,ans=0;
    for(int i = 0; i <= up; ++i){
    	ans += dfs(m+1, use+(i!=0), limit&&i==up); 
	}
    return dp[use][m][limit]=ans;
}
void run_case() {
    cin>>(str+1)>>K;
    n=strlen(str+1);
    memset(dp,-1,sizeof(dp));
    cout<<dfs(1, 0, 1)<<endl;
}
int main(){
    run_case();
    cout.flush();
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

ll n;
ll a[301];
ll dp[2][90001][8];
ll m=90000;
ll sum=0;
ll f[4];

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

  f[0]=1; f[1]=1; f[2]=2; f[3]=6;
  cin>>n;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }

  ll crt=0,nxt=1;
  dp[0][0][0]=1;
  rep(i,n){
    memset(dp[nxt],0,sizeof(dp[nxt]));
    rep(j,m+1)rep(k,8){
      if(j+a[i]<=m)(dp[nxt][j+a[i]][k|1]+=dp[crt][j][k])%=mod;
      (dp[nxt][j][k|2]+=dp[crt][j][k])%=mod;
      (dp[nxt][j][k|4]+=dp[crt][j][k])%=mod;
    }
    swap(crt,nxt);
  }

  ll res=0;
  repl(s,(sum+1)/2,m+1)rep(k,8){
    if((k&1)==0)continue;
    if(dp[crt][s][k]==0)continue;
    if(k==7)(res+=dp[crt][s][k]*3%mod)%=mod;
    if(k==3){
      if(sum%2==0&&s==sum/2)(res+=dp[crt][s][k]*3%mod)%=mod;
      else (res+=dp[crt][s][k]*6%mod)%=mod;
    }
    if(k==1)(res+=dp[crt][s][k]*3%mod)%=mod;
  }

  ll p=1;
  rep(i,n)(p*=3)%=mod;
  cout<<(p-res+mod)%mod<<endl;

  return 0;
}


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

using namespace std;


int main() {

	long long H, N, ans = 10000000000;
	cin >> H >> N;
	vector<long long>A(N), B(N), cost(30000, 10000000000);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i) >> B.at(i);
	}
	cost.at(0) = 0;
	for (size_t i = 0; i < N; i++)
	{
		cost.at(A.at(i)) = B.at(i);
	}
	for (size_t i = 0; i < 30000; i++)
	{
		for (size_t j = 0; j < N; j++)
		{
			if (i>=A.at(j) )
			{
				cost.at(i) = min(cost.at(i - A.at(j)) + B.at(j), cost.at(i));
			}
		}
	}
	for (size_t i = H; i < 30000; i++)
	{
		ans = min(ans, cost.at(i));
	}
	cout << ans;
}


Measured memory_bytes: 512
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

N = _I()
A = LI()
B = LI()
C = LI()
A = [i-1 for i in A]

ans = 0
previous = None
for i in range(N):
    ans += B[A[i]]
    if previous ==  A[i]-1:
        ans += C[A[i]-1]
    previous = A[i]
print(ans)


Measured memory_bytes: 80364
import math

while True:
    n = float(input())
    if n == 0: break
    student = list(map(float, input().split()))
    average = sum(student) / n
    deviation = [(point-average)**2  for point in student]
    dispersion = sum(deviation) / n
    sqrt = math.sqrt(dispersion)
    print(sqrt)



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

using namespace std;

int main(){
	int h1, m1, h2, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;

	int min = 60*(h2-h1) + (m2-m1);
	cout<<min-k<<'\n';
	return 0;
}

Measured memory_bytes: 3636
fun main(args: Array<String>) = yorukatsu16b()

fun yorukatsu16b() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val abList = (1..n).map {
        readLine()!!.split(' ').map { it.toInt() }.let { it[0] to it[1] }
    }
    val cdList = (1..m).map {
        it to readLine()!!.split(' ').map { it.toInt() }
    }

    val answer = abList.map { ab ->
        val (a, b) = ab
        cdList.minBy {
            val (index, cd) = it
            val (c, d) = cd
            Math.abs(c - a) + Math.abs(d - b)
        }!!.first
    }.joinToString(System.lineSeparator())

    println(answer)
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const long long MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll sum(n+1);
    repr(i, n) sum[i] = (sum[i+1] + a[i]) % MOD;
    ll ans = 0;
    rep(i, n-1) {
        ans = (ans + (a[i] * sum[i+1])) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6416
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

	int a, b;
	cin>> a>> b;

	if(b < a)	swap(b, a);

	if((b - a) % 2)	cout<< "IMPOSSIBLE"<< endl;
	else 			cout<< a + (b - a) / 2<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll pow2_m(ll x, ll n, ll mod) { //x^n 計算量O(logn)
	ll ans = 1ll;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

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

	ll n;
	cin >> n;
	Array a(n, 0);
	REP(i, n) cin >> a[i];

	sort(all(a));

	if (n % 2 == 0) {
		ll x = 1;
		for (ll i = 0; i < n; i += 2) {
			if (!(a[i] == x && a[i + 1] == x)) {
				cout << 0 << endl;
				return 0;
			}
			x += 2;
		}
	}
	else {
		if (a[0] != 0) {
			cout << 0 << endl;
			return 0;
		}
		int x = 2;
		for (int i = 1; i < n; i += 2) {
			if (!(a[i] == x && a[i + 1] == x)) {
				cout << 0 << endl;
				return 0;
			}
			x += 2;
		}
	}

	ll m = n / 2;
	cout << pow2_m(2, m, MOD) << endl;


	return 0;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
   if(b>c){
   	swap(b,c);
   }
	if(a+b> c){
		cout<<0;
		return 0;
	}
	else{
		cout<<c-a-b;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std; 

int main()
{
	int M, T, P, R;
	int m, t, p, j;
	int pena[51][11];
	int solve[51];
	int time[51];

	while(cin >> M >> T >> P >> R){
		if(M==0 && T==0 && P==0 && R==0){return 0;}

		map<int,map<int,map<int,int,greater<int> > >,greater<int> > ans;

		for(int i=1; i<=T; i++){
				solve[i]=0;
				time[i]=0;
			for(int k=1; k<=P; k++){
				pena[i][k]=0;
			}
		}

		for(int i=0; i<R; i++){
			cin >> m >> t >> p >> j;

			if(j==0){
				solve[t]++;
				time[t] = time[t] + m + 20*pena[t][p];
			}
			else{
				pena[t][p]++;
			}
		}

		for(int i=1; i<=T; i++){
			ans[solve[i]][time[i]][i]=0;
		}

		int pre_s=-1, pre_t=-1;

		for(map<int,map<int,map<int,int,greater<int> > >,greater<int> >::iterator it = ans.begin(); it != ans.end(); it++){
			for(map<int,map<int,int,greater<int> > >::iterator jt = (*it).second.begin(); jt != (*it).second.end(); jt++){
				for(map<int,int,greater<int> >::iterator kt = (*jt).second.begin(); kt != (*jt).second.end(); kt++){
					if(pre_s==-1 && pre_t==-1){ cout << (*kt).first; }
					else if(pre_s==(*it).first && pre_t==(*jt).first){cout << "=" << (*kt).first;}
					else{cout << "," << (*kt).first;}
					pre_s=(*it).first;
					pre_t=(*jt).first;
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1204
import copy
from collections import deque

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

e = [[] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
visited = [False]*n
visited[0] = True
d = deque([[0, visited]])

cnt = 0
while d:
    f, visited = d.pop()
    for t in e[f]:
        v = copy.deepcopy(visited)
        if not v[t]:
            v[t] = True
            if False in v:
                d.append([t, v])
            else:
                cnt += 1
print(cnt)

Measured memory_bytes: 9528
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
constexpr ll TEN(int n){
    return n == 0 ? 1 : TEN(n-1) * 10;
}
ll mod = 1e9+7;
struct edge{
    int to, cost;
    edge(int a = 0, int b = 0) : to(a), cost(b) {}
};
void ae(vector<vector<edge>>&g,int from, int to, int cost){
    g[from].emplace_back(to,cost);
    g[to].emplace_back(from,cost);
}
auto dijkstra(int s, vector<vector<edge>> &g){
    int n = (int)g.size();
    vector<ll> dist(n, 1LL<<60);
    vector<ll> way(n, 0);
    using ll_i = pair<ll, int>;
    priority_queue<ll_i,vector<ll_i>,greater<ll_i>>pq;
    dist[s] = 0;
    way[s] = 1;
    pq.push({dist[s], s});
    while(!pq.empty()){
        auto a = pq.top();
        pq.pop();
        int v = a.second;
        if(a.first > dist[v])continue;
        for(auto &x:g[v]){
            if(dist[x.to] > dist[v] + x.cost){
                dist[x.to] = dist[v] + x.cost;
                way[x.to] = 0;
                pq.push({dist[x.to], x.to});
            }
            if(dist[x.to] == dist[v] + x.cost){
                way[x.to] += way[v];
                way[x.to] %= mod;
            }
        }
    }
    return dist;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--,t--;
    vector<vector<edge>>g1, g2;
    g1.resize(n), g2.resize(n);
    while(m--){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--,v--;
        ae(g1,u,v,a);
        ae(g2,u,v,b);
    }
    auto d1 = dijkstra(s,g1);
    auto d2 = dijkstra(t,g2);
    constexpr ll inf = TEN(15);
    multiset<ll>st;
    rep(i,n){
        st.insert(d1[i]+d2[i]);
    }
    rep(i,n){
        cout << inf - *st.begin() << "\n";
        st.erase(st.find(d1[i]+d2[i]));
    }
}

Measured memory_bytes: 19960
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<vector>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pi;
///////////////////////////////

int const N = 1e5 + 41;
int n;
ll a[N];


void bad(){
	printf("NO\n");
	exit(0);
}

void ok(){
	printf("YES\n");
	exit(0);
}

void solve(){
	ll sum = 0;
	fi(0, n){
		sum += a[i];
	}
	ll sumA = (1LL + n) * 1LL * n / 2;
	if(sum % sumA != 0){
		bad();
	}
	ll cnt = sum / sumA;
	fi(0, n){
		a[i] -= cnt;
		if(a[i] < 0){
			bad();
		}
	}

	ll remCnt = cnt;
	a[n] = a[0];
	fi(1, n + 1){
		ll dif = (a[i] - a[i-1]);
		dif -= cnt;
		if(dif > 0){
			bad();
		}
		if(abs(dif) % n != 0){
			bad();
		}
		remCnt += (dif / n);
		if(remCnt < 0){
			bad();
		}
	}
	if(remCnt != 0){
		bad();
	}

	ok();
}

void read(){
	cin >> n;
	fi(0, n){
		cin >> a[i];
	}
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n,k,q; cin>>n>>k>>q;
  int a[n]; for(int i=0;i<n;i++) cin>>a[i];
  P p[n]; for(int i=0;i<n;i++) p[i]={a[i],i};
  bool u[n]; fill(u,u+n,false);
  sort(p,p+n);
  int an=1e9;
  for(int i=-1;i<n-1;i++) {
    // i番目までを無効にする
    if (i!=-1) u[p[i].second]=true;

    int mx=0, mn=p[i+1].first;
    priority_queue<int, vector<int>, greater<int>> que, que2;
    for(int j=0;j<=n;j++) {
      if (j==n || u[j]) {
        while(que.size() >= k) {
          que2.push(que.top()); que.pop();
        }
        while(!que.empty()) que.pop();
      } else {
        que.push(a[j]);
      }
    }
    if (que2.size() < q) break;
    for(int j=0;j<q;j++) {
      mx=max(mx,que2.top()); que2.pop();
    }
    an=min(an,mx-mn);
    //cout<<mx<<" "<<mn<<endl;
    //for(int j=0;j<n;j++) cout<<u[j]; cout<<endl;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
import qualified Data.Array as A
import qualified Data.Map as M
import qualified Data.Set as S
import Control.Applicative
import Control.Monad
import Control.Monad.RWS

main :: IO ()
main = do
  n <- readLn
  ascs <- replicateM n $ do
    (u:_:vs) <- map read . words <$> getLine
    return (u, vs)

  let arr = A.array (1,n) ascs
      (_,_,res) = runRWS (mapM_ dfs [1..n]) arr (S.empty,1)

  forM_ [1..n] $ \i -> let
      d = res M.! (i, False)
      f = res M.! (i, True)
    in putStrLn $ unwords $ map show [i,d,f]

dfs :: Int -> RWS (A.Array Int [Int]) (M.Map (Int, Bool) Int) (S.Set Int, Int) ()
dfs v = do
  (set, cur) <- get

  when (v`S.notMember`set) $ do
    tell $ M.singleton (v, False) cur
    put (v`S.insert`set, cur+1)
    vs <- reader (A.!v)
    mapM_ dfs vs
    (set', cur') <- get
    tell $ M.singleton (v, True) cur'
    put (set', cur'+1)
    return ()

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int maxn = 1e5 + 4;
long long n, dp[maxn], arr[maxn];

long long solve(int indx)
{
    if(indx >= n)
        return INT_MAX;
    if(indx == n - 1)
        return 0;
    if(dp[indx] != -1)
        return dp[indx];
    long long ans1 = 0, ans2 = 0, ans;
    ans1 += solve(indx + 1) + abs(arr[indx] - arr[indx + 1]);
    ans2 += solve(indx + 2) + abs(arr[indx] - arr[indx + 2]);
    ans = min(ans1, ans2);
    return dp[indx] = ans;
}

int main()
{
    IO;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
using ll=long long;
int main()
{
    ll a,b,c,d,sub,ans,rafi=0;
    cin>>a>>b>>c>>d;
    if(a>b)
    rafi=a-b;
    if(b>a)
    {
        b=a;
    }
    cout<<(b*c)+(rafi*d)<<endl;
    return 0;

}


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

int main() {
  int k, x;
  cin >> k >> x;
  int i = x - k + 1;
  while (i <= x + k - 1) {
    cout << i;
    if(i < x + k - 1) {
      cout << " ";
    }
    i++;
  }
  cout << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
const int maxn = 2e5 + 10;
ll qmod(ll a,ll n)
{
    ll ans = 1;
    while(n)
    {
        if (n & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}
int N, M, K;

ll fac[maxn], inv[maxn];

ll C(int n,int m)
{
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
    fac[0] = 1;
    for (int i = 1; i < maxn; ++i)
        fac[i] = fac[i - 1] * i % mod;
    inv[maxn - 1] = qmod(fac[maxn - 1], mod - 2);
    for (int i = maxn - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * (i + 1) % mod;
    read(N), read(M), read(K);
    ll res = 0;
    for (int i = 0; i <= K; ++i)
    {
        res += M * C(N - 1, i) % mod * qmod(M - 1, N - i - 1) % mod;
        res %= mod;
    }
    printf("%lld\n", res);
}

Measured memory_bytes: 6884
import sys
readline = sys.stdin.readline

def calc(t1, t2, a1, a2, b1, b2):
    x1 = a1*t1 + a2*t2
    x2 = b1*t1 + b2*t2
    if x1 == x2:
        return 'infinity'
    if x1 > x2:
        a1, a2, b1, b2, x1, x2 = b1, b2, a1, a2, x2, x1
    y1 = a1*t1
    z1 = b1*t1
    
    if y1 < z1:
        return 0
    res = 1
    ok = 0
    ng = 10**20
    while abs(ng - ok) > 1:
        med = (ng + ok)//2
        if med*x1 + y1 >= med*x2 + z1:
            if med*x1 + y1 == med*x2 + z1:
                res = 0
            ok = med
        else:
            ng = med
    return res + 2*ok
        
        
T1, T2 = map(int, readline().split())
A1, A2 = map(int, readline().split())
B1, B2 = map(int, readline().split())

print(calc(T1, T2, A1, A2, B1, B2))

Measured memory_bytes: 38384
/*
    to amy
    https://atcoder.jp/contests/abc130/tasks/abc130_c
*/

#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w,h,x,y;

    while(cin>>w>>h>>x>>y){
        double ans = (double(w)*double(h))/2;
        printf("%.6f ",ans);
        if(x+x==w && y+y==h)printf("1\n");
        else printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, data[101][100], v[101];

void visit(int x,int y){
  int i;
  if(v[x]==-1 || v[x]>y) v[x]=y;
  else return;
  for(i=0;data[x][i]!=0;i++) visit(data[x][i],y+1);
}

int main(){
  int i, j, a, b;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++) scanf("%d",&data[a][j]);
    data[a][j]=0;
  }
 
  for(i=1;i<=n;i++)  v[i]=-1;

  visit(1,0);

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

  return 0;
}





Measured memory_bytes: 2136
//#pragma comment(linker,"/STACK:36777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define itoc(c) (char)((int)'0' + c)
#define ctoi(c) (int)(c - '0')
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define emb emplace_back
#define pb push_back

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

const int oo = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  unordered_map<string, int> mp;
  for (int i = 1; i <= n; ++i) {
    string s; cin >> s;
    mp[s] += 1;
  }
  int mx = -1;
  vector<string> vs;
  for (auto &p: mp) {
    if (p.second >= mx) {
      if (p.second > mx) vs.clear();
      mx = p.second;
      vs.push_back(p.first);
    }
  }
  sort(vs.begin(), vs.end());
  for (string s: vs) cout << s << "\n";
  return 0;
}

Measured memory_bytes: 25284
import sys
from collections import defaultdict, deque
from functools import reduce
import math

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    order_list = [0] * N
    for i in range(N):
        order_list[A[i]-1] = i + 1
    print(' '.join(map(str, order_list)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 18940
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, mm, aa, bb, ans = 0;
	cin >> nn >> mm;
	bool table[nn][nn];
	for(int64 ii = 0;ii < nn;ii++)
	{
		for(int64 jj = 0;jj < nn;jj++)
		{
			table[ii][jj] = false;
		}
	}
	for(int64 ii = 0;ii < mm;ii++)
	{
		cin >> aa >> bb;
		table[aa-1][bb-1] = true;
		table[bb-1][aa-1] = true;
	}
	queue<pair<int64, int64>> qq;
	qq.push(make_pair(0, 1));
	while(!qq.empty())
	{
		int64 here = qq.front().first;
		int64 memo = qq.front().second;
		qq.pop();
		if(memo == (1 << nn) - 1)
		{
			ans++;
		}
		else
		{
			for(int64 ii = 1;ii < nn;ii++)
			{
				if(table[ii][here] && !(memo & (1 << ii)))
				{
					qq.push(make_pair(ii, memo + (1 << ii)));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	string s;
	cin>>s;
	int cnt = 0;
	int left = 0, right=s.size()-1;
	while(left < right){
		if(s[left] == s[right]){
			left++;
			right--;
			continue;
		}
		else if(s[left] == 'x' && s[right] != 'x'){
			left++;
			cnt++;
		}
		else if(s[left]!= 'x' && s[right] =='x'){
			right--;
			cnt++;
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
 	}
 	cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<numeric>
#include<cstdio>

int l[10],v,v2;

int main(){
	while(true){
		for(int i=0;i<10;i++){
			if(scanf("%d,",&l[i])==EOF)return 0;
		}
		if(scanf("%d,%d",&v,&v2)==EOF)return 0;

		double k=(double)std::accumulate(l,l+10,0)/(v+v2)*v;

		int sum=0;
		for(int i=0;i<10;i++){
			sum+=l[i];
			if(sum>=k){
				std::cout<<i+1<<std::endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1208
// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ████━████   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━

// Author        : WhyWhy
// Created Time  : 2017年04月20日 星期四 19时47分38秒
// File Name     : C.cpp

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

int N;
int rem[55][26];
int ans[26];
char s[55];

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d",&N);
	for(int i=1;i<=N;++i) {
		scanf("%s",s);
		for(int j=0;s[j];++j) ++rem[i][s[j]-'a'];
	}

	memset(ans,0x3f,sizeof(ans));
	for(int i=1;i<=N;++i)
		for(int j=0;j<26;++j)
			ans[j]=min(ans[j],rem[i][j]);

	for(int i=0;i<26;++i)
		for(int j=0;j<ans[i];++j)
			putchar('a'+i);
	puts("");

	return 0;
}

Measured memory_bytes: 256
a,b,m = gets.split.map(&:to_i)
aar = gets.split.map(&:to_i)
bar = gets.split.map(&:to_i)
array = []
m.times do
  x,y,c = gets.split.map(&:to_i)
  array << [c,x,y]
end
x = 10**9
for i in 0..(m-1)
  ans = aar[(array[i][1])-1] + bar[(array[i][2])-1] - array[i][0]
  x = ans if ans < x
end
puts [x,(aar.min)+(bar.min)].min

Measured memory_bytes: 19228
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	
	vector<int> B(m);
	vector<vector<int>> A(n, vector<int>(m));

	

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

	for (int i = 0; i < n; i++) {
		for (int k = 0; k < m; k++) {
			cin >> A[i][k];
		}
	}
	int sum=c;
	int counter = 0;
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < m; k++) {
			sum += A[i][k] * B[k];
		}
		if (sum > 0) {
			counter++;
		}
		sum = c;
	}

	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	int minn = 0x3f3f3f3f;
	for(int i=0;i<s.length()-2;i++){
		int sz = (s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48);
		int t = fabs(sz-753);
		minn = min(minn,t);
	}
	cout<<minn<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<map>
using namespace std;
int read()
{
	int f,c,x;
	while(!isdigit(c=getchar())&&c!='-'); c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while(isdigit(c=getchar())) x=(x<<3)+(x<<1)+c-'0'; return f?-x:x;
}
int h,w,n,X,Y;
long long ans[11];
map<pair<int,int>,int>ma;
int main()
{
	h=read(); w=read(); n=read();
	ans[0]=1ll*(h-2)*(w-2);
	for(int x,y,i=1;i<=n;i++)
	{
		x=read(); y=read();
		for(int j=0;j<3;j++)
		{
			X=x+j;
			for(int k=0;k<3;k++)
			{
				Y=y+k;
				if(X>=3&&X<=h&&Y>=3&&Y<=w)
				{
					ans[ma[make_pair(X,Y)]]--;
					ans[++ma[make_pair(X,Y)]]++;
				}
			}
		}
	}
	for(int i=0;i<=9;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int> > G(n, vector<int>(n, 1));
	for (int i = 0; i < n; ++i) G[i][i] = 0;
	while (m--) {
		int a, b; cin >> a >> b;
		G[a - 1][b - 1] = 0;
	}
	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
	for (int i = 0; i < n; ++i) {
		bool flag = false;
		for (int j = 0; j < n; ++j) {
			if (G[i][j] + G[j][i] == 0) {
				if (flag) cout << " ";
				cout << j + 1, flag = true;
			}
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3264
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

def main():
    n,x,y=map(int,input().split())
    dis=[0]*(n-1)
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i>=j: continue
            now=min(abs(j-i),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y))
            #print(i+1,j+1,now,(abs(j-i),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y)))
            dis[now-1]+=1

    for i in dis:
        print(i)

if __name__=="__main__":main()

Measured memory_bytes: 3444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main () {
    int n; cin >> n;
    V<V<mint>> dp(n+2, V<mint> (700, 0));
    V<V<mint>> dp2(n+2, V<mint> (700, 0));
    for (int i = 3; i <= n; i++) {
        dp[i][1] = 1;
        dp2[i][1] = i-2;
    }

    for (int i = 3; i <= n; i++) {
        for (int j = 2; j <= i/3 + 1; j++) {
            dp[i][j] += dp2[i-3][j-1];
            dp2[i][j] += dp[i][j];
            dp2[i+1][j] += dp2[i][j];
        }
    }
    mint ans = 0;
    rep(i, 700) ans += dp[n][i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25208
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	string s;
	cin >> s;

	ll n = s.size();
	bool flag = false;
	ll con = 0;

	string t;
	for (ll i = n - 1; i >= 0;i--) {
		ll num = s[i] - '0';
		if (flag) num++;
		if (num == 10) {
			flag = true;
		}else if (num > 5) {
			flag = true;
			con += 10 - num;
		}
		else if (num == 5) {
			if (i - 1 < 0) {
				con += 5;
				flag = false;
			}
			else if (s[i - 1] >= '5') {
				con += 5;
				flag = true;
			}
			else {
				con += 5;
				flag = false;
			}
		}else {
			con += num;
			flag = false;
		}
		
	}
	if (flag) con++;
	cout << con << endl;

	return 0;
}


Measured memory_bytes: 1948
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

const int N = 110;
const int MAXW = 100010;
int v[N];
int w[N];
long long int dp[N][MAXW];

int main() {
  int n;
  cin >> n;
  int W;
  cin >> W;
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
    cin >> v[i];
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < W; ++j) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);  // Do not take the item i
      if (j + w[i] <= W) dp[i + 1][j + w[i]] = dp[i][j] + v[i];
    }
  }

  long long int ans = 0;
  for (int j = 0; j <= W; ++j) {
    ans = max(ans, dp[n][j]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;

typedef long long LL;
int N;
LL K, S[MAXN];
unordered_map<LL,LL> M;

LL id(LL x) {
  LL p = (S[x] - x) % K;
  if (p < 0) p += K;
  return p;
}

void print(int x) {
  printf("%d has value %lld: M = %lld\n", x, id(x), M[id(x)]);
}

int main () {
  scanf("%d%lld",&N,&K);
  for (int i=1;i<=N;++i) {
    scanf("%lld",&S[i]);
    S[i] = (S[i] + S[i-1]) % K;
  }
  LL ans = 0;
  M[id(0)]++;
  //print(0);
  for (LL i=1;i<=N;++i) {
    //print(i);
    //print(i);
    LL x = id(i);
    ans += M[x];
    //printf("add %lld -> %lld\n", i, x);
    M[x]++;
    if (i-K+1ll >= 0) {
      M[id(i-K+1)]--;
      //printf("minus %lld -> %lld\n", i-K+1, id(i-K+1));
    }
  }
  if (K == 1) printf("0\n");
  else printf("%lld\n",ans);
}


Measured memory_bytes: 10056
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

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

const lli N = 1e5+2;
lli n, a[N], k;

struct cmp{
    bool operator()(const lli &a, const lli &b) {
        return a>b;
    }
};

void solve(){
    lli n; cin >> n;
    string ac = "AC", tle = "TLE", wa = "WA", re = "RE";
	lli a = 0, t = 0, w = 0, r = 0;
	string s;
	NA(i,0,n) {
		cin >> s;
		if(s==ac) {
			++a;
		} else if(s==tle) {
			++t;
		} else if(s==wa) {
			++w;
		} else {
			++r;
		}
	}
	cout << ac << " x " << a << '\n';
	cout << wa << " x " << w << '\n';
	cout << tle << " x " << t << '\n';
	cout << re << " x " << r << '\n';
	return;
}

int main(){
    fastIO;
    lli t = 1;
	// cin >> t;
	NA(i,0,t) solve();
	return 0;
}



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

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    if (S == "SUN") {
        ans = 7;
    } else if (S == "MON") {
        ans = 6;
    } else if (S == "TUE") {
        ans = 5;
    } else if (S == "WED") {
        ans = 4;
    } else if (S == "THU") {
        ans = 3;
    } else if (S == "FRI") {
        ans = 2;
    } else if (S == "SAT") {
        ans = 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256