akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << 0 << endl;
	else
		cout << 10 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define inf 1e9
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
#define mod 1e9 + 7
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
ll power(ll x, ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

void dfs(ll src, bool visited[], vll adj[], vll &v){
    visited[src] = true;
    v.pb(src);
    for(auto i:adj[src]){
        if(!visited[i])
        dfs(i,visited,adj,v);
    }
}

// string reverse(string s){
//     char temp;
//     int i=0, j=s.length()-1;
//     while(i<j){
//         swap(s[i],s[j]);
//         i++;
//         j--;
//     }
//     return s;
// }

int main(){
    string s, left="", right="";
    cin>>s;
    ll n,a=0;
    cin>>n;
    while(n--){
        ll x;
        cin>>x;
        if(x==2){
            ll y;
            cin>>y;
            char c;
            cin>>c;
            if(a==0 and y==1){
                left+=c;
            }
            else if(a==0 and y==2){
                right+=c;
            }
            else if(a==1 and y==1){
                right+=c;
            }
            else left+=c;
        }
        else{
            if(a==0){
                a=1;
            }else a=0;
        }
    }
    if(a==0){
        reverse(left.begin(),left.end());
        cout<<left<<s<<right;
    }else{
        reverse(right.begin(), right.end());
        reverse(s.begin(), s.end());
        cout<<right<<s<<left;
    }
}

Measured memory_bytes: 1088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

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<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;
}

int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll s = abs(a-b);
    ll D = v-w;
    if(D<=0){
        cout << "NO\n";
    }else{
        if(D*t>=s){
            cout << "YES\n";
        }else{
            cout << "NO\n";
        }

    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P[i];
  int answer {};
  std::sort(P.begin(), P.end());
  rep(i, N-1) {
    answer += P[i];
  }
  answer += P[N-1]/2;
  cout << answer << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    ll var=abs(x/d);
    if(x>0)
    {
        if(var>=k)
        {
            cout<<x-(k*d);
        }
        else
        {
            k-=var;
            if(k%2==0)
            {
                cout<<x-(var)*d<<'\n';
            }
            else
            {
                cout<<abs(x-(var+1)*d)<<'\n';
            }
            
        }
               
    }
    else if(x<0)
    {
        if(var>=k)
        {
            cout<<abs(x+k*d);
        }
        else
        {
            k-=var;
            if(k%2==0)
            {
                cout<<abs(x+(var)*d)<<'\n';
            }
            else
            {
                cout<<abs(x+(var+1)*d)<<'\n';
            }
            
        }

    }
    else
    {
        if(k%2==0)
        {
            cout<<"0\n";
        }
        else
        {
            cout<<d<<'\n';
        }
        
    }
    
    return 0;
} 

Measured memory_bytes: 3516
import java.util.*;

public class Main {
  public static void main(String args[]) {
    String[] wdays = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    sc.close();
    
    for (int i = 0; i < 7; i++) {
      if (S.equals(wdays[i])) {
        System.out.println(7 - i);
        break;
      }
    }
  }
}

Measured memory_bytes: 23764
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

int n,a[101111];
bool proc(){
	if(a[n] != 2)return false;
	long long int lo = 2, hi = 3;
	for(int i=n-1; i>=1; i--){
		long long int lo2 = lo / a[i] * a[i];
		while(lo2 < lo)lo2 += a[i];
		long long int hi2 = hi / a[i] * a[i];
		if(lo2 > hi2)return false;
		lo = lo2;
		hi = hi2 + a[i] - 1;
	}
	printf("%lld %lld\n",lo,hi);
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	if(!proc())puts("-1");
	return 0;
}

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    vec sum(200000+100);
    int dp=1;
    rep(i,n){
        int x=a[i];
        if(i!=0 && a[i]==a[i-1]){
            continue;
        }
        sum[x]+=dp;
        dp=(sum[x])%MOD;
    }
    cout<<dp<<endl;
    
}

Measured memory_bytes: 3456
//2018年  3月 26日 月曜日 16:49:42 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<pi, int> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ppi A[MAX_N]; //[0, A[i].fst.fst] に数A[i].secをA[i].fst.secだけマッチング。
ppi B[MAX_N]; //同様[B[i].fst.fst N * N]
int ans[510 * 510]; 

