akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

int main()
{
	int n,d;
	cin >> n >> d;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		double x,y;
		cin >> x >> y;
		double z=sqrt(x*x+y*y);
		if(z<=d)
			cnt++;
	}
	cout << cnt << endl;




}

Measured memory_bytes: 3804
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=110;
int n,a[N];
void main() {
    R(n);
    REP1(i,1,n) R(a[i]);
    int ans=0;
    REP1(i,1,n) if ( a[i]==a[i-1] ) {
        ans++;
        a[i]=0;
    }
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

vector<vector<ll>>g;
vector<ll>d;
queue<ll>que;
vector<ll>c;
vector<bool>memo;
void bfs(ll v,ll i){
    if(memo[v]==false)return;
    memo[v]=false;
    d[v]=c[i];
    for(auto u:g[v]){
        que.push(u);
    }
    while(!que.empty()){
        ll nx=que.front();
        que.pop();
        bfs(nx,i+1);
    }
}

int main(){
    ll n;cin >>n;
    g.assign(n,V());
    d.resize(n);
    c.resize(n);
    memo.assign(n,true);
    for (int i = 0; i < n-1; ++i) {
        ll a,b;cin >>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < n; ++i) {
        cin >>c[i];
    }
    sort(all(c));
    reverse(all(c));
    ll ans=0;
    for (int j = 0; j < n; ++j) {
        ans+=(j!=0)?c[j]:0;
    }
    bfs(0,0);
    cout <<ans<<endl;
    for (int k = 0; k < n; ++k) {
        cout << d[k]<<" ";
    }
    cout <<endl;
    return 0;
}

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

using namespace std;
using ll =long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,k;
    cin>>h>>w>>k;
    vector<int> from(w);
    auto to = from;
    from[0] = 1;
    for(int i=0;i<h;++i){
        fill(to.begin(),to.end(),0);
        for(int target=0;target<w;++target)
        for(int mask=0;mask<(1<<(w-1));++mask){
            bool ng = false;
            for(int j=1;j<w;++j){
                if((mask>>j&1)&&(mask>>(j-1)&1)) ng = true; 
            }
            if(ng)continue;
            if(target > 0 && mask&1<<(target-1)) to[target-1] += from[target],to[target-1] %= mod;
            else if(target < w-1 && mask&1<<target) to[target+1] += from[target],to[target+1] %= mod;
            else to[target] += from[target],to[target] %= mod;
        }
        swap(to,from);
    }
    
    cout << from[k-1] << endl;
    return 0;
}



Measured memory_bytes: 256
//#define		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<deque>
#include	<string>
#include	<unordered_map>

using namespace std;

#define		MAX		100000
struct SN
{
	char	S;
	int		N;
};

SN					A[MAX];

void swap(int a, int b)
{
	SN		temp(A[a]);

	A[a] = A[b];
	A[b] = temp;
}

int		Partition(int p, int r)
{
	int		x = A[r].N;
	int		i = p - 1;

	for (int j = p; j < r; ++j)
	{
		if (A[j].N <= x)
		{
			i = i + 1;
			swap(i, j);
		}
	}

	swap(i + 1, r);

	return (i + 1);
}

void QuickSort(int p, int r)
{
	if (p < r)
	{
		int	q = Partition(p, r);
		QuickSort(p, q - 1);
		QuickSort(q + 1, r);
	}
}

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE

	int					n;
	cin >> n;
	unordered_map<int, string>	um;
	unordered_map<int, string>	um2;
	deque<int>			dq;

	for (int i = 0; i < n; ++i)
	{
		cin >> A[i].S >> A[i].N;
		cin.clear();
		cin.ignore();

		um[A[i].N] += A[i].S;
	}

	QuickSort(0, n - 1);

	for (int i = 0; i < n; ++i)
	{
		um2[A[i].N] += A[i].S;
	}

	bool	isStable = true;
	for (auto it : um)
	{
		if (it.second != um2[it.first])
		{
			isStable = false;
			break;
		}
	}

	if (isStable)
	{
		cout << "Stable\n";
	}
	else
	{
		cout << "Not stable\n";
	}

	for (int i = 0; i < n; i++)
	{
		cout << A[i].S << " " << A[i].N << "\n";
	}

	return 0;
}

