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

typedef long long ll;
using namespace std;

bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {
  bool all_visited = true;
  for (int i = 0; i < N; i++) {
    if (visited[i] == false) {
      all_visited = false;
    }
  }

  if (all_visited) {
    return 1;
  }

  int ret = 0;

  for (int i = 0; i < N; i++) {
    if (graph[v][i] == false)
      continue;
    if (visited[i])
      continue;
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

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

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
  }

  bool visited[8];
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }

  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
}

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

int gcd(int a, int b) {
    while(b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int g = 0, x;
    while(n--) cin >> x, g = gcd(g, x);
    cout << g << endl;
}

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

// as + bt = GCD(a,b) a,b:const s,t:var(any)
// return GCD(a,b)
long long extGCD(long long a, long long b, long long& s,
                 long long& t) {
  s = 1, t = 0;
  while(b) {
    long long tmp = a / b;
    a -= b * tmp;
    s -= t * tmp;
    swap(a, b);
    swap(s, t);
  }
  return a;
}

// (mod)x+ay=1, calculate y -> a^-1 (mod m) (a,m : coprime)
long long calcinv(long long a, long long m) {
  long long s, t;
  extGCD(a, m, s, t);
  return (s + m) % m;
}

// P(x_i) = y_i(i:[0,n])
//  calc c_i : P(x) = c_n x^n + c_(n-1) x^(n-1)...c_0
vector<long long> lagrange_interpolation(
    long long mod, vector<long long>& y,
    vector<long long>& x) {
  assert(y.size() == x.size());
  long long n = y.size();
  vector<long long> ans(n, 0), Q(n), c[2];
  for(int i = 0; i < 2; ++i) c[i] = vector<long long>(n, 0);
  c[0][0] = 1;
  for(int i = 0; i < n; ++i) {
    long long inv = 1;
    for(int j = 0; j < n; ++j)
      if(j != i) {
        inv *= x[i] - x[j];
        if((inv %= mod) < 0) inv += mod;
      }
    Q[i] = y[i] * calcinv(inv, mod) % mod;
    for(int j = 0; j < n; ++j) {
      c[(i + 1) % 2][j] =
          (c[i % 2][j] * (-x[i]) % mod + mod) % mod;
      if(j != 0)
        (c[(i + 1) % 2][j] += c[i % 2][j - 1]) %= mod;
    }
  }
  for(int i = 0; i < n; ++i) {
    for(int j = n - 1; j >= 0; --j) {
      if(j == n - 1)
        c[(n + 1) % 2][j] = 1;
      else
        c[(n + 1) % 2][j] =
            (c[n % 2][j + 1] +
             c[(n + 1) % 2][j + 1] * x[i] % mod) %
            mod;
      (ans[j] += (c[(n + 1) % 2][j] * Q[i]) % mod) %= mod;
    }
  }
  return ans;
}

long long MOD;
vector<long long> ans;

int main() {
  cin >> MOD;
  vector<long long> a(MOD), b(MOD);
  for(int i = 0; i < MOD; ++i) cin >> a[i];
  for(int i = 0; i < MOD; ++i) b[i] = i;
  ans = lagrange_interpolation(MOD, a, b);
  for(int i = 0; i < MOD; ++i) {
    if(i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


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

int main() {
  int64_t n;
  cin >> n;
  int64_t ans=0;
  vector<int64_t> h(n);
  rep(i,n) cin >> h.at(i);
  vector<int64_t> cnt(1000005);
  rep(i,n){
    if(h.at(i)+i<=1000000) cnt.at(h.at(i)+i)++;
    if(i-h.at(i)>=0&&i-h.at(i)<=1000000){
      ans += cnt.at(i-h.at(i));
    }
  }
  cout << ans << endl;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
 */

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

template<int M>
class Combination
{
public:
  int n;
  vector<int> fac, finv;

  Combination(int n_) : n(n_), fac(n_), finv(n_)
  {
    fac[0] = 1;
    for(int i = 1; i < n; i++) fac[i] = fac[i-1]*i%M;
    finv[n-1] = pow(fac[n-1], M-2);
    for(int i = n-1; i > 0; i--) finv[i-1] = finv[i]*i%M;
  }

  int pow(int a, int b)
  {
    if(b == 0) return 1; 
    return pow(a*a%M, b/2)*(b%2?a:1)%M;
  }

  int C(int a, int b)
  {
    if(b < 0 or a < b) return 0;
    return fac[a]*finv[a-b]%M*finv[b]%M;
  }

  int P(int a, int b)
  {
    if(b < 0 or a < b) return 0;
    return fac[a]*finv[a-b]%M; 
  }

  int H(int a, int b){
    if(a == 0 and b == 0) return 1;
    return C(a+b-1, b);
  }
};

const int mod = 1e9+7;

signed main() {
  Combination<mod> comb(101010);

  int n, k;
  cin >> n >> k;

  vi a(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  vi b = a;
  reverse(all(b));

  int ma = 0, mi = 0;
  rep(i, k-1, n){
    int tmp = comb.C(i, k-1);
    (ma += a[i]*tmp%mod) %= mod;
    (mi += b[i]*tmp%mod) %= mod;
  }

  int ans = (ma - mi + mod) % mod;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

set<int> g[100005];
int n;

queue<pair<int,int> > q;
set<pair<int,int> > e;

bool asd(int x, int y){
	if(x>y)swap(x,y);
	if(e.count(mp(x,y)))return true;
	e.insert(mp(x,y));
	return false;
}

int main(){
	scanf("%d",&n);
	fore(i,1,n){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		g[x].insert(y);
		g[y].insert(x);
	}
	if(n==2){puts("Second");return 0;}
	fore(x,0,n)if(g[x].size()==1){
		int y=*g[x].begin();
		if(g[y].size()<=2)q.push(mp(x,y));
	}
	int r=n;
	while(!q.empty()){
		int x=q.front().fst,y=q.front().snd;q.pop();
		if(asd(x,y))continue;
		g[x].erase(y);g[y].erase(x);r-=2;
		for(auto z:g[x]){
			g[z].erase(x);
			if(g[z].size()==1){
				int zz=*g[z].begin();
				if(g[zz].size()<=2)q.push(mp(z,zz));
			}
			else if(g[z].size()==2){
				auto it=g[z].begin();
				int zz=*it;
				if(g[zz].size()==1)q.push(mp(z,zz));
				else {
					++it;
					zz=*it;
					if(g[zz].size()==1)q.push(mp(z,zz));
				}
			}
		}
		g[x].clear();
		for(auto z:g[y]){
			g[z].erase(y);
			if(g[z].size()==1){
				int zz=*g[z].begin();
				if(g[zz].size()<=2)q.push(mp(z,zz));
			}
			else if(g[z].size()==2){
				auto it=g[z].begin();
				int zz=*it;
				if(g[zz].size()==1)q.push(mp(z,zz));
				else {
					++it;
					zz=*it;
					if(g[zz].size()==1)q.push(mp(z,zz));
				}
			}
		}
		g[y].clear();
	}
	puts(r?"First":"Second");
	return 0;
}

Measured memory_bytes: 14464
#include "bits/stdc++.h"
using namespace std;

class Cube{
public:
	int f[6];
	Cube(){}
		void roll_z(){roll(1,2,4,3);}
		void roll_y(){roll(0,2,5,3);}//to W
		void roll_x(){roll(0,1,5,4);}//to N
		void roll(int i,int j,int k, int l){
			int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
		}
		void move(char ch){
			if(ch=='E')for (int i = 0; i < 3; ++i) {roll_y();}
			if(ch=='W')roll_y();
			if(ch=='N')roll_x();
			if(ch=='S')for (int i = 0; i < 3; ++i) {roll_x();}
		}
};
int getRight(Cube c1,int f1,int f2){
	for (int i = 0; i < 6; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (c1.f[0]==f1&&c1.f[1]==f2) {	return c1.f[2];}
			c1.roll_z();
		}
		if (i%2==0) {c1.roll_y();}
		else {c1.roll_x();}
		}
	return -1;
}

int main() {
	Cube c;
	int f1,f2;
	for (int i = 0; i < 6; ++i) cin>>c.f[i];
	int q;cin>>q;
	for (int i = 0; i < q; ++i) {
	cin>>f1>>f2;
	cout<<getRight(c,f1,f2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3056
/*
 * https://atcoder.jp/contests/abc144/tasks/abc144_b
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long


/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
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 MOD = 1e9 + 7;
int main() {
    INIT();

    ll n,result[2000001];

    cin >> n;
    REP(i,n - 1) {
        int a;
        cin >> a;
        a--;
        result[a]++;
    }
    REP(i,n) {
        cout << fixed << result[i] << endl;
    }
    return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var sequence = new [] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
        var k = int.Parse(Console.ReadLine());

        Console.WriteLine(sequence[k - 1]);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int64_t ans=0;
    if(A%2 && B%2 && C%2){
        vector<int64_t> v{A,B,C};
        sort(ToEnd(v));
        ans=v.at(0)*v.at(1);
    }else ans=0;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	auto n = readln.chomp.to!double;
	int cnt;
	while (n > 1) {
		n /= 3;
		cnt++;
	}
	cnt.writeln;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(rbegin(ret), rend(ret));
    return (ret);
}

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    auto d = divisor(accumulate(A.begin(), A.end(), 0));

    for(auto e: d) {
        vector<int> tmp(N);
        for(int i=0; i<N; i++) {
            tmp[i] = A[i] % e;
        }
        sort(tmp.begin(), tmp.end());
        for(int i=0; i<=N; i++) {
            int64_t sum1 = 0;
            int64_t sum2 = 0;
            for(int j=0; j<i; j++) {
                sum1 += tmp[j];
            }
            for(int j=i; j<N; j++) {
                sum2 += e-tmp[j];
            }
            if(sum1 == sum2 && sum1 <= K) {
                cout << e << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int calc(int*, int);


int main(){

	int data[100] = {};
	int count = 0;
	while (true){
		cin >> count;
		if (count == 0)break;
		for (int i = 0; i < count; i++){
			cin >> data[i];
		}

		for (int i = 1; i < count; i++){
			for (int j = i; j > 0; j--){
				if (data[j - 1] > data[j]){
					int tmp = data[j];
					data[j] = data[j - 1];
					data[j - 1] = tmp;
				}
			}
		}
		cout << calc(data, count) << endl;
	}

	return 0;
}

const int calc(int* a, int count){
	if (count <= 0)return 0;

	int ave = 0;

	for (int i = 1; i < count - 1; i++)ave += a[i];
	return ave / (count - 2);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n = 3;
    vector<vector<int>> c(3,vector<int>(3,0));
    rep(i,n)rep(j,n)cin >> c[i][j];

    int a[n];
    int b[n];

    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[0] = 0;
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    vector<vector<int>> c2(3,vector<int>(3,0));
    rep(i,n)rep(j,n) c2[i][j] = a[i] + b[j];
    
    if(c == c2)print("Yes");
    else print("No");
}

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


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

  int x[2],y[2];
  rep(i,2){
   cin >> x[i] >> y[i]; 
  }
  int v[2];
  v[0]=y[0]-y[1];
  v[1]=x[1]-x[0];
  cout << x[1]+v[0] << " " << y[1]+v[1] << " " << x[0]+v[0] << " " << y[0]+v[1] << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

vector<long long> divisor(long long n){
	vector<long long> res;
	for(int i = 1; (long long)i * i <= n; i++){
		if(n % i == 0){
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	sort(begin(res), end(res));
	return res;
}

signed main(){
	ll n;
	cin >> n;
	ll ans = 0;
	vector<ll> vec = divisor(n);
	for(int i = 1; i < vec.size(); i++){
		if(n / (vec[i] - 1) == n % (vec[i] - 1)){
			ans += vec[i] - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    string a[100005];
    int k;
    cin>>k;
    for(int i=1;i<10;i++)
        a[i]='0'+i;
    int i=1,j=10;
    if(k<10){
        cout<<a[k];
        return 0;
    }
    while(j<=k){
        char c=a[i][a[i].size()-1];
        if(c=='0'){
            a[j]=a[i]+'0';
            a[j+1]=a[i]+'1';
            j+=2;
        }
        else if(c=='9'){
            a[j]=a[i]+'8';
            a[j+1]=a[i]+'9';
            j+=2;
        }
        else{
            char p=c-1;
            a[j]=a[i]+p;
            a[j+1]=a[i]+c;
            p=c+1;
            a[j+2]=a[i]+p;
            j+=3;
        }
        i++;
    }
    cout<<a[k];
	return 0;
}


Measured memory_bytes: 6912
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static boolean vis[]=new boolean[(int)1e6+1];
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int nodes=fs.nextInt();
		int edges=fs.nextInt();
		ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<=nodes+1;i++)
		{
			adj.add(new ArrayList<Integer>());
		}
		for(int i=1;i<=edges;i++)
		{
			int u=fs.nextInt();
			int v=fs.nextInt();
			adj.get(u).add(v);
			adj.get(v).add(u);
		}
		int cc=0;
		int ans=0;
		for(int i=1;i<=nodes;i++)
		{
			if(!vis[i])
			{
				dfs(i,adj);
				cc++;
			}
		}
		ans+=(cc-1);
		for(int i=1;i<=nodes;i++)
		{
			if(!vis[i])
				ans++;
		}
		System.out.println(ans);
	}
	public static void dfs(int node,ArrayList<ArrayList<Integer>> adj)
	{
		vis[node]=true;
		for(int child:adj.get(node))
		{
			if(!vis[child])
				dfs(child,adj);
		}
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 72724
#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; }

int main(){
    ll a;
    cin >> a;
    int b1, b2;
    scanf("%d%*c%d", &b1, &b2);
    ll ans = a * (b1*100+b2) / 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  int ans = 0;
  rep(i, N){
    if(A[i] == B[i] && B[i] == C[i]){
    }else if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i]){
      ans++;
    }else{
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N;
int main(void) {
    cin >> N;
    veci b(N);
    rep(i, N) {
        cin >> b[i];
        b[i]--;
    }

    bool flag = true;

    stack<int> ans;
    while (b.size() != 0) {
        int k = -1;
        for (int i = 0; i < b.size(); ++i) {
            if (b[i] == i) {
                k = i;
            }
        }

        if (k == -1) {
            flag = false;
            break;
        }

        ans.push(k);
        b.erase(b.begin() + k);
    }

    if (!flag) {
        cout << -1 << endl;
        return 0;
    }

    while (!ans.empty()) {
        cout << ans.top() + 1 << endl;
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int a[1000];
	int i,sum=0;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(x>=a[i]){
			sum++;
			x=x-a[i];
		}else{
			break;
		}
	}
	if(x!=0&&i==n){
		sum--;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := getStdinInt()
	B := getStdinIntArr()

	ans := 0
	ans += B[0]
	prev := B[0]
	for i := 0; i < N-1; i++ {
		if prev > B[i] {
			ans -= prev
			ans += B[i]
		}
		ans += B[i]
		prev = B[i]
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2172
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef long long ll;
const double PI = acos(-1.0);
int dx[] = { 1,-1,0,0 };
int dy[] = { 0,0,1,-1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);// freopen("out.txt", "w", stdout);  
#endif
}
bool check_prime(ll a)
{
	bool flag = true;
	if (a <= 1)
		return false;
	else
	{
		for (ll i = 2; i <= sqrt(a); i++)
		{
			if (a % i == 0)
			{
				flag = false;
				break;
			}
		}
	}
	if (flag)
		return true;
	else
	{
		return false;
	}
}

int main()
{
	//file();
	Fast;
	ll n;
	cin >> n;
	int sum = 0;
	n = n * 2;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	if (n % 2 == 0)
	{
		for (int i = 0; i < n-1; i+=2)
		{
			sum += min(v[i], v[i + 1]);
		}
	}
	else
	{
		v.pop_back();
		for (int i = 0; i < n - 1; i += 2)
		{
			sum += min(v[i], v[i + 1]);
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	N := getStdinInt()
	A := getStdinIntArr64()
	Abig := make([]*big.Int, N)
	for i := 0; i < N; i++ {
		Abig[i] = big.NewInt(A[i])
	}

	for i := 0; i < len(A); i++ {
		if A[i] == 0 {
			fmt.Printf("0\n")
			return
		}
		if A[i] > 1000000000000000000 {
			fmt.Printf("-1\n")
			return
		}
	}

	ans := big.NewInt(1)
	cmp := big.NewInt(1000000000000000000)
	for i := 0; i < len(Abig); i++ {
		ans = ans.Mul(ans, Abig[i])
		if ans.Cmp(cmp) == 1 {
			fmt.Printf("-1\n")
			return
		}
	}
	fmt.Printf("%s\n", fmt.Sprint(ans))
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 15616
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
	eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

const M: i64 = 1000000007;

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let n: i64 = tr.read();
    let k: i64 = tr.read();

    let ans: i64 = (k..=(n + 1))
        .map(|i| (n + (n - i + 1)) * i / 2 - (i - 1) * i / 2 + 1)
        .fold(0, |a, x| (a + x) % M);
    println!("{}", ans);
}


Measured memory_bytes: 2172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

const int N = 55, M = N * N;

int h[N], e[M], ne[M], idx;
void add(int a, int b)
{
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx ++;
}

int n, m;
int dfn[N], low[N], tot;
int res;

void tarjan(int u, int fa)
{
    dfn[u] = low[u] = ++ tot;
    
    for(int i = h[u]; ~i; i = ne[i])
    {
        int j = e[i];
        if(!dfn[j])
        {
            tarjan(j, u);
            low[u] = min(low[u], low[j]);
            if(dfn[u] < low[j])  res ++;
        }else if(j != fa)
            low[u] = min(low[u], dfn[j]);
    }
}

int main()
{
    memset(h, -1, sizeof h);
    
    scanf("%d%d", &n, &m);
    while(m --)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        add(a, b),  add(b, a);
    }
    
    tarjan(1, -1);
    
    printf("%d", res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double EPS = 1e-9;

int a, b;

void read(){
  cin >> a >> b;
}

void solv(){
  cout << ((a <= 8 && b <= 8) ? "Yay!" : ":(") << '\n';
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d; 
    int s, t, u, v;
    cin >> a >> b >> c >> d;
    cin >> s >> t >> u >> v;
    int sum = a + b + c + d;
    int summ = s + t + u + v;
    if (sum < summ)
    cout << summ << endl;
    else
    cout << sum << endl;
    
    
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	cin>>S;
	int k;
	cin>>k;
	for(int i=0;i<S.size();i++){
		if(('z'-S[i]+1)%26>k)continue;
		k-=('z'-S[i]+1)%26;
		S[i]='a';
	}
	k%=26;
	S[S.size()-1]=(S[S.size()-1]-'a'+k)%26+'a';
	cout<<S<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0

int main(){

	lli n,t;
	cin>>n>>t;
	vector<lli> a(n);
	REP(i,n)cin>>a[i];

	/* dataMax[i] :iより右側のうち最大値 */
    
	lli dataMax[100010];
	lli dataDiff[100010];
	REP(i,100010){
		dataMax[i]=0;
		dataDiff[i]=0;
	}

	map<lli,vector<lli>> diff;
	lli diffMax=0;

	for(lli i=n-1;i>=0;i--){
		dataMax[i] = max(dataMax[i+1],a[i]);
		if(dataMax[i] >= a[i]){
			dataDiff[i] = dataMax[i]-a[i];
		}
		else dataDiff[i]=0;
		diffMax = max(diffMax,dataDiff[i]);
	}

	lli ans=0;
	REP(i,100010){
		if(diffMax == dataDiff[i])ans++;
	}

	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>

using namespace std;

void bigger(int *x, int *y);

int main(void){
	int data;
	int n1, n2, n3;
	cin >> data;
	for(int i = 0; i < data; i++){
		scanf("%d %d %d", &n1, &n2, &n3);
		bigger(&n1, &n2);
		bigger(&n1, &n3);
		
		if(n1* n1 == n2*n2 + n3*n3)
		cout << "YES" << endl;
		else
		cout << "NO" << endl;
		
	}
	return 0;
}

void bigger(int *x, int *y){
	if(*y > *x){
		int type = *x;
		*x = *y;
		*y = type;
	}
}
	

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

int main() {
    string s;
    int n, ac=0, wa=0, tle=0, re=0;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> s;
        if (s=="AC"){
            ac++;
        } else if (s=="WA"){
            wa++;
        } else if (s=="TLE"){
            tle++;
        } else {
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
}


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

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

    string s; cin >> s;
    int K; cin >> K;


    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'a') continue;
        if ('z'-s[i]+1 <= K) {
            K -= 'z'-s[i]+1;
            s[i] = 'a';
        }
    }

    K %= 26;
    while (K > 0) {
        if (s[s.size()-1] == 'z') s[s.size()-1] = 'a';
        else s[s.size()-1]++;
        K--;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 592
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

t=sum(b)

j=m
ans=0
for i in range(n+1):
  while j>0 and t > k:
    j-=1
    t -= b[j]
  if t > k:
    break
  ans = max(ans,i+j)
  if i==n:
    break
  t += a[i]
print(ans)

Measured memory_bytes: 40440
#include <iostream>

using namespace std;

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int counter = 0;
    for (int i = 0; i < s.length(); i++)
        if (s[i] != t[i])
            counter++;
    cout << counter;
    return 0;
}

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

int main() {
  int n; 
  cin >> n;
  int count = 0, a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == a[i+1]) {
      count++;
      a[i+1] = 10;
    }
  }
  cout << count << endl;
  return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	int max = a + b;
	if (max < a - b)
		max = a - b;
	if (max < a * b)
		max = a * b;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
INF = float("inf")
num = INF
rec = [INF] * N
for k in range(N):
    tmp = 0
    for j in range(N):
        rec[j] = min(rec[j], a[j - k])
        tmp += rec[j]

    num = min(tmp + k * x, num)

print(num)


Measured memory_bytes: 42972
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

LL n,m,k;
LL a[500005];
LL tmp = 1;

LL gcd(LL x,LL y){
	if(!y) return x;
	return gcd(y,x % y);
}

LL calc(LL x){
	LL ret = 0;
	while(x % 2 == 0){
		x >>= 1;
		ret ++;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	LL N = 10000;
	N = N * N * 30;
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i];
		tmp = tmp * a[i] / gcd(tmp,a[i]);
		if(tmp > N){
			cout << 0 << endl;
			return 0;
		}
	}
	
	for(LL i = 2;i <= n;i ++){
		if(calc(a[i]) != calc(a[1])){
			cout << 0 << endl;
			return 0;
		}
	}
	
	cout << (m + tmp / 2) / tmp << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n, y int

	fmt.Scan(&n, &y)
	for i := 0; i <= n; i++ {
		for j := 0; j <= (n - i); j++ {
			k := n - i - j
			if i*10000+j*5000+k*1000 == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 1768
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map>
#include<stdio.h>
#include<queue>
#include<tuple>

#define ALL(a)  (a).begin(),(a).end()
const long long MOD = 1000000007;

//いろんなstlの使い方　https://qiita.com/tukejonny/items/f4013547df761a0b3523
//http://y-mazun.hatenablog.com/entry/20111202/1322840281



using namespace std;


long long gcd(long long a, long long b) {
    if (a > b) {
        return gcd(b, a);
    }
    return a == 0 ? b : gcd(b % a, a);
}

int lcm(int m, int n) {
    // 引数に０がある場合は０を返す
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm


int moji(char in) {
    int ans = (int) in - (int) 'a';
    if ((ans < 0) || (ans > 25)) {
        ans = 26;
    }
    return ans;
}


int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int *) a - *(int *) b;
}



template<class T>
void chmin(T &a, T b) {
    if (a > b) {
        a = b;
    }
}

//formerは前方のindex(自分自身を含んで良い)
template<class T>
int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

//latterは後方のindex(自分自身を含んで良い)
template<class T>
int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}



//indexを用いてvectorから要素削除
template<typename T>
void remove(std::vector<T> &vector, unsigned int index) {
    vector.erase(vector.begin() + index);
}




int main() {
    int H,W;
    cin>>H>>W;
    char A[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>A[i][j];
        }
    }
    queue<pair<int,int>>x;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j]=='#'){
                x.push(make_pair(i,j));
            }
        }
    }
    int cnt=0;
    while(x.size()>0){
        int l=x.size();
        for(int i=0;i<l;i++){
            int p=x.front().first;
            int k=x.front().second;
            x.pop();
            if(p-1>=0){
                if(A[p-1][k]=='.'){
                    x.push(make_pair(p-1,k));
                    A[p-1][k]='#';

                }
            }
            if(k-1>=0){
                if(A[p][k-1]=='.'){
                    x.push(make_pair(p,k-1));
                    A[p][k-1]='#';

                }
            }
            if(p+1<H){
                if(A[p+1][k]=='.'){
                    x.push(make_pair(p+1,k));
                    A[p+1][k]='#';

                }
            }
            if(k+1<W){
                if(A[p][k+1]=='.'){
                    x.push(make_pair(p,k+1));
                    A[p][k+1]='#';

                }
            }
        }
        cnt++;

        


    }
    cout<<cnt-1<<endl;







}














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

using namespace std;

bool check[26];

int main(void)
{
    string ss;

    cin>>ss;

    for(int i = 0;i < ss.size();i++)
    {
	if(check[ss[i]-'a'])
	{
	    cout<<"no"<<endl;

	    return 0;
	}
	check[ss[i]-'a'] = true;
    }

    cout<<"yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
const ll mod = 1e9+7;

void solve(ll cas){
    ll n;cin>>n;
    vector<pll> d(n);
    for(ll i=0;i<n;i++){
        cin>>d[i].fr>>d[i].se;
    }
    for(ll i=0;i+2<n;i++){
        if(d[i].fr==d[i].se and d[i+1].fr==d[i+1].se and d[i+2].fr==d[i+2].se){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        solve(cas);
    }
}


Measured memory_bytes: 3648
program abc143b
   implicit none

   integer :: N, i, count, j
   integer, allocatable :: d(:)

   read(*,*) N
   allocate(d(N))
   read(*,*) d(:)

   count = 0

   do i = 1, N-1
      do j = i+1, N
         count = count + d(i)*d(j)
      end do
   enddo
   write(*,*) count

end program abc143b


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1000000000;
int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

int main() {
    int H, W; cin >> H >> W;
    int Ch, Cw; cin >> Ch >> Cw;
    int Dh, Dw; cin >> Dh >> Dw;
    Ch--, Cw--, Dh--, Dw--;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];

    vector<vector<int>> D(H, vector<int>(W, INF));
    deque<P> q;
    D[Ch][Cw] = 0;
    q.push_back({Ch, Cw});
    while(!q.empty()) {
        int h = q.front().first; 
        int w = q.front().second; 
        int d = D[h][w];
        q.pop_front();
        for (int i = 0; i < 4; i++) {
            int nh = h + dh[i], nw = w + dw[i];
            if (nh < 0 || nw < 0 || H <= nh || W <= nw) continue;
            if (S[nh][nw] == '#') continue;
            if (D[nh][nw] <= d) continue;
            D[nh][nw] = d;
            q.push_front({nh, nw}); 
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nh = h + i, nw = w + j;
                if (nh < 0 || nw < 0 || H <= nh || W <= nw) continue;
                if (S[nh][nw] == '#') continue;
                if (D[nh][nw] <= d + 1) continue;
                D[nh][nw] = d + 1;
                q.push_back({nh, nw});
            }
        }
    }
    int ans = D[Dh][Dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main()
{
    int no_of_piles;
    cin >> no_of_piles;
    
    int all_even = true;
    
    while(no_of_piles--)
    {
        int pile;
        cin >> pile;
        
        if(pile%2 == 1)
            all_even = false;
    }
    
    cout << (all_even ? "second\n" : "first\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll a;
  ld b;
  cin>>a>>b;
  
  cout<<(ll)(a*b)<<endl;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> h(n), dp(n, INT_MAX);
	for (int i = 0; i < n; i++) cin >> h[i];
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + k && j < n; j++) {
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1];
}



Measured memory_bytes: 3948
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int Max = 1000000;

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

  	ll L[N], X[N];
  	P H[N];
  	for(int i=0;i<N;i++){
  		cin >> X[i] >> L[i];
  		H[i] = make_pair(X[i]+L[i], X[i]-L[i]);
  	}

  	sort(H, H+N);


  	ll cnt = 0;
  	ll right = -3000000000;
  	int i=0;
  	while(i<N){
  		if(H[i].second>=right){
  			cnt++;
  			right = H[i].first;
  		}
  		i++;
  	}
  	cout << cnt <<endl;
    
  	return 0;
}


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

int main() {
    int a,b;
    long long ans=1;
    int add=0;
    cin>>a>>b;
    if (b==100) add=1;
    if (a==0) cout<<b+add;
    else{
    for (int i=1;i<=a;i++){
    	ans*=100;
    }
    if (b==100){
    	add=ans;
    }
    cout<<ans*b+add;
    }
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // 入力
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var N = input[0];
            var M = input[1];

            // P, Y, index, cityNum
            var list = new List<TupleDayo>();

            for (var i = 0; i < M; i++)
            {
                var input2 = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                list.Add(new TupleDayo(input2[0], input2[1], i, 0));
            }

            // 計算
            var tmpList = list.OrderBy(x => x.P)
                .ThenBy(x => x.Y);

            var prefectureNum = 0;
            var cityNumber = 0;
            foreach (var item in tmpList)
            {
                if (prefectureNum == 0)
                {
                    prefectureNum = item.P;
                    cityNumber = 1;
                    item.CityNumber = cityNumber;
                    cityNumber++;
                    continue;
                }

                if (prefectureNum != item.P)
                {
                    prefectureNum = item.P;
                    cityNumber = 1;
                    item.CityNumber = cityNumber;
                    cityNumber++;
                    continue;
                }

                prefectureNum = item.P;
                item.CityNumber = cityNumber;
                cityNumber++;
            }

            // 出力
            foreach (var item in tmpList.OrderBy(x => x.Index))
            {
                Console.Write("{0:000000}", item.P);
                Console.WriteLine("{0:000000}", item.CityNumber);
            }
        }
    }

    internal class TupleDayo
    {
        public int P { get; set; }

        public int Y { get; set; }

        public int Index { get; set; }

        public int CityNumber { get; set; }

        public TupleDayo(int p, int y, int index, int cityNumber)
        {
            P = p;
            Y = y;
            Index = index;
            CityNumber = cityNumber;
        }
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll tmp = a.at(0);
    for(i = 1;i < n;++i){
        tmp = gcd(tmp, a.at(i));
    }
    if(tmp != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    map<ll, ll> mp;
    for(i = 0;i < n;++i){
        for(j = 2;j < sqrt(a.at(i));++j){
            if(a.at(i)%j == 0){
                if(mp.count(j)){
                    cout << "setwise coprime" << endl;
                    return 0;
                }
                ++mp[j];
                while(a.at(i)%j == 0) a.at(i) /= j;
            }
            
        }
        if(a.at(i) != 1){
            if(mp.count(a.at(i))){
                cout << "setwise coprime" << endl;
                return 0;
            }else ++mp[a.at(i)];
        }
    }
    cout << "pairwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 11156
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  bool res = false;
  for (ll i = 0; i < N; i++) {
    ll j = N - i - 1;
    ll low = -D * i + C * j, high = -C * i + D * j;
    if (low <= B - A && B - A <= high) {
      res = true;
      break;
    }
  }
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}


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

int main() {
    int n; cin >> n;
    if (n%2 == 0) cout << n << endl;
    else cout << n*2 << endl;
    /*
    vector<int> v;
    for (int i=n*2; i>0; i--) {
        if (i%2 == 0 && i%n == 0) v.push_back(i);
    }

    int mini = *min_element(v.begin(), v.end());
    */
    //cout << mini << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod (long long)(1e9+7)
#define endl "\n"
using namespace std;

void using_01bfs(string G[],ll h,ll w,ll srcx,ll srcy,ll destx,ll desty){
	
	ll dist[h][w];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			dist[i][j]=INT_MAX;
		}
	}
	
	
	auto legal=[&](ll r,ll c)->bool{
		if(r<0||c<0||r>=h||c>=w||G[r][c]=='#'){
			return 0;
		}
		return 1;
	};
	
	
	deque<pair<ll,ll> > q;
	q.push_front({srcx,srcy});
	dist[srcx][srcy]=0;
	while(!q.empty()){
		pair<ll,ll> p=q.front();
		ll x=p.first;
		ll y=p.second;
		q.pop_front();
		for(pair<ll,ll> P:vector<pair<ll,ll> >({{x,y+1},{x+1,y},{x-1,y},{x,y-1}})){
			if(legal(P.first,P.second)){
				if(dist[x][y]<dist[P.first][P.second]){
					dist[P.first][P.second]=dist[x][y];
					q.push_front({P.first,P.second});
				}
			}
		}
		for(ll i=x-2;i<=x+2;i++){
			for(ll j=y-2;j<=y+2;j++){
				if(legal(i,j)){
					if(dist[i][j]>dist[x][y]+1){
						dist[i][j]=dist[x][y]+1;
						q.push_back({i,j});
					}
				}
			}
		}
	}
	cout<<(dist[destx][desty]==INT_MAX?-1:dist[destx][desty])<<endl;

}

void solve(){
	ll h,w;
	cin>>h>>w;
	ll srcx,srcy;
	ll destx,desty;
	cin>>srcx>>srcy;
	cin>>destx>>desty;
	srcx--,srcy--,destx--,desty--;
	string G[h];
	for(ll i=0;i<h;i++){
		cin>>G[i];
	}
	using_01bfs(G,h,w,srcx,srcy,destx,desty);
}


int main(){
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


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

int main() {
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	rep(i,H)cin>>S[i];

	rep(i,H)rep(j,W){
		if(S[i][j] == '.'){
			S[i][j]='0';
			for (int dx = -1; dx <= 1; ++dx){
				for (int dy = -1; dy <= 1; ++dy){
					int nx = i+dx,ny = j+dy;
					if(0<=nx&&nx<H&&0<=ny&&ny<W){
						if(S[nx][ny]=='#')S[i][j]++;
					}
				}
			}
		}
	}
rep(i,H)cout<<S[i]<<endl;
}

Measured memory_bytes: 3632