akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,T,A;
  cin >> N >> T >> A;
  
  vector<int> H(N);
  vector<float> temp(N);
  float N_min = 1000000;
  int index_min = N +1;
  
  for(int i=0;i<N;i++){
    cin >> H.at(i);
    temp.at(i) = T - 0.006*H.at(i);
//    cout << temp.at(i) << endl;
    if( abs(A - temp.at(i)) < N_min ){
      N_min = abs(A - temp.at(i));
      index_min = i;
//      cout << " if "<< abs(A - temp.at(i)) << endl; 
    }
  }
//  cout << N_min << endl;
  cout << index_min + 1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <fstream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstring>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <bitset>
#define MOD 8192
#define pb push_back
#define INF 0x3f3f3f3f
#define ll long long
#define NMAX 100005

using namespace std;

typedef pair<int, int> pii;

int v[NMAX];

int main() {
	int w,h,n,x,y,t,i,j,total=0,maxdif=0,nrmaxdif=0,maxv=0,minv=INF;

	cin>>n>>t;
	for(i=1;i<=n;++i) {
		cin>>v[i];
		minv=min(minv,v[i]);
		if(maxdif<v[i]-minv) {
			maxdif=v[i]-minv;
			nrmaxdif=1;
		}
		else if(maxdif==v[i]-minv) ++nrmaxdif;
	}

	cout<<nrmaxdif;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll count(ll N,ll r,ll d=2019){
    ll ret = N / d;
    if(r <= N % d) ret++;
    return ret;
}

int main(){

    /* for(int i=0;i<=10;i++){ */
    /*     for(int j=0;j<3;j++){ */
    /*         cout << i << " " << j << " " << count(i,j,3) << endl; */
    /*     } */
    /* } */

    /* return 0; */
    ll L,R; cin >> L >> R;

    vector<ll> rem(2020,0);
    rep(i,2019){
        rem[i] = count(R,i);
        if(L-1>=0) rem[i] -= count(L-1,i);
    }


    ll ans = 2019;

    rep(i,2019){
        rep(j,2019){
            if(i==j){
                if(rem[i]>=2){
                    ans = min<ll>(ans,i*i%2019);
                }
            }else{
                if(rem[i]>0 and rem[j]>0){
                    ans = min<ll>(ans,i*j%2019);
                }
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int mh[501][501],n;
int vis[501][501],dx[]={1,0,-1,0},dy[]={0,1,0,-1};

void dfs(int i,int j){
	int dis=vis[i][j]+mh[i][j];
	int p;
	REP(p,0,3){
		int x=i+dx[p],y=j+dy[p];
		if(x>0&&x<=n&&y>0&&y<=n&&vis[x][y]>dis) {
			vis[x][y]=dis;
			dfs(x,y);
		}
	} 
}

int main(){
	IOS;
	int i,temp,j,k,cnt=0,x,y;
	cin>>n;
	REP(i,1,n){
		REP(j,1,n) mh[i][j]=1,vis[i][j]=min({i-1,j-1,n-i,n-j});
	}
	ll ans=0;
	REP(i,1,n*n){
		cin>>temp;
		x=(temp+n-1)/n;
		y=temp%n;
		if(y==0) y=n;
		dbg(x,y);
		ans+=vis[x][y];
		mh[x][y]=0;
		dfs(x,y);
	}
	cout<<ans;
	return 0; 	
}




Measured memory_bytes: 24940
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#define endl '\n'
typedef long long int lli;
typedef long double ld;
typedef pair< lli,lli > ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef vector<vi> graph;
lli MOD=1000000007;long double EPS=1e-9;

void solve(){
	lli n,x;
	cin>>n;
	lli N=(1<<n);
	lli arr[N];
	set<ii> mst[N];
	fr(i,N){
		cin>>x;
		mst[i].insert(MP(x,i));
	}
	lli ans[N];
	ans[0]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<n;j++){
			if((i&(1<<j))==0){
				for(auto v:mst[i])mst[i|(1<<j)].insert(v);
				while(mst[i|(1<<j)].size()>2){
					auto v=mst[i|(1<<j)].begin();
					mst[i|(1<<j)].erase(v);
				}
			}
		}
		if(i>0){
			auto v=mst[i].begin();
			auto xx=mst[i].begin();
			xx++;
			ans[i]=(*v).F+(*xx).F;
		}
	}
	fr(i,N-1){
		remax(ans[i+1],ans[i]);
		cout<<ans[i+1]<<endl;
	}
}	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 50176
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N, A, B; cin >> N >> A >> B;
    ll k = N / (A+B);
    ll r = N % (A+B);
    ll b = k * A + min(r, A);
    cout << b << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	int n {in}, m {in}, r {m};
	times(i, n) {
		m += (int) in;
		m -= (int) in;
		r = max(r, m);
		if (m < 0) {
			outl(0);
			return 0;
		}
	}
	outl(r);
}


Measured memory_bytes: 2528
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll a1 = a * c;
    ll a2 = a * d;
    ll a3 = b * c;
    ll a4 = b * d;

    if (a1 > a2)
    {
        a2 = a1;
    }
    if (a2 > a3)
    {
        a3 = a2;
    }
    if (a3 > a4)
    {
        a4 = a3;
    }
    cout << a4;
}

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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
		for(int i=0;i<a;i++)
			cout<<b;
	else
		for(int i=0;i<b;i++)
			cout<<a;

	return 0;
}

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