void solve() {
	cin >> N;
	memset(ans, -1, sizeof(ans));
	rep(i, 0, N) {
		int a; cin >> a; a--;
		A[i] = make_pair(pi(a - 1, i), i);
		B[i] = make_pair(pi(-(a + 1), N - i - 1), i);
		ans[a] = i;
	}
	sort(A, A + N);
	sort(B, B + N);
	rep(i, 0, N) {
		int l = A[i].fst.fst, c = A[i].fst.sec, num = A[i].sec;
		// debug(l, c, num, vi(ans, ans + N * N));
		if(c == 0) continue;
		int at = 0;
		while(at <= l && c != 0) {
			if(ans[at] == -1) {
				ans[at] = num;
				c--;
			}
			at++;
		}
		if(at == l + 1 && c != 0) {
			cout << "No\n"; return;
		}
	}
	rep(i, 0, N) {
		int r = B[i].fst.fst * -1, c = B[i].fst.sec, num = B[i].sec;
		if(c == 0) continue;
		// debug(r, c, num, vi(ans, ans + N * N));
		int at = N * N - 1;
		while(at >= r && c != 0) {
			if(ans[at] == -1) {
				ans[at] = num;
				c--;
			}
			at--;
		}
		if(at == r - 1 && c != 0) {
			cout << "No\n"; return;
		}
	}
	cout << "Yes\n";
	rep(i, 0, N * N) cout << ans[i] + 1 << " ";
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

using namespace std;

using ll = long long;
const int N = 505;

int a[N][N];
ll fromL[N][N];
ll fromR[N][N];
ll f[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) if (i != j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) if (i != j) {
			if (i < j) {
				fromL[i + 1][j + 1] = a[i][j];
			} else {
				fromR[i + 1][j + 1] = a[i][j];
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			fromL[i + 1][j + 1] += fromL[i + 1][j] + fromL[i][j + 1] - fromL[i][j];
			fromR[i + 1][j + 1] += fromR[i + 1][j] + fromR[i][j + 1] - fromR[i][j];
		}
	}
	for (int i = 1; i < n; ++i) {
		f[0][i] = fromR[i][i];
	}
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			for (int k = 0; k < i; ++k) {
				ll cost = f[k][i];
				cost += fromR[j][j] - fromR[i][j] - fromR[j][k] + fromR[i][k];
				cost += fromL[i][j] - fromL[i][i];
				f[i][j] = max(f[i][j], cost); 
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans = min(ans, -f[i][n]);
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			ans += a[i][j];
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 7168
#include<stdio.h>

int main(void){
int n,s=0,nzm=114514,i,now;
scanf("%d",&n);
for(i = 1;i <= n;i++){
scanf("%d",&now);
s+=now;
if(now%10 && nzm>now){nzm = now;}
}
if(s%10){printf("%d\n",s);}
else if(nzm == 114514){printf("0\n");}
else{printf("%d\n",s-nzm);}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll X[202020],Y[202020];
pair<ll,ll> P[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll RI=1LL<<30,RA=0;
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		if(X[i]>Y[i]) swap(X[i],Y[i]);
		RI=min(RI,X[i]);
		RA=max(RA,Y[i]);
		P[i]={X[i],Y[i]};
	}
	sort(P,P+N);
	
	ll ret=1LL<<60;
	ll LA=0,RB=RA;
	FOR(i,N) {
		LA=max(LA,P[i].first);
		RB=min(RB,P[i].second);
	}
	ret=min(ret,(LA-RI)*(RA-RB));
	
	set<pair<ll,int>> S;
	S.insert({P[0].second,1000000});
	FOR(i,N) if(i) S.insert({P[i].second,i});
	while(1) {
		ll dif=S.rbegin()->first-S.begin()->first;
		ret=min(ret,(RA-RI)*dif);
		
		auto a=*S.rbegin();
		S.erase(*S.rbegin());
		if(a.second>=1000000) break;
		S.insert({P[a.second].first,1000000});
	}
	
	
	
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 19200
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,f=0;
	int a[105];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				f=1;
			}
		}
	}
	if(f==1) cout<<"DENIED\n";
	else cout<<"APPROVED\n";
	return 0; 
}

Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
vi vec;
pii res,ans[(1<<18)];
int a[(1<<18)];
int main(){
	std::ios::sync_with_stdio(false);
	int n,val,i,j;
	cin>>n;
	val=(1<<n);
	rep(i,val){
		cin>>a[i];
	}
	rep(i,val){
		ans[i].ff=a[i];
		ans[i].ss=-1;
	}
	rep(i,n){
		rep(j,val){
			if((1<<i)&j){
				vec.clear();
				vec.pb(ans[j].ff);
				vec.pb(ans[j].ss);
				vec.pb(ans[j^(1<<i)].ff);
				vec.pb(ans[j^(1<<i)].ss);
				sort(all(vec));
				ans[j].ff=vec[3];
				ans[j].ss=vec[2];
			}
		}
	}
	int maxx=ans[0].ff+ans[0].ss;
	f(i,1,val){
		maxx=max(maxx,ans[i].ff+ans[i].ss);
		cout<<maxx<<endl;
	}
} 
	