Measured memory_bytes: 8024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int v[n], c[n];
  for(int i = 0; i < n; i++){
	cin >> v[i];
  }
  for(int i = 0; i < n; i++){
	cin >> c[i];
  }
  
  //calc max(X-Y)
  int sum=0;
  for(int i = 0; i < n; i++){
	if(v[i]-c[i] > 0){
		sum += v[i]-c[i];
	}
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


//------------------変数-----------------------//
//-------------------関数----------------------//

int main() {
	ll n, retu[114540] = {}, num[145104] = {};
	cin >> n;
	REP(i, n) { ll hoge; cin >> hoge; num[hoge]++; }
	ll maxa = 0,mac=0;
	for (ll i = 2; i <=100000 ; i++)
	{
		if (mac < num[i] + num[i - 1] + num[i - 2]) {  mac = num[i] + num[i - 1] + num[i - 2]; }
	}
	cout << mac << endl;
	return 0;
}

Measured memory_bytes: 1408
# B - Resale

N = int(input())
V_n = list(map(int, input().split()))
C_n = list(map(int, input().split()))

ans = 0
dif = [0] * N

for i in range(N):
    dif[i] = V_n[i] - C_n[i]
    if dif[i] > 0:
        ans += dif[i]
print(ans)


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let (n,m,k): (usize,usize,u64)=(read(),read(),read());
    let u: Vec<u64>=(0..n).map(|_| read()).collect();
    let v: Vec<u64>=(0..m).map(|_| read()).collect();

    let mut a:Vec<u64> =vec![0];
    let mut b:Vec<u64> =vec![0];
    for u in u{
        a.push(a.last().unwrap()+u);
    }
    for v in v{
        b.push(b.last().unwrap()+v);
    }

    let mut ans=0;
    let mut j: usize=m;

    for i in 0..n+1{
        if(a[i]>k) {break;}
        while a[i]+b[j]>k {
            j-=1;
        }
        if ans < i+j {
            ans=i+j;
        } 
    }

    println!("{}",ans);
}

Measured memory_bytes: 7700
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
struct num
{
    int x;
    int sum;
};
num nums[100000+10];
bool cmp(const num& a,const num& b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    else
    return a.sum>b.sum;
}
int main()
{
    unsigned long long int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&nums[i].x,&nums[i].sum);
    }
    sort(nums,nums+n,cmp);
    unsigned long long int  add=0;
    unsigned long long int  res=0;
    for(int i=0;i<n;i++)
    {
        res+=nums[i].sum;
        if(res>=k)
        {
            cout<<nums[i].x<<endl;;
            break;
        }
        else
        add=res;
    }
    return 0;
}


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

int main()
{
  string s;
  int a = 0;
  int b = 0;
  cin >> s;
  if ((s[0] == '0' && s[1] != '0') || (s[0] == '1' && s[1] >= '0' && s[1] <= '2\
'))
    a++;
  if ((s[2] == '0' && s[3] != '0') || (s[2] == '1' && s[3] >= '0' && s[3] <= '2\
'))
    b++;
  if (a == 0 && b == 0)
    cout << "NA" << endl;
  else if (a == 1 && b == 0)
    cout << "MMYY" << endl;
  else if (a == 0 && b == 1)
    cout << "YYMM" << endl;
  else
    cout << "AMBIGUOUS" << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int		a, b;

	scanf("%d %d", &a, &b);

	if (a > b)			printf("a > b\n");
	else if (a < b)		printf("a < b\n");
	else				printf("a == b\n");

	return 0;
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<int> d(10, INF);
vector<edge> g[10];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    REP(i,g[v].size()) {
      edge e = g[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  IOS;
  int h, w; cin >> h >> w;
  REP(i,10) {
    REP(j,10) {
      int cost; cin >> cost;
      g[i].push_back({ j, cost });
    }
  }

  int memo[10];
  REP(i,10) {
    dijkstra(i);
    memo[i] = d[1];
  }

  int ans = 0;
  REP(i,h) REP(j,w) {
    int a; cin >> a;
    if (a == -1) continue;
    ans += memo[a];
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;


public class Main {
	
	public static void insertionSort(int [] A,int index){
		Integer i,j,k,v;
		
		for(k=0;k<index;k++){
			System.out.print(A[k]);
			if(k!=index-1)System.out.print(" ");
		}
		System.out.println();
		for(i=1;i<index;i++){
			v = A[i];
			j=i-1;
			
			while(j>=0 && A[j] > v){
				A[j+1] = A[j];
				j--;
				
			}
			A[j+1] = v;
			for(k=0;k<index;k++){
				System.out.print(A[k]);
				if(k!=index-1)System.out.print(" ");
			}
			System.out.println();
		}
		
	}
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		Integer i,n = sc.nextInt();
		int [] box = new int [n];
		
		
		for(i=0;i<n;i++){
			box[i] = sc.nextInt();
		}
		insertionSort(box,n);
	}

}


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

typedef long long ll;

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

	int N, K;
	cin >> N >> K;

	vector<int> h(N);

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

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

	int min = 1000000005;

	for(int i = 0; i < N - (K - 1); i++) {
		if(h[i + (K - 1)] - h[i] < min) {
			min = h[i + (K - 1)] - h[i];
		}
	}

	cout << min << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a,b,c,n;
	scanf("%d %d %d",&a,&b,&c);
	if(a!=b&&a!=c&&b!=c)
	printf("3");
	else if(a==b&&b==c&&a==c)
	printf("1");
	else
	printf("2");
	
	return 0;
 }

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

int main(){
	#ifndef ONLINE_JUDGE
		freopen ("../input.txt", "r", stdin);
		freopen ("../output.txt", "w", stdout);
	#endif

    double D,T,S; cin>>D>>T>>S;
    if((D/T) <= S) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

//配列を1つで行く場合
int main(void){

int N,M,C;

cin >> N >> M >> C;

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


int A[M];
int sum=0;
int count=0;
for (int n=0;n<N;n=n+1) {
    sum=0;
for (int m=0;m<M;m=m+1) {
cin >> A[m];
sum = sum + A[m]*B[m];
}
if (sum+C>0) count=count+1;
}

cout << count <<endl;

}


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

const ll INF = 1e18;
vector<vector<ll>> dist(300,vector<ll>(300,INF));
vector<vector<ll>> dist1(300,vector<ll>(300,INF));
vector<int> g[300];

int main(){
	int n,m,l; cin>>n>>m>>l;
	for(int i = 0; i < m; i++){
		int a,b,c;cin>>a>>b>>c;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
		dist[a][b] = c;
		dist[b][a] = c;
	}
	int q; cin>>q;
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(dist[i][j]>dist[i][k]+dist[k][j])
					dist[i][j]=dist[i][k]+dist[k][j];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0;  j < n; j++){
			if(i == j) continue;
			if(dist[i][j]<=l) dist1[i][j] = min(dist1[i][j],1LL);
		}
	}

	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(dist1[i][j]>dist1[i][k]+dist1[k][j])
					dist1[i][j]=dist1[i][k]+dist1[k][j];
			}
		}
	}


	for(int i=0; i<q; i++){
		int a,b;cin>>a>>b;
		--a,--b;
	    if(dist1[a][b]<INF) cout<<dist1[a][b]-1<<endl;
	    else cout<<-1<<endl;
	}

}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