template <typename T, int B = 1>
class persistent_array {
public:
	static const int mask = (1 << B) - 1;
	struct node {
		T val;
		node* ch[1 << B];
		node() {
			for (int i = 0; i < (1 << B); i++) ch[i] = nullptr;
		}
		node(T v) : val(v) {}
		node(node* t) { memcpy(ch, t->ch, sizeof(node*) << B); }
	};
private:
	const int h, n;
	const T id;
	node *root;
	int get_h(int n) {
		int cnt = 0, tmp = 1;
		while (tmp < n) tmp <<= B, cnt++;
		return cnt;
	}
	node* fix(node *t, int p, T val, int x) {
		if (x < 0) return new node(val);
		t = t ? new node(t) : new node();
		int to = (p >> x) & mask;
		t->ch[to] = fix(t->ch[to], p, val, x - B);
		return t;
	}
	node* dfs(int p, int d, const vector<T>& v) {
		if ((int)v.size() <= (p << d)) return nullptr;
		if (d == 0) return new node(v[p]);
		node* t = new node;
		for (int i = 0; i < (1 << B); i++) {
			t->ch[i] = dfs((p << B) | i, d - B, v);
		}
		return t;
	}
	node* init(const vector<T>& v) {
		return dfs(0, h * B, v);
	}
public:
	persistent_array(int n_, T id_ = 0)
		: h(get_h(n_)), n(1 << (h * B)), id(id_), root(nullptr) {}
	persistent_array(const vector<T>& v, T id_ = 0)
		: h(get_h(v.size)), n(1 << (h * B)), id(id_), root(init(v)) {}
	T set(int p, T val) {
		root = fix(root, p, val, B * (h - 1));
		return val;
	}
	T operator[](int p) const {
		node* t = root;
		for (int i = (h - 1) * B; i >= 0; i -= B) {
			if (!t) return id;
			t = t->ch[(p >> i) & mask];
		}
		return t ? t->val : id;
	}
	void trip_version(node* t) {
		root = t;
	}
	node* get_version() const {
		return root;
	}
};