Measured memory_bytes: 6144
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, N) for (int i=0; i<(int)N; i++)

using namespace std;

bool is_correct(int x, int A, int B) {
  bool flag1 = floor((double)x * 0.08 - A) == 0;
  bool flag2 = floor((double)x * 0.1 - B) == 0;
  return flag1 * flag2;
}  

int main() {
  int A, B;
  cin >> A >> B;
  rep(i, 10000) {
    if (is_correct(i, A, B)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<assert.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
template <class T>
int upmin(T &a, const T &b){return (b<a?a=b,1:0);}
template <class T>
int upmax(T &a, const T &b){return (b>a?a=b,1:0);}
namespace io
{
	const int SIZE=(1<<20)+1;
	char ibuf[SIZE],*iS,*iT;
	char obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1;
	int getc()
	{
		(iS==iT?iS=ibuf,iT=ibuf+fread(ibuf,1,SIZE,stdin):0);
		return iS==iT?EOF:*(iS++);
	}
	int f;
	char c;
	template <class T>
	void get(T &x)
	{
		f=1;
		for(c=getc();(c<'0'||c>'9')&&c!='-';c=getc());
		(c=='-'?f=-1,c=getc():0);
		x=0;
		for(;c>='0'&&c<='9';c=getc())
			x=x*10+c-'0';
		x*=f;
	}
	void flush()
	{
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	void putc(char x)
	{
		*(oS++)=x;
		if(oS==oT)
			flush();
	}
	int a[55],t;
	template <class T>
	void put(T x)
	{
		if(!x)
			putc('0');
		x<0?putc('-'),x=-x:0;
		while(x)
		{
			a[++t]=x%10;
			x/=10;
		}
		while(t)
			putc(a[t--]+'0');
	}
	void space()
	{
		putc(' ');
	}
	void enter()
	{
		putc('\n');
	}
	struct flusher
	{
		~flusher()
		{
			flush();
		}
	}
	io_flusher;
}
int n,m,k,x,ans;
int a[100];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&k);
		for(int i=1;i<=k;i++)
		{
			scanf("%d",&x);
			a[x]++;
		}
	}
	for(int i=1;i<=m;i++)
		if(a[i]==n)
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n; string k;
    cin >> n >> k;
    string k2 = "ABC";
   long long cnt = 0;
    for(int i = 0; i < k.size(); i++){
      string q; q.push_back(k[i]); q.push_back(k[i+1]); q.push_back(k[i+2]);
      if(q == k2) cnt++;
    }
   cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var a = new Array(N);
  var b = new Array(N);
  var c = new Array(N);
  var maxs = new Array(3);
  for(var i=0;i<3;i++){
    var maxsub=new Array(N).fill(0);
    maxs[i]=maxsub;
  }
  for(var i=0;i<N;i++){
    var tmp = input[i+1].split(" ");
    a[i]=parseInt(tmp[0]);
    b[i]=parseInt(tmp[1]);
    c[i]=parseInt(tmp[2]);
    for(var j=0;j<3;j++){
      if(i==0){
        maxs[j][i]=parseInt(tmp[j]);
      }else{
        if(j==0){
          maxs[1][i]=Math.max(maxs[1][i],maxs[0][i-1]+b[i]);
          maxs[2][i]=Math.max(maxs[2][i],maxs[0][i-1]+c[i]);
        }else if(j==1){
          maxs[0][i]=Math.max(maxs[0][i],maxs[1][i-1]+a[i]);
          maxs[2][i]=Math.max(maxs[2][i],maxs[1][i-1]+c[i]);
        }else{
          maxs[0][i]=Math.max(maxs[0][i],maxs[2][i-1]+a[i]);
          maxs[1][i]=Math.max(maxs[1][i],maxs[2][i-1]+b[i]);
        }
      }
    }
  }
  var ans = Math.max(maxs[0][N-1],maxs[1][N-1],maxs[2][N-1]);
  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 50868
#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type,
		less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
		less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	


const int mx=1e5+5;

int n,k;
int ara[105],dp[mx];

void make()
{
	dp[0]=0;
	
	for(int i=1;i<mx;i++)
	{		
		for(int j=0;j<n;j++)
		{
			if(i>=ara[j])
			{
				if(dp[i-ara[j]]==0)
				{
					dp[i]=1;
				}
			}
		}
	}
	
	if(dp[k]) cout<<"First";
	else cout<<"Second";
	
} 

void solve()
{
	cin>>n>>k;
	
	for(int i=0;i<n;i++) cin>>ara[i];
	
	make();
	
}
	
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 640
#define de puts("#")
#define bug(x) cout<<#x<<" : "<<x<<endl
#define cha1 printf("L : %d,R : %d,x : %d,l : %d,r : %d,rt : %d\n",L,R,x,l,r,rt)
#define cha2 printf("L : %d,R : %d,l : %d,r : %d,rt : %d\n",L,R,l,r,rt)
#define cha3 printf("pos : %d,x : %d,l : %d,r : %d,rt : %d\n",pos,x,l,r,rt)
#define lcha1 printf("L : %lld,R : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,x,l,r,rt)
#define lcha2 printf("L : %lld,R : %lld,l : %lld,r : %lld,rt : %lld\n",L,R,l,r,rt)
#define lcha3 printf("pos : %lld,x : %lld,l : %lld,r : %lld,rt : %lld\n",pos,x,l,r,rt)
#define huge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%d ",a[i][j]);puts("");}puts("")
#define lhuge(n,m,a) for(int i=1; i<=n; i++) {for(int j=1; j<=m; j++)printf("%lld ",a[i][j]);puts("");}puts("")
#define lowbit(x) (x&(-x))
#define IN freopen("in.txt","r",stdin)
#define OUT1 freopen("out1.txt","w",stdout)
#define OUT2 freopen("out2.txt","w",stdout)
#include<iostream>
#include<stdio.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int maxn1=0,maxn2=0,num=0;
	for(int i=1;i<=n;i++)maxn1=max(maxn1,a[i]);
	for(int i=1;i<=n;i++)if(a[i]!=maxn1)maxn2=max(maxn2,a[i]);
	for(int i=1;i<=n;i++)if(a[i]==maxn1)num++;
	for(int i=1;i<=n;i++){
		if(a[i]!=maxn1||a[i]==maxn1&&num>1)printf("%d\n",maxn1);
		else printf("%d\n",maxn2);
	}
	return 0;
}

Measured memory_bytes: 2432
object Main extends App {
  var read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  var a = array(0)
  var b = array(1)
  var sum = 0
  def getCoin() = {
    if(a >= b) {
      sum += a
      a = a - 1
    } else {
      sum += b
      b = b - 1
    }
  }
  getCoin()
  getCoin()
  println(sum)

}

Measured memory_bytes: 25540
#include <iostream>
#include <string>

using namespace std;
typedef long long int ll;

int main()
{
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0)
		{
			if (char(s[i]) == 'L')
			{
				cout << "No";
				return 0;
			}
		}
		else
		{
			if (char(s[i]) == 'R')
			{
				cout << "No";
				return 0;
			}
		}
	}

	cout << "Yes";

	return 0;
}


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

