akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
    using namespace std ;
    int main(){
        int a;
        cin>>a;
        if(a==25)cout<<"Christmas"<<endl;
        if(a==24)cout<<"Christmas Eve"<<endl;
        if(a==23)cout<<"Christmas Eve Eve"<<endl;
        if(a==22)cout<<"Christmas Eve Eve Eve"<<endl;
        return 0 ;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    for(int i=1;i*i<=c;++i){
        if(c%i==0){
            if(a<=i&&i<=b)++ans;
            if(i*i!=c&&a<=(c/i)&&(c/i)<=b)++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3096
/**
*   @Author : MeGaCrazy
*   @InitTime : Sat Dec 29 14:50:24 2018
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int n,a;
long long dp[2500][55][55];
vector<int>v;
long long solve(int value,int idx,int number){
//    cerr<<value<<" "<<idx<<" "<<number<<endl;
    if(idx>=n){
        if(number==0)return 0;
    	if((value%number)==0&&(value/number)==a)
    		return 1;
    	else
    	return 0;
    } 
    long long &ret=dp[value][idx][number];
    if(ret!=-1)return ret;
    ret=solve(value,idx+1,number);
    ret+=solve(value+v[idx],idx+1,number+1);
    return ret;
    
}
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
    scanf("%d %d",&n,&a);
    v.assign(n,0);
    for(int i=0;i<n;i++){
    	scanf("%d",&v[i]);
    //	cerr<<v[i]<<endl;
    }
 //   cerr<<"hello"<<endl;
    memset(dp,-1,sizeof(dp));
    printf("%lld",solve(0,0,0));
 //   cerr<<"hello"<<endl;


}

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

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  string s[h];
  vector<int> n(h,0);
  rep(i,h) cin >> s[i];
  rep(i,h) {
    rep(j,w) {
      if(s[i][j] == '#') n[i]++;
    }
  }
  vector<vector<int>> ans(h,vector<int>(w,-1));
  int p = 1;
  int f = -1;
  bool ini = false;
  rep(i,h) {
    if(ini && n[i] == 0) {
      rep(j,w) ans[i][j] = ans[i-1][j];
    } else if(n[i] != 0) {
      if(!ini) {
        ini = true;
        f = i;
      }
      if(n[i] == 1) {
        rep(j,w) ans[i][j] = p;
        p++;
      } else {
        int c = 0;
        rep(j,w) {
          if(s[i][j] == '#') {
            c++;
            if(c >= 2) p++;
          }
          ans[i][j] = p;
        }
        p++;
      }
    }
  }
  rep(i,f) {
    rep(j,w) ans[i][j] = ans[f][j];
  }
  rep(i,h) {
    rep(j,w) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner

object Main {
    case class pseudoMap(key:Int , count:Int)
    implicit def tupleToName(tup: (Int, Int)): pseudoMap = tup match {
        case (key, count) => pseudoMap(key, count)
    }

    def main(args: Array[String]): Unit = {
        val scanner = new Scanner(System.in)
        val n: Int = scanner.nextInt
        val vs: List[Int] = List.fill(n)(scanner.nextInt)
        println(calc(vs))
    }

    def calc(nums: List[Int] ): Int ={
        val (evens, odds) = nums.zipWithIndex.partition(_._2 % 2 == 0)
        val (evensFirst, evensSecond) = take2MostOrder(evens.map(_._1))
        val (oddsFirst, oddsSecond) = take2MostOrder(odds.map(_._1))

        if (evensSecond.key == -1 && oddsSecond.key == -1){
          if (evensFirst.key != oddsFirst.key)
              0
          else
              nums.length / 2
        }
        else {
          if (evensFirst.key != oddsFirst.key)
              nums.length - evensFirst.count - oddsFirst.count
          else
            (nums.length - evensFirst.count - oddsSecond.count) min (nums.length - evensSecond.count - oddsFirst.count)
        }
    }

    def take2MostOrder(nums: List[Int]): ((Int,Int),(Int,Int)) = {
      val sortedNums: Seq[(Int, Int)] = nums.groupBy(n => n).mapValues(_.length).toSeq.sortBy(_.count).reverse
      (sortedNums(0), try{sortedNums(1)}catch{case e :Exception => (-1, Int.MinValue)})
    }
}


Measured memory_bytes: 116880
package main

import(
        "fmt"
        "math"
)

func main() {
        var n uint64
        var c [5]uint64
        fmt.Scanf("%d", &n)
        var m uint64
        m = math.MaxUint64
        for i := 0; i < 5; i++ {
                fmt.Scanf("%d", &c[i])
                if c[i] < m {
                        m = c[i]
                }
        }
        if n%m == 0 {
                fmt.Println(5 + n / m - 1)
        } else {
                fmt.Println(5 + n / m)
        }
}


Measured memory_bytes: 512
// D - Integer Cards
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vector<ll> A(N);
	rp(i,N) cin>>A[i];
	sort(A.begin(), A.end());

	vector<pair<ll,int>> B;
	rp(i,M){
		int b; ll c; cin>>b>>c;
		B.push_back(make_pair(c,b));
	}
	sort(B.begin(), B.end());

	ll ans = 0;
	int ans_count = 0;
	int n=N-1;
	ll value; int count;
	for(int m=M-1; m>=0 && ans_count<N; --m){
		tie(value, count) = B[m];

		while(ans_count<N && n>=0 && value <= A[n]){
			ans += A[n--];
			++ans_count;
		}
		if(n<0 || ans_count>=N) break;

		while(ans_count<N && n>=0 && count-->0){
			ans += value;
			++ans_count;
		}
		if(n<0 || ans_count>=N) break;
	}

	if(ans_count<N)
		while(n && ans_count<N){ ans += A[n--]; ++ans_count; }

	cout<< ans <<endl;
}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
inline int fpow(int n, int p){
    int ans = 1, base = n;
    while(p){
        if(p & 1) ans = ans * base % mod;
        base = base * base % mod;
        p >>= 1;
    }
    return ans;
}
int n, m, k, ans = 1, chu = 1, cnt;
signed main(){
    scanf("%lld%lld%lld", &n, &m, &k);
    for(register int i = n * m - 2; i >= n * m - k + 1; --i) ans = ans * i % mod;
    for(register int i = k - 2; i >= 1; --i) chu = chu * i % mod;
    ans = (ans * fpow(chu, mod - 2)) % mod;
    for(register int d = 1; d < n; ++d){
    	int x = (n - d) * m, y = m;
    	cnt = (cnt + (x * y % mod) * d % mod) % mod;
	}
	for(register int d = 1; d < m; ++d){
		int x = (m - d) * n, y = n;
		cnt = (cnt + (x * y % mod) * d % mod) % mod;
	}
    printf("%lld\n", ans * cnt % mod);
    return 0;
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
struct Point{
  int x;
  int y;
};
struct Result{
  int ox;
  int oy;
  int nx;
  int ny;
};

using namespace std;
int main(){
  long h,w,ii,jj;
  long** ahw;
  vector<Point> path;
  vector<Result> result;
  cin >> h >> w;

  ahw = (long**)malloc(sizeof(long*) * (h+1));
  //path.resize(h*w);
  
  for(ii=1;ii<=h;ii++){
	ahw[ii] = (long*)malloc(sizeof(long) * (w+1));
	for(jj=1;jj<=w;jj++){
	  cin >> ahw[ii][jj];
	}
  }

  path.reserve(w*h);
  result.reserve(w*h);
  //1筆書きの道を作成
  for(ii=1;ii<=h;ii=ii+2){
	
	for(jj=1;jj<=w;jj++){
	  Point p ;
	  p.x = jj;
	  p.y = ii;
	  path.push_back(p);
	}
	if(h>=ii+1){
	  for(jj=w;jj>=1;jj--){
		Point p;
		p.x = jj;
		p.y = ii+1;
		path.push_back(p);
	  }
	}
	
  }

  long x,y;

//  for(Point p : path){
//	//cout << "x:" << p.x << "y:" << p.y << endl;
//	x = p.x;
//	y = p.y;
//	if(ahw[y][x] % 2 != 0){
//
//	}
//  }
  Point cur;
  Point next;
  
  for(ii=0;ii<path.size()-1;ii++){
	cur = path[ii];
	next = path[ii+1];
	if(ahw[cur.y][cur.x] % 2 != 0){
	  ahw[cur.y][cur.x] -= 1;
	  ahw[next.y][next.x] += 1;
	  Result res;
	  res.ox = cur.x;
	  res.oy = cur.y;
	  res.nx = next.x;
	  res.ny = next.y;
	  result.push_back(res);
	}
  }

  cout << result.size() << endl;

  for(Result res:result){
	cout << res.oy << " " << res.ox << " " << res.ny << " " << res.nx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 9856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long m = sc.NextLong();

        long answer = 0;

        if (n == 1 && m == 1)
        {
            answer = 1;
        }
        else if (n == 1)
        {
            answer = m - 2;
        }
        else if (m == 1)
        {
            answer = n - 2;
        }
        else
        {
            answer = n * m - 2 * n - 2 * m + 4;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int main () {
   vector<int>A(5);
   int x=0;
   for(int i=0;i<5;i++){
       cin>>A[i];
       x+=(A[i]+9)/10*10;
   }
   int y = x;
   for(int i=0;i<5;i++){
       if(A[i]%10>0)
           y=min(y,(x-10)+A[i]%10);
   }
   cout<<y<<endl;
    return 0;}


Measured memory_bytes: 256
#include <iostream>                                                             
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  while (true) {                                                                
    int x,y;                                                                    
    cin >> x >> y;                                                              
    if (x==0 && y==0) {                                                         
      break;                                                                    
    }                                                                           
    cout << min(x,y) << " " << max(x,y) << endl;                                
  }                                                                             
}                                         

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

typedef long long ll;
const int INF = 1e8;
// const ll INF = 1LL << 60;
typedef pair<int, int> P;

string s;
int main() {
    cin >> s;
    ll N = s.size();
    // 0-idx
    ll size = (N - 1) / 2; 

    string part1 = s.substr(0, size);
    string part2 = s.substr(size + 1);
    // cout << part1 << " " << part2 << endl;

    for (int i = 0; i < size; i++) {
        if (s[i] != s[N - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 0; i < (part1.size() / 2); i++) {
        if (part1[i] != part1[part1.size() - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }

        if (part2[i] != part2[part2.size() - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    // ll loop = middle / 2;

    // for (int i = 0; i < loop; i++) {
    //     cout << i << " " << middle - 1 - i << endl;
    //     if (s[i] != s[middle - 1 - i]) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }

    // ll cnt = 0;
    // for (int i = middle + 1; i < middle + 1 + loop; i++) {
    //     cout << i << " " << N - 1 - cnt << endl;
    //     if (s[i] != s[N - 1 - cnt]) {
    //         cout << "No" << endl;
    //         // return 0;
    //     }
    //     cnt++;
    // }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string A,B,C;
  cin >> A >> B >> C;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == B[i] && B[i] == C[i]) {
    } else if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) {
      ans += 2;
    } else {
      ans += 1;
    }
  }
  cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int x1, y1, x2, y2, x3, y3, x4, y4, w1, w2;
	
	cin >> x1 >> y1 >> x2 >> y2;
	
	w1 = x2 - x1;
	w2 = y2 - y1;
	
	x3 = x2 - w2;
	y3 = y2 + w1;
	
	x4 = x1 - w2;
	y4 = y1 + w1;
	
	cout << x3 << " "<< y3 << " " << x4  << " " << y4;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vec(T) vector<T>
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    string S;
    cin >> S;
    S.at(K - 1) = tolower(S.at(K-1));
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
  int n;
  cin >> n;
  int f[n+1][5][2], p[n+1][11];
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 2; k++)  cin >> f[i][j][k];
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= 10; j++)  cin >> p[i][j];
  }
  int ans = -INF;
  for(int i = 1; i < (1 << 10); i++){
    int a[n+1] = {0};
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 2; k++){
        for(int l = 1; l <= n; l++){
          if(((1 << k*5+j) & i) && f[l][j][k]) a[l]++;
        }
      }
    }
    int c = 0;
    for(int j = 1; j <= n; j++)  c += p[j][a[j]];
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}


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

struct data{
  int id;
  int color;
  int dist;
};

int N,M,Q;
vector<int> G[MAX_N];
int visited[MAX_N];
data ans[MAX_N];
int v[MAX_N],d[MAX_N],c[MAX_N];

int main(){
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  scanf("%d",&Q);
  
  for(int i=0;i<Q;i++){
    scanf("%d %d %d",&v[i],&d[i],&c[i]);
    v[i]--;
  }

  for(int i=0;i<N;i++){
    ans[i]=(data){-1,0,-100};
  }
  
  for(int q=Q-1;q>=0;q--){
    int si=v[q];
    int di=d[q];
    int ci=c[q];
    
    queue<int> que;
    unordered_map<int,int> d;
    
    if( ans[si].id !=-1 && ans[si].dist>=di)continue;
    
    que.push(si);
    
    d[si]=0;
    
    if(ans[si].id==-1){
      ans[si].id=q;
      ans[si].color=ci;
      ans[si].dist=di;
    }else{
      ans[si].dist=max(ans[si].dist,di);
    }

    
    while(!que.empty()){
      int pos=que.front();que.pop();

      if(d[pos]==di)continue;
      
      for(int i=0;i<(int)G[pos].size();i++){
        int to=G[pos][i];
        if(d.count(to)==0)d[to]=1e9;
        
        if(d[to]>d[pos]+1){
          d[to]=d[pos]+1;
          if( ans[to].id != -1 && ans[to].dist>=di-d[to] )continue;
          
          if(ans[to].id==-1){
            ans[to].id=q;
            ans[to].color=ci;
            ans[to].dist=di-d[to];
          }else{
            ans[to].dist=max(ans[to].dist,di-d[to]);
          }
          que.push(to);
        }
      }
    }
  }

  for(int i=0;i<N;i++){
    printf("%d\n",ans[i].color);
  }
  return 0;
}


Measured memory_bytes: 13404
#include <bits/stdc++.h>
using namespace std;
int n;
long long f[100];
int main()
{
    cin >> n;
    f[0] = 2;
    for (int i = 1;i <= n;i++)
    {
        f[i] = f[i-1]*2+2;
    }
    cout << f[n] << endl;
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    CIN(N,K,C);
    SCIN(s);
    vector<int> front(K), back(K);
    int cnt=0;
    int i=0;
    while(1){
        if(s[i]=='o'){
            front[cnt]=i;
            i=i+C+1;
            cnt++;
        }else{
            i++;
        }
        if(i>N-1||cnt>=K)
            break;
    }
    cnt=K-1;
    i=N-1;
    while(1){
        if (s[i] == 'o'){
            back[cnt]=i;
            i=i-C-1;
            cnt--;
        }else{
            i--;
        }
        if(i<0||cnt<0)
            break;
    }
    rep(i,K){
        if(front[i] == back[i]){
            printf("%d\n",front[i]+1);
        }
    }
 
    return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int dist(int h1, int w1, int h0, int w0) { return abs(h1 - h0) + abs(w1 - w0); }

int main() {
  int H, W;
  cin >> H >> W;
  char A[H][W];
  queue<VEC<int>> q;
  REP(i, 0, H) {
    REP(j, 0, W) {
      cin >> A[i][j];
      if (A[i][j] == '#') q.push({(int)i, (int)j, 0});
    }
  }
  int ma = 0;
  while (!q.empty()) {
    auto e = q.front();
    q.pop();
    int h = e[0];
    int w = e[1];
    int dist = e[2];
    // DUMP(h,w,dist);
    ma = max(ma, dist);
    if (0 <= h + 1 && h + 1 < H && A[h + 1][w] != '#') {
      A[h + 1][w] = '#';
      q.push({h + 1, w, dist + 1});
    }
    if (0 <= h - 1 && h - 1 < H && A[h - 1][w] != '#') {
      A[h - 1][w] = '#';
      q.push({h - 1, w, dist + 1});
    }
    if (0 <= w + 1 && w + 1 < W && A[h][w + 1] != '#') {
      A[h][w + 1] = '#';
      q.push({h, w + 1, dist + 1});
    }
    if (0 <= w - 1 && w - 1 < W && A[h][w - 1] != '#') {
      A[h][w - 1] = '#';
      q.push({h, w - 1, dist + 1});
    }
  }
  cout << ma << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d[100001] ={0};
  for(int i =0; i < N; i++){
    int a;
    cin >> a;
    d[a]++;
  }
  int max = 0;
  for(int x = 1; x< 100000;x++){
    int sum = d[x-1]+ d[x] + d[x+1];
    if(sum > max) max = sum;
  }
  cout << max << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
	int main(void) {
		int r, g, b, n;
		scanf("%d %d %d", &r, &g, &b);
		if(r>9 || r<1 || g>9 || g<1 || b>9 || b<1){
			return 1;
		}
		n = g*10 + b;
		if(n % 4 == 0){printf("YES");}
		else{printf("NO");}
		return 0; 
	}

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

int main(){
    int A, B, C, X;
    int count = 0;
    cin >> A >> B >> C >> X;
    X /= 50;
    for(int i = 0; i < A + 1; i++){
        for(int f = 0; f < B + 1; f++){
            for(int g = 0; g < C + 1; g++){
                if(X == (10 * i + 2 * f + g )) count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
while 1:
    n, x = map(int,input().split())
    if n == x ==0:
        break
    ans  = 0
    for i in range(1, n+1):
        for j in range(i+1,n+1):
           for k in range(j+1,n+1):
               if i + j +k ==x:
                   ans += 1
    print(ans)



Measured memory_bytes: 5596
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define sprint(X) printf("%f\n", (X))
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll K ,X;
  cin >> K >> X;

  for(ll i=X-K+1; i<X+K; i++){
    cout << i << " ";
  }

  cout << "\n";

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll dp[100010] = {};
    rep(i,0,N+1) dp[i] = INF;
    dp[0] = 0;
    vector<ll> v;
    ll cnt = 1;
    while(cnt <= N){
        v.push_back(cnt);
        cnt *= 6;
    }
    cnt = 9;
    while(cnt <= N){
        v.push_back(cnt);
        cnt *= 9;
    }
    rep(i,0,N+1){
        rep(j,0,v.size()){
            if(i - v[j] >= 0){
                dp[i] = min(dp[i], dp[i-v[j]] + 1);
            }
        }

    }
    print(dp[N]);
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n>>k;
    ans=0;
    map<ll,ll>freq;
    for(i=0;i<k;i++)
    {
        cin>>v;
        while(v--)
        {
            cin>>var;
            if(freq[var]==0)ans++;
            freq[var]=1;
        }
    }
    cout<<n-ans;
}

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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        for(int i=0; i<9; i++){
            int a;
            cin >> a;
            n -= a;
        }
        cout << n << endl;
    }
    return 0;
}



Measured memory_bytes: 3008
import java.util.Scanner;

public class Main 
{	
	static int toMillenial(int startY, int startM, int startD)
	{
		int y = startY;
		int m = startM;
		int d = startD;
		int remy = 1000-startY;
		int remm = 0;
		int remd = 0;
		int ans = 0;
		
		//go to the first day of next month.
		if(d > 1)
		{
			if(y%3 == 0 || m%2 == 1)
			{ //big month
				ans += (21-d);
				d = 1;
			}
			else
			{ //small month
				ans += (20-d);
				d = 1;
			}
			m += 1;
			while(m>10)
			{
				m -= 10;
				y += 1;
			}
		}
//		System.out.println("Going to first day: " + ans);
//		System.out.println("It is now " + y + " " + m + " " + d);
		
		//go to the first month of next year.
		if(m > 1)
		{
			if(y%3 == 0)
			{ //big year
				ans += (11-m)*20;
				m = 1;
				y += 1;
			}
			else
			{ //common year
				while(m <= 10)
				{
					if(m%2 == 1)
					{ //big month
						ans += 20;
					}
					else
					{ //small month
						ans += 19;
					}
					m += 1;
				}
				m = 1;
				y += 1;
			}
		}
//		System.out.println("Going to first month: " + ans);
//		System.out.println("It is now " + y + " " + m + " " + d);
		
		while(y < 1000)
		{
			if(y%3 == 0)
			{ //big year
				ans += 200;
			}
			else
			{ //small year
				ans += 195;
			}
			y += 1;
		}
//		System.out.println("Going to year 1000: " + ans);
//		System.out.println("It is now " + y + " " + m + " " + d);
		
		return ans;
	}
	
	public static void main(String[] args) 
	{		
		//normal year: 195 days
		//big year: 200 days
//		System.out.println(19*5);
		
		Scanner scan = new Scanner(System.in);
		int ppl;
		ppl = scan.nextInt();
		int[] year = new int[ppl];
		int[] month = new int[ppl];
		int[] day = new int[ppl];		
		
		for(int i = 0; i < ppl; i++)
		{
			year[i] = scan.nextInt();
			month[i] = scan.nextInt();
			day[i] = scan.nextInt();
			
			System.out.println(toMillenial(year[i],month[i],day[i]));
		}
	}
	
}



Measured memory_bytes: 26580
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
#include <sstream>
#include <fstream>
ifstream ifs;
void init(string s){ifs.open(s);}
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss, buffer, sep)) v.push_back(buffer);
    return v;
}
ll read(){
  string str;
  getline(ifs, str);
  return stoll(str);
}
string read_str(){
  string str;
  getline(ifs, str);
  return str;
}
vector<ll> read_vec(){
  string str;
  getline(ifs, str);
  std::vector<ll> num;
  vector<string> data = split(str, ' ');
  for(int i=0;i<data.size();i++) num.push_back(stoll(data[i]));
  return num;
}
vvl read_mat(ll h){
  string str;
  vvl num = vv(h, 0, 0, ll);
  for(int i=0;i<h;i++){
    getline(ifs, str);
    vector<string> data = split(str, ' ');
    for(int j=0;j<data.size();j++) num[i].push_back(stoll(data[j]));
  }
  return num;
}
//-------------------------------------------------------------------

//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll a, n;std::cin >> n;
  init("001.in");
  //n = read();
  init();
  vvl q = vv(0, 2, 0, ll);
  re(i, n){std::cin >> a;q.push_back(vll{a, 1});}
  re(i, n){std::cin >> a;q.push_back(vll{a, 0});}
  sort(q.begin(), q.end());
  ll x=0, y=0, ans = 1;

  re(i, 2*n){
    (q[i][1]==0?x:y)++;
    if(x>0&&y>0){
      ans = (ans * (q[i][1]==0?y:x))%P;
      x--;y--;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 59312
#include<bits//stdc++.h>
using namespace std;
int main()
{
    int k,a,b,m,n;
    cin>>k>>a>>b;
    m=a/k;
    n=b/k;
    if(a==b && a%k==0)
        cout<<"OK"<<endl;
    else if(n>m || a%k==0 || b%k==0)
        cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

}


Measured memory_bytes: 3624
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int S=sc.nextInt();
        int W=sc.nextInt();
        if(W>=S){
            System.out.println("unsafe");
        }
        else{
            System.out.println("safe");
        }
        
        
    }
}

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

#define lli long long int
#define Sort(n) sort(n.begin(), n.end())
#define Reve(n) reverse(n.begin(), n.end())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define VI(a, n) vector<long long int> a(n)

int main(void)
{
  int h, w;
  cin >> h >> w;
  for(int i = 0;i < h;i++) {
    string a;
    cin >> a;
    cout << a << endl << a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if(n==0)break;
            double u=2000001;
            int p=0;
            for(int i=0;i<n;i++) {
                int a=sc.nextInt(),b=sc.nextInt();
                double t=Math.abs(22-(double)sc.nextInt()*10000/b/b);
                if(u>t) {
                    u=t;
                    p=a;
                }
            }
            System.out.println(p);
        }
    }
}


Measured memory_bytes: 37524
C_num = 1
while True:
    Nap = []
    W = int(input())

    if W == 0:
        break
    N = int(input())
    for i in range(N):
        v,w = map(int,input().split(","))
        Nap.append([v,w])
    DP = [[0 for j in range(W + 1)] for i in range(N + 1)]
    for i in range(1,N+1):
            for j in range(W+1):
                if j - Nap[i-1][1] >= 0:
                    DP[i][j] = max(DP[i-1][j],DP[i - 1][j - Nap[i - 1][1]] + Nap[i - 1][0])
                else:
                    DP[i][j] = DP[i-1][j]
    omo = DP[N].index(DP[N][W])
    print("Case ",C_num,":",sep = "",end = "\n")
    print(DP[N][W])
    print(omo)
    C_num += 1

Measured memory_bytes: 20020
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 H = sc.nextInt();
		int M = sc.nextInt();
		double ra = H / 12.0;
		double rb = M / 60.0;
		ra += 1 / 12.0 * rb;
		double a = (Math.max(ra, rb) - Math.min(ra, rb)) * 360;
		if (a > 180) {
			a = 360 - a;
		}
		double cosA = Math.cos(Math.toRadians(a));
		System.out.println(Math.sqrt(A * A + B * B - 2 * A * B * cosA));
	}

}


Measured memory_bytes: 35968
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)



signed main(){
	string S;
	int N,K;
	cin>>N>>K>>S;
	REP(i,N){
		if(i==K-1){
			cout<<char(S[i]+('a'-'A'));
		}
		else{
			cout<<S[i];
		}
	}
	cout<<endl;
	return 0;
}


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

int main() {
  long long A,B,C,D,v,s,t,u,a,b,c,ans,g;
  
  cin >>A>>B>>C>>D;
  s=B-A;
  if(C>D){
    a=C;
    b=D;
    c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
  }
   else{
    a=D;
    b=C;
    c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
  }
  g=D*C/b;
  v=B/D-A/D;
  u=B/C-A/C;
  t=B/g-A/g;
  ans=B-A-v-u+t+1;
  if(A%C==0||A%D==0){
    ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
 
typedef long long ll;
ll m, n;
 
#define MOD 1000000007
 
ll mod_power(ll x, ll n, ll mod) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
 
int main() {
  cin >> m >> n;
  cout << mod_power(m, n, MOD) << endl;
  return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
 
lower = 0
upper = n
 
for i in range(m):
    l, r = map(int, input().split())
    if lower < l:
        lower = l
    if upper > r:
        upper = r
if upper < lower:
    print(0)
else:
    print(upper - lower + 1)

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

int main(){
    int a;
    cin >> a ;
    int h = a/3600 ;
    int m =(a%3600)/60;
    int s = (a%3600)%60;
    
    cout << h<<":"<<m <<":" << s<<endl;
    return 0;
    
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
    string s;
    int count[27] = {0};
    int size = 0;

    while(std::getline(cin,s)){
    size = s.size();
    rep(i, size)
    {
        rep(j, 26)
        {
            if (s[i] == 'A' + j)
                count[j + 1]++;
            else if (s[i] == 'a' + j)
                count[j + 1]++;
        }
    }

    }

    rep(i, 26)
    {
        char a = 'a';
        a = a + i;
        cout << a << " : " << count[i + 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3184
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int num = 0;
	stringstream ss;
	string s;
	ss << n;
	ss >> s;
	int size = s.size();
	for (int i = 0; i < size; i++) {
		stringstream ss1;
		ss1 << s[i];
		int a = 0;
		ss1 >> a;
		num += a;
	}
	if (n%num == 0)cout << "Yes"<<endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import numpy as np
N, K = map(int, raw_input().split())
R = []
for i in xrange(K):
    ia, ib = map(int, raw_input().split())
    R.extend([ia, ib])

R = sorted(R)
R.reverse()

count = 1
c = 0
r = R.pop()

for i in xrange(N):
    while count == r:
        c += 1
        if len(R) > 0:
             r = R.pop()
        else:
             break

    print c
    count += 1
    c = 0

Measured memory_bytes: 10508
#include<bits/stdc++.h>
using namespace  std;
int main(){
    int a,b,k;cin>>a>>b>>k;
    //vector<int> ans(b+10,0);b=10^9のときMLEか?
    for(int i=a;i<=min(a+k-1,b);i++){
        //ans[i]=i;
        cout<<i<<endl;
    }
    for(int i=max(b-k+1,a+k);i<=b;i++){
        //ans[i]=i;
        cout<<i<<endl;
    }
    for(int i=a;i<=b;i++){
        //if(ans[i]!=0){
            //cout<<ans[i]<<endl;
        //}
    }
}

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
(1..50000).each do |d|
  ko = (d*1.08).floor
  if(n == ko)
    puts d
    exit
  end
end
puts ":("

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

int main(){
	long long a;
  	string b; cin >> a >> b;
  	long long B100 = (b[0] - '0')*100 +(b[2] - '0')*10 + b[3]-'0';
  	 
  	
  	cout << a*B100/100 << endl;
  	
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

struct UnionFind {
  std::vector<int> parent;
  int __size;
  UnionFind(int n) : parent(n, -1), __size(n) {}
  void unite(int x, int y) {
    if ((x = root(x)) != (y = root(y))) {
      if (parent[y] < parent[x]) { std::swap(x, y); }
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  int size(int x) { return -parent[root(x)]; }
  int size() { return __size; }
};

int main() {
  int N, M, K; cin >> N >> M >> K;
  UnionFind uf_tree1(N);
  UnionFind uf_tree2(N);

  vector<vector<int>> friends(N, vector<int>());
  vector<vector<int>> blocks(N, vector<int>());

  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    uf_tree1.unite(a, b);
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  for (int i = 0; i < K; i++) {
    int c, d; cin >> c >> d;
    c--; d--;
    uf_tree2.unite(c, d);
    blocks[c].push_back(d);
    blocks[d].push_back(c);
  }

  for (int i = 0; i < N; i++) {
    int ans = uf_tree1.size(i) - 1;
    set<int> cand;
    // 友達は友達候補ではない
    for (int j = 0; j < friends[i].size(); j++) {
      cand.insert(friends[i][j]);
    }
    // 同じ連結成分に含まれていてもブロック関係なら友達にはなれない
    for (int j = 0; j < blocks[i].size(); j++) {
      if ( uf_tree1.same(i, blocks[i][j]) ) {
        cand.insert(blocks[i][j]);
      }
    }
    ans -= cand.size();
    cout << ans << ((i == N-1) ? "\n" : " ");
  }

  return 0;
}

Measured memory_bytes: 17272
struct tbl_t {
	int c;
	int l;
	unsigned char b; // LSB aligned
} tbl[]= {
	{'A', 6, 0x25},
	{'B', 8, 0x9a},
	{'C', 4, 0x05},
	{'D', 4, 0x01},
	{'E', 3, 0x06},
	{'F', 5, 0x09},
	{'G', 8, 0x9b},
	{'H', 6, 0x10},
	{'I', 4, 0x07},
	{'J', 8, 0x98},
	{'K', 4, 0x06},
	{'L', 5, 0x04},
	{'M', 8, 0x99},
	{'N', 8, 0x9e},
	{'O', 5, 0x05},
	{'P', 3, 0x07},
	{'Q', 8, 0x9f},
	{'R', 4, 0x08},
	{'S', 5, 0x06},
	{'T', 5, 0x07},
	{'U', 8, 0x9c},
	{'V', 8, 0x9d},
	{'W', 6, 0x02},
	{'X', 8, 0x92},
	{'Y', 8, 0x93},
	{'Z', 8, 0x90},
	{' ', 3, 0x05},
	{'.', 6, 0x11},
	{',', 6, 0x03},
	{'-', 8, 0x91},
	{'\'',6, 0x00},
	{'?', 6, 0x01},
};
c,b,l,i,r,f;
main(){
	for(;c=getchar(),c+1;){
		for(i=0;i<32;i++){
			r=l-tbl[i].l;
			if(r>=0&&b>>r==tbl[i].b){
				putchar(tbl[i].c);
				b&=(1<<r)-1;
				l-=tbl[i].l;
				i=-1;
			}
		}
		if(c=='\n'){
			putchar(c);
			b=l=0;
		}else{
			for(i=0;i<32;i++)
				if(tbl[i].c==c){
					b=b<<5|i;
					l+=5;
				}
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
    int N;
    int A, B, C, D;
    scanf("%d", &N);

    A = N / 1000;
    B = (N - A * 1000) / 100;
    C = (N - A * 1000 - B * 100) / 10;
    D = (N - A * 1000 - B * 100 - C * 10);

    if(A + B + C + D == 7) printf("%d+%d+%d+%d=7\n", A, B, C, D);
    else if(A + B + C - D == 7) printf("%d+%d+%d-%d=7\n", A, B, C, D);
    else if(A + B - C + D == 7) printf("%d+%d-%d+%d=7\n", A, B, C, D);
    else if(A + B - C - D == 7) printf("%d+%d-%d-%d=7\n", A, B, C, D);
    else if(A - B + C + D == 7) printf("%d-%d+%d+%d=7\n", A, B, C, D);
    else if(A - B + C - D == 7) printf("%d-%d+%d-%d=7\n", A, B, C, D);
    else if(A - B - C + D == 7) printf("%d-%d-%d+%d=7\n", A, B, C, D);
    else if(A - B - C - D == 7) printf("%d-%d-%d-%d=7\n", A, B, C, D);

    return 0;

}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	for i := 0; i <= 100; i++ {
		for j := 0; j <= 100; j++ {
			a := i + j
			b := i*2 + j*4
			if a == x && b == y {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1752
#include <iostream>
#include <vector>

using namespace std ;


		
  	bool triangleExists(int a, int b, int c) { 
    
       		if (a + b <= c || a + c <= b || b + c <= a){
					return false; 
	  		}else{
		 			return true; 
	 		}
    } 

	bool lenghtsDifferent(int x , int y , int z){

			if((x != y) && (y != z) && (z != x)){
				return true;
			}else{
				return false;
			}
	} 
  
	
	int main(){
		
		int mSticks ;
		
		int mLength ;
		
		int answer {0} ;
		
		int x , y , z ;
		
		int i , j , k ;

		vector <int> lengths ;
		
		cin>>mSticks;
		
		for( int n {0} ; n < mSticks ; n++){
			
			cin>>mLength;
			
			lengths.push_back(mLength);
			
		}
		
		for( i = 0; i < lengths.size() ; i++){

			x = lengths.at(i);
			
		//	cout<<"x = "<<x<<endl ;

			for( j =  i + 1 ; j < lengths.size() ; j++){

				y = lengths.at(j);
				
				//	cout<<"y = "<<y<<endl ;

				for( k =  j + 1 ; k < lengths.size() ; k++){

					z = lengths.at(k);
					
					//	cout<<"z = "<<z<<endl ;
						
						if((triangleExists(x , y , z) == true) && (lenghtsDifferent(x , y , z) ==  true)){
							answer++ ;
						}

				}

			}

		}
	
			
			
		cout<<answer;	
			
	
		return 0 ;
		
		
		
		
		
		
		
	}

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

int main(){
vector<int>A(3);
  cin>>A[0]>>A[1]>>A[2];
  
  sort(A.begin(), A.end());
  if(A[0]==5 && A[1]==5 && A[2]==7){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin >>n;
  ll ans=0;
  for(ll i=1;i<n+1;i++){
    if(i%3!=0&&i%5!=0){
      ans = ans+i;
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3636
//Tuvshee
 
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define I int
#define D double
#define F float
#define C char
#define S string
#define B bool
#define L long long
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define whL while
#define eL endl
#define oR ||
#define rtn return
#define pause system("PAUSE")
#define Max 300
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)
 
I main()
{
    I a, b;
    cin>>a>>b;
    if(a<b)cout<<"a < b"<<eL;
    else if(a>b)cout<<"a > b"<<eL;
    else cout<<"a == b"<<eL;
    rtn 0;
}

Measured memory_bytes: 1156
for e in iter(input,'0 0'):
 r=int(e.split()[0])
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for m in range(1<<~-r):
  t=0
  for s in d:
   c=bin(m^s).count('1')
   t+=c if c>r//2 else r-c
  if a<t:a=t
 print(a)


Measured memory_bytes: 6912
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll a = inl(), p = inl();
        ll s = a * 3 + p;
        cout << s / 2 << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256