akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

vi dx={1,0,-1,0},dy={0,1,0,-1};
const int INF = 100100101;
int main() {
  int h,w;
  cin >> h >> w;

  vvi maze(h,vi(w,0));
  rep(i,h) rep(j,w) {
    char a;
    cin >> a;
    if(a=='.') maze.at(i).at(j)=1;
    else maze.at(i).at(j)=0;
  }

  vvi defa(h,vi(w,INF));

  int ans=0;
  rep(i,h) rep(j,w) {
    if(!maze.at(i).at(j)) continue;
    queue<P>  que;
    que.push(P(i,j));
    int tmp=0;
    vvi d=defa;
    d.at(i).at(j)=0;
    while(que.size()) {
      P q=que.front();que.pop();
      int x=q.fi,y=q.se;
      rep(k,4) {
        int nx=x+dx[k];int ny = y+dy[k];
        if(isin(nx,0,h) and isin(ny,0,w) and maze.at(nx).at(ny)==1 and d.at(nx).at(ny)==INF) {
          que.push(P(nx,ny));
          d[nx][ny]=d[x][y]+1;
          tmp=max(tmp,d[x][y]+1);
        }
      }
    }
    ans=max(ans,tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
x,k,d=map(int,input().split())
x=abs(x)
c=x//d
if k<=c:
  print(abs(x-k*d))
else:
  f=x-c*d
  k-=c
  if f>0:
    if k%2==1:
      print(abs(f-d))
    else:
      print(abs(f))
  if f<0:
    if k%2==1:
      print(abs(f+d))
    else:
      print(abs(f))
  if  f==0:
    if k%2==1:
      print(abs(f+d))
    else:
      print(0)

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

int main(){
    int r = 1, l = 1, mem, i;
    string s;
    cin >> s;
    int n = s.length();
    int count[n] = {};
    for(i=1; i<n; i++){
        if(s[i] == s[i-1]){
            if(s[i] == 'R') r++;
            else l++;
        }else{
            if(s[i] == 'L'){
                count[i] += r/2;
                count[i-1] += (r+1)/2; 
                l = 1;
                mem = i;
            }else{
                count[mem] += (l+1)/2;
                count[mem-1] += l/2;
                r = 1;
            }
        }
    }
    count[mem] += (l+1)/2;
    count[mem-1] += l/2;
    for(i=0; i<n; i++){
        cout << count[i] << ' ';
    }
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long

int main(){
    IOS;

    string s;
    cin>>s;

    if(s == "Sunny")
        cout<<"Cloudy";
    else if(s == "Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";

    return 0;
}

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

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 INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int N;
ll D;
vector<ll> A;
vector<tuple<ll, int, int>> edges;

void rec(int left, int right){
    if(right - left <= 1) return;
    int mid = (left + right) >> 1;

    ll lmin = LINF;
    int lmidx = -1;
    for(int i=left;i<mid;i++) if(chmin(lmin, A[i]-D*i)) lmidx = i;
    ll rmin = LINF;
    int rmidx = -1;
    for(int i=mid;i<right;i++) if(chmin(rmin, A[i]+D*i)) rmidx = i;

    for(int i=left;i<mid;i++) edges.emplace_back(A[i] + A[rmidx] + D * (rmidx - i), i, rmidx);
    for(int i=mid;i<right;i++) edges.emplace_back(A[i] + A[lmidx] + D * (i - lmidx), lmidx, i);

    rec(left, mid);
    rec(mid, right);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> D;
    A.resize(N);
    REP(i,N) cin >> A[i];
    edges.clear();
    rec(0, N);

    UnionFind uf(N);
    ll res = 0;
    sort(edges.begin(), edges.end());

    for(auto e : edges){
        ll w, u, v;
        tie(w, u, v) = e;
        if(uf.issame(u, v)) continue;
        res += w;
        uf.unite(u, v);
    }
    cout << res << endl;
}

Measured memory_bytes: 69472
X=int(input())
A=[]
i,p=0,True
while p:
  a=i**5
  A.append(a)
  for b in A:
    if a-b==X:
      p=False
      print(i,A.index(b))
      break
    elif a+b==X:
      p=False
      print(i,-1*A.index(b))
      break
  i+=1

Measured memory_bytes: 63264
#include<stdio.h>

int main(void){
	int n,d;
	int x;
	scanf("%d %d",&n,&d);

	x = 0;
	while(n > d*2*x + x){
		x++;
	}

	printf("%d\n",x);
	return 0;
}

/*
int main(void){

	int r;

	scanf("%d",&r);
	printf("%d\n",3*r*r);


	return 0;
}
*/

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
int main(void){
    int n,bstart,temp,sum=0;
    std::cin>>n>>bstart;
    while(std::cin>>temp){
        if(std::abs(temp-bstart)>=temp){
            sum+=temp*2;
        }else{
            sum+=std::abs(temp-bstart)*2;
        }
    }
    std::cout<<sum<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

bool used[30][30];
int mv[4][2]={{0,1},{0,-1},{1,0},{-1,0}};

bool check(int n){
	int m;
	int i,j,k;
	int a,b,c,d;
	char ca;
	memset(used,false,sizeof(used));
	for(i=0;i<n;i++){
		cin>>a>>b;
		used[a][b]=true;
	}
	a=10,b=10;
	cin>>m;
	for(i=0;i<m;i++){
		cin>>ca>>d;
		if(ca=='N')c=0;
		if(ca=='S')c=1;
		if(ca=='E')c=2;
		if(ca=='W')c=3;
		for(j=0;j<d;j++){
			a+=mv[c][0],b+=mv[c][1];
			if(used[a][b])n--,used[a][b]=false;
		}
	}
	if(n)return false;
	return true;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	while(cin>>n){
		if(n==0)return 0;
		if(check(n))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3088
n= int(input())
dp =[0]*3
for i in range(n):
    ndp=[0]*3
    c =list(map(int,input().split()))
    for j in range(3):
        for k in range(3):
            #print(j,k)
            if j !=k:
                ndp[k] = max(ndp[k],dp[j]+c[k])
                
    dp = ndp
    
print(max(dp))
        

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array boumnds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/
#define MAXM 1009
#define MAXN 15
int n, m, tmp, box;
int arr[MAXM], masks[MAXM];

int dp[1<<12+10];
typedef bitset<12> MASK;
int best(int state){


    for(int i = 0; i < 1<<n; i++)dp[i] = 1e9;
    dp[0] = 0;
    for(int i = 0; i < (1 << n); i++){
        if(dp[i] == 1e9)continue;
        for(int j = 0; j < m; j++){
            dp[i | masks[j] ] = min(dp[i | masks[j] ], dp[i] + arr[j] );
        }

    }


    return dp[ (1<<n) - 1];
}

int main(){
    fIO
    cin >> n >> m;

    memset(dp,-1,sizeof(dp));
    for(int i = 0; i < m; i++){
        cin >> arr[i] >> tmp;
        int mask = 0 ;
        for(int j = 0; j < tmp; j++){
            cin >> box;
            mask |= (1 << (box-1));
        }
        masks[i] = mask;
    }
    //for(int i = 0; i < m; i++)cout << masks[i] << " ";
    cout << (best((1<<n) - 1 ) == 1e9 ? -1 : best((1 << n)-1));
    //cout << endl << " " << (1 << n)-1;
}







Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    map<int,int> mp;
    ll ans = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        ans += mp[i-a];
        mp[i+a]++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 20664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int p = scan.nextInt();
        int q = scan.nextInt();
        int r = scan.nextInt();

        if (Math.max(Math.max(p, q), r) == p) {
            System.out.println(q + r);
        } else if (Math.max(Math.max(p, q), r) == q) {
            System.out.println(p + r);
        } else {
            System.out.println(p + q);
        }
    }
}

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

struct Edge { int to, cost; };
vector<vector<Edge> > G;

const int INF = 1e8;
int n, m;

void addEdge(int a, int b, int cost) {
    G[a].push_back((Edge){ b, cost });
    G[b].push_back((Edge){ a, cost });
}

int prim() {
    vector<int> mincost(n, INF);
    vector<bool> used(n, false);
    mincost[0] = 0;
    int res = 0;
    while (1) {
        int v = -1;
        for (int i=0; i<n; ++i) {
            if ( ! used[i] && (v == -1 || mincost[i] < mincost[v])) v = i;
        }
        if (v == -1) break;
        used[v] = true;
        res += mincost[v];

        for (int i=0; i<(int)G[v].size(); ++i) {
            Edge &e = G[v][i];
            mincost[e.to] = min(mincost[e.to], e.cost);
        }
    }
    return res;
}

int main() {
    while (cin >> n >> m, n) {
        G.resize(n);
        fill(G.begin(), G.end(), vector<Edge>());
        int a, b, c;
        char dlm;
        for (int i=0; i<m; ++i) {
            cin >> a >> dlm >> b >> dlm >> c;
            addEdge(a, b, c / 100 - 1);
        }
        cout << prim() << endl;
    }
    return 0;
}

Measured memory_bytes: 1332
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {
        cin >> x;
        if (x == 0)
            break;
        else
            cout << "Case " << i << ": " << x << endl;
    }
}


Measured memory_bytes: 3000
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int tb[]={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};
	cout<<tb[n-1];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
string s[111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w;cin>>h>>w;
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<h;i++){
    ll cnt = 0;
    for(int j=0;j<w;j++){
      bool fl2 = true;
      for(int k=0;k<h;k++){
	if(s[k][j] == '#')fl2 = false;
      }
      bool fl = true;
      for(int k=0;k<w;k++){
	if(s[i][k] == '#')fl = false;
      }
      if(fl == false && fl2 == false){cnt++;cout<<s[i][j];}
    }
    if(cnt)
      cout<<endl;
  }
  return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll n;
VL a;

signed main() {
    cin >> n;
    REP(i, n) a.emplace_back(IN());
    auto ntgt = max_element(All(a));
    ll tmp = LINF, ktgt = 0;
    auto itr = a.begin();
    for(; itr != a.end(); itr++) {
        if(abs(*ntgt / 2 - *itr) < tmp && ntgt != itr) {
            ktgt = *itr;
            tmp = abs(*ntgt / 2 - *itr);
        }
    }
    cout << *ntgt << " " << ktgt << "\n";
}


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

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

    int x;
    cin >> x;
    for(int i=1;i<=360;++i){
        if(x*i % 360 == 0){ cout << i << endl; return 0; }
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#define MAX 1000


int lcs(std::string X, std::string Y) {
    int c[MAX+1][MAX+1];
    int maxl = 0;
    int m = X.size();
    int n = Y.size();
    for (int i = 1; i <= m; i++) {
        c[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        c[0][i] = 0;
    }
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i] == Y[j]) {
                c[i][j] = c[i-1][j-1] + 1;
            } else {
                c[i][j] = std::max(c[i-1][j], c[i][j-1]);
            }
            maxl = std::max(maxl, c[i][j]);
        }
    }
    return maxl;
}

int main() {
    std::string s1, s2;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        std::cin >> s1 >> s2;
        
        printf("%d\n", lcs(s1, s2));
    }
    
    return 0;
}



Measured memory_bytes: 7240
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class UnionFind {
public:
    vector<int> par, rank;
    vector<int> forest_size;
    int forest_cnt;
    int N;

    UnionFind(int n) : forest_cnt(n), N(N) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
        forest_size.resize(n, 1);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        int fsz = forest_size[x] + forest_size[y];
        if (rank[x] < rank[y]) {
            par[x] = y;
            forest_size[y] = fsz;
        } else {
            par[y] = x;
            forest_size[x] = fsz;
            if (rank[x] == rank[y]) rank[x]++;
        }
        forest_cnt--;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int get_forest_size(int x) {
        return forest_size[root(x)];
    }
};

signed main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf = UnionFind(N);

  for (int i = 0; i < M; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    s--; t--;
    uf.unite(s, t);
  }

  cout << uf.forest_cnt << endl;
  return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

void foo(string& s) {
	for (int i = 0; i < s.length(); i++)
		if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 'a' - 'A';
}

int main() {
	string W; cin >> W;
	foo(W);
	int cnt = 0;
	string s;
	while (getline(cin, s)) {
		stringstream ss(s);
		string T;
		while (getline(ss, T, ' ')) {
			foo(T);
			if (T == W) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1208
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
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 ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){

    int n,m;
    cin >> n >> m;

    int a[n+m] = {};
    rep(i,0,n)a[i] = 2;
    rep(i,n,m+n) a[i] = 3;

    int ans = 0;
    rep(i,0,n+m){
	rep(j,i+1,n+m){
	    if(((a[i] + a[j]) & 1) == 0)ans++;
	}
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P{ double x, y; };

int main()
{
	vector<P> p(3);

	char k;
	while(true)
	{
		cin >> p[0].x >> k >> p[0].y >> k >> p[1].x >> k >> p[1].y >> k >> p[2].x >> k >> p[2].y;
		if(cin.eof()) break;


		P res = p[2];
		if(!(p[0].x - p[1].x))
			res.x += 2 * (p[0].x - res.x);
		else if(!(p[0].y - p[1].y))
			res.y += 2 * (p[0].y - res.y);
		else
		{
			double oa = (p[0].y - p[1].y) / (p[0].x - p[1].x), ob = p[0].y - oa * p[0].x;
			double a = -1.0 / oa, b = p[2].y - a * p[2].x;

			double x = -(b - ob) / (a - oa), y = a * x + b;

			res.x = 2.0 * x - p[2].x;
			res.y = 2.0 * y - p[2].y;
		}

		printf("%.6f %.6f\n", res.x, res.y);
	}
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int sum = 0;
  int m = n;
  while (0 < m) {
    sum += m % 10;
    m /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	s := scanText()
	if s[2:3] == s[3:4] && s[4:5] == s[5:6] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")

}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N, R;
    cin >> N >> R;

    int inner;

    if(N < 10)
    {
        inner = R + 100 * (10 - N);
    }
    else
    {
        inner = R;
    }

    cout << inner;
    
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,j,k,h,n,ans;cin>>n;ans=n;
	vector<pair<llint,llint>>ball(n);
	for(i=0;i<n;i++){cin>>ball[i].fir>>ball[i].sec;}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			llint p=ball[i].fir-ball[j].fir;
			llint q=ball[i].sec-ball[j].sec;
			int gen=n;
			for(k=0;k<n;k++){
				for(h=0;h<n;h++){
					if(ball[k].fir+p==ball[h].fir&&ball[k].sec+q==ball[h].sec){gen--;}
				}
			}
			mineq(ans,gen);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	ll n;
	while(cin>>n,n+1){
		double q=n,x=q/2.0;
		while(abs(x*x*x-q)>0.00001*q){
			x-=(x*x*x-q)/(3*x*x);
		}
		printf("%.9f\n",x);
	}
}

Measured memory_bytes: 1192
function GCD() {
  m=$1 n=$2
  if [[ $((m>=n)) = 0 ]]; then
    ((tmp=n,n=m,m=tmp))
  fi
  while [[ $((n==0)) = 0 ]]; do
    ((tmp=n,n=m%n,m=tmp))
  done
  echo $m
}

function LCM() {
  m=$1 n=$2
  echo $(((m*n)/$(GCD $m $n)))
}

read A B C D

echo $((
  A--,
  lcm=$(LCM $C $D),
  (B-A)-((B/C-A/C)+(B/D-A/D)-(B/lcm-A/lcm))
))

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;


int main() {
    vector<int> node(5);
    int x, y;
    for (int i = 0; i < 3; ++i) {
        cin >> x >> y;
        node[x]++;
        node[y]++;
    }
    sort(node.begin(), node.end());
    if (node[1] == 1 && node[2] == 1 && node[3] == 2 && node[4] == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	if n > k {
		fmt.Fprintln(writer, 0)
		return
	}
	dp := makeGrid(n+5, k-n+5)
	dp[0][0] = 1
	for i := 0; i < n+1; i++ {
		for j := 0; j < k-n+1; j++ {
			dp[i][j+1].addAs(dp[i][j])
			dp[i+1][j].addAs(dp[i][j])
		}
	}
	fmt.Fprintln(writer, dp[n][k-n+1])
}

func makeGrid(h, w int) [][]mint {
	index := make([][]mint, h, h)
	data := make([]mint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n%2 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



Measured memory_bytes: 1852
[N,M] = list(map(int,input().split()))
P = []
S = []
for i in range(M):
    [ptmp,stmp] = list(input().split())
    P.append(ptmp)
    S.append(stmp)
ans1 = [0]*N
ans2 = [0]*N
for i in range(M):
    prob = int(P[i])
    resu = S[i]
    if resu=="AC":
        ans1[prob-1]=1
    elif resu=="WA" and ans1[prob-1]!=1:
        ans2[prob-1]+=1

cnt1=0
cnt2=0
for i in range(N):
    if ans1[i]==1:
        cnt1+=ans1[i]
        cnt2+=ans2[i]

output = str(cnt1) + " " + str(cnt2)

print(output)

Measured memory_bytes: 65624
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W, K): (usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let s: Vec<Vec<char>> = (0..H)
        .map(|_| {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect()
        })
        .collect();

    let mut res = vec![vec![0; W]; H];
    let mut x = 1;
    let mut u = 0;

    for i in 0..H {
        let mut k = s[i].iter().filter(|&&c| c == '#').count();
        if k >= 1 {
            for j in 0..W {
                for l in u..(i + 1) {
                    res[l][j] = x;
                }
                if s[i][j] == '#' && k >= 2 {
                    k -= 1;
                    x += 1;
                }
            }
            x += 1;
            u = i + 1;
        }
    }
    for i in u..H {
        for j in 0..W {
            res[i][j] = res[i - 1][j];
        }
    }

    let ans = (0..H)
        .map(|i| {
            res[i]
                .iter()
                .map(|&r| r.to_string())
                .collect::<Vec<_>>()
                .join(" ")
        })
        .collect::<Vec<_>>()
        .join("\n");

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


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

int main() {
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout<<"vowel"<< endl;
  }
  else{
    cout<<"consonant"<< endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int sum;
string str;
map<int,int> ans;
map<int,int> ans2;

int to_s(const string &in) {
    int res;
    sscanf(in.c_str(),"%d",&res);
    return res;
}

void dfs(int pos,int s,int bit) {
    // cout<<pos<<","<<s<<endl;
    if(pos >= str.size()) {
        if(s <= sum) ans[s]++,ans2[s]=bit;
        return;
    }

    for(int i=1;i<=str.size()-pos;i++) {
        string tmp=str.substr(pos,i);
        // cout<<"  "<<s<<" + "<<to_s(tmp)<<endl;
        dfs(pos+i,s+to_s(tmp),bit | (1<<(pos+i)));
    }

}

void solve() {
    ans.clear();
    dfs(0,0,0);
    if(ans.size() == 0) {
        cout<<"error"<<endl;
        return;
    }
    auto it=ans.end();
    --it;

    if(it->sc==0) {
        cout<<"error"<<endl;
    }
    else if(it->sc==1) {
        int s=it->fr;
        int bit=ans2[s];
        cout<<s<<" ";
        rep(i,str.size()) {
            if((bit>>i)&1) cout<<" ";
            cout<<str[i];
        }
        cout<<endl;

    }
    else {
        cout<<"rejected"<<endl;
    }

}

int main() {
    while(cin>>sum>>str) {
        if(sum==0&&str=="0") break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>

int main(){
    int A,B,C,diff1,diff2;
    
    scanf("%d %d %d",&A,&B,&C);
    
    diff1=A-B;
    
    if(diff1<C){
        diff2=C-diff1;
        printf("%d\n",diff2);
    }
    
    else{
        printf("0\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
arr = []
for i in range(5):
    arr.append(int(input()))

k = int(input())

flag = True
for i in range(len(arr)-1):
    for j in range(i+1,len(arr)):
        if arr[j] - arr[i] > k:
            flag = False

if flag:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 2940
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

class C{
  public:
    int num, ac, time;
    vector<int> wa;
    C(int p, int n){
      num = n;
      ac = 0;
      time = 0;
      wa = vector<int>(p, 0);
    }
    C(){}
    bool operator < (const C &c) const {
      if(ac != c.ac) return ac > c.ac;
      if(time != c.time) return time < c.time;
      return num < c.num;
    }
};

int main() {
  int T, P, R;
  while(cin >>T >>P >>R && T){
    vector<C> teams(T);
    REP(i, T) teams[i] = C(P, 1 + i);
    REP(i, R){

      int t, p, time;
      string s;
      cin >>t >>p >>time >>s;
      --t; --p;
      if(s == "CORRECT"){
        ++teams[t].ac;
        teams[t].time += 1200 * teams[t].wa[p] + time;
      } else ++teams[t].wa[p];
    }
    SORT(teams);
    REP(i, T) cout <<teams[i].num <<" " <<teams[i].ac <<" " <<teams[i].time <<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;

class Card {
        static int[] appears = new int[101];
        int value;
        int appearNum;
        Card(int value) {
                this.value = value;
                appearNum = appears[value]++;
        }
}

public class Main {

        int count = 0;

        void swap(Card[] A, int a, int b) {
                Card tmp = A[a];
                A[a] = A[b];
                A[b] = tmp;
                count++;
        }

        void bubbleSort(Card[] A) {
                boolean f = true;
                while (f) {
                        f = false;
                        for (int i = A.length - 1; i >= 1; i--) {
                                if (A[i].value < A[i-1].value) {
                                        Card tmp = A[i];
                                        A[i] = A[i-1];
                                        A[i-1] = tmp;
                                        f = true;
                                        count++;
                                }
                        }
                }
        }
void selectionSort(Card[] A) {
                for (int i = 0; i < A.length; i++) {
                        int minj = i;
                        for (int j = i; j < A.length; j++) {
                                if (A[j].value < A[minj].value) {
                                        minj = j;
                                }
                        }
                        if (minj != i) swap(A, i, minj);
                }
        }

        void printCards(Card[] cards) {
                System.out.print(cards[0].value);
                for (int i = 1; i < cards.length; i++) {
                        System.out.print(" " + cards[i].value);
                }
                System.out.println();
        }

        void run() {
                Scanner scan = new Scanner(System.in);
                int n = scan.nextInt();
                Card[] A = new Card[n];
                for (int i = 0; i < A.length; i++) {
                        A[i] = new Card(scan.nextInt());
                }
                count = 0;
                selectionSort(A);
                System.out.print(A[0].value);
                for (int i = 1; i < A.length; i++) {
                        System.out.print(" " + A[i].value);
                }
                System.out.println("\n"+count);
        }
        public static void main(String[] args) {
                // TODO Auto-generated method stub
                new Main().run();
        }

}


Measured memory_bytes: 26236
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
    n <- readInt
    if n == 0 then return ()
    else do
        prices <- replicateM n $ do
            [x, y, h, w] <- readInts
            let size = x + y + h
                price1
                  | size <= 60 = 600
                  | size <= 80 = 800
                  | size <= 100 = 1000
                  | size <= 120 = 1200
                  | size <= 140 = 1400
                  | size <= 160 = 1600
                  | otherwise = 0
                price2
                  | w <= 2 = 600
                  | w <= 5 = 800
                  | w <= 10 = 1000
                  | w <= 15 = 1200
                  | w <= 20 = 1400
                  | w <= 25 = 1600
                  | otherwise = 0
            return $ if price1 == 0 || price2 == 0 then 0 else max price1 price2
        print $ sum prices
        main

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFormat :: Double -> String
doubleFormat = Text.Printf.printf "%.12f"

Measured memory_bytes: 13480
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a, b, c;
    scanf("%d %d %d",&a,&b, &c);
    int ab = a + b;
    int ac = a + c;
    int bc = b + c;

    // 出力
    if(ab > bc && ac > bc)
        cout << bc << endl;
    else if(ab > ac)
        cout << ac << endl;
    else
        cout << ab << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define MXN 3003
ll a[MXN], dp[MXN][MXN];
bool mark[MXN][MXN];

ll calc(int l, int r, bool turn)
{
	if(l==r) return turn? a[l]:-a[l];
	if(mark[l][r]) return dp[l][r];

	if(turn) dp[l][r] = max(calc(l+1, r, !turn)+a[l], calc(l, r-1, !turn)+a[r]);
	else dp[l][r] = min(calc(l+1, r, !turn)-a[l], calc(l, r-1, !turn)-a[r]);
	mark[l][r] = true;
	return dp[l][r];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N; cin>>N;
	for(int i=1; i<=N; i++) cin>>a[i];

	cout << calc(1, N, true) << '\n';
	return 0;
}

Measured memory_bytes: 78592
#include<iostream>
using namespace std;
int main(void)
{
	int in;
	char TDN ;
	int YJSNPI;
	cin >> in ;
	cin >> TDN;


	YJSNPI = in;

	while (1)
	{
		if (TDN == '=')
		{
			cout << YJSNPI << endl;
			break;
		}

		cin >> in;

		if (TDN == '*')
		
			YJSNPI *= in;
		
		if (TDN == '+')
		
			YJSNPI += in;
		
		if (TDN == '/')
		
			YJSNPI /= in;
		
		if (TDN == '-')
		
			YJSNPI -= in;
		
		cin >> TDN;



		
	}
	return 0;
}


Measured memory_bytes: 3056
import sys
sys.setrecursionlimit(2 * (10 ** 6))

def main():
    N, M = map(int, input().split())
    AB = [[] for _ in range(N)]

    for _ in range(M):
        a,b = map(lambda x: int(x)-1, input().split())
        AB[a].append(b)
        AB[b].append(a)

    def dfs(v):
        visited[v] = 1
        for i in AB[v]:
            if visited[i]:
                continue
            dfs(i)

    visited = [0]*N
    cnt = 0
    for i in range(N):
        if visited[i]:
            continue
        dfs(i)
        cnt += 1
    print(cnt-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 55136
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	
	while(kbd.hasNext()){
	    int w = kbd.nextInt();
	    if(w!=-1){
		int t = 1150;
		w-=10;
		int m = 0;
		while(w>0){
		    if(m/10 == 0) t += 125;
		    else if(m/10 == 1) t+=140;
		    else t+=160;
		    
		    w--;
		    m++;
		}
		System.out.println(4280 - t);
	    }
	}
    }
}

Measured memory_bytes: 19244
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define print(x) cout << x << endl
#define input(x) cin >> x

typedef long long llint;

struct Query {
    int a, b, c, d;
};

vector<Query> queries;

llint dfs(int cur, int pre, int n, int m, vector<int>& path) {
    if (cur == n) {
        /*
        for (auto num: path) {
            printf("%d ", num);
        }
        puts("");
        */
        llint tot = 0;
        for (auto q: queries) {
            if (path[q.b] - path[q.a] == q.c) {
                tot += q.d;
            }
        }
        return tot;
    }

    llint maxi = 0;
    for (int i = pre; i <= m; i++) {
        path.push_back(i);
        maxi = max(maxi, dfs(cur + 1, i, n, m, path));
        path.pop_back();
    }
    return maxi;
}

int main() {
    int n, m, q;
    input(n >> m >> q);

    int a, b, c, d;
    for (int i = 0; i < q; i++) {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        a--;
        b--;
        queries.push_back({a, b, c, d});
    }

    vector<int> path;
    llint res = dfs(0, 1, n, m, path);
    print(res);
    return 0;
}



Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int D = 25 - sc.nextInt();
		
	sc.close();
	
	System.out.print("Christmas");
	for (int i=0;i<D;i++) {
		System.out.print(" Eve");
	}
	}

}


Measured memory_bytes: 21844