const int M = 1e9 + 7;

int bp(int b, int p) {
    int res = 1;
    while (p) {
        if (p & 1) res = 1ll * res * b % M;
        p >>= 1;
        b = 1ll * b * b % M;
    }
    return res;
}

int main() {
    int n, k;
    while (scanf("%d %d", &n, &k) == 2) {
        int res = 0;
        vector<int> divs;
        for (int x = 1; x <= k; x++) 
            if (k % x == 0) divs.push_back(x);

        unordered_map<int, int> q;
        for (int d = k; d >= 1; d--) {
            int tq = 0, nNums = k / d;
            for (int m = 1; 1ll * m * d <= k; m++) tq = (tq + M - q[d * m]) % M;
            tq = (tq + bp(nNums, n)) % M;
            res = (res + 1ll * tq * d % M) % M;
            q[d] = tq;
        }

        printf("%d\n", res);
    }
}


Measured memory_bytes: 7324
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();

		char[] chars = { s1.charAt(0), s2.charAt(0), s3.charAt(0) };

		String ansLower = String.valueOf(chars);

		System.out.println(ansLower.toUpperCase());

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27004
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int Maxn = 100010;
const int inf = 0x7fffffff;
int neg[Maxn], nl, pos[Maxn], pl;
int n, K;
int _min(int x, int y) { return x < y ? x : y; }
int main() {
	int i, j, k;
	scanf("%d%d", &n, &K);
	int fl = 0;
	for(i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		if(x > 0) fl = 1;
		if(fl == 0) neg[++nl] = -x;
		else pos[++pl] = x;
	}
	for(i = 1; i <= nl/2; i++) swap(neg[i], neg[nl-i+1]);
	int ans = inf;
	for(i = 0; i <= K; i++){
		if(i > nl) break;
		if(K-i <= pl) ans = _min(ans, neg[i]+pos[K-i]+_min(neg[i], pos[K-i]));
	}
	printf("%d\n", ans);
	return 0;
}

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