map<int,int> ptm;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	int X = 0;
	cin >> X;

	// 1 : 1sec
	// 2 : wait + 2sec
	// 3 : 1sec + 2sec
	// 4 : 1sec + wait + 3sec
	// 5 : wait + 2sec + 3sec 
	// 6 : 1sec + 2sec + 3sec
	// 7 : 1sec + 2sec + wait + 4sec
	// 8 : 1sec + wait + 3sec + 4sec
	// 9 : wait + 2sec + 3sec + 4sec
	//10 : 1sec + 2sec + 3sec + 4sec

	int t = 0;
	int d = 0;
	while(true) {
		t++;
		d+=t;
		if(X<=d) {
			break;
		}
	}

	cout << t << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

const int INF = 1001001001;

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >>h2 >>m2 >>k;
  int tmp = h2*60+m2 - (h1*60+m1) - k;
  cout << tmp << endl;
  // int counter = 0;
  // for (;;) {
  //   if (tmp < k) break;
  //   tmp -= k;
  //   counter++;
  //   // cout << tmp << endl;
  //   // cout << counter << endl;
  // }
  //
  // int ans = k*counter;
  // cout << ans << endl;

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;

ll dp[125][5*5*5*5];
bool ng[625];
int f(int a,int b,int c,int d){
  return a*125 + b*25 + c*5 + d;
}
// a:1, g:2, c:3, t:4

int main(){
  scanf("%d",&n);
  dp[0][0] = 1;
  REP(i,5)ng[f(i,1,2,3)] = true;
  REP(i,5)ng[f(1,i,2,3)] = true;
  REP(i,5)ng[f(1,2,i,3)] = true;
  REP(i,5)ng[f(i,2,1,3)] = true;
  REP(i,5)ng[f(i,1,3,2)] = true;
  REP(i,n)REP(st,625)if(dp[i][st]){
    FOR(x,1,5){
      int nxt = (st * 5 % 625) + x;
      if(ng[nxt])continue;
      (dp[i+1][nxt] += dp[i][st]) %= MOD;
    }
  }
  ll ans = 0;
  REP(i,625)ans += dp[n][i];
  ans %= MOD;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 768
n,m,l = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(i) for i in input().split()] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(n):
    print(' '.join(map(str,c[i])))

