akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 100
char farm[MAX][MAX];

void infection(int i, int j, int H, int W, char moji)
{
    if( farm[i][j] == moji ){
        farm[i][j] = '+';
        if( j + 1 < W ) infection(i, j + 1, H, W, moji);
        if( i + 1 < H ) infection(i + 1, j, H, W, moji);
        if( j - 1 >= 0 )infection(i, j - 1, H, W, moji);
        if( i - 1 >= 0 )infection(i - 1, j, H, W, moji);
    }
}

int main()
{
    int H, W, i, j, cnt;
    while(1){
        cnt = 0;
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;

        for(i = 0; i < H; i++){
            scanf("%s", farm[i]);
        }
        for(i = 0; i < H; i++ ){
            for(j = 0; j < W; j++){
                if(farm[i][j] == '+') continue;
                cnt++;
                infection(i, j, H, W, farm[i][j]);
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 2248
#include <stdio.h>
#include <string.h>
 
int main() {
    int change = 0;
	char str1[200002] = {0}, str2[200002] = {0};
    fgets(str1, 200002, stdin);
    fgets(str2, 200002, stdin);
    for (int i = 0; i < strlen(str1); i++) {
        if (str1[i] != str2[i]) {
            change++;
        }
    }
    printf("%d", change);
}

Measured memory_bytes: 1932
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

struct point{
	double x,y;
	point operator+(point p){
		return point{x+p.x,y+p.y};
	}
	point operator-(point p){
		return point{x-p.x,y-p.y};
	}
	point operator*(double p){
	return point{x*p,y*p};
	}
	point operator/(double p){
		if(!p) return point{0,0}; 
		return point{x/p,y/p};
	}
	bool operator==(point p){
		return fabs(x-p.x)<eps&&fabs(y-p.y)<eps;
	}
};

typedef pair<point,point> pp;
const point O{0,0};

class Geom{
	public:
	double Length(point x,point y){
		point z=y-x;
		return sqrt(z.x*z.x+z.y*z.y);
	}
	double IP(point p,point q){
		return p.x*q.x+p.y*q.y;
	}
	double CP(point p,point q){
		return p.x*q.y-q.x*p.y;
	}
	string Counter_Clockwise(pp a,point x){
		point A=a.second-a.first;
		point X=x-a.first;
		double ip=IP(A,X),cp=CP(A,X),Al=Length(O,A),Xl=Length(O,X);
		if(cp>eps) return "COUNTER_CLOCKWISE";
		if(cp<-eps) return "CLOCKWISE";
		if(ip<-eps) return "ONLINE_BACK";
		if(Xl<Al||fabs(Xl-Al)<eps) return "ON_SEGMENT";
		return "ONLINE_FRONT";
	}
	string Parallel_Orthogonal(pp a,pp b){
		point A=a.second-a.first,B=b.second-b.first;
		double ip=IP(A,B),cp=CP(A,B);
		string f=Counter_Clockwise(pp(a.first,a.second),b.first),s=Counter_Clockwise(pp(a.first,a.second),b.second);
		if(f[0]!='C'&&s[0]!='C') return "Agreement";
		if(cp<eps&&cp>-eps) return "Parallel";
		if(ip<eps&&ip>-eps) return "Orthogonal";
		else return "Commonly";
	}
	point Inter(pp  a,double x,double y){
		return (a.first*y+a.second*x)/(x+y);
	}
	point Exterior(pp a,double x,double y){
		return (a.first*-y+a.second*x)/(x-y);
	}
	point Projection(pp a,point x){
		point A=x-a.first,B=a.second-a.first;
		double l=Length(O,B);
		return B*IP(A,B)/(l*l)+a.first;
	}
	point Cross_Point(pp a,pp b){
		string s=Parallel_Orthogonal(a,b);
		if(s[0]=='A') return point{inf,inf};
		if(s[0]=='P') return point{inf,0};
		point p=Projection(a,b.first),q=Projection(a,b.second);
		double pl=Length(b.first,p),ql=Length(b.second,q);
		string S=Counter_Clockwise(a,b.first),T=Counter_Clockwise(a,b.second);
		if(S==T) return Exterior(b,pl,ql);
		else return Inter(b,pl,ql);
	}
	void Point_in(point& p){
		cin>>p.x>>p.y;
	}
	void Point_out(point p){
		cout<<p.x<<' '<<p.y<<endl;
	}
};

int Q;
vector<point> p(4);

int main(){
	cout<<syosu(10);
	Geom geo;
	cin>>Q;
	for(int i=0;i<Q;i++){
		for(int j=0;j<4;j++) geo.Point_in(p[j]);
		geo.Point_out(geo.Cross_Point(pp(p[0],p[1]),pp(p[2],p[3])));
	}
}

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

int num[6]={5,7,5,7,7};
int n;
int t[55];

bool check(int a,int s=0,int i=0){
	if(s>num[i])return false;
	if(s==num[i])i++,s=0;
	if(i==5)return true;
	if(a>=n)return false;
	return check(a+1,s+t[a],i);
}

int main(){
	int i,j,k;
	int a,b,c;
	char ca[15];
	while(cin>>n){
		if(!n)break;
		for(i=0;i<n;i++){
			cin>>ca;
			t[i]=strlen(ca);
		}
		for(i=0;i<n;i++){
			if(check(i)){
				cout<<i+1<<endl;
				break;
			}
		}
	}
}



Measured memory_bytes: 3004
#include <iostream>
#include <string>
#include <cstdio>
#include <cctype>
using namespace std;

int main(){
    char c='a';
    string s;
    while(c=getchar(), isprint(c)) s += c;
    size_t p;
    string res;
    {
        while(p=s.find("peach"), p!=string::npos){
            res += s.substr(0,p) + "@@@@@";
            s = s.substr(p+5);
        }
        s = res+s, res = "";
    }
    {
        while(p=s.find("apple"), p!=string::npos){
            res += s.substr(0,p) + "peach";
            s = s.substr(p+5);
        }
        s = res+s, res = "";
    }
    {
        while(p=s.find("@@@@@"), p!=string::npos){
            res += s.substr(0,p) + "apple";
            s = s.substr(p+5);
        }
        s = res+s, res = "";
    }
    cout << s << endl;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1000000007;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

vector<int> z_algorhythm(const string &S) {
  const int N = S.size();
  vector<int> res(N);
  res[0] = N;

  int i = 1, j = 0;
  while (i < N) {
    while (i + j < N && S[j] == S[i + j]) ++j; // j = 開始位置 i から何文字等しいか
    res[i] = j;
    if (j == 0) {++i; continue;} // 何文字も等しくなければ continue

    int k = 1;
    while (i + k < N && k + res[k] < j) {
      res[i + k] = res[k];
      ++k;
    }
    i += k, j -= k;
  }
  return res;
}

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

  int n; cin >> n;
  string s; cin >> s;

  int ans = 0;

  rep(i, n) {
    string str = s.substr(i);
    int strn = str.size();
    auto lcp = z_algorhythm(str);

    rep(j, strn) {
      chmax(ans, min(lcp[j], j));
    }
  }

  cout << ans << endl;
}


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

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  int s=0;
  rep(i,n) {
    cin>>a[i];
    s+=a[i];
  }
  sort(all(a),greater<int>());
  ans(s<=a[m-1]*(4*m));
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n,z,w;
  cin >> n >> z >> w;
  vector<int> a(n);
  for(auto& x: a) cin >> x;
  if(n == 1){
    cout << abs(a[0] - w) << endl;
  }else{
    cout << max(abs(a[n-2] - a[n-1]), abs(a[n-1] - w)) << endl;
  }
}

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


using namespace std;

pair <int, int> precalc[300300];

int main() {
    ios :: sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long remainder1 = 0;
    long long remainder2 = 0;
    int modulo = 0;
    for (auto &x : s) {
        if (x == '1') {
            modulo ++;
        }
    }
    for (auto &x : s) {
        int dig = x - '0';
        remainder1 = (remainder1 * 2LL + dig) % (modulo + 1);
        if (modulo - 1 > 0) {
            remainder2 = (remainder2 * 2LL + dig) % (modulo - 1);
        }
    }
    precalc[0] = {1, 1};
    if (modulo - 1 == 1)
        precalc[0].second = 0;
    for (int i = 1; i <= 260000; ++ i) {
        precalc[i].first = static_cast<int>(precalc[i - 1].first * 2LL % (modulo + 1));
        if (modulo - 1 > 0)
            precalc[i].second = static_cast<int>(precalc[i - 1].second * 2LL % (modulo - 1));
    }
    for (int i = 0; i < (int)s.size(); ++ i) {
        if (s[i] == '1') {
            // => modulo - 1
            if (modulo - 1 == 0) {
                cout << 0 << '\n';
            }
            else {
                int current = static_cast<int>((1LL * remainder2 - 1LL * precalc[(int)s.size() - i - 1].second +
                                                (modulo - 1LL)) % (modulo - 1));
                int op = 1;
                while (current) {
                    current %= __builtin_popcount(current);
                    op += 1;
                }
                cout << op << '\n';
            }
        }
        else {
            int current = static_cast<int>((1LL * remainder1 + 1LL * precalc[(int)s.size() - i - 1].first) % (modulo + 1));
            int op = 1;
            while (current) {
                current %= __builtin_popcount(current);
                op += 1;
            }
            cout << op << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 5804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	int n,l;
	cin>>n>>l;
	vi v(n);
	int sum=0;
	for(int i=0;i<n;i++){
		v[i]=l+i;
		sum+=v[i];
	}
	int ans=0;
	for(int i=1;i<n;i++){
		if(abs(v[i])<abs(v[ans]))ans=i;
	}
	cout<<sum-v[ans];
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3616
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
def nli(x):return [input for _ in range(x)]
def hukusuu(): 
  listA=[] #appendのために宣言が必要
  while True:
    try:listA.append(list(map(int,input().split())))
    except:break #または、quit(),os.exit()をして止める。
  return listA

n=ri()
if n%2==0:
  print(0.5)
else:
  print(((n//2)+1)/n)


Measured memory_bytes: 3064
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <string>
#include <utility>

using namespace std;

typedef enum {ROOT, LEAF, INTR} LEAF_TYPE;
string lt2str(LEAF_TYPE lt){
  switch(lt){
  case ROOT:
    return "root";
  case LEAF:
    return "leaf";
  case INTR:
    return "internal node";
  default:
    return "?";
  }
}

void dfs(int node, vector<int>& d, int depth, const vector<vector<int> > & ch){
  const vector<int>& childs = ch[node];
  d[node] = depth;
  for (int child : childs){
    dfs(child, d, depth+1, ch);
  }
}

int main(){
  int n; // 1..100000
  cin >> n;

  vector<int> v(n);
  vector<vector<int> > ch(n);
  vector<int> p(n, -1); //parent
  for(int i=0;i<n;++i){
    int id;
    cin >> id;
    int k;
    cin >> k;
    for(int j=0; j<k; ++j){
      int child;
      cin >> child;
      ch[id].push_back(child);
      p[child] = id;
    }
  }

  const int root_id = find(p.begin(), p.end(), -1) - p.begin();

  vector<int> d(n, -1);
  //dfs
  dfs(root_id, d, 0, ch);

  vector<LEAF_TYPE> l(n);
  for(int i=0; i<n; ++i){
    if(ch[i].size() == 0){
      l[i] = LEAF;
    }
    else{
      l[i] = INTR;
    }
  }
  l[root_id] = ROOT;

  //node 0: parent = -1, depth = 0, root, [1, 4, 10]

  for(int i=0; i<n; ++i){
    cout << "node " << i << ": "
	 << "parent = " << p[i] << ", "
	 << "depth = " << d[i] << ", "
	 << lt2str(l[i]) << ", "
	 << "[";
    for(int j=0; j<ch[i].size(); ++j){
      cout << (j==0 ? "": ", ") << ch[i][j];
    }
    cout << "]"
	 << endl;
    
  }


  
  //cout  << endl;
  return 0;
}

Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;


bool judge(int x){
    vector<int> v;
    while(x!=0){
        v.emplace_back(x%10);
        x = x/10;
    }
    vector<int> w = v;
    reverse(w.begin(), w.end());
    bool b=true;
    int s = v.size();
    rep(i,s){
        if(v[i]!=w[i]) {
            b=false;
            break;
        }
    }
    return b;
}


void solve(){
    int a,b;
    cin >> a >> b;
    int count = 0;
    for(int i=a; i<=b; i++){
        if(judge(i)) count++;
    }
    cout << count << endl;
}

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


Measured memory_bytes: 256
q,h,s,d=map(int,input().split())
N=int(input())
h=min(2*q,h)
s=min(2*h,s)
ans=0
if 2*s>d:
  ans+=(N//2)*d
  if N%2!=0:
    ans+=s
else:
  ans=N*s
print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0,nn=(intl)(n);i<nn;++i)
#define Rep1(i,n) for(intl i=1,nn=(intl)(n)+1;i<nn;++i)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);}
#define Input2(a,b) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);cin>>(b).at(ii);}
#define mp make_pair
#define mt make_tuple
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
using si = set<intl>;
using vsi = vec<si>;
using mii = map<intl,intl>;
using vmii = vec<mii>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;

int main(){
  intl N,M;
  cin >>N>>M;
  
  vsi path(N+1);
  intl A,B;
  Rep1(i,M){
    cin >>A>>B;
    path[A].insert(B);
    path[B].insert(A);
  }
  
  vi sign(N+1);
  vector<bool> visited(N+1,0);
  deque<intl> next;
  
  next.pub(1);
  visited[1]=1;
  
  while(!next.empty()){
    intl r = next.front();
    next.pop_front();
    for(auto&& cave : path[r]){
      if(!visited[cave]){
        next.pub(cave);
        sign[cave] = r;
        visited[cave] = 1;
      }
    }
  }
  
  cout <<"Yes"<<'\n';
  for(intl i = 2;i <= N;++i){
    cout <<sign[i]<<'\n';
  }
  
  
  
}
    
    

Measured memory_bytes: 30480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

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; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
// dp[i][j][k][b] iビット以上, j∈(0,1) yがR未満か, k∈(0, 1) xがLより大きいか, b∈(0, 1) (1, 1)が出たか
ll dp[65][2][2][2];

int main() {
    init();
    ll L, R;
    cin >> L >> R;

    vl lb(60), rb(60);
    rep(i, 60) lb[i] = L >> i & 1, rb[i] = R >> i & 1;

    dp[60][0][0][0] = 1;
    repr(i, 60) rep(j, 2) rep(k, 2) rep(b, 2) rep(y, 2) rep(x, 2){
        ll v = dp[i + 1][j][k][b], toj = j, tok = k, tob = b;

        bool skip = false;
        skip |= (x > y);
        skip |= (rb[i] == 0 and j == 0 and y == 1);
        skip |= (lb[i] == 1 and k == 0 and x == 0);
        skip |= (x != y and b == 0);
        if (skip) continue;

        if (rb[i] == 1 and j == 0 and y == 0) toj = 1;
        if (lb[i] == 0 and k == 0 and x == 1) tok = 1;
        if (x == 1 and y == 1) tob = 1;

        (dp[i][toj][tok][tob] += v) %= MOD;
    }

    ll ans = 0;
    rep(j, 2) rep(k, 2) ans += dp[0][j][k][1];

    cout << ans % MOD << endl;
}

Measured memory_bytes: 3632
def solve(K,S):
    return "".join(S) if(len(S) <= K) else "".join(S[:K]) + "..."
        
    return
def main():
    K = int(input())
    S = list(input())
    # solve()
    print(solve(K,S))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include <stdio.h>
int isprime(int n){
  for(int i = 2; i * i <= n; i++){
    if(n % i == 0)return 0 ;
  }
  return 1;
}
int main(){
  int n;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(int i = n; i > 3; i--){
      if(isprime(i) == 1 && isprime(i-2) == 1){
        printf("%d %d\n",i-2,i);
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>

using namespace std;

int main() {
        string a, b;
        cin >> a >> b;

        if (a.size()>b.size()) {
                cout << "GREATER" << endl;
        } else if (a.size()<b.size()) {
                cout << "LESS" << endl;
        } else {
                size_t i;
                for (i=0; i<a.size(); ++i) {
                        if (a[i]>b[i]) {
                                cout << "GREATER" << endl;
                                break;
                        } else if (a[i]<b[i]) {
                                cout << "LESS" << endl;
                                break;
                        } else {
                                continue;
                        }
                }
                if (i==a.size()) cout << "EQUAL" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define r_0 return 0
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;
int n , m , a[N] , x , y;
map < int , int > mp , mp1;
int main(){
    TIME
    cin >> n >> m;
    for(int i = 1 ; i <= m ; i ++){
        int k;
        string s;
        cin >> k >> s;
        if(s == "AC" && !mp1[k]){
            y += mp[k];
            x ++;
            mp1[k] = 1;
        }
        else if(s == "WA") {
            mp[k] ++;
        }
    }
    cout << x << " " << y;
}
///...


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    string s;

    cin >> s;

    for (int i = 0; i < s.size(); i++) {

        if (s[i] == '9') {

            cout << "Yes";
            return 0;
        }
    }

    cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	unsigned long long int x, n;
	cin >> x;

	if (x % 11 == 0) {
		n = 2 * (x / 11);
	}
	else if (x % 11 <= 6) {
		n = 2 * (x / 11) + 1;
	}
	else {
		n = 2 * (x / 11) + 2;
	}


	cout << n << endl;

	return 0;
}

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

int main() {
  int N;
  cin>>N;
  int p=1;
  int ans=0;
  vector<int> s(N);
  for(int i=0;i<N;i++){
    cin>>s.at(i);
  }
  while(true){
    if(s.at(p-1)==2){
      ans++;
      break;
    }
    p=s.at(p-1);
    ans++;
    if(ans>100000){
      cout<<-1<<endl;
      break;
    }
  }
  if(ans<=100000){
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int h,w;

// ll encode(int a[10][10]) {
//   ll res = 0;
//   REP(i,h)REP(j,w) res = res*3+a[i][j];
//   return res;
// }
// void decode(int a[10][10], ll e) {
//   for (int i=h-1; i>=0; --i) {
//     for (int j=w-1; j>=0; --j) {
//       a[i][j] = e%3;
//       e /= 3;
//     }
//   }
// }
typedef vector<int> vec;
typedef vector<vec> mat;

// int ba[10][10];
// int now[10][10];
// int nxt[10][10];

bool visited[10][10];

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

int ans;
void dfs(mat now, int d) {
  // cout << d << endl;
  // REP(i,h) {
  //   REP(j,w) cout << now[i][j];
  //   cout << endl;
  // }
    
  int col = now[0][0];
  queue<pii> Q;
  Q.push(pii(0,0));
  REP(i,h)REP(j,w)visited[i][j] = 0;
  visited[0][0] = 1;
  vector<pii> ps;
  bool ncol[3] = {};
  while(!Q.empty()) {
    pii p = Q.front(); Q.pop();
    ps.push_back(p);
    REP(i,4) {
      int y = p.first + dy[i];
      int x = p.second + dx[i];
      if (y<0||y>=h || x<0||x>=w)continue;
      if (now[y][x] != col) {
        ncol[now[y][x]] = 1;
        continue;
      }
      if (!visited[y][x]) {
        visited[y][x] = 1;
        Q.push(pii(y,x));
      }
    }
  }
  if (ps.size() == h*w) {
    ans = min(ans,d);
    return;
  }
  if (d == ans-1) return;
  REP(k,3) {
    if (ncol[k] == 0) continue;
    FOR(it, ps) {
      now[it->first][it->second] = k;
    }
    dfs(now, d+1);
  }
}

int main() {
  while(cin>>w>>h,h||w) {
    mat ba(h,vec(w));
    REP(i,h) {
      REP(j,w) {
        char c; cin >> c;
        if (c == 'R') ba[i][j] = 0;
        else if (c == 'G') ba[i][j] = 1;
        else ba[i][j] = 2;
      }
    }
    ans = INF;
    dfs(ba, 0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1276
#include <stdio.h>
int main(){

	int n = 0;
	int a = 0;
	int b = 0;
	int max = 0;
	int tmp = 0;

	scanf(" %d", &n);

	for (int i = 1; i < n+1; i++){
		a = i;
		b = 0;
		while (1){
			if (a % 2 != 0){
				//printf("%d\n", b); 
				break;
			}
			else{
				a /= 2;
				b++;
				//printf("%d\n", b);
			}
			
		}
		if (max <= b){
			max = b;
			tmp = i;
		}
	}
	printf("%d",tmp);
	return 0;
}

Measured memory_bytes: 128
#pragma comment(linker, "/STACK:256000000")
#pragma GCC optimize("O3")

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <assert.h>
#include <set>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <random>
#include <map>
#include <bitset>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair

#define X first
#define Y second

using namespace std;

mt19937 rng(time(NULL));

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
using vb = vector<bool>;

const ll MOD = 1000000007;

ll sqr(ll a) {
	return a * a;
}

ll powmod(ll a, ll x, ll p = MOD) {
	if (x <= 0) return 1;
	if (x % 2 == 0) return sqr(powmod(a, x >> 1, p)) % p;
	else return (a * powmod(a, x - 1, p)) % p;
}

ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}


int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string s;
	cin >> s;

	int n = sz(s) + 1;

	vector<int> growing(n), shrinking(n);

	for (int i = 1; i < n; i++) {
		if (s[i - 1] == '<') growing[i] = growing[i - 1] + 1;
	}

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') shrinking[i] = shrinking[i + 1] + 1;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) ans += max(growing[i], shrinking[i]);
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4764
parseInt(x) = parse(Int, x)

function main()
	n = readline() |> parseInt
	v = map(parseInt, split(readline()))
	od = Dict{Int,Int}()
	ed = Dict{Int,Int}()
	for i in 1:2:n
		if haskey(od,v[i])
			od[v[i]] += 1
		else
			od[v[i]] = 1
		end
	end
	for i in 2:2:n
		if haskey(ed,v[i])
			ed[v[i]] += 1
		else
			ed[v[i]] = 1
		end
	end
	co = sort(collect(od), by=x->x[2], rev=true)
	ce = sort(collect(ed), by=x->x[2], rev=true)
	if co[1][1] == ce[1][1]
		if length(ce) == 1 && length(co) == 1
			print(n-co[1][2])
		elseif length(ce) == 1
				print(min(n-co[1][2],n-ce[1][2]-co[2][2]))
		elseif length(co) == 1
			print(min(n-ce[1][2],n-co[1][2]-ce[2][2]))
		else
			print(min(n-co[1][2]-ce[2][2],n-co[2][2]-ce[1][2]))
		end
	else
		print(n-co[1][2]-ce[1][2])
	end
end

main()

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n){
    cin >> x[i];
  }
  int sum = 100100100;
  rep(i, 100){
    int hp, hpsum = 0;
    rep(j, n){
    hp = (x[j] - (i + 1)) * (x[j] - (i + 1)); 
    hpsum += hp;
    }
    if(hpsum < sum){
      sum = hpsum;
    }
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;

ll n, k;

vector<ll> vc;

ll dp[305][305][305];

ll rec(ll idx, ll kk, ll lst) {
  if (kk > k) return (ll) 1e12;
  if (idx == n) return 0;
  ll &ans = dp[idx][kk][lst];
  if (ans != -1) return ans;
  ans = (ll) 1e13;
  ans = min(ans, rec(idx+1, kk+1, lst));
  if (vc[lst] < vc[idx]) {
    ans = min(ans, vc[idx]-vc[lst]+rec(idx+1, kk, idx));
  } else ans = min(ans, rec(idx+1, kk, idx));
  return ans;
}

int main() {
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  cin >> n >> k;
  vc.resize(n);
  for (ll i = 0; i < n; i++) {
    cin >> vc[i];
  }
  vc.pb(0);
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, n) << endl;
  return 0;
}


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

int n, K, cnt;

int main() {
    cin >> n >> K;
    while (n) n /= K, cnt++;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << '\n';
    return 0;
}

Measured memory_bytes: 3576
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    string N;

    cin >> N;

    if(N.find("7") != std::string::npos) {
        cout << "Yes";
    } else {
        cout << "No";
    }


    

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  vector<i64> p(N);
  rep(i,0,N - 1) cin >> p[i];
  i64 a = 0,b = 0,c = 0;
  for(auto x : p) {
    if(x <= A) a++;
    else if(x <= B) b++;
    else c++;
  }

  cout << min({a,b,c}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        long long x, y;
        cin >> x >> y;
        a[i] = x + y;
        b[i] = x - y;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    cout << max(a[n - 1] - a[0], b[n - 1] - b[0]) << '\n';
    return 0;
}

Measured memory_bytes: 6368
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll N, M; cin >> N >> M;
    ll ans = (M <= 2 * N ? M / 2 : N + (M - 2 * N) / 4);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
#pragma endregion

const lint INF = 10000000000000000;
const int mod = 1000000007;
int n, m;
struct Edge {
	int to;
	int cost;
};
vector<pair<int, int>> r;
vector<int> d;
vector<vector<Edge>> c;

void dfs(int a, vector<int> &ans) {
	for (int i = 0; i < c[a].size(); i++) {
		if (ans[c[a][i].to] != mod) continue;
		ans[c[a][i].to] = ans[a] + -c[a][i].cost;
		dfs(c[a][i].to, ans);
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	r.resize(m);
	d.resize(m);
	c.resize(n);
	for (int i = 0; i < m; i++) {
		cin >> r[i].first >> r[i].second >> d[i];
		r[i].first--; r[i].second--;
		c[r[i].first].push_back({ r[i].second, d[i] });
		c[r[i].second].push_back({ r[i].first, -d[i] });
	}
	vector<int> ans(n, mod);
	for (int j = 0; j < n; j++) {
		if (ans[j] == mod) 
			ans[j] = 0;
		dfs(j, ans);
	}
	bool h = true;
	for (int i = 0; i < m; i++) {
		if (ans[r[i].first] - ans[r[i].second] != d[i]) h = false;
	}
	if (h) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 17152
import java.io.*;

class Tranp{
    private int[][] card;
    public Tranp(){
	card=new int[4][];
	for(int i=0;i<4;i++) card[i]=new int[13];
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
		    card[i][j]=0;
		}
	}
    }
    public void markcard(String mark,int num){		   	
	if(mark.equals("S")) card[0][num-1]++;
	else if(mark.equals("H")) card[1][num-1]++;
	else if(mark.equals("C")) card[2][num-1]++;	
	else if(mark.equals("D")) card[3][num-1]++;
    }

    public void printcard(){
	for(int i=0;i<4;i++){
	    for(int j=0;j<13;j++){
		if(card[i][j]==0){
		    if(i==0) System.out.println("S " + (j+1));
		    else if(i==1) System.out.println("H " + (j+1));
		    else if(i==2) System.out.println("C " + (j+1));
		    else if(i==3) System.out.println("D " + (j+1));
		}
	    }
	}
    }
    
}    
class Main{
    public static void main(String[] args)throws IOException{
	final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	final Tranp tr=new Tranp();
	
	String str=br.readLine();
	int n=Integer.parseInt(str);
	for(int i=0;i<n;i++){
	    String[] st=br.readLine().split(" ");
	    String mark=st[0];
	    int num=Integer.parseInt(st[1]);
	    tr.markcard(mark,num);
	}
	tr.printcard();
    }
}

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

int main() {
  int a,b,c,d,n;
  cin >> n;
  
  a = n / 1000;
  b = (n - a * 1000) / 100;
  c = (n - a * 1000 - b * 100) / 10;
  d = n- a * 1000 - b * 100 - c * 10;

  if (a == b && b == c) {
	cout << "Yes" << endl;
  } else if (b == c && c == d) {
	cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll d,n,i,f=0,s=0;
	d=1000000007;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	for(i=0;i<n-1;i++)
	{
		s=s-a[i];
		f+=a[i]*(s%d)%d;
		f=f%d;
	}
	cout<<f<<endl;
	return;
	
}






int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int t=1;
	//cin >> t;

	while (t--)
	{
		solve();
	}


	return 0;
}


Measured memory_bytes: 5200
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL N, S;

bool isS(LL x,LL p) {

	
	LL pow = 1;
	while (pow*p <= x) {
		pow *= p;
	}

	LL sum = 0;
	while (x > 0) {
		sum += x / pow;
		x = x % pow;

		pow /= p;
	}


	return S == sum;
}

LL func(LL b, LL n)
{
	if (n == 0)return 0;
	return func(b, n / b) + (n % b);
}


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

	if (N < S) {
		cout << "-1" << endl;
		return 0;
	}
	
	if (N == S) {
		cout << N + 1 << endl;
		return 0;
	}

	LL ans = INF2;
	for (LL i = 2; i*i <=N; i++) {
		if (isS(N, i)) {
			ans = min(ans, i);
		}
	}

	if (ans != INF2) {
		cout << ans << endl;
		return 0;
	}

	LL D = N - S;
	for (LL p = 1; p*p <= N; p++) {


		if (D%p==0 && D/p!=0) {
			

			LL b = (N - S) / p + 1;

			if (func(b, N) == S) {
				ans = min(ans, b);
			}
			
		}
	}

	if (ans == INF2) {
		cout << "-1" << endl;
		return 0;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;

int main() {
    ios::sync_with_stdio(false);

    int k;
    cin >> k;
    int x, y;
    cin >> x >> y;

    bool px = true, py = true;
    if (x < 0) {
        x = -x;
        px = false;
    }
    if (y < 0) {
        y = -y;
        py = false;
    }

    if (k % 2 == 0 && (x + y) % 2 != 0) {
        cout << -1 << endl;
        return 0;
    }

    vp ans;
    int cx = 0, cy = 0;
    ans.push_back({0, 0});

    while (cx + k <= x) {
        cx += k;
        ans.push_back({cx, cy});
    }
    while (cx + cy + k <= x + y) {
        cy += k - (x - cx);
        cx += x - cx;
        ans.push_back({cx, cy});
    }

    if (cx != x || cy != y) {
        if (k % 2 == 1 && (x - cx + y - cy) % 2 == 1 || k % 2 == 0) {
            if (ans.size() >= 2) {
                ans.pop_back();
                cx = ans.back().first;
                cy = ans.back().second;
            }
        }

        if (k % 2 == 1 && (x - cx + y - cy) % 2 == 1) {
            cy -= k - (x - cx);
            cx = x;
            ans.push_back({cx, cy});
        }

        int d = (k + k - (x - cx + y - cy)) / 2;
        if (x - cx < y - cy) {
            cy += k - (x - cx + d);
            cx += x - cx + d;
            ans.push_back({cx, cy});
            cx -= d;
            cy += k - d;
            ans.push_back({cx, cy});
        } else {
            cx += k - (y - cy + d);
            cy += y - cy + d;
            ans.push_back({cx, cy});
            cx += k - d;
            cy -= d;
            ans.push_back({cx, cy});
        }
    }

    cout << ans.size() - 1 << endl;
    for (int i = 1; i < ans.size(); i++) {
        cout << ans[i].first * (px ? 1 : -1) << " " << ans[i].second * (py ? 1 : -1) << endl;
    }

    return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n, k, q;
	cin >> n >> k >> q;
	V<int> a(q);
	RBF(i, a) {
		cin >> i;
	}

	V<int> maru(n, 0);
	RBF(i, a) {
		maru[i - 1]++;
	}

	RBF(i, maru) {
		int life = k - q + i;
		if (life > 0) {
			col("Yes");
		}
		else {
			col("No");
		}
	}
	return 0;
}

Measured memory_bytes: 3968
use std::io;
use std::cmp;
use std::collections::BTreeMap;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    
    let n = read_t_in_line::<i32>()[0];
    let a = read_t_in_line::<i32>();

    let mut h = BTreeMap::new();
    
    for x in a {
        if !h.contains_key(&x) {
            h.insert(x, 1);
        }
        else {
            *h.get_mut(&x).unwrap() += 1;
        }
    }


    let mut edge = vec![];
    for (k, v) in h.iter().rev() {
        let mut cnt = *v;
        if cnt >= 2 {
            edge.push(*k);
            cnt -= 2;
        }
        if cnt >= 2 {
            edge.push(*k);
        }
        if edge.len() >= 2 {
            break;
        }
    }

    let mut ans = 0 as i64;
    if edge.len() >= 2 {
        ans = (edge[0] as i64) * (edge[1] as i64);
    }

    println!("{}", ans);

}


Measured memory_bytes: 10740
#include<iostream>
#include<vector>
using namespace std;
struct tree{
    vector<int> par;
    tree(int n):par(n){
        for(int i=0;i<n;i++){
            par[i] = i;
        }
    }
    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    tree ut(n);
    for(int i=0;i<m;i++){
        int x,y,z;cin >> x >> y>>z;x--;y--;
        ut.unite(x,y);
    }
    bool par[n];
    for(int i=0;i<n;i++){
        par[i] = false;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(par[ut.root(i)]){

        }
        else{
            ans ++;
            par[ut.root(i)] = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for(int i = 0; i < n - 1; i++){
    if(s[i] != s[i+1]){
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int res = n;
  for(int i=0;i+1<n;++i){
    if (s[i]!=s[i+1]){
      res = min(res, max(i+1,n-i-1));
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 512
#include "assert.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <vector>

using namespace std;

#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int, int> PII;
mt19937 mrand(random_device{}());

inline int in() {
  char ch = getchar();
  int f = 1, x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return f * x;
}

const int inf = (1 << 30);
const int mod = 998244353;
const int N = 100010;

LL cnt[50][30];

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
  // freopen("out.out", "w", stdout);
#endif
  int n = in();
  int tmp = 1e9, A = 0, B = 0;
  while (tmp % 2 == 0)
    ++A, tmp /= 2;
  while (tmp % 5 == 0)
    ++B, tmp /= 5;
  cerr << A << " " << B << endl;
  LL ans = 0;
  rep(_, 1, n) {
    double x;
    cin >> x;
    LL tmp = llround(x * 1e9) ;
    int a = 0, b = 0;
    while (tmp % 2 == 0)
      ++a, tmp /= 2;
    while (tmp % 5 == 0)
      ++b, tmp /= 5;
    rep(i, 0, 49) rep(j, 0, 29) {
      if (i + a >= A * 2 && j + b >= B * 2)
        ans += cnt[i][j];
    }
    cnt[a][b]++;
    cerr << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3748
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
typedef pair<int,int> P;

signed main(){
	int n,W;
	cin>>n>>W;
	vector<int> w(n),v(n);
	rep(i,n) cin>>w[i]>>v[i];
	int M=w[0]-1;
	rep(i,n) w[i]-=M;
	int a=min(1LL*400,W);
	
	vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(a+1,vector<int>(n+1,0)));
	int ans=0;
	rep(i,n){ 
		rep(j,a+1){
			if(j-w[i]>=0){
				rep(k,n){
					int p=dp[i][j-w[i]][k];
					dp[i+1][j][k+1]=max(dp[i][j][k+1],p+v[i]);
				}
			}
			else dp[i+1][j]=dp[i][j];
			//cout<<dp[i+1][j].first<<" \n"[j==a];
		}
		rep(j,a+1) rep(k,n+1){
			if(W-k*M-j>=0) ans=max(dp[n][j][k],ans);
		}
	}
	cout<<ans<<endl;
}

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

int gcd(int a, int b){
  if(b==0)return a;
  else return gcd(b, a%b);
}

int main(){
  int k;
  cin >> k;
  int ret = 0;
  vector<vector<vector<int>>>memo(k+1, vector<vector<int>>(k+1, vector<int>(k+1, -1)));
  for(int i=0; i<=k; i++)for(int j=0; j<=k; j++)for(int l=0; l<=k; l++){
    int mn = min({i, j, l});
    int mx = max({i, j, l});
    int md = i+j+l-mn-mx;
    if(mn==i && mx==l)memo[i][j][l]=gcd(gcd(i, j), l);
    else memo[i][j][l]=memo[mn][md][mx];
  }
  /*for(int i=0; i<=k; i++)for(int j=0; j<=k; j++)for(int l=0; l<=k; l++){
    cerr << i << ' ' << j << ' ' << l << ' ' << ": " << memo[i][j][l] << endl;
  }*/
  for(int i=1; i<=k; i++)for(int j=1; j<=k; j++)for(int l=1; l<=k; l++){
    ret += memo[i][j][l];
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 36336