class persistent_union_find {
public:
	using pa = persistent_array<int>;
	using node = typename pa::node;
private:
	pa par;
	int find(int a) {
		return par[a] < 0 ? a : par.set(a, find(par[a]));
	}
public:
	persistent_union_find(int n) : par(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] > par[b]) swap(a, b);
		par.set(a, par[a] + par[b]);
		par.set(b, a);
	}
	int size(int a) {
		return -par[find(a)];
	}
	void trip_version(node* t) {
		par.trip_version(t);
	}
	node* get_version() {
		return par.get_version();
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	persistent_union_find uf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else {
			printf("%d\n", uf.same(x, y));
		}
	}
	return 0;
}



Measured memory_bytes: 98444
n = int(input())
D ={}
for i in range(n):
    s = input()
    if s in D.keys(): #sが辞書Dにあるのかチェック(これはある場合)
        D[s] += 1 #D[s] += 1 ->{'s':今までに出てきた回数+1}となる
    else:  #sが辞書Dにない場合
        D[s] = 1 #D[s] = 1 ->{'s':1}となる
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
print('\n'.join(sorted(poll)))

Measured memory_bytes: 36636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = x * a + y * b;
  ans = min(ans, max(x, y) * 2 * c);
  if (x > y) {
    ans = min(ans, a * (x - y) + y * 2 * c);
  } else {
    ans = min(ans, x * 2 * c + b * (y - x));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  while(true)
    {
      int m,f,r;
      cin>>m;
      cin>>f;
      cin>>r;
      if(m==-1 && f==-1 && r==-1)break;
      if(m==-1 ||f==-1)cout<<'F'<<endl;
      else if(m+f>=80)cout<<'A'<<endl;
      else if(m+f>=65 && m+f<80)cout<<'B'<<endl;
      else if((m+f>=50 && m+f<65) || (r>=50))cout<<'C'<<endl;
	      else if(m+f>=30 && m+f<50)cout<<'D'<<endl;
	      else if(m+f<30)cout<<'F'<<endl;
    }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N - 1) * (M - 1) << endl;
}

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

#define int int64_t
#define MAX 100005

#define INF 100000007

using namespace std;

int input[MAX][4];
int dp[MAX][4];
int N;

int f(int index, int flag) {
    if(index == N+1) return 0;
    if(dp[index][flag] != -1) return dp[index][flag];


    int ret = -1;

    for(int s=1; s<=3; s++){
        if(s != flag) {
            ret = max(ret, input[index][flag]+f(index+1, s));
        }
    }

    dp[index][flag] = ret;

    return dp[index][flag];
}

signed main() {
    scanf("%lld", &N);

    for(int i = 1; i<=N; i++) {
        scanf("%lld %lld %lld", &(input[i][1]), &(input[i][2]), &(input[i][3]));

        for(int j = 0; j<=3; j++)
            dp[i][j] = -1;
    }

    printf("%lld\n", max(max(f(1, 1),f(1,2)),f(1,3)));
}


Measured memory_bytes: 14336
using System;

namespace _050_AppleandPeach
{
	class Program
	{
		static void Main ( string[] args )
		{
			char[] result = Console.ReadLine ().ToCharArray ();
			string Apple = "apple";
			string Peach = "peach";

			int index = 0;
			while (index < result.Length)
			{
				//apple
				Parse (result, index, Apple, Peach, out index);
				//peach
				Parse (result, index, Peach, Apple, out index);

				index++;
			}

			Console.WriteLine (result);
		}

		static void Parse ( char[] charArray, int index, string searchStr, string parseStr, out int resultIndex )
		{
			if (index + searchStr.Length <= charArray.Length) 
			{
				bool isParse = true;

				for (int index2 = 0; index2 < searchStr.Length; index++, index2++)
				{
					if (charArray[index] != searchStr[index2])
					{
						isParse = false;
						break;
					}
				}

				if (isParse)
				{
					int shift = index - parseStr.Length;
					for (int lp = 0; lp < parseStr.Length; lp++)
					{
						charArray[lp + shift] = parseStr[lp];
					}
				}
			}

			resultIndex = index;
		}
	}
}

Measured memory_bytes: 8724
N = int(input())
A = [int(x) for x in input().split()]