Measured memory_bytes: 8868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 512;
const int zero = 250;
int fa[maxn],siz[maxn],oud[maxn],ind[maxn];bool h[maxn];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
inline void Union(int x,int y){
    x=find(x);y=find(y);if(x==y){++siz[x];return;}
    fa[x]=y;siz[y]+=siz[x]+1;
}
int main(){
	ios::sync_with_stdio(false);
    int n,H;cin>>n>>H;
    rep(i,1,H)  fa[i+zero]=i+zero,siz[i+zero]=1;
    rep(i,-H,-1)fa[i+zero]=i+zero,siz[i+zero]=1;
    int a,b,c,d;rep(i,1,n){
        int x,y;cin>>a>>b>>c>>d;
        if(c == 0)x=a;else x=-c;if(d == 0)y=-b;else y=d;
        ++oud[x+zero];++ind[y+zero];Union(x+zero,y+zero);
    }rep(i,1,H)	if(oud[i+zero]<ind[i+zero])return puts("NO"),0;
    rep(i,-H,-1)if(ind[i+zero]<oud[i+zero])return puts("NO"),0;
    rep(i,1,H)  h[find(i+zero)]|=(ind[i+zero]!=oud[i+zero]);
    rep(i,-H,-1)h[find(i+zero)]|=(ind[i+zero]!=oud[i+zero]);
    rep(i,1,H)  if(siz[find(i+zero)]>1&&(find(i+zero) == i+zero)&&(h[i+zero]==false))return puts("NO"),0;
    rep(i,-H,-1)if(siz[find(i+zero)]>1&&(find(i+zero) == i+zero)&&(h[i+zero]==false))return puts("NO"),0;
    puts("YES");
}

Measured memory_bytes: 384
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll x, k, d; cin >> x >> k >> d;

	if(abs(x) / d >= k){
		ll ans = x;
		if(0 <= ans){
			ans -= d * k;
		}
		else{
			ans += d * k;
		}
		cout << abs(ans) << endl;
		return 0;
	}

	ll val1 = x - (x / d) * d;
	ll val2 = 0;
	if(0 <= x){
		val2 = val1 - d;
	}
	else{
		val2 = val1 + d;
	}

	if((k - x / d) % 2 == 0){
		cout << abs(val1) << endl;
	}
	else{
		cout << abs(val2) << endl;
	}

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  int res = (2*B)-A;
  if(res>0)
    cout<<"0"<<endl;
  else
    cout<<A-(2*B)<<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 a,b;
  cin >> a >> b;
  
  if(a%b == 0) cout << 0 << endl;
  else cout << 1 << endl;
  
}


Measured memory_bytes: 256
//In the name of the Almighty

   #include <bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main( )
{

  optimize();
  int n,x,t;
  cin>>n>>x>>t;

  if (n%x==0)
  {
      int nt=n/x;
      cout<<nt*t<<endl;
  }
  else
  {
      int nt=(n/x)+1;
      cout<<nt*t<<endl;
  }


       return 0;
}



Measured memory_bytes: 3604
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n = int(input())
words = [input()]
for _ in range(n-1):
    word = input()
    if word in words or word[0] != words[-1][-1]:
        print("No")
        break
    else:
        words.append(word)
else:
    print("Yes")
    

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

def factorization(n):
	lista=[]
	temp=n
	
	i=2
	while i<=int(n**0.5//1):
		if temp%i==0:
			lista.append(i)
			temp=temp//i
		else:
			i=i+1
	if temp!=1:
		lista.append(temp)
#	if lista==[]:
#		lista.append(n)
	
	#lista.append(1)
	return lista
	
#print(factorization(a))
#print(factorization(b))
seta=set(factorization(a))
setb=set(factorization(b))
setc=seta&setb

ans=len(setc)+1
print(ans)

Measured memory_bytes: 39536
import java.util.Scanner;

public class Main {


public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int A = sc.nextInt();
			int B = sc.nextInt();
			int T = sc.nextInt();

			int count = 0;

			if( A > T ) {
				count = 0;
				System.out.println(count);
			}
			if( A == T ) {
				count = B;
				System.out.println(count);
			}
			if( A < T ){
				count = B * (T / A);
				System.out.println(count);
			}
		}

	}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

void ruiseki(vector<int> &sum){
	for(int i=1;i<sum.size();i++){
		sum[i] = mod(sum[i] + sum[i-1]);
	}
}

