akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 7;

long long M = 1e9 + 7;
long long fac[N];
long long n, x, y;
int c[N], w[N], mnc[N];
map <int, int> mp;
int lft[N];
int cnt;
long long power(long long a, long long b) {
	if (b == 0)
		return 1;
	long long t = power(a, b / 2);
	t = (t * t) % M;
	if (b % 2) 
		t = (t * a) % M;
	return t;
}
long long chs(long long a, long long b) {
	long long t = fac[b];
	t = (t * power(fac[a], M - 2)) % M;
	t = (t * power(fac[b - a], M - 2)) % M;
	return t;
}

int mn[2], cl[2];

int main() {
	fac[0] = 1;
	for (long long i = 1; i < N; i++)
		fac[i] = (fac[i - 1] * i) % M;
	cin >> n >> x >> y;
	memset(mnc, 127, sizeof mnc);
	mn[0] = mn[1] = 1e9 + 7;
	for (int i = 1; i <= n; i++) {
		cin >> c[i] >> w[i];
		mnc[c[i]] = min(mnc[c[i]], w[i]);
		if (w[i] < mn[0]) {
			if (c[i] == cl[0])
				mn[0] = w[i];
			else {
				cl[1] = cl[0];
				mn[1] = mn[0];
				cl[0] = c[i];
				mn[0] = w[i];
			}
		}
		else if (cl[0] != c[i] && mn[1] > w[i]) {
			cl[1] = c[i];
			mn[1] = w[i];
		}
	}
	for (int i = 1; i <= n; i++) {
		if (w[i] + mnc[c[i]] <= x)
			w[i] = mnc[c[i]];
	}
	if (cl[1] == 0) {
		cout << 1;
		return 0;
	}
	int ps = 0;
	for (int i = 1; i <= n; i++) {
		if (c[i] != cl[0]) {
			if (w[i] + mn[0] > y)
				continue;
			if (mp[c[i]] == 0)
				cnt++, mp[c[i]] = cnt;
			lft[mp[c[i]]]++;
		}
		else {
			if (w[i] + mn[1] > y)
				continue;
			if (mp[c[i]] == 0)
				cnt++, mp[c[i]] = cnt;
			lft[mp[c[i]]]++;
		}
	}
	for (int i = 1; i <= cnt; i++)
		ps += lft[i];
	long long ans = fac[ps];
	for (int i = 1; i <= cnt; i++)
		ans = (ans * power(fac[lft[i]], M - 2)) % M;
	cout << ans;
	return 0;
}









































Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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(){

    double N,Y;
    cin >> N >> Y;
    vector<double> M(3,0);
    M[0]=10000; M[1]=5000; M[2]=1000;

    for(int x=0; x <= N; x++){
        for(int y=0; y <= (N-x); y++){
            for(int z=N-x-y; z <= (N-x-y); z++){
                if(M[0]*z + M[1]*y + M[2]*x == Y && x+y+z==N){
                    cout << z << " " << y << " " << x << endl; 
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}


// ----------------------------------------------------------------------------

vector<int> dice(vector<int> faces,char com){
  vector<int> temp(7);
  if(com == 'N'){
    temp[1] = faces[2];
    temp[2] = faces[6];
    temp[3] = faces[3];
    temp[4] = faces[4];
    temp[5] = faces[1];
    temp[6] = faces[5];
  }else if(com == 'W'){
    temp[1] = faces[3];
    temp[2] = faces[2];
    temp[3] = faces[6];
    temp[4] = faces[1];
    temp[5] = faces[5];
    temp[6] = faces[4];
  }else if(com == 'S'){
    temp[1] = faces[5];
    temp[2] = faces[1];
    temp[3] = faces[3];
    temp[4] = faces[4];
    temp[5] = faces[6];
    temp[6] = faces[2];
  }else if(com == 'E'){
    temp[1] = faces[4];
    temp[2] = faces[2];
    temp[3] = faces[1];
    temp[4] = faces[6];
    temp[5] = faces[5];
    temp[6] = faces[3];
  }else{
    temp[1] = faces[1];
    temp[2] = faces[4];
    temp[3] = faces[2];
    temp[4] = faces[5];
    temp[5] = faces[3];
    temp[6] = faces[6];
  }
  return temp;
}

bool issame(vector<int> a,vector<int> b){
  for(int i=1; i<=6; i++){
    if(a[i] != b[i]){
      return false;
    }
  }
  return true;
}


int main(){
  vector<int> D1(7);
  vector<int> D2(7);
  for(int i=1; i<=6; i++){
    cin >> D1[i];
  }
  for(int i=1; i<=6; i++){
    cin >> D2[i];
  }
  bool same = false;
  for(int i=0; i<4; i++){
    D1 = dice(D1,'R');
    for(int j=0; j<4;j++){
      D1 = dice(D1, 'N');
      if(issame(D1,D2)){
        same = true;
      }
    }
  }
  D1 = dice(D1,'E');
  for(int j=0; j<4; j++){
    D1 = dice(D1,'N');
    if(issame(D1,D2)){
      same = true;
    }
  }
  D1 = dice(D1,'W');
  D1 = dice(D1,'W');
  for(int i=0; i<4; i++){
    D1 = dice(D1,'N');
    if(issame(D1,D2)){
      same = true;
    }
  }
  if(same){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include<stdio.h>

int main(void)
{
  int h,w;
  for(;;)
  {
    scanf("%d %d", &h, &w);
    if(h==0 && w==0){
      break;
    }
    int i,j;
    for (i=0; i<h; ++i) {
      for (j = 0; j < w;  ++j) {
        if (((i+j)%2)==0) {
          putchar('#');
        }
        else{
          putchar('.');
        }
      }
      puts("");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


using Graph = vector<vector<int>>;
Graph G;
vector<int> ans;
vector<int> a;
vector<int> dp(200010, INF);
void dfs(int v, int p)
{
    auto it = lower_bound(ALL(dp), a[v]);
    int tmp = *it;
    *it = a[v];
    ans[v] = lower_bound(ALL(dp), INF) - dp.begin();
    for (auto &nv : G[v])
    {
        if (nv == p)
        {
            continue;
        }

        dfs(nv, v);
    }
    *it = tmp;
}

signed main(){
    int n;
    cin>>n;
    a.resize(n);
    REP(i, n)
    {
        cin>>a[i];
    }
    G.assign(n,vector<int>());
    for (int i = 0; i < n-1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);   
    }
    ans.resize(n);
    dfs(0, -1);
    REP(i, n)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 30276
a,b,c,d,e,f = map(int, input().split())
total = 0
sugar = 0
p,q,r,s = 0,0,0,0
p_max,q_max,r_max,s_max = 0,0,0,0
p_max = f // (100*a)
q_max = f // (100*b)
r_max = int((0.01 * f * e) // c)
s_max = int((0.01 * f * e) // d)
set_water = set()
set_sugar = set()

for p in range(0,p_max+1):
    for q in range(0,q_max+1):
        if 100*(a*p + b*q) <= f:
            set_water.add(100*(p*a+q*b))
for r in range(0,r_max+1):
    for s in range(0,s_max+1):
        if c*r + d*s <= 0.01*f*e:
            set_sugar.add(r*c+s*d)
conc_max = 0
max_sugar = 0
max_tot = 0
for water in set_water:
    for sugar in set_sugar:
        if water + sugar > f:
            pass
        elif water == 0 or sugar == 0:
            pass
        elif sugar / water > 0.01*e:
            pass
        else:
            conc = sugar / (water+sugar)
            if conc >= conc_max:
                conc_max = conc
                max_sugar = sugar
                max_tot = water+sugar
            else:
                pass
if max_tot == 0:
    max_tot = 100*a
print(max_tot,max_sugar)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

string s;
bool f(){
  if(sz(s)%2)return false;
  string l = s.substr(0,sz(s)/2);
  string r = s.substr(sz(s)/2,sz(s));
  return (l == r);
}

int main() {
  cin >> s;
  s.pop_back();
  while(!f()){
    if(sz(s) == 0){
      cout<<0<<endl;
      return 0;
    }
    s.pop_back();
  }
  cout<<sz(s)<<endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k;cin>>k;
  rep(i,1,k+1)rep(j,1,k+1)rep(o,1,k+1){
    res+=gcd(gcd(i,j),o);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
import java.math.*;
	        public class Main {
	    	static void solve(int[] arr, int n) {
	    	}
	        public static void main(String args[]) throws IOException {
	        	FastReader sc = new FastReader();
	        	double d = sc.nextDouble(), t = sc.nextDouble(), s = sc.nextDouble();
	        		double time = d/s;
	        		
	        		if(time <= t) pn("Yes");
	        		else pn("No");
	       }
	       static void p(Object p){System.out.print(p);}
	       static void pn(){System.out.println();}
	       static void pn(Object o){System.out.println(o);}
	       
	       static class FastReader {
	       static BufferedReader br;
	       StringTokenizer st;
	       public FastReader() {
	       br = new BufferedReader(new InputStreamReader(System.in));
	       }
	            
	       String next(){
	       while (st == null || !st.hasMoreElements()) {
	            try{
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e) {
	                e.printStackTrace();
	            }}
	            return st.nextToken();
	            }
	            
	            int nextInt(){ 
	                return Integer.parseInt(next());
	            }
	            
	            long nextLong(){ 
	                return Long.parseLong(next());
	            }
	            
	            static int max(int[] a){
	            int max = Integer.MIN_VALUE;
	            for(int i : a) max = Math.max(max, i);
	            return max;
	            }
	            
	            public int[] readIntArray(int n) {
	            int[] arr = new int[n];
	            for(int i=0; i<n; ++i) arr[i]=nextInt();
	            return arr;
	            }
	            
	            public long[] readLongArray(int n){
	            long[] arr = new long[n];
	            for(int i=0; i<n; ++i) arr[i]=nextLong();
	            return arr;
	            }
	            
	            public int[][] readIntArray(int m, int n){
	            int[][] arr = new int[m][n];
	            for(int i = 0;i<m;i++) 
	            for(int j = 0;j<n;j++) arr[i][j] = nextInt();
	            return arr;
	            }
	            
	            public String[] readStringArray(int n) {
	            String[] arr = new String[n];
	            for(int i=0; i<n; ++i) arr[i]= nextLine();
	            return arr;
	            }
	            
	            double nextDouble() {return Double.parseDouble(next());}
	            
	            String nextLine() {
	            String str = "";
	            try{str = br.readLine();}
	            catch (IOException e) {e.printStackTrace();}
	            return str;}}
	        }

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 998244353;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    int x, n;
    cin >> x >> n;
    vector<int> cnt(N);
    for(int i=0;i<n;i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int dist = 1e9;
    int res = x;
    for(int i=0;i<=101;i++) {
        if(cnt[i] > 0) continue;
        else {
            if(abs(i - x) < dist) {
                res = i;
                dist = abs(i - x);
            }
        }
    }
    cout << res << endl;
    return 0; 
}



Measured memory_bytes: 3968
#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 h,w;
    cin >> h >> w;
    //vector <int> ans(10,100000);
    //ans[1]=0;
    vector <vector <int>> c(10,vector <int> (10)),ans(10,vector <int> (10,100000));

    ans[1][1]=0;
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
        }
    }

    rep(i,10){
        rep(j,10){
            rep(k,10){
                c[j][k]=min(c[j][k],c[j][i]+c[i][k]);
            }
        }
    }

   /* rep(i,10){
        rep(j,10){
            cout << c[i][j];
        }
        cout << endl;
    }*/


int x;
ll ans2=0;
    rep(i,h*w){
        cin >> x;
        if(x!=-1){
        ans2+=c[x][1];
        }
    }

    cout << ans2 << endl;
    

    return 0;
}

Measured memory_bytes: 3588
h, w = map(int,input().split())
AA = [list(input()) for i in range(h)]

import string
A = [chr(i) for i in range(ord("a"), ord("z")+1)]
B = {}
for i in range(26):
    B[A[i]] = i

C = [0, 0, 0]
if h%2 == 1 and w%2 == 1:
    C = [(h-1) * (w-1) // 4, ((h-1) + (w-1)) // 2, 1]
elif h%2 == 1:
    C = [(h-1) * w // 4, w // 2, 0]
elif w%2 == 1:
    C = [(w-1) * h // 4, h // 2, 0]
else:
    C = [h * w // 4, 0, 0]

D = [0] * 26
for i in range(h):
    for j in range(w):
        D[B[AA[i][j]]] += 1

E = [0, 0, 0]
for i in range(26):
    if D[i] % 2 > 0:
        E[2] += 1
    elif D[i] % 4 > 0:
        E[1] += 1

if C[2] == E[2] and C[1] >= E[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 39408
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int K;
int A, B;

signed main(){
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int n,A[55];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	double ans=(A[1]+A[2])/2.0;
	for(int i=3;i<=n;++i)ans=(ans+A[i])/2.0;
	printf("%6f",ans);
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (N >= 1000) cout << "ABD" << endl;
  else cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void) {
  int n, h, w;
  std::cin >> n;
  std::cin >> h;
  std::cin >> w;

  int a1 = n - h + 1;
  int a2 = n - w + 1;

  std::cout << a1 * a2 << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String a = sc.next();
	a=a.replace("1","q");
    a=a.replace("9","l");
    a=a.replace("q","9");
    a=a.replace("l","1");
    System.out.println(a);
  }
}

Measured memory_bytes: 22612
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long P = 1000000007;

long long add(long long a, long long b) { return (a + b) % P; }

long long mul(long long a, long long b) { return (a * b) % P; }

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;
  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }
  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }
  long long comb(int N, int K) {
    if (N == 0 || K == 0 || K == N)
      return 1;
    if (N < K || K < 0 || N < 0)
      return 0;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }
};

int main() {
  C cmp(100100);
  string s;
  cin >> s;
  long long b_a[100002] = {0}, a_c[100002] = {0}, a_q[100002] = {0},
            b_q[100002] = {0};
  int n = s.size();
  b_a[0] = 0;
  b_q[0] = 0;
  for (int i = 0; i < n; i++) {
    b_a[i + 1] = b_a[i] + (s[i] == 'A' ? 1 : 0);
    b_q[i + 1] = b_q[i] + (s[i] == '?' ? 1 : 0);
  }
  a_c[n] = 0;
  a_q[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    a_c[i] = a_c[i + 1] + (s[i] == 'C' ? 1 : 0);
    a_q[i] = a_q[i + 1] + (s[i] == '?' ? 1 : 0);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B' || s[i] == '?') {
      ans = add(
          ans, mul(mul(b_a[i], a_c[i + 1]), cmp.power(3, b_q[i] + a_q[i + 1])));
      if (b_q[i] > 0) {
        ans = add(ans, mul(mul(b_q[i], a_c[i + 1]),
                           cmp.power(3, b_q[i] + a_q[i + 1] - 1)));
      }
      if (a_q[i + 1] > 0) {
        ans = add(ans, mul(mul(b_a[i], a_q[i + 1]),
                           cmp.power(3, b_q[i] + a_q[i + 1] - 1)));
      }
      if (b_q[i] > 0 && a_q[i + 1] > 0) {
        ans = add(ans, mul(mul(b_q[i], a_q[i + 1]),
                           cmp.power(3, b_q[i] + a_q[i + 1] - 2)));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6392
#include <stdio.h>

int main() {
    char S[4];
    char T[4];
    
    int n = 0;
    int i;
    
    scanf("%s", S);
    scanf("%s", T);
    
    for(i = 0; i < 3; i++){
        if(S[i] == T[i]){
            n++;
        }
    }
    
    printf("%d\n", n);
    
    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector< vector<int> > vvi;

bool visit[6001][2001];
vector<pii> edge[6001];
vector<int> mst;
struct node {
	int id, cap, dist;
	node(int i, int c, int d) {
		id = i;
		cap = c;
		dist = d;
	}
};

bool operator<(const node& lhs, const node& rhs) {
	return lhs.dist > rhs.dist;
}

int main() {
	int n, m, cap;
	while(cin >> n >> m >> cap, n and m and cap) {
		memset(visit, 0, sizeof(visit));
		mst.clear();
		cap *= 10;
		map<string, int> mp;
		rep(i, 2*n+1) edge[i].clear();
		string start, goal;
		cin >> start >> goal;
		int k=0;
		rep(i, n) {
			string a, b;
			int d;
			cin >> a >> b >> d;
			if( mp.find(a) == mp.end() ) mp[a] = k++;
			if( mp.find(b) == mp.end() ) mp[b] = k++;
			edge[ mp[a] ].push_back(pii(mp[b], d));
			edge[ mp[b] ].push_back(pii(mp[a], d));
		}
		rep(i, m) {
			string s;
			cin >> s;
			mst.push_back(mp[s]);
		}
		sort(mst.begin(), mst.end());
		priority_queue<node> que;
		que.push( node(mp[start], cap, 0) );
		bool found = false;
		while( !que.empty() ) {
			node nd = que.top();
			que.pop();
			if( visit[nd.id][nd.cap] ) continue;
			visit[nd.id][nd.cap] = true;
			if( nd.id == mp[goal] ) {
				cout << nd.dist << endl;
				found = true;
				break;
			}
			if( binary_search(mst.begin(), mst.end(), nd.id) and !visit[nd.id][cap] ) {
				que.push( node(nd.id, cap, nd.dist) );
			}
			rep(i, edge[nd.id].size()) {
				pii p = edge[nd.id][i];
				if( nd.cap >= p.second && !visit[p.first][nd.cap-p.second] ) {
					que.push( node(p.first, nd.cap-p.second, nd.dist + p.second) );
				}
			}
		}
		if(!found) {
			cout << -1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 65216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint sum = 0;
	vector<lint>A(5);
	rep(i, 5) {
		cin >> A[i];
		sum += A[i];
	}
	cout << 15 - sum << endl;
}

Measured memory_bytes: 3596
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        double ans = 0;
        double btc = 380000.0;

        for (int i = 0; i < N; i++) {
            double x = sc.nextDouble();
            String u = sc.next();

            if(u.equals("BTC")){
                ans += x * btc;
            } else {
                ans += x;
            }
        }

        out.println(ans);
    }
}


Measured memory_bytes: 24148
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N,sum=0;
	string S;
	cin>>N>>S;
	for(int i=0;i<S.length()-2;i++){
		if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')sum++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Arrays.sort(s);
		System.out.println((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ? "Yes" : "No");	
	}
}

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

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

int32_t main()
{
    IOS;
    
    int n,k,s;
    cin>>n>>k>>s;
    
    if(k==0)
    {
        if(s!=1e9)
            for(int i=1;i<=n;i++)
                cout<<s+1<<" ";
        else
            for(int i=1;i<=n;i++)
                cout<<"1"<<" ";
        return 0;        
    }
    
    for(int i=1;i<=k;i++)
        cout<<s<<" ";
    
    if(s!=1e9)
        for(int i=k+1;i<=n;i++)
            cout<<s+1<<" ";
    else
        for(int i=k+1;i<=n;i++)
            cout<<1<<" ";
        
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
main(){
	int w=0,n=0;
	scanf("%d",&w);
	scanf("%d",&n);
	
	//阿弥陀の数字
	int data[1000];
	int i,j=0;
	for(i=0;i<w;i++){
		data[i]=i+1;
	}
	
	//iのjにコピー
	j=i;
	
	//入れ替える場所
	int a[1000],b[1000];
	for(i=0;scanf("%d,%d",&a[i],&b[i])!=EOF;i++);

	//入れ替え
	int tmp=0;
	for(i=0;i<j;i++){
		tmp=data[a[i]-1];
		data[a[i]-1]=data[b[i]-1];
		data[b[i]-1]=tmp;
	}
	
	//出力
	for(i=0;i<j;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if((A == B && B != C) || (A != B && B == C) || (A == C && B != C)) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];

		for(int i = 0 ; i < n ; ++i){
			a[i] = sc.nextInt();
		}

		Map<Integer , Integer> m = new HashMap<Integer , Integer>();

		for(int i = 0 ; i < n ; ++i){
			m.put(a[i], m.containsKey(a[i]) ? m.get(a[i]) +1 : 1);
		}
		
		int sum = 0;
		for(int k : m.keySet()){
			int v = m.get(k);
			
			if(k < v){
				sum += v-k;
			}else if(k > v){
				sum += v;
			}
		}
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 53560
lst=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
for i in range(28):
    lst[int(input())-1]=0
for i in lst:
    if i:
        print(i)


Measured memory_bytes: 5604
// 2012/11/19 Tazoe

#include <iostream>
using namespace std;

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

	int P[100];
	for(int i=0; i<N; i++){
		P[i] = 0;
	}

	for(int i=0; i<N*(N-1)/2; i++){
		int A, B, C, D;
		cin >> A >> B >> C >> D;

		if(C>D){
			P[A-1] += 3;
		}
		else if(C<D){
			P[B-1] += 3;
		}
		else{
			P[A-1] += 1;
			P[B-1] += 1;
		}
	}

	int R[100];
	for(int i=0; i<N; i++){
		R[i] = 1;
	}

	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(P[i]<P[j]){
				R[i]++;
			}
		}
	}

	for(int i=0; i<N; i++){
		cout << R[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 1160
import sys
input()
e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]
for (t0, a0, b0), (t1, a1, b1) in zip(e, e[1:]):
    d = (t1 - t0) - abs(a1 - a0) - abs(b1 - b0)
    if d < 0 or d % 2 == 1:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 28148
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main()
{

    ll n;
    cin >> n;
    vll ans(100000);
    ll x = 0;

    rrep(a, 100)
    {
        rrep(b, 100)
        {
            rrep(c, 100)
            {
                x = a * a + b * b + c * c + a * b + b * c + c * a;
                ans[x]++;
                if (x > n)
                {
                    x = 0;
                    break;
                }
            }
            if (x > n)
            {
                x = 0;
                break;
            }
        }
        if (x > n)
        {
            x = 0;
            break;
        }
    }

    rrep(i, n) cout << ans[i] << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;
int n, m;
int a[N];
ll ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a + n);
    if (n & 1)
        m = a[n / 2];
    else
        m = (a[n / 2 - 1] + a[n / 2]) / 2;

    for (int i = 0; i < n; ++i) {
        ans += abs(a[i] - m);
    }

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


Measured memory_bytes: 4364
N = int(input())
S = input()

## 0:sheep, 1:wolf
first_state_circle = [[0,0,0],[0,1,1],[1,0,1],[1,1,0]] ## [1st,2nd,-1th]
first_state_cross = [[0,0,1],[0,1,0],[1,0,0],[1,1,1]] ## [1st,2nd,-1th]
transtable = str.maketrans({'0':'S', '1':'W'})

if S[0] == 'o':
  first_state = first_state_circle
else:
  first_state = first_state_cross

for state in first_state:
  lst = [-1]*N
  lst[0] = state[0]
  lst[1] = state[1]
  for i in range(1,N-1):
    lst[i+1] = (lst[i-1] + lst[i] + (S[i]=='x')) % 2
  #print(state,lst)
  if lst[N-1] != state[2]:
    continue
  if lst[0] != (lst[N-2] + lst[N-1] + (S[N-1]=='x')) % 2:
    continue
  ans = ''.join(map(str,lst)).translate(transtable)
  print(ans)
  exit()
else:
  print('-1')

Measured memory_bytes: 10964
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a,b,c,d,e,k;
  cin >>a>>b>>c>>d>>e>>k;
  if(e-a<=k) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int k;
ll ans;
vector<vector<int>> to(100000);

void dfs(int v, int p = -1){
  for(int u : to[v]){
    if(u == p) continue;
    dfs(u, v);
  }
  int nk = (p==-1) ? k : k-2;
  int nc = (p==-1) ? to[v].size()+1 : to[v].size()-1;
  ll kpc = 1;
  REP(i, nc) kpc = kpc * (nk-i) % mod;
  ans = (ans*kpc) % mod;
}

int main(void){
  int n;
  cin >> n >> k;
  
  REP(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }

  ans = 1;
  dfs(0);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>

int linearSearch(int S[],int T[],int n,int q){
	int k = 0;
	for (int i = 0; i < q; i++){
		for (int j = 0; j < n; j++){
			if (T[i] == S[j]){
				k++;
				break;
			}
		}
	}
	return k;
}

int main(){
	int n, q;
	int S[10000], T[500];
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%d", &T[i]);
	}
	printf("%d\n", linearSearch(S, T, n, q));
	return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={0, 1, 0, -1};
int dy[]={-1, 0, 1, 0};

map<int,int> m;

int n,d[30][30],abosum[30],ans;
bool abo[30][30],exist[30];

int check(bool tmp[30]){
	int ret = 0,bit = 1;
	for(int i = 1;i <= n;i++){
		if(tmp[i] == true){
			ret += bit;
		}
		bit *= 2;
	}
	return ret;
}

void solve(int tmpans,bool texist[30],int tabosum[30]){
	ans = max(ans,tmpans);
	int bit = check(texist);
	auto itr = m.find(bit);
	if(itr != m.end()) return;
	m[bit] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = i+1;j <= n;j++){
			if(texist[i] == false || texist[j] == false)continue;
			if(tabosum[i] != 0 || tabosum[j] != 0) continue;
			if(d[i][3] != d[j][3]) continue;
			texist[i] = false; texist[j] = false;
			bit = check(texist);
			auto itr = m.find(bit);
			texist[i] = true; texist[j] = true;
			if(itr != m.end()) continue;
			bool tmpexist[30];
			for(int k = 1;k <= n;k++){
				tmpexist[k] = texist[k];
				if(k == i || k == j) tmpexist[k] = false;
			}
			int tmpabosum[30];
			for(int k = 1;k <= n;k++){
				tmpabosum[k] = tabosum[k];
				if( abo[i][k] == true && i < k )tmpabosum[k]--;
				if( abo[j][k] == true && j < k )tmpabosum[k]--;
			}
			solve(tmpans+2,tmpexist,tmpabosum);
		}
	}
}

int main(){
	while(true){
		cin >> n;
		if(n == 0)break;
		ans = 0;
		m.clear();
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				abo[i][j] = false;
			}
		}
		for(int i = 1;i <= n;i++){
			exist[i] = true;
			abosum[i] = 0;
			for(int j = 0;j < 4;j++){
				scanf("%d",&d[i][j]);
				//cin >> d[i][j];
			}
		}
		for(int i = 1;i <= n;i++){
			for(int j = i+1;j <= n;j++){
				if(  (d[i][0]-d[j][0])*(d[i][0]-d[j][0]) + (d[i][1]-d[j][1])*(d[i][1]-d[j][1]) < (d[i][2]+d[j][2])*(d[i][2]+d[j][2])    ){
					abo[i][j] = true; abo[j][i] = true;
					abosum[j]++;
				}
			}
		}
		solve(0,exist,abosum);

		cout << ans << endl;
	}
}


Measured memory_bytes: 52316
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    ct=0
    while n>0:
        n=n//k
        ct+=1
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
n=gets.to_i
a=(1..n).map{gets.split.map &:to_i}
a.unshift([0,0,0])
f=true
(0...n).each{|i|
    d=(a[i][1]-a[i+1][1]).abs+(a[i][2]-a[i+1][2]).abs
    t=a[i+1][0]-a[i][0]
    f=f&&t%d==0
}
puts f ? :Yes: :No

Measured memory_bytes: 9724
from math import sqrt
def main():
    n = int(input())
    C = [s for s in input()]
    al = "".join(C).count("R")
    now = 0
    for c in C[:al]:
        if c == "R":
            now += 1
    print(al - now)
    return 

if __name__ == "__main__":
    main()

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) cin<<(x);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1

typedef long long ll;

using namespace std;

#define N 100005
int main() {
	ios::sync_with_stdio(0);
	int n, a;
	cin>>n;
	int cnt[N] = {0};
	F(n) {cin>>a; cnt[a]++;}
	int mv=0;
	mv = cnt[1]+cnt[0];
	FI(100001) {
		mv = max(mv, cnt[i]+cnt[i-1]+cnt[i+1]);
	}
	cout<<mv<<endl;
	return 0;
}

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

using namespace std;

long long fun(long long a) {
    long long res[] = {a,1,a+1,0};
    return res[a%4];
}

long long get(long long a, long long b) {
    return fun(b)^fun(a-1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long a,b;
    cin>>a>>b;
    if(a)
      cout<<get(a,b)<<endl;
    else if(b)
      cout<<get(1,b)<<endl;
    else
      cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
S += 'J'
L = []
for i in range(Q):
  L.append(list(map(int,input().split())))
cnt = [0]*(N+1)
for i in range(N):
  if S[i] == 'A' and S[i+1] == 'C':
    cnt[i+1] = 1
for i in range(1,N+1):
  cnt[i] += cnt[i-1]
for j in range(Q):
  print(cnt[L[j][1]-1]-cnt[L[j][0]-1])

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

int main() {
    int n;
    cin >> n;
    vector<int> oe (n);
    for(int i=0; i<n; i++){
        cin >> oe.at(i);
    }
    set<int> s;
    for(int i=n; i>=1; i--){
        int count = 0;
        for(int j=i*2; j<=n; j+=i){
            if(s.count(j)) count++;
        }
        if(count%2 != oe.at(i-1)){
            s.insert(i);
        }
    }
    if(s.size() == 0){
        cout << 0 << endl;
    }
    else{
        cout << s.size() << endl;
        for(int x : s){
            cout << x << " ";
        }
    }
}

Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if (a==1&&b==1&&c==0)
  {
      cout<<"Open"<<endl;
  }
  else if(a==0&&b==0&&c==1){
      cout<<"Open"<<endl;
  }
  else cout<<"Close"<<endl;

}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int N=10010<<1,INF=0x3f3f3f3f;

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
    char ch=nc();int sum=0;
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum;
}

struct E{
	int f,t,capa,flow,xt;
}e[N];

int h[N],cnt;

inline void adge(int f,int t,int capa){
	e[++cnt]=(E){f,t,capa,0,h[f]};h[f]=cnt;
	e[++cnt]=(E){t,f,0,0,h[t]};h[t]=cnt;
}

int d[N],cur[N],p[N],num[N];

int ISAP(int s,int t,int n){     			//ISAP大法好！！！！！！！ 
	for(int i=0;i<=n;i++) cur[i]=h[i],d[i]=INF;
	int flow=0;
	queue<int>q;
	q.push(t);
	d[t]=0;
	while(!q.empty()){
		int u=q.front();q.pop();
		for(int i=h[u];~i;i=e[i].xt){
			if(d[e[i].t]==INF) num[d[e[i].t]=d[u]+1]++,q.push(e[i].t);
		}
	}
	for(int x=s;d[s]<n;){
		if(x==t){
			int a=INF;
			for(;x!=s;x=e[p[x]].f) a=min(a,e[p[x]].capa-e[p[x]].flow);
			for(x=t;x!=s;x=e[p[x]].f) e[p[x]].flow+=a,e[p[x]^1].flow-=a;
			flow+=a;
		}
		bool ok=0;
		for(int i=cur[x];~i;i=e[i].xt){
			if(e[i].capa>e[i].flow&&d[e[i].t]==d[x]-1){
				ok=1;
				cur[x]=i;
				x=e[i].t;
				p[x]=i;
				break;
			}
		}
		if(!ok){
			int m=n-1;
			for(int i=cur[x]=h[x];~i;i=e[i].xt){
				if(e[i].capa>e[i].flow) m=min(m,d[e[i].t]);
			}
			if(--num[d[x]]==0) break;
			num[d[x]=m+1]++;
			if(x!=s) x=e[p[x]].f;
		}
	}
	return flow;
}

int pos[110],od[110],ev[110],c1,c2;

bool isp(int n){
	if(n==0||n==1) return 0;
	int m=sqrt(n);
	for(int i=2;i<=m;i++)
		if(n%i==0) return 0;
	return 1;
}

inline void add(int x){
	if(x&1) od[++c1]=x;
	else ev[++c2]=x;
}
int main(){
	memset(h,cnt=-1,sizeof(h));
	int n;
	n=read();
	for(int i=1;i<=n;i++){
		pos[i]=read();
		if(pos[i-1]+1!=pos[i]||i==1){		
			if(i>1) add(pos[i-1]+1);
			add(pos[i]);
		}
	}
	add(pos[n]+1);
	for(int i=1;i<=c1;i++){
		for(int j=1;j<=c2;j++){
			if(isp(abs(od[i]-ev[j]))){
				adge(i,j+c1,1);
			}
		}
	}
	for(int i=1;i<=c1;i++) adge(0,i,1);
	for(int i=1;i<=c2;i++) adge(i+c1,c1+c2+1,1);
	int ans=ISAP(0,c1+c2+1,c1+c2+1);
	int t=ans;
	ans=ans+(c1-t)/2*2;
	ans=ans+(c2-t)/2*2;
	if((c1-t)%2) ans+=3;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
int main(){
	int n,ret=0,u,v,d=1;
	scanf("%d",&n);
	--n;
	while(d<=n){
		u=(n/d),v=n/u;
		ret += 1LL*(v-d+1)*u;
		d=v+1;
	}
	printf("%d\n",ret);
}


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

int main( void ) {
    
    string str1, str2, str3;
    cin >> str1 >> str2 >> str3;
    
    cout << (char) toupper( str1[0] ) << (char) toupper( str2[0] ) << (char) toupper( str3[0] );
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int w,h,n; cin >> w >> h >> n;
    vector<int> x(n),y(n),a(n);
    rep(i,n) cin >> x[i] >> y[i] >> a[i];

    int c[h][w];
    rep(i,h)rep(j,w) c[i][j] = 0;

    rep(i,n){
        if(a[i] == 1){
            rep(j,h) rep(k,x[i]) c[j][k] = 1;
        }else if(a[i] == 2){
            rep(j,h) for(int k = x[i]; k < w; k++) c[j][k] = 1;
        }else if(a[i] == 3){
            rep(j,y[i]) rep(k,w) c[j][k] = 1;
        }else{
            for(int j = y[i]; j < h; j++)rep(k,w) c[j][k] = 1;
        }
    }
    int ans = 0;
    rep(i,h) rep(j,w) if(c[i][j] == 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtoCoder118B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);// 人数
            int M = int.Parse(input[1]);// 食べ物の種類
            Dictionary<int, int> dict = new Dictionary<int, int>();
            // 食べ物、好きと答えた人数
            for(var key = 1; key <= M; key++)
            {
                dict[key] = 0;
            }
            for(var i = 0; i < N; i++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                int K = int.Parse(input2[0]);
                int[] A = new int[K+1];
                for(var j = 1; j <= K; j++)
                {
                    A[j] = int.Parse(input2[j]);
                    dict[A[j]]++;
                }
            }
            int ans = 0;
            for(var p=1; p <= M; p++)
            {
                if (dict[p] == N)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int ab,bc,ca;
  cin >> ab >> bc >> ca;
  cout << (ab*bc)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

ll dp[52][2525];
vector<tuple<ll, ll, ll>> G[52];
pair<ll, ll> X[52];

int main() {
	for (int i = 0;i < 52;i++)
		for (int j = 0;j < 2525;j++)
			dp[i][j] = -1;
	ll N, M, S;
	cin >> N >> M >> S;
	if (S > 2510) {
		S = 2510;
	}
	priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> Q;
	Q.push(make_tuple(0, S, 1));
	ll U, V, A, B, C, D;
	for (int i = 0;i < M;i++) {
		cin >> U >> V >> A >> B;
		G[U].push_back(make_tuple(V, A, B));
		G[V].push_back(make_tuple(U, A, B));
	}
	for (int i = 1;i <= N;i++) {
		cin >> C >> D;
		X[i] = { C,D };
	}
	while (!Q.empty()) {
		tie(U, S, V) = Q.top();
		Q.pop();
		if (dp[V][S] >= 0)continue;
		dp[V][S] = U;
		for (auto i : G[V]) {
			tie(C, A, B) = i;
			if (A > S)continue;
			Q.push(make_tuple(U + B, S - A, C));
		}
		tie(C, D) = X[V];
		Q.push(make_tuple(U + D, min(S + C, 2510LL), V));
	}
	ll ans = 0;
	for (int v = 2;v <= N;v++) {
		ans = LLONG_MAX;
		for (int i = 0;i < 2525;i++) {
			if (dp[v][i] < 0)continue;
			ans = min(ans, dp[v][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 16460