def func():
    for i in range(N):
        if A[i] % 2 != 0 or A[i] % 3 == 0 or A[i] % 5 == 0:
            pass
        else:
            print('DENIED')
            return
    print('APPROVED')
func()

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b, c*d)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w;
    cin >> h >> w;
    vector<vector<int>> dist(10,vector<int>(10));
    rep(i,10) rep(j,10) cin >> dist[i][j];
    rep(k,10) rep(i,10) rep(j,10) {
        chmin(dist[i][j],dist[i][k]+dist[k][j]);
    }
    int ans = 0;
    rep(i,h) rep(j,w) {
        int a;
        cin >> a;
        if(a != -1) ans += dist[a][1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans = 1;
  while(n >= k) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  int tmp = N, tot = 0;
  while (tmp > 0) {
    tot += tmp % 10;
    tmp /= 10;
  }

  if (N % tot == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int h,w;
  string s[10],t;
  map<string,int> v;
  while(1){
    cin>>h>>w;
    if(!h&&!w) break;
    for(int i=0;i<h;i++) cin>>s[i];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=-1;k<=1;k++){
	  for(int l=-1;l<=1;l++){
	    if(!k&&!l) continue;
	    int y=i,x=j;
	    t="";
	    t+=s[y][x];
	    while(1){
	      y+=k;
	      x+=l;
	      if(y<0) y+=h;
	      if(x<0) x+=w;
	      if(h<=y) y-=h;
	      if(w<=x) x-=w;
	      if(y==i&&x==j) break;
	      t+=s[y][x];
	      if(v.find(t)!=v.end()) v[t]++;
	      else v.insert(make_pair(t,0));
	    }
	  }
	}
      }
    }
    int ans=0;
    for(map<string,int>::iterator it=v.begin();it!=v.end();it++){
      string z=it->first;
      if(it->second>0&&ans<z.size()) ans=z.size();
    }
    if(ans>=2){
      for(map<string,int>::iterator it=v.begin();it!=v.end();it++)
	if(it->second>0&&ans==it->first.size()){
	  cout<<it->first<<endl;
	  break;
	}
    }else cout<<0<<endl;
    v.clear();
  }
  return 0;
}

Measured memory_bytes: 36032
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int G[9][9];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        G[a][b]=1;
        G[b][a]=1;
    }
    vec A;
    rep(i,n-1) A.push_back(i+2);
    int ans=0;
    do{
        int z=1;
        rep(i,n-1){
            if(i==0){
                if(!G[1][A[i]]) z=0;
            }
            else if(!G[A[i-1]][A[i]]) z=0;
        }
        if(z) ans++;
    }while(next_permutation(all(A)));
    cout<<ans;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,k,ans;
    cin>>n>>k;
    ans=k*pow(k-1,n-1);
    cout<<ans;
}

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