int n, m;

int main() {
	cin >> n >> m;
	dsu d(n);
	int ans = n - 1;
	for (int i = 0, a, b; i < m; ++i) {
		cin >> a >> b;
		--a;
		--b;
		if (!d.same(a, b)) {
			--ans;
			d.merge(a, b);
		}
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

const int maxn=100005;

vi G[maxn];
bool vis1[maxn],vis2[maxn];
int dis1[maxn],dis2[maxn];

void dfs1(int u){
	vis1[u]=1;
	for(auto v:G[u]){
		if(!vis1[v]){
			dis1[v]=dis1[u]+1;
			dfs1(v);
		}
	}
}
void dfs2(int u){
	vis2[u]=1;
	for(auto v:G[u]){
		if(!vis2[v]){
			dis2[v]=dis2[u]+1;
			dfs2(v);
		}
	}
}

int main()
{
	fast_cin
    int n;
	int chaserpos, chaseepos;
	cin >> n >>chaseepos >> chaserpos;

	for(int i=0;i<n-1;i++){
		int u,v;
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs2(chaserpos);
	dfs1(chaseepos);
	int mx=0;
	for(int i=1;i<=n;i++){
		if(dis2[i]>=dis1[i]) mx=max(mx,dis2[i]);
	}
	cout << mx-1 << endl;

}


Measured memory_bytes: 9344
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;
fn main() {
    input!{
        n: usize,
        k: usize,
        a: [u32; n],
    };
    let mut count = HashMap::new();
    for v in a{
        *count.entry(v).or_insert(0) += 1u32;
    }
    let mut cvec = count.values().map(|&x| x).collect::<Vec<_>>();
    cvec.sort_by(|a,b| b.cmp(a));
    println!(
        "{}",
        cvec.iter().skip(k).sum::<u32>()
    );
}


Measured memory_bytes: 14060
#include <stdio.h>
#include <iostream>

int main()
{
	int n;
	scanf("%d", &n);
	int R[200000];
	for (int i = 0; i < n; i++)
		scanf("%d", R + i);
	int max = (int)0x80000000;
	int min = R[0];
	for (int i = 1; i < n; i++)
	{
		if (R[i] - min > max)
			max = R[i] - min;
		if (R[i] < min)
			min = R[i];
	}
	/*
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int diff = R[j] - R[i];
			if (diff > max)
			{
				max = diff;
			}
		}
	}
	//*/
	
	printf("%d\n", max);
    return 0;
}



Measured memory_bytes: 3960
#include<stdio.h>
#define MAX 120
#define NIL -1

#define WHITE 1
#define GRAY 2
#define BLACK 3

struct node{
  int list2[MAX];
  int color;
  int number;
};
typedef struct node Node;

void enq(int);
int deq(void);
void bfss(Node*);

int Q[MAX],atama=1,tail=1,hozon;
Node list1[MAX];


int num,degree,time,d[MAX];
main()
{
  
  int i,j;
  scanf("%d",&num);
  for(i=1;i<=num;i++)
    {
      scanf("%d",&list1[i].number);/*list1は添字番号がそのまま値*/
      scanf("%d",&degree);
      list1[i].list2[degree+1] = NIL;

      if(degree != 0)
	{
	  for(j=1;j<=degree;j++)
	    {
	      scanf("%d",&list1[i].list2[j]);
	    }
	}/*ifとじ*/

    }/*これで情報は入った*/


  bfss(list1);

  for(i=1;i<=num;i++)
    {
      printf("%d %d",i,d[i]);
    
  printf("\n");
}
  return 0;
}

void bfss(Node* list1)
{
  int i,j;
  for(i=1;i<=num;i++)/*初期化*/
    {
      list1[i].color = WHITE;
      d[i] = NIL;
    }

  list1[atama].color = GRAY;
  d[atama] = 0;

  enq(list1[atama].number);/*これで一個モノが入ってatama=1,tail=2*/

while(Q[atama]!=Q[tail])
    {
      hozon = deq();

      for(i=1;i<=MAX;i++)/*degreeをあさる*/
	{
	  if(list1[list1[hozon].list2[i]].color == WHITE)/*vはuのdegreeの文字*/
	    {
	      list1[list1[hozon].list2[i]].color = GRAY;
	      d[list1[hozon].list2[i]] = d[hozon] + 1;
	      enq(list1[list1[hozon].list2[i]].number);

	    }
	}
      list1[hozon].color = BLACK;
    }


} 

void enq(int number)
{
  Q[tail] = number;
  tail+=1;
}

int deq(void)
{
  atama+=1;
  return Q[atama-1];
}

Measured memory_bytes: 652
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let (n, m) = (io.read::<usize>(), io.read::<usize>());
    let mut cnt = vec![0; 55];
    for _ in 0..m {
        let a = io.read::<usize>();
        let b = io.read::<usize>();
        cnt[a] += 1;
        cnt[b] += 1;
    }
    for i in 1..n + 1 {
        io.writeln(cnt[i]);
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

int h,w;
char s[100][100];

void dfs(int y,int x,char f){
	if((x<0)||(w<=x)||(y<0)||(h<=y)){
		return;
	}
	if(s[y][x]==f){
		s[y][x]='x';
	}else{
		return;
	}
	dfs(y,x+1,f);
	dfs(y,x-1,f);
	dfs(y+1,x,f);
	dfs(y-1,x,f);
}

int main(){
	while(cin >> h >> w,h){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> s[i][j];
			}
		}
		int count=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(s[i][j]=='x');
				else{
					dfs(i,j,s[i][j]);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3380
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=100005;
int degree[MAX];
int n,m;
int main()
{
	int a,b;
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		cin>>a>>b;
		degree[a]++;
		degree[b]++;
	}
	for(int i=1;i<=n;++i){
		if(degree[i]%2==1){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n, m, x, y, x_[1000], y_[1000];
    cin >> n >> m >> x >> y;
    REP(i, n)
    cin >> x_[i];
    REP(i, m)
    cin >> y_[i];

    sort(x_, x_ + n);
    sort(y_, y_ + m);

    if (x_[n - 1] >= y_[0])
    {
        cout << "War" << endl;
        return 0;
    }

    int z1 = x_[n - 1] + 1;
    int z2 = y_[0];

    if (x >= z2 || y < z1)
    {
        cout << "War" << endl;
        return 0;
    }

    cout << "No War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N,K,X,Y;

	std::cin >> N >> K>>X>>Y;

	if(N > K){
		std::cout << K*X+(N-K)*Y<<std::endl;
	}
	else {
		std::cout << N*X<<std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    Sa = input()
    Sb = input()
    Sc = input()

    S = [Sa, Sb, Sc]
    A = "abc"
    B = "ABC"
    t = 0

    while True:
        s = S[t][0]
        S[t] = S[t][1:]
        t = A.index(s)

        if len(S[int(t)]) == 0:
            break

    print(B[t])


main()


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
   	int hash[10];
   	mset(hash,0);
   	int arr[3];
   	for(int i=0;i<3;++i)
   	{
   		cin>>arr[i];
   		hash[arr[i]]++;
   	}
   	for(int i=0;i<9;++i)
   	{
   		if(hash[i]==2)
   		{
   			cout<<"Yes";
   			return;
   		}
   	}
   	cout<<"No";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}


Measured memory_bytes: 3560
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int main() {

	string s, t;
	while (cin >> s >> t) {
		int dp[4040][4040] = {};
		for (int i = 1; i <= s.size(); i++) {
			for (int j = 1; j <= t.size(); j++) {
				if (s[i - 1] == t[j - 1]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < s.size() + 1; i++) {
			for (int j = 0; j < t.size() + 1; j++) {
				ans = max(ans, dp[i][j]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 66816
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
const int mod = 998244353;
const int MAXN = 20000005;

struct mint {
	int val;
	mint() { val = 0; }
	mint(const lint& v) {
		val = (-mod <= v && v < mod) ? v : v % mod;
		if (val < 0) val += mod;
	}

	friend ostream& operator<<(ostream& os, const mint& a) { return os << a.val; }
	friend bool operator==(const mint& a, const mint& b) { return a.val == b.val; }
	friend bool operator!=(const mint& a, const mint& b) { return !(a == b); }
	friend bool operator<(const mint& a, const mint& b) { return a.val < b.val; }

	mint operator-() const { return mint(-val); }
	mint& operator+=(const mint& m) { if ((val += m.val) >= mod) val -= mod; return *this; }
	mint& operator-=(const mint& m) { if ((val -= m.val) < 0) val += mod; return *this; }
	mint& operator*=(const mint& m) { val = (lint)val*m.val%mod; return *this; }
	friend mint ipow(mint a, lint p) {
		mint ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mint inv(const mint& a) { assert(a.val); return ipow(a, mod - 2); }
	mint& operator/=(const mint& m) { return (*this) *= inv(m); }

	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
	operator int64_t() const {return val; }
};

mint fact[MAXN], invf[MAXN];

mint bino(int x, int y){
	if(y < 0) return mint(0);
	return fact[x] * invf[y] * invf[x-y];
}

mint CatalanUp(int x, int y){
	if(x > y) return mint(0);
	return bino(x + y, x) - bino(x + y, x - 1);
}

mint f(int x, int y){
	if(y < 0) return mint(0);
	if(y == 0) return mint(x >= 0);
	return bino(x + y - 1, x - 1);
}

int main(){
	fact[0] = mint(1);
	for(int i=1; i<MAXN; i++){
		fact[i] = fact[i-1] * mint(i);
	}
	invf[MAXN - 1] = mint(1) / fact[MAXN - 1];
	for(int i=MAXN-1; i>=1; i--) {
		invf[i - 1] = invf[i] * mint(i);
	}
	int n, a, b; cin >> n >> a >> b;
	if(b == 0){
		puts("1");
		return 0;
	}
	mint ret = 0;
	if(a + b == n) ret += CatalanUp(n - b, b - 1);
	for(int k = 0; k <= min({a, n - b - 1}); k++){
		ret += f(a-k+1, n-b-k-1) * CatalanUp(k, b-1);
	}
	cout << ret << endl;
}

Measured memory_bytes: 159892