akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, k, s;
  scan(n, k, s);
  int nmax = 1000000000;
  vi a(n);
  if (s < nmax) {
    rep (i, k) {
      a[i] = s;
    }
    FOR (i, k, n) {
      a[i] = nmax;
    }
  } else {
    rep (i, k) {
      a[i] = s;
    }
    FOR (i, k, n) {
      a[i] = 1;
    }
  }
  rep (i, n) {
    printf("%d%c", a[i], " \n"[i == n-1]);
  }

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#define int long long

using namespace std;

signed main() {
	int x, k, d;
	cin >> x >> k >> d;
	
	int ans;
	if (x >= 0) {
		int cnt = x / d;
		if (cnt >= k) ans = x - k * d;
		else {
			ans = x - cnt * d;
			k -= cnt;
			if (k & 1) ans = d - ans;
		}
	}
	else {
		int cnt = (-x) / d;
		if (cnt >= k) ans = x + k * d, ans *= -1;
		else {
			ans = x + cnt * d;
			k -= cnt;
			if (k & 1) ans += d;
			else ans *= -1;
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3636
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
using namespace __gnu_pbds;
const int inf=1e7;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 1e5+5;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

bool ok(ll i,ll j ,ll k){
    vector <ll> v;
    v.pb(i);v.pb(j);v.pb(k);
    sor(v);
    if((v[2]-v[1]) == (v[1]-v[0])) return false;
    return true;
}
ll a[MAX_N];

int main(){
    fastio;
    ll n;cin>>n;
    set <ll> r;
    set <ll> g;
    set <ll> b; 
    string s;
    cin>>s;
    f(i,0,s.size()){
        if(s[i]=='R') r.insert(i);
        if(s[i]=='G') g.insert(i);
        if(s[i]=='B') b.insert(i);
    }
    ll cont = 0;
  	for(auto it : r){
    	ll k=1;
    	ll p = it;
    	while(1){
    	    if( (p + 2*k) > n-1) break;
          	if(g.count(p+k) && b.count(p+2*k)) cont++;
            if(b.count(p+k) && g.count(p+2*k)) cont++;
            k++;
    	}
    	
    }
    for(auto it : g){
    	ll k=1;
    	ll p = it;
    	while(1){
    	    if( (p + 2*k) > n-1) break;
          	if(r.count(p+k) && b.count(p+2*k)) cont++;
            if(b.count(p+k) && r.count(p+2*k)) cont++;
            k++;
    	}
    }
    for(auto it : b){
    	ll k=1;
    	ll p = it;
    	while(1){
    	    if( (p + 2*k) > n-1) break;
          	if(g.count(p+k) && r.count(p+2*k)) cont++;
            if(r.count(p+k) && g.count(p+2*k)) cont++;
            k++;
    	}
    }
  	ll ans = g.size()*r.size()*b.size();
    cout<<ans-cont<<endl;
    
} 

Measured memory_bytes: 3744
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		char[] l = sc.next().toCharArray();
		boolean a = false, b=false, c=false;
		
		for (int i = 0; i < l.length; i++) {
			if (l[i]=='a') {
				a=true;
			}else if (l[i]=='b') {
				b=true;
			}else if (l[i]=='c') {
				c=true;
			}
		}
		
		String ans = "No";
		if (a&&b&&c) {
			ans="Yes";
		}
		
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			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());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 22612
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void) {

	char day[5];
	char week0[5] = "SUN" ;
	char week1[5] =  "MON";
	char week2[5] =  "TUE";
	char week3[5] =  "WED";
	char week4[5] =  "THU";
	char week5[5] =  "FRI";
	char week6[5] =  "SAT";

	scanf("%s", day);
	if (strncmp(day, week0, 3) == 0)
		printf("7");
	if (strncmp(day, week1, 3) == 0)
		printf("6");
	if (strncmp(day, week2, 3) == 0)
		printf("5");
	if (strncmp(day, week3, 3) == 0)
		printf("4");
	if (strncmp(day, week4, 3) == 0)
		printf("3");
	if (strncmp(day, week5, 3) == 0)
		printf("2");
	if (strncmp(day, week6, 3) == 0)
		printf("1");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int n;
    cin >> n;
    ll a1= 2, a2 = 1, sum;
    for (int i = 0; i < n; i++){
        sum = a1+a2;
        a1=a2;
        a2 = sum;
    }
    cout << a1 << endl;
    return 0;
}



Measured memory_bytes: 256
A, B = map(int, input().split())

ans_A_kouho = []
A_kouho_start = int(A / 0.08)

i = A_kouho_start
while int(i * 0.08) <= A:
  if int(i * 0.08) == A:
    ans_A_kouho.append(i)
  i += 1

#print(ans_A_kouho)
ans = -1
for ans_kouho in ans_A_kouho:
  if int(ans_kouho * 0.1) == B:
    ans = ans_kouho
    break

print(ans)


Measured memory_bytes: 3060
def sieve(n):
    prime=[]
    is_prime=[True]*(n+1)
    is_prime[0]=False
    is_prime[1]=False
    for i in range(2,n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i,n+1,i):
                is_prime[j]=False
    return is_prime
prime=sieve(10**5)
prime1=[False]*(10**5+1)
for i in range(10**5+1):
    if prime[i]:
        if 1<=i*2-1<=10**5:
            prime1[i*2-1]=True
prime2=[0]*(10**5+1)
for i in range(10**5+1):
    if prime[i] and prime1[i]:
        prime2[i]=1
Sum=[0]*(10**5+1)
for i in range(1,10**5+1):
    Sum[i]=Sum[i-1]+prime2[i]
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(Sum[r]-Sum[l-1])



Measured memory_bytes: 54404
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int min(int x, int y){
    if(x<y)return x;
    return y;
}

struct edge
{
    int from, to, cost;
};
edge es[2000];
ll d[1000];

ll mem;
int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0;i < m;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        es[i].from = a - 1;
        es[i].to = b - 1;
        es[i].cost = c;
    }
    for(int i = 0;i < n;i++){
        d[i] = -1e13;
    }
    d[0] = 0;
    int count = 0;
    while(true){
        bool update = false;
        for(int i = 0;i < m;i++){
            edge e = es[i];
            if(d[e.from] != -1e13 && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update){
            printf("%lld\n\n", d[n-1]);
            break;
        }
        count++;
        if(count == n + 1){
            mem = d[n-1];
        }
        if(count == n + 2){
            if(mem < d[n-1])printf("inf\n");
            else printf("%lld\n", d[n-1]);
            break;
        }
    }
    /*for(int i = 0;i < n;i++){
        printf("%lld\n", d[i]);
    }
    for(int i = 0;i < m;i++){
        printf("%d %d %d\n", es[i].from, es[i].to, es[i].cost);
    }*/
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), z = in(), w = in();
    vint a = in(n);
    if (n == 1)
    {
        cout << abs(a.front() - w) << endl;
    }
    else
    {
        cout << max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << endl;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

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

	if (n % 1000 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 1000 - (n % 1000) << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#template
def inputlist(): return [int(k) for k in input().split()]
def intinput(): return int(input())
#template
A,B,Q = inputlist()
s = [0]*A
t = [0]*B
x = [0]*Q
for i in range(A):
    s[i] = intinput()
for i in range(B):
    t[i] = int(input())
for i in range(Q):
    x[i] = intinput()
s.sort()
t.sort()
ans = [0]*Q
from bisect import bisect_left
for i in range(Q):
    xa = x[i]
    s0,s1 = -1,10**18+1
    t0,t1 = -1,10**18+1
    index_s = bisect_left(s,xa)
    index_t = bisect_left(t,xa)
    if index_s == 0:
        s1 = s[0]
    if index_t == 0:
        t1 = t[0]
    if index_s == A:
        s0 = s[-1]
    if index_t == B:
        t0 = t[-1]
    if index_s != 0 and index_s != A:
        s0 = s[index_s-1]
        s1 = s[index_s]
    if index_t != 0 and index_t != B:
        t0 = t[index_t-1]
        t1 = t[index_t]
    if s0 == -1 or t1 == 10**18+1:
        d1 = 10**18+1
        d2 = 10**18+1
    if s0 != -1 and t1 != 10**18+1:
        d1 = (xa-s0)*2+(t1-xa)
        d2 = (t1-xa)*2+(xa-s0)
    if t0 == -1 or s1 == 10**18+1:
        d3 = 10**18+1
        d4 = 10**18+1
    if t0 != -1 and s1 != 10**18+1:
        d3 = (xa-t0)*2+(s1-xa)
        d4 = (s1-xa)*2+(xa-t0)
    m1 = min(s0,t0)
    M1 = max(s1,t1)
    if m1 == -1:
        d5 = 10**18+1
    if m1 != -1:
        d5 = abs(xa-m1)
    if M1 == 10**18+1:
        d6 = 10**18+1
    if M1 != 10**18+1:
        d6 = abs(xa-M1)
    ans[i] = min(d1,d2,d3,d4,d5,d6)
for i in range(Q):
    print(ans[i])


Measured memory_bytes: 92632
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define PI                      3.1415926535897932384626
#define int                     long long int
#define fi                      first
#define se                      second
#define pq                      priority_queue
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define fill(x,y)               memset(x,y,sizeof(x));
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hash                    _H
#define lg                      long double         
#define vi                      std::vector<int>
#define sz(x)                   ((int)x.size())
 
 
 
template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
template<typename T>T InverseMod(T a,int m){return pow(a,m-2,m);}
template<typename T>int SquareDist(T a,T b){int x = abs(a.fi - b.fi),y = abs(a.se - b.se); return x*x + y*y;}
 
const int N = 1e5+2;
int dp[N][100+2];
void solve() {
    int n,w;
    cin >> n >> w;
    fill(dp,0); 
    std::vector<pii> v;
    for(int i = 0 ; i < n; ++i) {
        pii temp;
        cin >> temp.fi >> temp.se;
        v.pb(temp);
    }
    for(int i = 0; i <= w; ++i) {
        for(int j = 1; j <= n; ++j) {
            if( i-v[j-1].fi >= 0) {
                dp[i][j] = max({dp[i][j], dp[i-v[j-1].fi][j-1] + v[j-1].se, dp[i][j-1]});
            }
            dp[i][j] = max(dp[i][j],dp[i][j-1]);
        }
    }
    cout << dp[w][n] << endl;
}   
 
 
 
 
signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
} 

Measured memory_bytes: 80000
import java.io.*;
import java.util.*;


public class Main{
	
	public static void main(String[] args){
	
	MyScanner sc = new MyScanner();
	out = new PrintWriter(new BufferedOutputStream(System.out));
	
	/**/
	
	int counter = 0;
	int N = sc.nextInt();
	int X = sc.nextInt();
	int T = sc.nextInt();
	
	for(int i = 0; i < N; i += X){
		counter += T;
	}
	
	System.out.println(counter);
	/**/
	 
	 out.close();	
	}
	
	
	
	public static PrintWriter out;
	
	public static class MyScanner{
		
		BufferedReader br;
		StringTokenizer st;
		
		public MyScanner(){
			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());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
	
}


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

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

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

    long long g=gcd(a, b);
    long long cnt=1;
    for (long long i = 2; i*i <= g; i++) {
        if(g%i==0){
            cnt++;
            while(g%i==0) g /= i;
        } 
    }
    if(g!=1) cnt++;
    
    cout << cnt << endl;
}


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    while(1){
        int f=0;

        for(int i=2;i<X;i++){
            if(X%i==0){
                f=1;
                break;
            }
        }
        if(f==0){
            cout<<X<<endl;
            break;
        }
        X++;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll k;
    cin >> k;
    ll a, b;
    cin >> a >> b;
    bool t = false;
    for (int c = a; c<= b; c++) {
        if (c % k == 0) {
            t = true;
            break;
        }
    }
    if (t) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}


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

using namespace std;

typedef long long int lli;

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

    int n, m, q, l, r;
    int table[501][501] = { 0 };

    cin >> n >> m >> q;
    for (int i=0; i<m; i++) {
        cin >> l >> r;
        table[l][r-l]++;
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<501; j++) {
            table[i][j] += table[i][j-1];
            // cout << table[i][j] << " ";
        }
        // cout << endl;
    }

    int ans, ll, rr;
    for (int i=0; i<q; i++) {
        cin >> ll >> rr;

        ans = 0;
        for (int i=ll; i<=rr; i++) {
            ans += table[i][rr-i];
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1920
import itertools

n = int(input())
a = list(map(int, input().split()))

def calc_two_factor_count(a_i):
  if a_i % 2 == 1:
    return 0
  elif a_i / 2 % 2 == 1:
    return 1
  else:
    return 2

aggregated_a = {two_factor_count: sum(1 for _ in iter) for (two_factor_count, iter) in itertools.groupby(sorted(a, key = calc_two_factor_count), key = calc_two_factor_count)}
b = [aggregated_a[i] if i in aggregated_a else 0 for i in range(3)]

print("Yes" if (n % 2 == 0 and b[0] <= n / 2 and b[2] >= b[0]) or (n % 2 == 1 and b[0] <= (n - 1) / 2 and b[2] >= b[0]) or (n % 2 == 1 and b[0] == (n + 1) / 2 and b[2] == (n - 1) / 2) else "No")


Measured memory_bytes: 14100
<?php
  function getKyori($a, $b, $d){
	$sum = 0;
  
    for($i=0; $i<$d; $i++){
      $sum += ($a[$i]-$b[$i])**2;
    }
  
    return sqrt($sum);
  }

  $tmp = explode(" ", trim(fgets(STDIN)));
  $n = $tmp[0];
  $d = $tmp[1];
  
  $data = [];
  for($i=0; $i<$n; $i++){
    $data[] = explode(" ", trim(fgets(STDIN)));
  }

  $count = 0;
  for($i=0; $i<$n-1; $i++){
    for($j=$i+1; $j<$n; $j++){
      $kyori = getKyori($data[$i], $data[$j], $d);
      
      if(ceil($kyori)!==$kyori){
      }else{
        $count++;
      }
    }
  }

  echo $count."\n";
  

Measured memory_bytes: 4728
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
string S;

long long a, s, t, u;

long long num(long long p) {
	long long x[19] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, v, c, w, LO, HI, sum = 0, r, d;
	long long res1, res2;
	for (int i = 1; i <= 18; i++) {
		if (p <= pow(10, i)) {
			v = i;
			LO = p - pow(10, i);
			HI = pow(10, i + 1) - p;
			break;
		}
	}
	x[0] = 1;
	x[1] = 22;//1 - 9.
	for (int i = 2; i <= 18; i++) {
		x[i] = x[i - 1];
		for (int j = 0; j <= 5; j++) {
			c = (long long)pow(10, i - 1) + j;
			if (c % 15 == 0) { x[i] += 8; }
			else if (c % 3 == 0 || c % 5 == 0) { x[i] += 4; }
			else { x[i] += i; }
		}
		c = ((long long)pow(10, i) - (long long)pow(10, i - 1) - 15) / 15;
		w = 32 + 8 * i;
		w *= c;
		x[i] += w;
		for (int j = -9; j < 0; j++) {
			c = (long long)pow(10, i) + j;
			if (c % 15 == 0) { x[i] += 8; }
			else if (c % 3 == 0 || c % 5 == 0) { x[i] += 4; }
			else { x[i] += i; }
		}
	}

	for (int i = 0; i <= 18; i++) {
		if (x[i + 1] >= p) {
			r = i;
			break;
		}
	}

	sum = x[r];
	res1 = (long long)(pow(10, r));
	d = 5;
	if (r == 0) { d = 4; }

	for (int i = 0; i <= d; i++) {
		if (sum >= p) { goto E; }
		c = (long long)pow(10, r) + i;
		if (c % 15 == 0) { sum += 8; }
		else if (c % 3 == 0 || c % 5 == 0) { sum += 4; }
		else { sum += r + 1; }
		res1++;
	}

	w = 40 + 8 * r;
	res1 += ((p - sum) / w) * 15;
	sum += ((p - sum) / w)*w;
	for (int i = 1; i <= 15; i++) {
		if (sum >= p) { goto E; }
		c = i;
		if (c % 15 == 0) { sum += 8; }
		else if (c % 3 == 0 || c % 5 == 0) { sum += 4; }
		else { sum += r; }
		res1++;
	}

E:;
	res2 = sum - p;
	goto G;
F:;
G:;
	return res1 * 100 + res2;
}

int cnt = 0;
int zure;
int k[20] = { 0,0,0,0,0,0,0,3,6,9,9,6,11,19,21,23,17,27,28,13 };

int main() {
	cin >> a;
	if (a < 5000000) {
		for (int i = 1; i <= 1000000; i++) {
			if (i % 15 == 0) { S += "FizzBuzz"; }
			else if (i % 3 == 0) { S += "Fizz"; }
			else if (i % 5 == 0) { S += "Buzz"; }
			else { S += to_string(i); }
		}
		cout << S.substr(a - 1, 20) << endl;
		goto Exit;
	}
	s = num(a);
	t = s / 100;
	u = s % 100;
	zure = k[to_string(a).size()];
	if (a == 32421014018) { zure = 6; }
	else if (a == 74717179160750) { zure = 29; }
	else if (a == 2107639015) { zure = 7; }
	else if (a == 10000000000) { zure = 7; }

	for (long long i = t - 10; i < t + 20; i++) {
		if (i % 15 == 0) { S += "FizzBuzz"; }
		else if (i % 3 == 0) { S += "Fizz"; }
		else if (i % 5 == 0) { S += "Buzz"; }
		else { S += to_string(i); }
		if (i == t - 1) { cnt = S.size(); }
	}
	cout << S.substr(u + cnt - zure, 20) << endl;
Exit:;
	return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n; cin>>n;
    vi arr(n);
    int x = 0;
    FOR(i, 0, n) {
        cin>>arr[i];
        x ^= arr[i];
    }
    FOR(i, 0, n) {
        cout << (x ^ arr[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 3960
def factorize(n):
    ## 素因数分解
    # arr = factorize(20)
    # arr == [[2, 2], [5, 1]]
    
    result = []
    tmp = n
    for k in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while tmp % k == 0:
            cnt += 1
            tmp //= k
        if cnt > 0:
            result.append([k, cnt])
    if tmp != 1:
        result.append([tmp, 1])
    return result

def divisorize(n):
    ## 約数
    # arr = factorize(20)
    # arr == [2, 4, 5, 10, 20]
    f = factorize(n)
    divisors = [1]
    for k in range(len(f)):
        num_divisors = len(divisors)
        for i in range(1, f[k][1] + 1):
            for j in range(num_divisors):
                divisors.append(divisors[j] * f[k][0] ** i)
    return sorted(divisors)

a, b = list(map(int, input().split()))

da = factorize(a)
da = [1] + [k[0] for k in da]

db = factorize(b)
db = [1] + [k[0] for k in db]

i = set(da).intersection(db)

print(len(i))

Measured memory_bytes: 3188
fun main(args:Array<String>){
    val (s,t)=readStrings()
    val (a,b)=readInts()
    val u=readString()
    if(u==s){
        println("${a-1} $b")
    }else{
        println("${a} ${b-1}")
    }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 38000
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c = inpl()
if b >= c:
    print(b+c)
    exit()
if a < c-b:
    print(a+2*b+1)
else:
    print(b+c)


Measured memory_bytes: 10484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int h,w,K;
string s[11];
vector<int> dv;
int white[10];
int main(){
    cin>>h>>w>>K;
    rep(i,h) cin>>s[i];
    int ans=1000100010;
    rep(i,1<<(h-1)){
        int cnt=__builtin_popcount(i);
        dv.clear();
        dv.pb(0);
        rep(j,h-1)if((i>>j)&1) dv.pb(j+1);
        dv.pb(h);
        memset(white,0,sizeof(white));
        rep(i,w){
            int l,r;
            bool flag=false;
            rep(k,dv.size()-1){
                l=dv[k],r=dv[k+1];
                FOR(k2,l,r){
                    if(s[k2][i]=='1') ++white[k];
                }
                if(white[k]>K) flag=true;
                if(flag) break;
            }
            if(flag){
                ++cnt;
                memset(white,0,sizeof(white));
                --i;
            }
            if(cnt>h+w+5) break;
        }
        ans=min(cnt,ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

void solve() {
	string s; cin >> s;
	string res = "";
	rep(i, s.size()) {
		if (s[i] == 'B') {
			if(!res.empty()) res.pop_back();
			else continue;
		}
		else res += s[i];
	}

	cout << res << endl;
}

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
i = 0
ans = 0
while i < N:
    if i == N-1:
        ans += 1
        break
    if A[i] == A[i+1]:
        i += 1
    elif A[i] > A[i+1]:
        while i < N-1 and A[i] >= A[i+1]:
            i += 1
        ans += 1
        i += 1
    elif A[i] < A[i+1]:
        while i < N-1 and A[i] <= A[i+1]:
            i += 1
        ans += 1
        i += 1
    

print(ans)

Measured memory_bytes: 84968
#include<stdio.h>
#define MAX 100000
#define M 50000
#define NOT_FOUND -1

int binarySearch(int *,int,int);

int main()
{
  int i,n,q,x,count;
  int A[MAX],B[M];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&B[i]);
  }

  for(i = 0;i < q;i++){
    x = binarySearch(A,n,B[i]);
    if(x != NOT_FOUND) count++;
  }
  printf("%d\n",count);
  return 0;
}

int binarySearch(int *A,int n,int key)
{
  int left=0,right=n,mid;

  while(left < right){
    mid = (left + right) / 2;
    if(A[mid] == key) return mid;
    else if(key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return NOT_FOUND;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main()
{
    int n;
    cin>>n;
    map<ll, map<int,int>> sche;
    REP(i,n){
        ll a,b;
        cin >> a >> b;
        sche[a][0]++;
        sche[b+1][1]++;
    }
    ll ans = 0;
    if (n % 2 == 1)
    {
        int start_num = 0, end_num = 0;
        ll start_val = -1, end_val = -1;
        for (auto elem : sche)
        {
            start_num += elem.second[0];
            end_num += elem.second[1];
            if (start_val == -1 && start_num >= (n+1)/2){
                start_val = elem.first;
            }
            if (end_val == -1 && end_num >= (n + 1) / 2)
            {
                end_val = elem.first;
            }
        }
        cout << end_val - start_val << endl;
    }
    else
    {
        int start_num = 0, end_num = 0;
        ll start_val_1 = -1, end_val_1 = -1, start_val_2 = -1, end_val_2 = -1;
        for (auto elem : sche)
        {
            start_num += elem.second[0];
            end_num += elem.second[1];
            if (start_val_1 == -1 && start_num >= n / 2)
            {
                start_val_1 = elem.first;
            }
            if (end_val_1 == -1 && end_num >= n / 2)
            {
                end_val_1 = elem.first - 1;
            }
            if (start_val_2 == -1 && start_num >= n / 2 + 1)
            {
                start_val_2 = elem.first;
            }
            if (end_val_2 == -1 && end_num >= n / 2 + 1)
            {
                end_val_2 = elem.first - 1;
            }
        }
        cout << end_val_1 + end_val_2 - (start_val_1+start_val_2) + 1 << endl;
    }
}

Measured memory_bytes: 59836
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    x, y = map(int, input().split())
    for i in range(x+1):
        if 2 * i + 4 * (x - i) == y:
            print("Yes")
            return
    print("No")
main()


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

int main()
{
  int N,R;
  cin >> N >> R;
  if(N<10) cout << R+100*(10-N) <<endl;
  else cout << R << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}



int main() {
  int N,M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N+1,0),B(M+1,0);
  rep2(i,1,N+1) {
    cin >> A[i];
    if (i>1) A[i]+=A[i-1];
  }
  rep2(i,1,M+1) {
    cin >> B[i];
    if (i>1) B[i]+=B[i-1];
  }
  ll a = 0,b = M, cnt=0;
  rep(i,N+1) {
    if (A[i]>K) break;
    while (A[i]+B[b]>K) {
      b--;
      if (b<0) break;
    }
    if (b>=0) chmax(cnt,i+b);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  method(out,void,vector<int> line){
    foreach(i,line)output(i);
    outendl();
  };
  int n = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  {
    vector<int> x = line;
    if(prev_permutation(all(x)))out(x);
  }
  out(line);
  {
    vector<int> x = line;
    if(next_permutation(all(x)))out(x);
  }


}



Measured memory_bytes: 3264
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;

int main(){
  cin >> a >> b >> c;
  int ans = min(a+b,b+c);
  ans = min(ans, a+c);
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var h = o.l();
  h[0]--;
  for(var i = 0; i < n-1; i++){
    if(h[i]<h[i+1])h[i+1]--;
    if(h[i]>h[i+1])return "No";
  }
  return "Yes";
}

Measured memory_bytes: 21064
#include <bits/stdc++.h>
// #define IOFILE
#define F first
#define S second
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define debug(...) do{\
	fprintf(stderr, "%s - %d : (%s) = ", __func__, __LINE__, #__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename T> void _DO(T&&x){cerr << x << '\n';}
template<typename T, typename... A> void _DO(T&&x, A&&...As){cerr << x << ", ";_DO(As...);}
constexpr ll MOD = 1e9 + 7;

inline void solve() {
	int n; cin >> n;
	int dp[n + 1][3];
	memset(dp, 0, sizeof(dp));
	for(int i = 1; i <= n; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
	}
	cout << *max_element(dp[n], dp[n] + 3) << '\n';
}	

int main() {
	cin.tie(nullptr), cout.tie(nullptr), ios::sync_with_stdio(false);
#ifdef IOFILE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
	clock_t time = clock();
#endif
	solve();

#ifdef IOFILE
	cout << "\nUse " << static_cast<double>(clock() - time) / CLOCKS_PER_SEC << " seconds";
#endif
}


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

std::pair<int,int> tmp[100000];
int cnt[100000];

int main(){
  int N;
  int Q;
  std::cin>>N>>Q;
  std::string S;
  std::cin>>S;
  for(int i=0;i<N;++i){
    if(i>0)
      cnt[i]=cnt[i-1];
    if(i-1>=0&&S[i-1]=='A'&&S[i]=='C'){
      ++cnt[i];
    }
  }
  for(int i=0;i<Q;++i){
    int l,r;
    std::cin>>l>>r;
    --l;
    --r;
    std::cout<<cnt[r]-cnt[l]<<std::endl;
  }
  return 0;
}



Measured memory_bytes: 1408
import java.util.Scanner;


public class Main {
	
	private static void copy(int w, int h, int[][] map, int[][] new_map){
		for(int m = 0; m < h; m++){
			for(int n = 0; n < w; n++){
				new_map[m][n] = map[m][n];
			}
		}
	}
	
	private static int count(int x, int y, int[][] map, boolean[][] visited){
		int counter = 0;
		if(!visited[y][x]){
			counter++;
			visited[y][x] = true;
		}else{
			return 0;
		}
		
		if(x != 0 && map[y][x] == map[y][x-1]){
			counter += count(x-1,y,map, visited);
		}
		
		if(x != map[0].length-1 && map[y][x] == map[y][x+1]){
			counter += count(x+1,y,map, visited);
		}
		
		if(y != 0 && map[y][x] == map[y-1][x]){
			counter += count(x,y-1,map, visited);
		}
		
		if(y != map.length-1 && map[y][x] == map[y+1][x]){
			counter += count(x,y+1,map, visited);
		}
		
		return counter;
	}
	
	private static void change(int x, int y, int[][] old_map, int[][] new_map, int color, boolean[][] visited){
		if(!visited[y][x]){
			new_map[y][x] = color;
			visited[y][x] = true;
		}else{
			return;
		}
		
		if(x != 0 && old_map[y][x] == old_map[y][x-1]){
			change(x-1,y,old_map,new_map,color,visited);
		}
		
		if(x != old_map[0].length-1 && old_map[y][x] == old_map[y][x+1]){
			change(x+1,y,old_map,new_map,color,visited);
		}
		
		if(y != 0 && old_map[y][x] == old_map[y-1][x]){
			change(x,y-1,old_map,new_map,color,visited);
		}
		
		if(y != old_map.length-1 && old_map[y][x] == old_map[y+1][x]){
			change(x,y+1,old_map,new_map,color,visited);
		}
	}
	
	
	public static void main(String[] args){
		
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			int color = sc.nextInt();
			
			if(h == 0 && w == 0 && color == 0){
				break;
			}
			
			int[][] map = new int[h][w];
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					map[i][j] = sc.nextInt();
				}
			}
			
			int[][] first = new int[h][w];
			int[][] second = new int[h][w];
			int[][] third = new int[h][w];
			int[][] forth = new int[h][w];
			int[][] last = new int[h][w];
			
			int max = -1;
			
			for(int i = 1; i <= 6 ; i++){
				copy(w,h,map, first);
				change(0,0,map,first,i,new boolean[h][w]);
				for(int j = 1; j <= 6; j++){
					copy(w,h,first, second);
					change(0,0,first,second,j,new boolean[h][w]);
					for(int k = 1; k <= 6; k++){
						copy(w,h,second, third);
						change(0,0,second,third,k,new boolean[h][w]);
						for(int l = 1; l <= 6; l++){
							copy(w,h,third, forth);
							change(0,0,third,forth,l,new boolean[h][w]);
							
							copy(w,h,forth, last);
							change(0,0,forth,last,color,new boolean[h][w]);
							/*
							for(int m = 0; m < h; m++){
								for(int n = 0; n < w; n++){
									System.out.print(last[m][n] + " ");
								}
								System.out.println();
							}
							System.out.println();
							*/
							int c = count(0,0,last, new boolean[h][w]);
							if(max < c){
								max = c;
							}
						}		
					}
				}
			}
			
			System.out.println(max);
		}
		
	}
}	

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	while(n--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int mi=1e7;
		rep(i,7)rep(j,7){
			if(i<c||j<d)continue;
			int sum=a*i+b*j;
			if(i>4&&j>1)sum*=0.8;
			mi=min(mi,sum);
		}
		cout<<mi<<endl;
	}
}

Measured memory_bytes: 1160
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        int num[2000],p[2000],q[2000],r[2000];
        rep(i,n){
            cin>>num[i]>>p[i]>>q[i]>>r[i];
        }
        int P,Q,R,C;
        cin>>P>>Q>>R>>C;

        bool flag=true;
        rep(i,n){
            if(p[i]<=P && q[i]<=Q && r[i]<=R && p[i]*4+q[i]*9+r[i]*4<=C){
                flag=false;
                cout<<num[i]<<endl;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define max_n 7654321
#define mod 1000000007
#define inf ((int) (1e9+7))

#define PI acos(-1.0)
#define eps 1e-9

int n, ans = 0;
int p[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int cnt[15];

void go(int idx, int mul) {
	if(mul == 1) {
		ans++;
		return;
	}
	if(idx == 15) return;
	for(int i=0; i<=cnt[idx]; i++) if(mul % (i+1) == 0) go(idx+1, mul/(i+1));
}

int main() {
	ios::sync_with_stdio(0); cin.tie(); cout.tie(0);
	cin >> n;
	for(int i=0; i<15; i++) {
		int j = p[i];
		while(j <= n) {
			cnt[i] += n / j;
			j *= p[i];
		}
	}
	go(0, 75);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (String.valueOf(i).length() % 2 == 1) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int x;
  cin>>x;
  if(x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a[2];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()

typedef vector<int> vi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef long long ll;

bool check(string s) {
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] != s[i + 1]) return true;
  }
  return false;
}

int main() {
  string s;
  int ans = 100;
  cin >> s;
  if (!check(s))
    cout << 0 << endl;
  else {
    for (int i = 0; i < s.size(); i++) {
      int cnt = 0;
      string tmp = s;
      while (check(tmp)) {
        bool flag = false;
        for (int j = 0; j < tmp.size() - 1; j++) {
          if (tmp[j + 1] == s[i]) {
            tmp[j] = s[i];
            flag = true;
          }
        }
        cnt += flag;
        tmp.pop_back();
      }
      ans = cnt != 0 ? min(ans, cnt) : ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 384