int main(){
	
	int N;
	int A[10];
	int sum;
	sum =0;
	
	cin >> N;
	
	for(int i=0; i<4; i++){
		A[i]=N%10;
		N = N/10;
	}
	for(int j=0; j<3; j++){
		if(A[j]==A[j+1]){
			sum++;
		}
	}
	if(sum>0){
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
def atcoder(string):
    acgt = set('ACGT')                                               
    on_count = False                                                 
    count = 0 
    max_count = 0                                                    
    
    for c in string:
        if c in acgt:
            if not on_count:
                on_count = True                                      
            count += 1                                               
        else:
            if on_count:
                on_count = False
                max_count = max(max_count, count)
                count = 0 

    if on_count:
        max_count = max(max_count, count)
                                  
    return max_count              
                                  
                                  
if __name__ == "__main__":
    string = input()
    print(atcoder(string))


Measured memory_bytes: 38256
//https://beta.atcoder.jp/contests/abc099/submissions/2652078

#include <iostream>
using namespace std;

int memo[100010];

int f(int n) {
	int& ret = memo[n];
	//cout << "n=" << n << ", memo[" << n << "]=" << ret << endl; 
	if(ret != -1) return ret;
	if(n == 0) return 0;
	ret = 1e9;
	for (int b: {6, 9}) {
		for (int x=1; x<=n; x *= b) {
			ret = min(ret, 1 + f(n-x));
		}
	}
	return ret;
}

// 
// 求める値をf(N)とする. つまりNの関数として表す.
// N = (N-x)+x
// と表せば, f(N) = f(N-x + x)
// ここでxを基数をBとして, x = N-B^0, N-B, N-B^2,... 
// なるものに限定し, f(N-x)がすでに求まっているとすれば,
// f(N) = min_x {f(N-x)} + 1 = min_x {f(N-x) + 1} 
// が成立する.min_xとしているのは, f(N)はf(N-1), f(N-B), f(N-B^2), ... の内の
// 最も大きくない値に1を加算したものとして定義する関数だからである.
// ここでBは{6,9}のいずれも取りうる.
// また, f(0) = 0である.これは終了条件となる.
// 
int main(){
	int N;
	cin >> N;
	fill(memo, memo+N+1, -1);
	cout << f(N) << endl;
	return 0;
}


Measured memory_bytes: 3712
juni=[int(thing) for thing in input().split(" ")]
shokin=0
for x in juni:
    if x==1:
        shokin=shokin+300000
    elif x==2:
        shokin=shokin+200000
    elif x==3:
        shokin=shokin+100000
if juni[0]==juni[1] and juni[0]==1:
    shokin=shokin+400000
print(shokin)

Measured memory_bytes: 3060
L = int(input())

r = 0
while 1:
    if 2**(r+1)<=L:
        r += 1
    else:
        break

N = r + 1
M = 0
ans = []

for i in range(1, N):
    ans.append((i, i+1, 2**(i-1)))
    ans.append((i, i+1, 0))
    M += 2

for t in range(1, N)[::-1]:
    if L-(2**(t-1))>=2**r:
        ans.append((t, N, L-(2**(t-1))))
        M += 1
        L -= 2**(t-1)

print(N, M)
for i in ans:
    print(*i)


Measured memory_bytes: 80672
n, a, b = map(int, input().split())
sum_all = 0
for i in range(1,n+1):
    sum = 0
    i_ = i
    while i_ > 0:
        sum += i_ % 10
        i_ //= 10
    if a <= sum <= b:
        sum_all += i
print(sum_all)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);
  int A, B;
  cin >> A >> B;
  cout << A * B << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
	int a,b,i,x=-50;
	scanf("%d",&a);
	for(i=0;i<2;i++)
	{
		scanf("%d",&b);
		if(b<a)
			a=b;
	}
	x+=a;
	scanf("%d\n%d",&a,&b);
	if(b<a)
		printf("%d\n",x+=b);
	else
		printf("%d\n",x+=a);

  return 0;
}

Measured memory_bytes: 1020
import sys
fin = sys.stdin.readline

N = int(fin())
D, X = [int(elem) for elem in fin().split()]
A_list = [int(fin()) for _ in range(N)]

eaten_num_chocolate = 0
for A in A_list:
    eaten_num_chocolate += (D - 1) // A + 1

