akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

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

    int H, W;
    cin >> H >> W;
    vector<string> map(H);
    for (int i = 0; i < H; i++)
    {
        string M;
        cin >> M;
        map.at(i) = M;
    }
    vector<int> dh = {-1, 1, 0, 0};
    vector<int> dw = {0, 0, -1, 1};
    queue<pi> moves;
    //全マスを起点で全探索
    int answer = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(map.at(i).at(j) == '#'){
                continue;
            }
            vector<vector<int>> moveCount(H, vector<int>(W, -1));
            moves.push(make_pair(i, j));
            moveCount.at(i).at(j) = 0;
            while(moves.size()){
                pi move = moves.front();
                moves.pop();
                int curH, curW;
                tie(curH, curW) = move;
                int count = moveCount.at(curH).at(curW);
                answer = max(answer, count);
                int nextH, nextW;
                for(int k = 0; k < 4; k++){
                    nextH = curH + dh.at(k);
                    nextW = curW + dw.at(k);
                    if(0 <= nextH && nextH < H
                    && 0 <= nextW && nextW < W                    
                    && map.at(nextH).at(nextW) == '.' 
                    && moveCount.at(nextH).at(nextW) == -1){
                        moves.push(make_pair(nextH, nextW));
                        moveCount.at(nextH).at(nextW) = count + 1;
                    }
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

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

int main(){
	double d,w,h;
	while(~scanf("%lf %lf %lf",&d,&w,&h)){
		if(d==w && w==h && h==0) break;
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			double r;
			scanf("%lf",&r);
			if((d/2.0)*(d/2.0) + (h/2.0)*(h/2.0) < r*r
				|| (d/2.0)*(d/2.0) + (w/2.0)*(w/2.0) < r*r
				|| (w/2.0)*(w/2.0) + (d/2.0)*(d/2.0) < r*r
				|| (w/2.0)*(w/2.0) + (h/2.0)*(h/2.0) < r*r
				|| (h/2.0)*(h/2.0) + (d/2.0)*(d/2.0) < r*r
				|| (h/2.0)*(h/2.0) + (w/2.0)*(w/2.0) < r*r)
			{
				cout << "OK" << endl;
			}
			else{
				cout << "NA" << endl;
			}
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll r; cin >> r;
    cout << r - min(ll(0), 100*(n-10)) << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int n;
	int v[220];
	int ans=0;
	bool b=1;
	cin >> n;
	TFOR(i, n) { cin >> v[i]; if (v[i] % 2 != 0)b = 0; }
	while (b) {
		++ans;
		TFOR(i, n) {
			v[i] /= 2;
			if (v[i] % 2 != 0)b = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

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

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

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

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

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

  int x;cin >> x;
  cout << 1 - x << '\n';
}


Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <functional>

int main(void){
	int n, m;

	while(1){
		int result[100];
		int sortedInd[100];
		for(int i=0; i < 100; i++){
			result[i] = 0;
		}
		std::cin >> n >> m;
		if(n == 0 && m == 0)	return 0;

		for(int i=0; i < n; i++){
			for(int j=0; j < m; j++){
				int temp;
				std::cin >> temp;
				if(temp == 1){
					result[j]++;
				}
			}
		}

		for(int i=0; i < m; i++){
			int max = -1, ind;
			for(int j=0; j < m; j++){
				if(max < result[j]){
					ind = j;
					max = result[j];
				}
			}
			result[ind] = -1;
			sortedInd[i] = ind;
		}

		for(int i=0; i < m; i++){
			if(i == m-1){
				std::cout << sortedInd[i] + 1 << std::endl;
			}else{
				std::cout << sortedInd[i] + 1 << " ";
			}
		}
	}
}

Measured memory_bytes: 1160
N, M =  map(int, input().split(' '))
def gcd(a, b):
    a, b = (a, b) if a >= b else (b, a)
    while b > 0:
        a, b = b, a % b
    return a

S = input()
T = input()
g = gcd(N, M)
#print('gcd',g)
#print('',N//g,M//g)
#print(S[0::N//g] ,T[0::M//g])
if S[0::N//g] == T[0::M//g]:
    print(N*M//g)
else:
    print(-1)

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

using namespace std;


#define MAXN 100002
typedef long long ll;
ll sum[MAXN];
int r[MAXN], lo[MAXN], hi[MAXN];
int x, k;
void solve(int t, int a) {
  int i = upper_bound(r+1, r+k+2, t) - r - 1;
  int ans = (i%2 ? 1 : -1)*(t-r[i]);
  if (a<=lo[i]-sum[i]) {
    ans += lo[i];
  } else if (a<=hi[i]-sum[i]) {
    ans += sum[i] + a;
  } else {
    ans += hi[i];
  }
  cout << min(max(ans, 0), x) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> x >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> r[i];
    sum[i] += sum[i-1] + ((i%2) ? -1 : 1)*(r[i]-r[i-1]);
  }
  r[k+1] = 2e9;
  hi[0] = x;
  for (int i = 1; i <= k+1; ++i) {
    if (i%2) {
      lo[i] = max(0, lo[i-1]-r[i]+r[i-1]);
      hi[i] = max(0, hi[i-1]-r[i]+r[i-1]);
    } else {
      lo[i] = min(x, lo[i-1]+r[i]-r[i-1]);
      hi[i] = min(x, hi[i-1]+r[i]-r[i-1]);
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int t, a;
    cin >> t >> a;
    solve(t, a);
  }
  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    int max, mid, min, ptr;
    
    scanf("%d %d %d", &a, &b, &c);
    
    max = a;
    mid = b;
    min = c;
    
    if (max < mid) {
        ptr = max;
        max = mid;
        mid = ptr;
    }
    if (mid < min) {
        ptr = mid;
        mid = min;
        min = ptr;
    }
    if (max < mid) {
        ptr = max;
        max = mid;
        mid = ptr;
    }
    
    printf("%d %d %d\n", min, mid, max);
    
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
      if (num % i == 0){
        // 素数ではない
        return false;
      }
    }
    // 素数である
    return true;
}

int main()
{
  int n;
  int count = 0;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    if (IsPrime(A[i])) count++;
  }
  std::cout << count << endl;
  return 0;
}



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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;
const ll TREE_SIZE = 100100;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);

class Unionfind {
    public:
        vector<ll> par, siz, rank;
        Unionfind();
        ll root(ll x);
        void merge(ll x, ll y);
        bool issame(ll x, ll y);
        ll size(ll x);
};

int main() {
    ll n, m, ans = 0; cin >> n >> m;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];

    Unionfind t;
    rep(i, m) {
        ll x, y; cin >> x >> y;
        t.merge(x, y);
    }

    rep(i, n) {
        if(t.issame(p[i], i+1)) ans++;
    }

    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}

Unionfind::Unionfind() {
    par.resize(TREE_SIZE);
    siz.resize(TREE_SIZE);
    rank.resize(TREE_SIZE);
    rep(i, TREE_SIZE) {
        par[i] = i;
        siz[i] = 1;
        rank[i] = 0;
    }
}
ll Unionfind::root(ll x) {
    if(par[x] == x) return x;
    else {
        return par[x] = root(par[x]);
    }
}
void Unionfind::merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
        par[x] = y;
        siz[y] += siz[x];
    }
    else {
        par[y] = x;
        siz[x] += siz[y];
        if(rank[x] == rank[y]) rank[x]++;
    }
}
bool Unionfind::issame(ll x, ll y) {
    return root(x) == root(y);
}
ll Unionfind::size(ll x) {
    return siz[root(x)];
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	int l,a,b,c,d;
	int md,jd;
	cin>>l>>a>>c>>b>>d;
	jd=(a+b-1)/b;
	md=(c+d-1)/d;
	cout<<l-max(jd,md)<<"\n";
	return 0;
}

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

using namespace std;

int count[26];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, p;
    cin>>s>>p;
    s += s;
    if(s.find(p, 0) != string::npos) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

int fff(double x){
	if(x==(int)x){return 3;}
	else if(x*10==(int)(x*10)){return 2;}
	else if(x*100==(int)(x*100)){return 1;}
	else if(x*1000==(int)(x*1000)){return 0;}
}

int main(){
	double k[60000]={0};
	int i=0;
	while(cin>>k[i++]);
	int n=i-1;
	for(int j=0;j<n;j+=6){
		double x=0,y=0,a=k[j],b=k[j+1],c=k[j+2],d=k[j+3],e=k[j+4],f=k[j+5];
		x=(c*e-b*f)/(-b*d+a*e);
		y=(c*d-a*f)/(b*d-a*e);
		if(x==0)x=abs(x);
		if(y==0)y=abs(y);
		x*=1000,x=round(x),x/=1000;
		y*=1000,y=round(y),y/=1000;
		cout<<x;int fx=fff(x);
		if(fx==3){cout<<".000 ";}
		if(fx==2){cout<<"00 ";}
		if(fx==1){cout<<"0 ";}
		if(fx==0){cout<<" ";}
		cout<<y;int fy=fff(y);
		if(fy==3){cout<<".000";}
		if(fy==2){cout<<"00";}
		if(fy==1){cout<<"0";}
		cout<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a[300000];
	int n,s=0,x=-2,y,z=0;
	cin>>n;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    if(a[i]=='E') s++;
	    else s--;
	    if(x<s){
	        x=s;
	        y=i;
	    }
	}
	for(int i=0;i<n;i++){
	    if((i<y&&a[i]=='W')||(i>y&&a[i]=='E')) z++;
	}
	cout<<z<<endl;
	return 0;
}



Measured memory_bytes: 512
s = int(input())
a = [s]
i = 1
while True:
  if a[i-1]%2==0:
    if a[i-1]/2 in a:
      break
    else:
      a.append(a[i-1]/2)
  else:
    if 3*a[i-1]+1 in a:
      break
    else:
      a.append(3*a[i-1]+1)
  i += 1

print(i+1)

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

int main(){
  int N; cin >> N;
  vector<pair<string,int>> M;
  for (int w = 0; w < N; w++) {
    string s; int t;
    cin >> s >> t;
    M.push_back({s,t});
  }
  string X; cin >> X;
  int total = 0;
  bool start = false;
  for (int i = 0; i < N; i++) {
    if (start) total += M[i].second;
    else if (M[i].first == X) start = true;
  }
  cout << total << endl;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    if(A != 1 && B != 1){
        cout << 1 << endl;
    }
    else if(A != 2 && B != 2){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include<bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)

#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define mclr(strn) strn.clear()
#define ignr cin.ignore()
#define PB push_back
#define SZ size
#define MP make_pair
#define fi first
#define sec second

std::vector<int> all, x[2];
set<int> v[2];
int N;

int main()
{
	int i, j;

	cin >> N;

	fl(i,0,N)
	{
		int temp;
		cin >> temp;

		if(i & 1)
			v[1].insert(temp);
		else
			v[0].insert(temp);
		all.PB(temp);
	}

	sort(all.begin(), all.end());

	fl(i,0,all.SZ())
	{
		if(i&1)
			x[1].PB(all[i]);
		else
			x[0].PB(all[i]);
	}

	int ans = 0;
	
	fl(i,0,x[0].SZ())
	{
		if(v[0].find(x[0][i]) == v[0].end())
		{
			ans++;
			// cout<<x[0][i]; nline;
		}
	}

	// fl(i,0,x[1].SZ())
	// {
	// 	if(v[1].find(x[1][i]) == v[1].end())
	// 	{
	// 		// cout<<x[1][i]; nline;
	// 	}
	// }

	cout<<ans;
	


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 6008
#include<iostream>
#include<algorithm>

using P = std::pair<int, int>;

int n;

P dolls[200];

int dp[200];

int main() {
	while (1) {
		int m;
		std::cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; ++i)
			std::cin >> dolls[i].first >> dolls[i].second;
		std::cin >> m;
		for (int i = n; i < n + m; ++i)
			std::cin >> dolls[i].first >> dolls[i].second;
		n += m;
		std::sort(dolls, dolls + n);
		std::fill(dp, dp + n, 1);
		for (int i = 1; i < n; ++i) {
			for (int j = i - 1; j >= 0; --j) {
				if (dolls[i].first > dolls[j].first&&
					dolls[i].second > dolls[j].second) {
					dp[i] = std::max(dp[j] + 1, dp[i]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; ++i)
			ans = std::max(ans, dp[i]);
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int min = 1000000000;
    int max = 0;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        if (min > a) { min = a; }
        if (max < a) { max = a; }
    }
    cout << max - min << endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#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 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 fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    LL N,M;
    cin >> N >> M;
    LL amari=(int) pow(10,9)+7;
    LL num=0;
    LL num_max=max(M,N);
    LL num_min=min(N,M);
    LL res=1;
    LL LEVEL=num_max+num_min;
    if(num_max==num_min+1){
        num=1;
        while(num_max>0){
            num=num*num_max%amari;
            --num_max;
        }
             while(num_min>0){
            num=num*num_min%amari;
            --num_min;
        }
    }
    else{
            if(num_max==num_min){
        num=1;
        while(num_max>0){
            num=num*num_max%amari;
            --num_max;
        }
             while(num_min>0){
            num=num*num_min%amari;
            --num_min;
        }
        num=num*2%amari;
    }
    }
    cout << num;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B_001_60
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //new Logic_A().Start();
            new Logic_B().Start();
            //Console.ReadLine();
        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var a = Convert.ToInt32(str[0]);
                var b = Convert.ToInt32(str[1]);
                var c = Convert.ToInt32(str[2]);

                var boolList = new int[b];

                for (int i = 0; i < a * b; i++)
                {
                    var mod = a * i % b;
                    if (mod == c)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    else
                    {
                        boolList[mod] = 1;
                    }

                    if (boolList.Where(n => n == 1).Count() == b - 1)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
                Console.WriteLine("NO");
            }
        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var a = str[0];
                var b = str[1];
                var c = str[2];

                if (a.Last() == b.First() && b.Last() == c.First())
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

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

int main()
{
	string str;
	int ans = 0;

	cin >> str;
	for (int i = 0; i < (str.length() / 2); i++)
	{
		if (str[i] != str[(str.length() - 1) - i])
		{
			ans++;
		}
	}

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

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


#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

string shuffle(string merry)
{
	char temp[8];
	rep(i,8) temp[i] = merry[i];
	merry[0] = temp[7];
	REP(i,1,8) merry[i] = temp[i-1];
	return merry;
}


int main()
{
	string merry = "41412121";
	int a[8];
	
	while(cin >> a[0])
	{
		REP(i,1,8)
		{
			cin >> a[i];
		}

		
		vector<int> counter;
		int max_count = 0;
		rep(i,8)
		{
			int count = 0;
			rep(j,8)
			{
				if(merry[j] - '0' >= a[j])
				{
					count += a[j];
				}
				else
				{
					count += merry[j] - '0';
				}
			}

			counter.push_back(count);
			max_count = max(max_count,count);

			merry = shuffle(merry);
		}

		vector<string> ans;
		rep(i,8)
		{
			if(counter[i] == max_count)
			{
				rep(j,i)
				{
					merry = shuffle(merry);
				}
				ans.push_back(merry);
				merry = "41412121";
			}
		}

		string min_ans = ans[0];
		rep(i,ans.size())
		{
			min_ans = min(min_ans,ans[i]);
		}

		
		rep(i,8)
		{
			if(i == 7)
			{
				cout << min_ans[i] << endl;;
			}
			else
			{
				cout << min_ans[i] << " ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>

using namespace std;

int main(){
    int s;
    int x = 0;
    
    cin >> s;
    x = x + (s / 100);
    s = s % 100;
    x = x + (s / 10);
    s = s % 10;
    x = x + s;
    cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
    public class Main {
    	public static void main(String[] args){
    		Scanner as = new Scanner(System.in);
    		int a = as.nextInt();
int b = as.nextInt();
int c = as.nextInt();
int d = as.nextInt();
if(a*b>c*d){
System.out.println(a*b);
}else{
    		System.out.println(c*d);
}
    	}
    }

Measured memory_bytes: 9680
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, int64_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, int64_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr int64_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<string> s(N);
    for (auto &si: s) cin >> si;

    unordered_map<string, bool> exist;
    exist[s[0]] = true;
    for (size_t i = 1; i < N; ++i) {
        if (s[i][0] != s[i - 1].back()) {
            return cout << "No" << "\n", 0;
        }
        if (exist[s[i]]) {
            return cout << "No" << "\n", 0;
        }
        exist[s[i]] = true;
    }

    cout << "Yes" << "\n";

    return 0;
}


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

int main() {
 int N, A;
  cin >> N ;
  A = N/100000000+N%100000000/10000000+N%10000000/1000000+N%1000000/100000+N%100000/10000+N%10000/1000+N%1000/100+N%100/10+N%10;
  if(N%A == 0){
  cout<< "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    ll N, K; cin >> N >> K;
    ll h[100100]; REP(i, N) cin >> h[i];

    ll ans = 0;
    REP (i, N) {
        if (h[i] >= K) ++ans;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lld         long long int
#define llf         long double
#define pb          push_back
#define mp          make_pair
#define IN          insert
#define loopN(n)    for(lld i=0;i<n;i++)
#define loop(p,n)   for(lld i=p;i<=n;i++)
#define rloop(p,n)  for(lld i=n;i>=p;i--)
#define loop2(p,n)  for(lld j=p;j<=n;j++)
#define all(v)      v.begin(),v.end()
#define F1          first
#define F2          second
#define INF         2e18
#define FILE        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define PI          2*acos(0.0)
#define ISO         ios::sync_with_stdio(false);cin.tie(0)
#define mem(a,b)    memset(a,b,sizeof(a))
#define case(z)     cout<<"Case "<<z<<": ";
using namespace std;
const lld mod=1e9+7;

lld n;
lld a[100005];
lld dp[100005];

lld fun(lld p)
{

    if(p==n-1)
    {
        return 0;
    }
    if(p==n-2)
    {
        return abs(a[p]-a[p+1]);
    }
    if(dp[p]!=-1)
    {
        return dp[p];
    }
    return dp[p]=min(abs(a[p]-a[p+2])+fun(p+2),abs(a[p]-a[p+1])+fun(p+1));


}

int main()
{
    ISO;

    //lld t;cin>>t;while(t--)
    mem(dp,-1);
    cin>>n;
    loopN(n)cin>>a[i];
    cout<<fun(0)<<endl;

    return 0;
}



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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int s = A*10+B+C;
  int t = A+B*10+C;
  int u = A+B+C*10;
  if(s>=t && s>=u){
    cout << s << endl;
  }
  else if(t>=s && t>=u){
    cout << t << endl;
  }
  else{
    cout << u << endl;
  }
}


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

int main()
{
  bool is_prime[1000000];
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<1000000; i++){
    is_prime[i] = true;
  }

  for(int i=2; i*i<1000000; i++){
    if(is_prime[i]){
      for(int j=i*i; j<1000000; j+=i){
        is_prime[j] = false;
      }
    }
  }

  while(1){
    int n;
    cin >> n;

    if(cin.eof())
      break;

    int i=n-1, j=n+1;
    while(1){
      if(is_prime[i]){
        break;
      }
      i-=1;
    }

    while(1){
      if(is_prime[j])
        break;
      j++;
    }
    cout << i << ' ' << j << endl;
  }
  return 0;
}



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

int main() {
    int n; cin >> n;
    set<int> s;
    while (n--) {
        int a; cin >> a;
        if (s.count(a)) s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=1e6+1;
int n,m;
int a[N],b[N];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	if(n%2==0){
		int l=1,r=n/2;
		int p=0;
		while(l<r){
		//	cout << l << ' ' <<r  << endl;
			++p;
			a[p]=l;b[p]=r;
			l++;r--;
		}
		l=n/2+1;r=n-1;
		while(l<r){
			++p;
			a[p]=l;b[p]=r;
			l++;r--;
		}
	}
	else{
		for(int i=1; i<=n/2 ;i++){
			a[i]=i;b[i]=n-i+1;
		}
	}
	cin >> m;
	for(int i=1; i<=m ;i++) cout << a[i] << ' ' << b[i] << '\n';
}

Measured memory_bytes: 4252
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            int k = s.nextInt();
            int a = s.nextInt();
            int b = s.nextInt();
            int mod = a % k;
            int d = b - a;
            System.out.println((mod == 0 || (k - mod) <= d) ? "OK" : "NG");
        }
    }
}


Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll m,n;
  cin >> m >> n;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n);
  ll ans=0;
  rep(i,n-1) ans=max(ans,a[i+1]-a[i]);
  ans=max(ans,m-a[n-1]+a[0]);
  pr(m-ans);
}

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


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
using namespace std;

struct counts{
    string str;
    int count;
};

void solve() {
    int n; cin >> n;
    unordered_map<string, int> s;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        string tmp; cin >> tmp;
        sort(tmp.begin(), tmp.end());
        auto itr = s.find(tmp);
        if(itr != s.end()){
            sum += itr->second;
            itr->second++;
        } else {
            s.emplace(tmp, 1);
        }
    }
    cout << sum << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 10660
#include <stdio.h>
#include <string.h>

int main(void)
{
    int board[102][102];
    int w, h;
    int xs, ys, xg, yg;
    int c, d, x, y;
    int n;
    int i, j;
    int flag;
    int c2;    
    while (1){
        scanf("%d%d", &w, &h);
        if (w == 0 && h == 0){
            break;
        }
        scanf("%d%d%d%d", &xs, &ys, &xg, &yg);

        memset(board, 0, sizeof(board));

        scanf("%d", &n);
        for (i = 0; i < n; i++){
            scanf("%d%d%d%d", &c, &d, &x, &y);
            
            if (d == 0){
                for (j = 0; j < 4; j++){
                    board[y    ][x + j] = c;
                    board[y + 1][x + j] = c;
                }
            }
            else {
                for (j = 0; j < 4; j++){
                    board[y + j][x    ] = c;
                    board[y + j][x + 1] = c;
                }
            }
        }
        
        
        c2 = board[ys][xs];
        board[ys][xs] = -1;
        
        while (1){
            flag = 0;
            for (i = 1; i <= h; i++){
                for (j = 1; j <= w; j++){
                    if (board[i][j] == c2){
                        if (board[i][j - 1] == -1){
                            board[i][j] = -1;
                            flag = 1;
                        }
                        else if (board[i][j + 1] == -1){
                            board[i][j] = -1;
                            flag = 1;
                        }
                        else if (board[i + 1][j] == -1){
                            board[i][j] = -1;
                            flag = 1;
                        }
                        else if (board[i - 1][j] == -1){
                            board[i][j] = -1;
                            flag = 1;
                        }
                    }
                }
            }
            if (flag == 0){
                break;
            }
        }
        
        if (board[yg][xg] == -1){
            printf("OK\n");
        }
        else {
            printf("NG\n");
        }
    }
    return (0);
}

Measured memory_bytes: 0
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, ans=inf;

ll f(ll x, ll y){

ll temp=0, res=0;

while(x>0){
    x/=10;
    temp++;
}

while(y>0){
    y/=10;
    res++;
}

return max(res, temp);

}


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

for(ll i = 1; i*i<=n; i++){
    if(n%i==0){
        ans = min(ans, f(i, n/i));
    }
}

cout << ans << endl;






return 0;}
///....


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int num;
    cin >> num;
    int temp = num;

    int n = 0;
    while(temp)
    {
        n += temp % 10;
        temp /= 10;
    }

    if(0 == num % n)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>

using namespace std;

int main(){
    int i, o;
    for (o = 1; o <= 9; ++o) {
        for (i = 1; i <= 9; ++i) {
            cout << o << "x" << i << "=";
            cout << i * o << endl;
        }
    }
    return 0;
}



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

using lint = long long;
const int MAXN = 6005;
const int INF = 1e5;

int N;
int A[MAXN];

int ans = 0;
int base = 0;
int nxt[MAXN];
int dp[MAXN][MAXN];

inline int Cost(int a, int b, int c) {
  return A[a] == A[b] && A[b] == A[c];
}

inline void Transition(int i, int j, int cur) {
  if (cur > 3 * N) return;
  if (cur == 3 * N) {
    ans = max(ans, dp[i][j] + Cost(i, j, cur));
    return;
  }
  dp[cur + 0][cur + 1] = max(dp[cur + 0][cur + 1], dp[i][j] + Cost(i, j, cur + 2));
  dp[cur + 0][cur + 2] = max(dp[cur + 0][cur + 2], dp[i][j] + Cost(i, j, cur + 1));
  dp[cur + 1][cur + 2] = max(dp[cur + 1][cur + 2], dp[i][j] + Cost(i, j, cur + 0));

  dp[i][cur + 0] = max(dp[i][cur + 0], dp[i][j] + Cost(j, cur + 1, cur + 2));
  dp[i][cur + 1] = max(dp[i][cur + 1], dp[i][j] + Cost(j, cur + 0, cur + 2));
  dp[i][cur + 2] = max(dp[i][cur + 2], dp[i][j] + Cost(j, cur + 0, cur + 1));

  dp[j][cur + 0] = max(dp[j][cur + 0], dp[i][j] + Cost(i, cur + 1, cur + 2));
  dp[j][cur + 1] = max(dp[j][cur + 1], dp[i][j] + Cost(i, cur + 0, cur + 2));
  dp[j][cur + 2] = max(dp[j][cur + 2], dp[i][j] + Cost(i, cur + 0, cur + 1));
}

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

  cin >> N;
  for (int i = 1; i <= 3 * N; i++) {
    cin >> A[i];
  }

  while (true) {
    bool change = false;
    for (int i = 3; i + 2 <= 3 * N; i += 3) {
      if (A[i] == A[i + 1] && A[i + 1] == A[i + 2]) {
        base += 1;
        for (int j = i + 3; j <= 3 * N; j++) {
          A[j - 3] = A[j];
        }
        N -= 1;
        change = true;
        break;
      }
    }
    if (!change) {
      break;
    }
  }
  
  vector<int> last(3 * N + 1, 3 * N + 1);
  for (int i = 3 * N; i > 0; i--) {
    nxt[i] = last[A[i]];
    last[A[i]] = i;
  }
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXN; j++) {
      dp[i][j] = -INF;
    }
  }
  dp[1][2] = 0;
  for (int i = 1; i <= 3 * N; i++) {
    for (int j = i + 1; j <= 3 * N; j++) {
      Transition(i, j, (j + 3) / 3 * 3);
      // Find next occurrence of A[i]
      if (j / 3 * 3 < nxt[i] / 3 * 3) {
        Transition(i, j, nxt[i] / 3 * 3);
      }
      // Find next occurrence of A[j]
      if (j / 3 * 3 < nxt[j] / 3 * 3) {
        Transition(i, j, nxt[j] / 3 * 3);
      }
    }
  }

  cout << ans + base << "\n";
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	while(1){
		string s;
		s = to_string(n);
		if(s[0] == s[1] && s[1] == s[2]){
			cout << n << endl;
			return 0;
		}
		n++;
	}
}

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

int main()
{
    int n;
    cin>> n;
    vector<pair <int,int> >p(n);
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i]>> b[i];
        p[i]=make_pair(b[i],a[i]);
    }
    sort(p.begin(),p.end());
    int t=0;
    int ans=1;
    for(int i=0;i<n;i++){
        t+=p[i].second;
        if(t>p[i].first)ans=0;
    }
    if(ans==0)cout << "No"<< endl;
    else cout << "Yes"<< endl;
    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var a = new List<int>();
            for (var i = 0; i < n; i++) {
                a.Add(cin.ReadInt);
            }
            a.Sort();
            a.Reverse();

            long ans = long.MaxValue;
            for (var i = 0; i < n; i++) {
                if (i == 0) {
                    ans = a[i];
                    continue;
                }
                ans = Gcd(ans, a[i]);
            }
            WriteLine(ans);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b) {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        private double MultipleCeil(double value, double multiple) {return Math.Ceiling(value / multiple) * multiple;}

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;
	n%=10;

	if(n==2||n==4||n==5||n==7||n==9)
	{
		cout << "hon" << endl;
		return 0;
	}

	if(n==3)
	{
		cout << "bon" << endl;
		return 0;
	}

	cout << "pon" << endl;
}

Measured memory_bytes: 3652
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] prime = new int[1001];
		for(int i = 2; i <= N; i++){
			int n = i;
			for(int p = 2; p * p <= n; p++){
				if(n % p == 0){
					int count = 0;
					while(n % p == 0){
						n /= p;
						count++;
					}
					prime[p] += count;
				}
			}
			if(n > 1) prime[n] += 1;
		}
		
		long ans = 1;
		for(int p : prime){
			ans = (ans * (p + 1)) % 1000000007;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21460
//37
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int n,q;
int p[100001];
bool m[100001];
vector<int> t[100001];

void dfs(int v,int np){
  p[v]=np;
  if(!m[v]){
    for(int i=0;i<t[v].size();i++){
      dfs(t[v][i],np);
    }
  }
}

void dfsa(int v,int pn){
  if(!m[v]){
    p[v]=pn;
    for(int i=0;i<t[v].size();i++){
      dfsa(t[v][i],pn);
    }
  }
}

int main(){
  while(cin>>n>>q,n|q){
    fill(p,p+n+1,1);
    fill(m,m+n+1,false);
    m[1]=true;
    for(int i=1;i<=n;i++){
      t[i].clear();
    }
    for(int i=2;i<=n;i++){
      int pn;
      cin>>pn;
      t[pn].push_back(i);
    }
    long long s=0;
    while(q--){
      char e;
      int v;
      cin>>e>>v;
      if(e=='Q'){
	s+=p[v];
      }else{
	m[v]=true;
	p[v]=v;
	for(int i=0;i<t[v].size();i++){
	  //	  dfs(t[v][i],v);
	  dfsa(t[v][i],v);
	}
      }
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 10164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC104_B solver = new ABC104_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC104_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String ans = "AC";
            if (s.charAt(0) != 'A') {
                ans = "WA";
            }

            String sub = s.substring(2, s.length() - 1);

            int cnt = 0;
            for (char c : sub.toCharArray()) {
                if (c == 'C') {
                    cnt++;
                }
            }
            if (cnt != 1) {
                ans = "WA";
            }


            for (char c : s.toCharArray()) {
                if (c != 'A' && c != 'C') {
                    if (!Character.isLowerCase(c)) {
                        ans = "WA";
                    }
                }
            }


            out.print(ans);

        }

    }
}



Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,cnt=0;
  cin >> N;
  for(int i = 0; i < N; i++){
    int d1,d2;
    cin >> d1 >> d2;
    if(d1 == d2) cnt++;
    else cnt = 0;
    if(cnt >= 3) break;
  }
  if(cnt >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  long N;
  cin >> N;
  long ans;
  if(N==1) ans=0;
  else if(N==2) ans=1;
  else ans=N*(N-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
if n == 1:
  print(1)
  exit()
xy = []
for _ in range(n):
  x, y = map(int, input().split())
  xy.append([x, y])

vecs = {}
for i in range(n):
  for j in range(i+1, n):
    if xy[i][0] < xy[j][0]:
      vec = (xy[j][0] - xy[i][0], xy[j][1] - xy[i][1])
    elif xy[i][0] > xy[j][0]:
      vec = (xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])
    else:
      vec = (0, abs(xy[j][1] - xy[i][1]))
    
    if vec in vecs:
      vecs[vec] += 1
    else:
      vecs[vec] = 1

vec_max = max(list(vecs.values()))
print(n - vec_max)
    

Measured memory_bytes: 3188
#define C
typedef long long readtype;

/* Header {{{ */
#ifdef C
#include <stdio.h>
#include <math.h>
#include <string.h>
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)
template<typename type> type abs(type a) { return a < 0 ? -a : a; }
template<typename type> type min(type a, type b) { return a < b ? a : b; }
template<typename type> type beMin(type &a, type b) { return a = (a < b ? a : b); }
template<typename type> type max(type a, type b) { return a > b ? a : b; }
template<typename type> type beMax(type &a, type b) { return a = (a > b ? a : b); }
template<typename type> void swap(type &a, type &b) { type c; c = a; a = b; b = c; }
#endif

#ifdef Cpp
#include <bits/stdc++.h>
using namespace std;
#endif

typedef long long var;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}
/* }}} */

const int N = 311;

int n, m;
int a[N][N], have[N], pos[N];
bool ban[N];

bool check(int t);

int main() {
  /*
#ifndef ONLINE_JUDGE
  freopen("source.in", "r", stdin);
  freopen("source.out", "w", stdout);
#endif
*/
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) a[i][j] = read();
  }
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (!check(mid)) l = mid + 1;
    else r = mid;
  }
  printf("%d\n", l);
  return 0;
}

bool check(int t) {
  memset(ban, false, sizeof(ban));
  memset(have, 0, sizeof(have));
  memset(pos, 0, sizeof(pos));
  for (int i = 1; i <= n; ++i) have[a[i][++pos[i]]]++;
  while (true) {
    bool ok = true;
    for (int i = 1; i <= m; ++i) {
      if (have[i] <= t) continue;
      ok = false;
      ban[i] = true;
    }
    if (ok) break;
    for (int i = 1; i <= n; ++i) {
      while (pos[i] <= m && ban[a[i][pos[i]]]) {
        have[a[i][pos[i]]]--;
        have[a[i][++pos[i]]]++;
      }
      if (pos[i] > m) return false;
    }
  }
  return true;
}


Measured memory_bytes: 512