int main(){
	
	string S;
	cin>>S;
	
	int K;
	cin>>K;
	
	K = min(K,400);
	while(S.size()!=0&&S.back()=='0'){
		S.pop_back();
	}
	
	if(S.size()==1){
		cout<<1<<endl;
		return 0;
	}
	
	vector<int> num;
	
	for(int i=0;i<S.size();i++){
		if(S[i]=='0'){
			int c = 0;
			for(int j=i+1;j<S.size();j++){
				if(S[j]=='0')break;
				c++;
			}
			num.push_back(c);
		}
	}
	
	if(S[0]=='0')num.insert(num.begin(),0);
	else{
		int c = 0;
		for(int i=0;i<S.size();i++){
			if(S[i]=='0'){
				c++;
				if(i+1==S.size()){
					cout<<1<<endl;
					return 0;
				}
			}
			else{
				break;
			}
		}
		num.insert(num.begin(),c);
	}
	
	reverse(num.begin(),num.end());
	
	vector<vector<vector<int>>> dp(num.size()+1,vector<vector<int>>(K+1,vector<int>(S.size()+1,0)));
	dp[0][0][0] = 1;
	
	vector<vector<vector<int>>> sum = dp;
	ruiseki(sum[0][0]);
	
	for(int i=1;i<=num.size();i++){
		for(int j=0;j<=K;j++){
			for(int k=0;k<=S.size();k++){
				dp[i][j][k] = mod(sum[i-1][j].back() - sum[i-1][j][k]);
				
				for(int t=0;t<=num[i-1];t++){
					if(j-t<0||k-t<0)break;
					dp[i][j][k] = mod(dp[i][j][k] + dp[i-1][j-t][k-t]);
				}
				sum[i][j][k] = dp[i][j][k];
			}
			ruiseki(sum[i][j]);
		}
	}
	int ans = 0;
	for(int i=0;i<=K;i++){
		ans = mod(ans + dp.back()[i][0]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main()
{
    int n, l;
    std::cin >> n >> l;

    std::vector<std::string> s(n);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    std::sort(s.begin(), s.end());
    for (auto c : s) {
        std::cout << c;
    }
    putchar('\n');
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";   
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int main(){
	ios::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<char>ss;
    REP(i,0,s.size()){
        if(s[i]!='/'){
            ss.PB(s[i]);
        }
    }

    int month=(ss[4]-'0')*10+(ss[5]-'0');
    int day=(ss[6]-'0')*10+(ss[7]-'0');
    //deb(month);
    //deb(day);

    if(month <= 4){
        /*if(day<=30)
        cout<<"Heisei\n";
        else if(month!=4){
            cout<<"Heisei\n";
        }*/
        cout<<"Heisei\n";
    }

    else{
        cout<<"TBD\n";
    }



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if (h > H || w > W) {
    	cout << "No" << endl;
    	return 0;
    }
    int D[500][500];
    ll sum = 0;
    memset(D, 0, sizeof(D));
    for (int i = 0;i < H;i += h) {
    	for (int j = 0;j < W;j += w) {
    		D[i][j] = 1E9 - 1;
    		sum += 1E9 - 1;
    	}
    }
    for (int i = h - 1;i < H;i += h) {
    	for (int j = w - 1;j < W;j += w) {
    		D[i][j] = -1E9;
    		sum -= 1E9;
    	}
    }
    if (sum <= 0) {
    	cout << "No" << endl;
    }
    else {
    	cout << "Yes" << endl;
    	for (int i = 0;i < H;i++) {
    		for (int j = 0;j < W;j++) {
    			if (j != 0) cout << ' ';
    			cout << D[i][j];
    		}
    		cout << endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 3968
import sys
sys.setrecursionlimit(500000)


n = int(input())
lis = [[]for _ in range(n+1)]

for i in range(n-1):
    a,b = map(int,input().split())
    lis[a].append((b,i))
    lis[b].append((a,i))
k = max(len(li) for li in lis)
print(k)
ans = [-1] * (n-1)
def dfs(v = 1, p = 0, p_col = -1):
    col = 1
    for u,idx in lis[v]:
        if u != p:
            if col == p_col:
                col += 1
            ans[idx] = col
            dfs(u,v,col)
            col += 1
dfs()
print("\n".join(map(str,ans)))

Measured memory_bytes: 85636
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int iSP(Pt a, Pt b, Pt c) {
	int s = sig((b - a).det(c - a));
	if (s) return s;
	if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
	if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
	return 0;
}
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
double x[6];
double y[6];
double z[6];
Pt p[6];
int main(){
	for(int i=0;i<5;i++)scanf("%lf%lf%lf",x+i,y+i,z+i);
	for(int i=1;i<5;i++){
		x[i]-=x[0];y[i]-=y[0];z[i]-=z[0];
	}
	double th=atan2(y[1],x[1]);
	for(int i=1;i<5;i++){
		double X=x[i]*cos(th)+y[i]*sin(th);
		double Y=-x[i]*sin(th)+y[i]*cos(th);
		x[i]=X;y[i]=Y;
	}
	th=atan2(z[1],x[1]);
	for(int i=1;i<5;i++){
		double X=x[i]*cos(th)+z[i]*sin(th);
		double Z=-x[i]*sin(th)+z[i]*cos(th);
		x[i]=X;z[i]=Z;
	}
	for(int i=0;i<5;i++)p[i]=Pt(y[i],z[i]);
	double S=ABS((p[3]-p[2]).det(Pt(p[4]-p[2])));
	//for(int i=1;i<5;i++)printf("%f %f %f\n",x[i],y[i],z[i]);
	if(S<EPS){
		printf("HIT\n");return 0;
	}
	bool L=true;
	bool R=true;
	for(int i=0;i<3;i++){
		int res=iSP(p[2+i],Pt(0,0),p[2+(1+i)%3]);
		if(res==-1)L=false;
		if(res==1)R=false;
	}
	if(!L&&!R){
		printf("HIT\n");return 0;
	}
	for(int i=3;i<4;i++){
		if((p[i]).ABS()>EPS){
			swap(x[2],x[i]);
			swap(p[2],p[i]);
		}
	}
	Pt v=pLL(Pt(0,0),p[2],p[3],p[4]);
	double s1=(v-p[3]).ABS();
	double s2=(v-p[4]).ABS();
	double f=(x[3]*s2+x[4]*s1)/(s1+s2);
	double s3=(p[2]).ABS();
	double s4=v.ABS();
	double g=(f*s3+x[2]*s4)/(s3+s4);
	//printf("%f %f %f %f\n",v.x,v.y,f,g);
	if(g<x[1]+EPS&&g>-EPS)printf("MISS\n");
	else printf("HIT\n");
}

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

long long lcm(long long x, long long y) {
    return x / __gcd(x, y) * y;
}

int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long nU = B - A + 1;
    long long nC = B / C - (A - 1) / C;
    long long nD = B / D - (A - 1) / D;
    long long nCD = B / lcm(C, D) - (A - 1) / lcm(C, D);

    cout << nU - (nC + nD - nCD) << endl;
}

Measured memory_bytes: 256
N = gets.to_i
S = Hash.new
m = 0
N.times {
    b = gets.chomp
    S[b] = S[b].nil? ? 0 : (S[b] + 1)
    if S[b] > m then m = S[b] end
}

AR = []

for k in S.keys do
    if S[k] == m then AR.push(k) end
end

AR.sort!

for e in AR do
    puts e
end

Measured memory_bytes: 35556
n,d=[int(i) for i in input().split()]
a=[]
for i in range(n):
    arr=[int(i) for i in input().split()]
    a.append(arr)
ans=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        val=0
        for k in range(d):
            val+=(a[i][k] - a[j][k])**2
        val = val**0.5
        if(int(val)==val):
            ans+=1
print(ans)


Measured memory_bytes: 3188
#include <set>
#include <tuple>
#include <string>
#include <iostream>
using namespace std;
int n, q, a, b; string s;
int main() {
	while (cin >> n >> q, n | q) {
		set<tuple<int, int, int> > d;
		for (int i = 0; i < q; i++) {
			cin >> s >> a >> b;
			for (int j = 1; j <= n; j++) {
				if (s == "xy") d.insert(make_tuple(a, b, j));
				if (s == "xz") d.insert(make_tuple(a, j, b));
				if (s == "yz") d.insert(make_tuple(j, a, b));
			}
		}
		cout << n * n * n - d.size() << endl;
	}
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1000000;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 1e5 + 5;
vector <int> in[maxn], out[maxn];
bool odw[maxn];
int label[maxn], n, m, a, b;
ll res;
int ile[4], size, pyklo = 1, NO_MORE;
void dfs(int x)
{
	odw[x] = 1;
	++size;
	NO_MORE += (int)out[x].size();
	NO_MORE += (int)in[x].size();
	
	for (auto u : out[x])
		if (!odw[u])
		{
			label[u] = (label[x] + 1)%3;
			ile[label[u]]++;
			dfs(u);
		}
		else if (label[u] != (label[x] + 1)%3) pyklo = 0;
	
	for (auto u : in[x])
		if (!odw[u])
		{
			label[u] = (label[x] + 2)%3;
			ile[label[u]]++;
			dfs(u);
		}
		else if (label[u] != (label[x] + 2)%3) pyklo = 0;
}

ll solve(int x)
{
	NO_MORE = 0;
	pyklo = 1;
	size = 0;
	label[x] = 0;
	ile[0] = ile[1] = ile[2] = 0;
	ile[0]++;
	dfs(x);
	
	if (!pyklo) return (ll)size * size;
	bool flag = 0;
	FOR(i, 0, 2)
		if (!ile[i]) flag = 1;
	
	if (flag) return NO_MORE / 2;
	return (ll)ile[0] * ile[1] + (ll)ile[1] * ile[2] + (ll)ile[2] * ile[0];
}

int main()
{
	boost;
	cin >> n >> m;
	FOR(i, 1, n) label[i] = -1;
	FOR(i, 1, m)
	{
		cin >> a >> b;
		out[a].pb(b);
		in[b].pb(a);
	}
	
	res = 0;
	FOR(i, 1, n)
		if (!odw[i]) res += solve(i);
	cout << res;
}


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

int64_t gcd(int64_t a, int64_t b){
  while(a % b != 0){
    int64_t tmp = a % b;
    a = b;
    b = tmp;
  }
  return b;
}

int main(){
  int64_t a, b; 
  while(cin >> a >> b){ 
    cout << gcd(a,b) << " " << a * b / gcd(a,b) << endl;
  }
}


Measured memory_bytes: 3084
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    a[n+1] = 0;
    rep(i,n) cin >> a[i+1];
    ll ans = 0;
    rep(i,n+1){
        ans += abs(a[i+1]-a[i]);
    }
    for(int i=1;i<n+1;i++){
        cout << ans - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var sum = 0;
	list.sort(function(a,b){
		return a - b;
	});
	for(var i = 0; i < N - 1; i++){
		var mae = list.shift();
		var ato = list.shift();
		var newV = (mae + ato) / 2;
		list.unshift(newV);
	}
	myout(list[0]);
}


Measured memory_bytes: 30920
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
int a[MAXN], b[MAXN];

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m, k; read(n), read(m), read(k);
  int Ma = 0x7f7f7f7f, Mb = 0x7f7f7f7f;
  for (RI i = 1; i <= n; ++i) read(a[i]), Ma = min(Ma, a[i]);
  for (RI i = 1; i <= m; ++i) read(b[i]), Mb = min(Mb, b[i]);
  int ans = Ma + Mb;
  while (k--) {
    int x, y, z; read(x), read(y), read(z);
    ans = min(ans, a[x] + b[y] - z);
  }
  printf("%d\n", ans);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

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

using namespace std;

int main() {
  map<string, int> result{
    {"AC", 0},
    {"WA", 0},
    {"TLE", 0},
    {"RE", 0}
  };

  int N;
  cin >> N;

  string s;
  for(int i = 0; i < N; i++) {
    cin >> s;
    result[s]++;
  }

  cout << "AC x " << result["AC"] << endl;
  cout << "WA x " << result["WA"] << endl;
  cout << "TLE x " << result["TLE"] << endl;
  cout << "RE x " << result["RE"] << endl;
}

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

int d,G;
int p[10],c[10];
int dp[1001];

int main(){
  int d,g;
  cin >> d >> g;
  vector<int> p(d),c(d);
  for(int i=0;i<d;i++){
    cin >> p.at(i) >> c.at(i);
  }
  vector<int> dp(1001);
  for(int i=0;i<d;i++){
    for(int k=1000;k>=1;k--){
      for(int j=1;j<=p.at(i)&&j<=k;j++){
        dp.at(k)=max(dp.at(k),
          dp.at(k-j)+(i+1)*100*j+(j==p.at(i)?c.at(i):0));
      }
    }
  }
  for(int i=0;i<=1000;i++){
    if(dp.at(i)>=g){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct DATA{
  int x;
  char c;
} CARD;

void bubble(int,CARD *);
void selection(int,CARD *);

int main (){
  CARD bub[36],sel[36];
  int n,i,flag=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&bub[i].c,&bub[i].x);
    sel[i].c=bub[i].c;
    sel[i].x=bub[i].x;
  }
  bubble(n,bub);
  selection(n,sel);
  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%c%d",bub[i].c,bub[i].x);
  }
  printf("\nStable\n");
  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%c%d",sel[i].c,sel[i].x);
    if(bub[i].c!=sel[i].c){
      flag=1;
    }
  }
  if(flag){
    printf("\nNot stable\n");
  }
  else{
    printf("\nStable\n");
  }
  return 0;
}

void bubble(int n,CARD *x){
  int i,j,flag=0,tmp_x;
  char tmp_c;
  flag=1; 
  while(flag){
    flag=0;
    for(j=1;j<=n-1;j++){
      if(x[j].x<x[j-1].x){
	tmp_x=x[j].x;
	tmp_c=x[j].c;
	x[j].x=x[j-1].x;
       	x[j].c=x[j-1].c;
	x[j-1].x=tmp_x;
	x[j-1].c=tmp_c;
	flag=1;
      }
    }
  }
}

void selection(int n,CARD *x){
  int i,j,flag=0,tmp_x,min;
  char tmp_c;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(x[j].x<x[min].x){
	min=j;
      }
    }
    tmp_x=x[i].x;
    tmp_c=x[i].c;
    x[i].x=x[min].x;
    x[i].c=x[min].c;
    x[min].x=tmp_x;
    x[min].c=tmp_c;
  }
}



Measured memory_bytes: 2104
#include<stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	(((0<=a)&&(a<=100))&&((b>=0)&&(b<=100))&&((c>=0)&&(c<=100)));
	if((a < b)&&(b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int a,b,c,x,y;
    int p1=0,p2=0,p3=0,p4=0,p5=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    p1=a*x;
    p2=b*y;
    if(x>y){
        p3=c*y*2;
        p4=(x-y)*a;
        p5=c*x*2;
    }
    else{
        p3=c*x*2;
        p4=(y-x)*b;
        p5=c*y*2;
    }
    if((p1+p2)>(p3+p4)){
        if((p3+p4)>(p5))
        printf("%d\n",p5);
        else
            printf("%d\n",p3+p4);
    }
    else{
        if(p5>(p1+p2))
        printf("%d\n",p1+p2);
        else
            printf("%d\n",p5);
    }
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int H,W;
    
    while(1){
    
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        
        for(int i=0;i<H;i++){
            
            for(int j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
        
        putchar('\n');
        
    }
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;

void solve() {

    ll n, m;
    cin >> n >> m;

    if(n == m){
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
    return;
}

int main() {
    solve();
    return 0;

}

Measured memory_bytes: 256
s=input()
if s[0]=='0':
  print(-1)
elif s[-1]=='1':
  print(-1)
else:
  l=len(s)
  for i in range(l-1):
    if s[i]!=s[l-i-2]:
      print(-1)
      exit()
  ans=[]
  base=1
  for i in range(l-1):
    if s[i]=='1':
      print(base,i+2)
      base=i+2
    else:
      print(base,i+2)

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n), r(n);
  for(int i=0; i<n; i++) cin >> p[i];
  for(int i=0; i<n; i++) cin >> q[i];
  for(int i=0; i<n; i++) r[i] = i + 1;
  int rank = 1;
  int p_rank = 0, q_rank = 0;
  do {
    if (p==r) p_rank = rank;
    if (q==r) q_rank = rank;
    rank++;
  } while(next_permutation(r.begin(), r.end()));
  cout << abs(p_rank - q_rank) << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(b <= c || d <= a){
    cout << 0 << endl;
  }
  
  else if(a <= c){
    if(b <= d){
      cout << b - c << endl;
    }
    else{
      cout << d - c << endl;
    }
  }
  
  else{
    if(b <= d){
      cout << b - a << endl;
    }
    else{
      cout << d - a << endl;
    }
  }
}


Measured memory_bytes: 256
N = int(input())
alphabet_lst = list('abcdefghijklmnopqrstuvwxyz')
#print(alphabet_lst)

keta = 0
keta_lst = []
sum_lst = []
while N>=sum(keta_lst):
    keta_lst.append(26**keta)
    sum_keta = sum(keta_lst)
    sum_lst.append(sum_keta)
    keta += 1
    
keta -= 1
keta_lst = keta_lst[:keta]
#print(keta_lst)
#print(keta)

ans_lst = []
for i in range(keta):
    ans_n = (N - sum(keta_lst[:-(i+1)])) // keta_lst[-(i+1)]
    #print(ans_n)
    #print(keta_lst[-(i+1)])
    N -= ans_n*keta_lst[-(i+1)]
    ans_lst.append(alphabet_lst[ans_n-1])

for i in range(keta):
    print(ans_lst[i],end="")

Measured memory_bytes: 61952
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()
B = LI()


def main():
    s = [A[i] ^ A[(i + 1) % N] for i in range(N)]
    t = [B[i] ^ B[(i + 1) % N] for i in range(N)] * 2
    w = [0] * N
    for i in range(1, N):
        j = w[i - 1]
        while j != 0 and s[i] != s[j]:
            j = w[j - 1]
        if s[i] == s[j]:
            w[i] = j + 1
        else:
            w[i] = 0

    k_list = []
    i, j = 0, 0
    while i < N:
        while j < N and t[i + j] == s[j]:
            j += 1
        if j == N:
            k_list.append(-i % N)
        if j == 0:
            i += 1
        else:
            i += j - w[j - 1]
    
    k_list.sort()
    for k in k_list:
        x = A[k] ^ B[0]
        print(k, x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47308