print(eaten_num_chocolate + X)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_114
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var ps = new int[25];
            var spNums = new int[25] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
            for(int i = 2; i <= n; i++)
            {
                int ii = i;
                for(int j = 0; j < 25; j++)
                {
                    while (ii % spNums[j] == 0)
                    {
                        ii /= spNums[j];
                        ps[j]++;
                    }
                }
            }
            for(int i = 0; i < 25; i++)
            {
                //Console.WriteLine(ps[i]);
            }
            Console.WriteLine(Cnt(ps, 74) + Cnt(ps, 24) * (Cnt(ps, 2) - 1)
                + Cnt(ps, 14) * (Cnt(ps, 4) - 1)
                + Cnt(ps, 4) * (Cnt(ps, 4) - 1) / 2 * (Cnt(ps, 2) - 2));
        }

        static int Cnt(int[] ps,int bottom)
        {
            int cnt = 0;
            for(int i = 0; i < ps.Length; i++)
            {
                if (ps[i] >= bottom) cnt++;
            }
            return cnt;
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

ll dp[55][55][3000]; 
// dp[i][k][s] : iまで見てk枚選んで合計をsにするような選び方の総数

int main() {
    ll n, a;
    cin >> n >> a;
    Vl x(n);
    rep(i, 0, n) cin >> x[i];

    dp[0][0][0] = 1;
    rep(i, 0, n){ // i番目まで見る
        for(int s = 0; s <= n*a; s++){ // 合計がsとなる
            Rep(k, 0, n){ // k枚選ぶ
                if(dp[i][k][s] == 0) continue; 
                dp[i+1][k][s] += dp[i][k][s]; // i番目を選ばないとき
                dp[i+1][k+1][s+x[i]] += dp[i][k][s]; // i番目を選ぶとき
            }
        }
    }
    ll ans = 0;
    Rep(k, 1, n) ans += dp[n][k][a*k];
    co(ans);

    return 0;
}


Measured memory_bytes: 12840
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

const ll INF=1000000000000000001;
int main() {

	int n,k;
	ll x[50]={};
	ll y[50]={};

	cin>>n>>k;
	ll total=4000000000000000001;
	for(int i=0;i<n;++i)cin>>x[i]>>y[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int o=0;o<n;o++){
				for(int l=0;l<n;l++){
					int t=0;
					ll x1=max(x[i],x[j]);
					ll x2=min(x[i],x[j]);
					ll y1=max(y[o],y[l]);
					ll y2=min(y[o],y[l]);
					for(int m=0;m<n;m++){
						if(((x[m]<=x1)&&(x[m]>=x2))&&((y[m]<=y1)&&(y[m]>=y2)))t++;
					}
					if(t>=k)total=min(total,(x1-x2)*(y1-y2));
				}
			}
		}
	}
	cout<<total<<endl;
	return 0;
}


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

int main()
{
	string S;
	bool n = false, w = false, s = false, e = false;
	cin >> S;
	for (auto c : S) {
		if (c == 'N') {
			n = true;
		}
		else if (c == 'W') {
			w = true;
		}
		else if (c == 'S') {
			s = true;
		}
		else {
			e = true;
		}
	}
	if (n == s && w == e)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 5e4 + 50, M = 1e5 + 50;
int n, m, T, x[M], y[M];
bitset<N> S[N]; char ans[N];
void work(int t){
	static bool ok[N];
	ok[t] = true;
	for(int i=m; i>=1; i--)
	if(ok[x[i]]) ans[i] = '^', ok[y[i]] = true;
	else ans[i] = 'v', ok[x[i]] |= ok[y[i]];
	for(int i=1; i<=m; i++)
	putchar(ans[i]);
} int ct[N], tr[N];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d%d",&n,&m,&T);
	for(int i=1; i<=m; i++)
	scanf("%d%d",&x[i],&y[i]);
	if(T==1){
		for(int i=1; i<=n; i++)
		S[i].set(i);
		for(int i=m; i>=1; i--)
		S[x[i]]=S[y[i]]=S[x[i]]|S[y[i]];
		bitset<N> t; t.set();
		for(int i=1; i<=n; i++)
		t = t & S[i]; 
		for(int i=1; i<=n; i++)
		if(t.test(i)) return work(i), 0;
		return puts("-1"), 0; 
	} else{
		if(n<=2) return puts("-1"), 0;
		for(int i=1; i<=n; i++) ct[i]=1, tr[i]=i;
		for(int i=m, o, e; i>=1; i--)
		if(ct[o=tr[x[i]]] > ct[e=tr[y[i]]])
		tr[x[i]] = tr[y[i]], ans[i] = 'v', --ct[o], ++ct[e];
		else ++ct[o], --ct[e], tr[y[i]] = tr[x[i]], ans[i] = '^';
		for(int i=1; i<=m; i++) putchar(ans[i]);
		return 0;
	}
}

Measured memory_bytes: 310524
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<tuple>

using namespace std;

//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int A,B;

	cin >> A >> B;

	if ((A + B) % 2 != 0) {
		cout << "IMPOSSIBLE"<< endl;
		return 0;
	}

	cout << (A+B)/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int a,b,d,e,p1;
    cin>>a>>b;
    if(a%2==0)
    p1=a/(0.08);
    else
    p1=a/(0.08)+1;
    d=p1/10;
    e=p1*(0.08);
    while(d!=b && e==a)
    {
        ++p1;
        d=p1/10;
        e=p1*(0.08);
    }
    if(d==b && e==a)
    {
        cout<<p1;
    }
    else 
    cout<<-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.2.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int h,w;
  cin >> h >> w;
  Vs a(h),b(h);
  Vin(a);
  Vin(b);
  
  int ans = 0;
  rep(i,0,h){
    rep(j,0,w){
      if(a[i][j]!=b[i][j])ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11328
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)

int main()
{
    int n;
    string s[100000];
    ll cnt[5] = {};
    char c[5] = {'M', 'A', 'R', 'C', 'H'};
    ll ans = 0;

    cin >> n;
    rep(i, 0, n) cin >> s[i];
    rep(i, 0, n)
    {
        rep(j, 0, 5)
        {
            if (s[i][0] == c[j])
            {
                cnt[j]++;
                break;
            }
        }
    }
    rep(i, 0, 5)
    {
        rep(j, i + 1, 5)
        {
            rep(k, j + 1, 5)
            {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
int main()
{
	int n;
	while(cin>>n){

		vector<int> res;
		for(int i=0;i<10;i++){
			if(n & (1<<i)) res.push_back((1<<i));
		}

		for(int i=0;i<res.size()-1;i++) cout<<res[i]<<" ";
		cout<<res[res.size()-1]<<endl;

	}

	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> G;
vector<bool> seen;
vector<int> d,f;
void DFS(int v,int& time){
    d[v]=time++;
    seen[v]=1;
    for(auto p:G[v]){
        if(seen[p])continue;
        DFS(p,time);
    }
    f[v]=time++;
}
int main(){
    scanf("%d",&n);
    seen=vector<bool>(n);
    d=f=vector<int>(n);
    G=vector<vector<int>>(n,vector<int>());
    for(int i=0;i<n;i++){
        int v,k;scanf("%d%d",&v,&k);
        for(int j=0;j<k;j++){
            int a;scanf("%d",&a);
            G[v-1].push_back(a-1);
        }
    }
    for(int i=0;i<n;i++) sort(G[i].begin(),G[i].end());
    int time=1;
    for(int i=0;i<n;i++){
        if(!seen[i])DFS(i,time);
    }
    for(int i=0;i<n;i++){
        printf("%d %d %d\n",i+1,d[i],f[i]);
    }
    return 0;
}


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

signed main() {
	int x; 
	cin >> x;
	int ac=0,wa=0,tre=0,re=0;
	rep(i, x) {
		string a;
		cin >> a;
		if(a == "AC") ac++;
		else if (a=="WA") wa++;
		else if (a == "TLE") tre++;
		else re++;
	}
	cout << "AC" << ' ' << 'x' << ' ' << ac << endl;
	cout << "WA" << ' ' << 'x' << ' ' << wa << endl;
	cout << "TLE" << ' ' << 'x' << ' ' << tre << endl;
	cout << "RE" << ' ' << 'x' << ' ' << re << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=366,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;cin>>Q;
    while(Q--){
        vector<int> S,deg;
        while(1){
            int a;cin>>a;
            if(a==0) break;
            if(a>0) deg.push_back(a);
            S.push_back(a);
        }
        
        int N=si(deg);
        
        vector<vector<int>> E(N);
        vector<int> depth(N,INF),par(N,-1);
        depth[0]=0;
        
        int now=0,nex=1;
        
        for(int t=1;t<si(S);t++){
            int a=S[t];
            if(a>0){
                while(deg[now]==0) now=par[now];
                deg[now]--;
                deg[nex]--;
                E[now].push_back(nex);
                E[nex].push_back(now);
                depth[nex]=depth[now]+1;
                par[nex]=now;
                
                //cout<<now<<" "<<nex<<endl;
                
                now=nex;
                nex++;
            }else{
                while(deg[now]==0) now=par[now];
                for(int i=0;i<N;i++){
                    if(depth[i]==depth[now]+a&&deg[i]){
                        deg[i]--;
                        deg[now]--;
                        E[i].push_back(now);
                        E[now].push_back(i);
                        
                        //cout<<now<<" "<<i<<endl;
                        break;
                    }
                }
            }
        }
        
        for(int i=0;i<N;i++){
            cout<<i+1;
            sort(all(E[i]));
            for(int j:E[i]) cout<<" "<<j+1;
            cout<<endl;
        }
        
    }
}




Measured memory_bytes: 3264
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
/*ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}*/

/*void decToBinary(ll n)
{
    string s;
int binaryNum[32];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--) {
 char c = binaryNum[j] +'0';
 s=s+c;
}
 
 //cout<<s<<endl;
 
 
 
 // for (int j = i - 1; j >= 0; j--)
 // cout<<s[j];
 
sort(s.begin(), s.end());
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end())); */
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll mindig(ll n){
ll x;
ll ans=mod;
 while(n>0)
        {
            x=n%10;
            ans=min(ans,x);
            n=n/10;
        }
        return ans;
}
ll maxdig(ll n)
{
    ll x;
    ll ans1=-1;
         while(n>0)
        {
            x=n%10;
            ans1=max(ans1,x);
            n=n/10;
        }
        return ans1;
}
 ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
    ll n,m,sum=0,i;
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(i=0;i<m;i++)
    {
        sum=sum+a[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			//1行読み込む
			String a = sc.nextLine();
			int sum;
			
			//終了条件
			if (a.equals("0")){
				break;
			}
			
            sum = 0;
			for(int i = 0; i < a.length(); i++){
			    sum += a.charAt(i) - '0'; 
			}
			System.out.println(sum);
		}
	}
}



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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    string s; cin >> s;
    ll sum  = 0;
    rep(i,s.size()){
        sum += s[i] - '0';
    }
    if(sum % 9 == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3724
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
bool comp(vector<ll> v1, vector<ll> v2)
{
    if(v1[0]>v2[0]) return true;
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k; cin>>n>>k;
    vector<vector<ll>> v(n);
    for(int i=1;i<=n;i++){
        ll a,x; cin>>a>>x;
        a--;
        v[a].push_back(x);
    }
    for(int i=0;i<n;i++){
        if(v[i].size()==0) v[i].push_back(INT_MIN);
        else {
            sort(v[i].rbegin(),v[i].rend());
        }
    }
    sort(v.begin(),v.end(),comp);
    priority_queue<ll> pq;
    ll ans=k*k;
    ll sum=0;
    for(int i=0;i<k;i++){
        sum+=v[i][0];
        for(int j=1;j<v[i].size();j++) pq.push(v[i][j]);
    }
    ans=ans+sum;
    
    for(int i=k;i<n;i++){
        for(int j=0;j<v[i].size();j++) pq.push(v[i][j]);
    }
    for(int i=k-1;i>=1;i--)
    {
        ll a=v[i][0]; ll b=pq.top();
        if(a>=b) continue;
        pq.pop();
        sum-=a; sum+=b;
        pq.push(a);
        ans=max(ans,sum+(ll)i*i);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 11456