akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int a, b;

int main(void) {
	cin >> a >> b;
	int ret = 0;
	int tmp = 1;
	while (tmp < b) {
		tmp += a - 1;
		ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#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 fib[50];

int main() {
    int n;
    cin >> n;
    
    fib[0] = 1;
    fib[1] = 1;
    
    if(n <= 1){
        cout << 1 << endl;
        return 0;
    }
    
    for(int i = 2; i <= n; ++i){
        fib[i] = fib[i-1] + fib[i-2];
    }
    
    cout << fib[n] << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
#include<string>
using namespace std;
#define ll long long

typedef pair<ll,ll> p;
int main(void){
    string a;
    cin >> a;
    if((a[0]==a[1] and a[2]==a[3]) or(a[0]==a[2] and a[1]==a[3])or(a[0]==a[3] and a[1]==a[2])){
        if(a[0]==a[1] and a[1]==a[2] and a[2]==a[3]){
            cout << "No"<<endl;
            
        }else{
            cout << "Yes"<<endl;
        }
        
    }else{
        cout << "No"<<endl;
    }
            
        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
    int ret = 1; while (b > 0) {
        if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1;
    } return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
typedef vector<int> Vec;
typedef vector<Vec> Mat;
Vec mulMatVec(Mat a, Vec b)
{
    int n = b.size(); Vec ret(n, 0);
    rep(i, 0, n) rep(j, 0, n) ret[i] = add(ret[i], mul(a[i][j], b[j]));
    return ret;
}
Mat mulMatMat(Mat a, Mat b)
{
    int n = a.size(); Mat ret(n, Vec(n, 0));
    rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
    return ret;
}
Mat mulMatMatForJunkai(Mat a, Mat b)
{
    int n = a.size(); Mat ret(n, Vec(n, 0));
    rep(j, 0, n) rep(k, 0, n) ret[0][j] = add(ret[0][j], mul(a[0][k], b[k][j]));
    rep(i, 1, n) rep(j, 0, n) ret[i][j] = ret[0][(j - i + n) % n];
    return ret;
}
Mat fastpow(Mat x, ll n)
{
    Mat ret(x.size(), Vec(x.size(), 0));
    rep(i, 0, x.size()) ret[i][i] = 1;
    while (0 < n) { if ((n % 2) == 0) { x = mulMatMatForJunkai(x, x); n >>= 1; } else { ret = mulMatMatForJunkai(ret, x); --n; } }
    return ret;
}
void printVec(Vec a) { cout << "[\t"; rep(i, 0, a.size()) cout << a[i] << "\t"; cout << "]" << endl; }
void printMat(Mat a) { rep(i, 0, a.size()) printVec(a[i]); }
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/

int N, M, K, P[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> K;
    rep(i, 0, M) cin >> P[i];

    Mat m(N, Vec(N, 0));
    Vec v(N, 0);
    v[0] = 1;

    rep(from, 0, N) rep(i, 0, M) {
        int to = (from + P[i]) % N;
        m[to][from]++;
    }
    rep(i, 0, N) m[i][i]++;

    //printMat(m);

    m = fastpow(m, K);
    v = mulMatVec(m, v);
    rep(i, 0, N) printf("%d\n", v[i]);
}

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

typedef vector<int> vi;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, i, s = 0, ans;
	cin >> n;
	vi as(n), bs(n), cs(n - 1);
	for (i = 0; i < n; i++)
		cin >> as[i];
	for (i = 0; i < n; i++)
		cin >> bs[i];
	for (i = 0; i < n - 1; i++)
		cin >> cs[i];

	for (i = 0; i < n; i++) {
		s += bs[as[i] - 1];
		if (i < n - 1 and as[i] + 1 == as[i + 1]) 
			s += cs[as[i] - 1];
	}
	cout << s << "\n";
	return 0;
}

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

int n, m;
vector<int> v;


int main(void) {
	cin >> n >> m;
	v = vector<int>(n, 1);
	int l = 0, r = 100000;
	for (int i = 0; i < m; i++) {
		int li, ri;
		cin >> li >> ri;
		if (li > l)
			l = li;
		if (ri < r)
			r = ri;

	}
	int ret = r - l + 1;
	if (ret < 0)
		ret = 0;
	cout << ret << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

typedef struct {
	int parent, rank;
} Node;

Node node[10000];

void init(int n) {
	int i;
	for (i = 0; i < n; i++) {
		node[i].parent = i;
		node[i].rank = 0;
	}
}

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

void unite(int x, int y) {
	int xr = find(x), yr = find(y);

	if (node[xr].rank < node[yr].rank)
		node[xr].parent = yr;
	else {
		node[yr].parent = xr;
		if (node[xr].rank == node[yr].rank)
			node[xr].rank++;
	}
}

int main(void) {
	int n, q;

	scanf("%d %d", &n, &q);

	init(n);
	while (q--) {
		int com, x, y;

		scanf("%d %d %d", &com, &x, &y);

		switch (com) {
			case 0:
				unite(x, y);
				break;
			case 1:
				printf("%d\n", find(x) == find(y));
				break;
		}
	}

	return 0;
}

Measured memory_bytes: 676
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);

    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 200010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
ll a[maxn],b[maxn];
int main(){
	ll n;
	inl(n);
	ll ans=0;
	ll k=0;
	FOR(i,1,n){
		inl2(a[i],b[i]);
		k=max(k+b[i]-(a[i]-a[i-1]),b[i]);
		ans=max(ans,k);
	}
	outl(ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string T;
  cin >> T;
  int ans = 0;
  for(int a=0; a<N-1; a++){
    string S = T.substr(a);
    int A[S.size()];
    //Z-algorithm
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
    }
    for(int b=0; b<S.size(); b++){
      if(A[b] > ans && b >= A[b]){
        ans = A[b];
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
const int NMAX = 100;
const int INF  = (1 << 30);

int d[NMAX+2][NMAX+2];
int N, M, T;
int m[NMAX+2][NMAX+2];
pair<int,int> inter[NMAX+2];
vector<pair<int,int>> G[NMAX+2];

void init()
{
    for( int i = 1;  i <= N;  ++i )
        for( int j = 1;  j <= N;  ++j ) if( i != j )
            d[i][j] = INF;
}

int main()
{
    int N, P, K;
    cin >> N >> K;
    for( int i = 1;  i <= N;  ++i ) {
        int x;
        cin >> x;
        if( x == 1 )
            P = i;
    }
    int steps = 1;
    int lg = N - K;
    steps += lg / (K - 1);
    steps += (lg % (K - 1) != 0);
    cout << steps << '\n';
    return 0;
}



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

int	main()
{
	int	N;
	cin >> N;
	string S;
	cin >> S;
	int	cost = 0;
	int	min_cost;
	for (int i = 1; i < N; ++i) {
		if (S[i] == 'E') 
			++cost;
	}
	min_cost = cost;
	for (int i = 1; i < N; ++i) {
		if (S[i - 1] == 'W')
			++cost;
		if (S[i] == 'E')
			--cost;
		min_cost = (min_cost > cost) ? cost : min_cost;
	}
	cout << min_cost << endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define llu unsigned long long 
#define ll unsigned long long 
ll read() { ll  x; if (scanf("%lld", &x) == -1)exit(0); return x; }
#define vi vector<int>
#define vb vector<bool>
const int INF = 1001001001;

#define LOCAL_JUDGE
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    //c_p_c();
    auto n = read();
    ll k = read();
    vi a(n);
    rep(i, 0, n) a[i] = read();
    vi s;
    vi ord(n + 1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while (ord[v] == -1) {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }

        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l) {
        cout << s[k] << endl;
    }
    else {
        k -= l;
        k %= c;
        cout << s[l + k] << endl;
    }

    return 0;
}



Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    vector<set<int>> g(N);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        g[x-1].insert(y-1);
        g[y-1].insert(x-1);   
    }
    vi per;
    repp(i, N)per.push_back(i);
    do {
        int now = 0;
        int sum = 1;
        set<int> visited;
        repp(i, N-1) {
            visited.insert(now);
            int next = per[now] - 1;
            if (g[now].count(next)&&!visited.count(next)) {
                now = next;
                sum++;
            }
            else break;
        }
        if (sum==N) ans++;
    } while (next_permutation(per.begin(), per.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.math.BigDecimal;

class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;

        while((str= br.readLine()) != null){
            String[] str2 = str.split(" ");
            double a = Double.parseDouble(str2[0]);
            double b = Double.parseDouble(str2[1]);
            double c = Double.parseDouble(str2[2]);
            double d = Double.parseDouble(str2[3]);
            double e = Double.parseDouble(str2[4]);
            double f = Double.parseDouble(str2[5]);


            double x = (c*e - b*f) / (a*e - b*d);
            double y = (c*d - a*f) / (b*d - a*e);

            BigDecimal bdY = new BigDecimal(y);
            BigDecimal bdX = new BigDecimal(x);

            bdY = bdY.setScale(3, BigDecimal.ROUND_HALF_UP);
            bdX = bdX.setScale(3, BigDecimal.ROUND_HALF_UP);


            System.out.printf("%.3f %.3f\n",bdX,bdY);
        }
    }
}

Measured memory_bytes: 24968
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;

ll p[100] = {};

int main()
{
	ll n, h, w;

	cin >> n >> h >> w;

	cout << ((n - h) + 1) * ((n - w) + 1) << endl;
	return 0;
	
	
}



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

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice { 
	public:
		dice() {
			id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
			id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
		}
		T& operator[] (FACE f) { return var[id[f]]; }
		const T& operator[] (FACE f) const { return var[id[f]]; }
		bool operator==(const dice<T>& b) const {
			const dice<T> &a = *this;
			return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
				a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
				a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
		}
		void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
		void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
		void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
		vector<dice> all_rolls() {
			vector<dice> ret;
			for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
				for (int i = 0; i < 4; roll_z(), ++i)
					ret.push_back(*this);
			return ret;
		}
		bool equivalent_to(const dice& di) {
			for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
				for (int i = 0; i < 4; roll_z(), ++i)
					if (*this == di) return true;
			return false;
		}
	protected:
		void roll(FACE a, FACE b, FACE c, FACE d) {
			T tmp = id[a];
			id[a] = id[b]; id[b] = id[c];
			id[c] = id[d]; id[d] = tmp;
		}
		T var[6];
		int id[6];
};

template <class T>
class mydice : public dice<T> {
	public:
		mydice(T top, T front, T right, T left, T back, T bottom) {
			this->var[this->id[TOP]] = top;
			this->var[this->id[FRONT]] = front;
			this->var[this->id[RIGHT]] = right;
			this->var[this->id[LEFT]] = left;
			this->var[this->id[BACK]] = back;
			this->var[this->id[BOTTOM]] = bottom;
		}
		void roll_n() { this->roll(TOP, FRONT, BOTTOM, BACK); }
		void roll_e() { this->roll(TOP, LEFT, BOTTOM, RIGHT); }
		void roll_w() { this->roll(TOP, RIGHT, BOTTOM, LEFT); }
		void roll_s() { this->roll(TOP, BACK, BOTTOM, FRONT); }
};

main () {
	int n[6], q, t, f;
	for (int i=0; i<6; i++) cin >> n[i];
	mydice<int> a(n[0], n[1], n[2], n[3], n[4], n[5]);
	vector<dice<int> > all = a.all_rolls();
	for (cin >> q; q--;) {
		cin >> t >> f;
		for (int i=0; i<all.size(); i++) {
			if (all[i][TOP] == t && all[i][FRONT] == f) {
				cout << all[i][RIGHT] << endl;
				break;
			}
		}
		
	}
}

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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
int H,A;
  cin>>H>>A;
  int counter=0;
  while(H>0){
    H-=A;
    counter++;
  }
  
  cout<<counter<<endl;
  
  
}



Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  long long T1;
  long long T2;
  long long A1;
  long long A2;
  long long B1;
  long long B2;
  long long x1;
  long long x2;
  long long y1;
  long long y2;
  long long res;
  rd(T1);
  rd(T2);
  rd(A1);
  rd(A2);
  rd(B1);
  rd(B2);
  x1 = T1 * A1;
  x2 = x1 + T2 * A2;
  y1 = T1 * B1;
  y2 = y1 + T2 * B2;
  if(x1 == y1 || x2 == y2){
    wt_L("infinity");
    wt_L('\n');
    return 0;
  }
  if(x2 > y2){
    swap(x1,y1);
    swap(x2,y2);
  }
  if(y1 > x1){
    wt_L(0);
    wt_L('\n');
    return 0;
  }
  res = (x1-y1)/(y2-x2) * 2 + 1;
  if((x1-y1)%(y2-x2) == 0){
    res--;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// {
//   ll T1, T2, A1, A2, B1, B2;
//   ll x1, x2, y1, y2;
//   ll res;
//   rd(T1,T2,A1,A2,B1,B2);
//   x1 = T1 * A1; x2 = x1 + T2 * A2;
//   y1 = T1 * B1; y2 = y1 + T2 * B2;
// 
//   if(x1 == y1 || x2 == y2) wt("infinity"), return 0;
//   if(x2 > y2){
//     swap(x1,y1);
//     swap(x2,y2);
//   }
//   if(y1 > x1) wt(0), return 0;
// 
//   res = (x1-y1)/(y2-x2) * 2 + 1;
//   if((x1-y1)%(y2-x2) == 0) res--;
//   wt(res);
// }


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

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

    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int ans = 0, t = 0;
    for (auto& x : a) {
        t += x;
        if (!x) {
            ans += t / 2;
            t = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,n,m,k;
	cin>>n>>m>>k;
	ll ar[n],b[m];
	for(i=0;i<n;i++)
	cin>>ar[i];
	for(j=0;j<m;j++)
	cin>>b[j];
	i=0,j=0;
	ll rem=k;
	//cout<<rem;
	ll ctr=0;
	bool fl=false;
	while(j<m and rem>=b[j])
	{
		rem-=b[j];
//		cout<<rem<<endl;
		j++;
		ctr++;
		fl=true;
	}
	//if(fl)
	j--;
//	cout<<rem<<' ';
	while(i<n and rem>=ar[i])
	{
		rem-=ar[i];
		i++;
		ctr++;
	}
	ll ans=ctr;
	//cout<<ans<<" "<<rem<<' '<<j<<endl;
	while(j>=0)
	{
		rem+=b[j];
		ctr--;
		j--;
		while(i<n and rem>=ar[i])
		{
			rem-=ar[i];
			i++;
			ctr++;
		}
		ans=max(ans,ctr);
	}
	cout<<ans;
}

Measured memory_bytes: 6748
from sys import stdin
X=int(stdin.readline().rstrip())
dif=1000
for i in range(1,32):
    for j in range(2,10):
        if pow(i,j) > X:
          break
        if X-pow(i,j) < dif:
            dif=X-pow(i,j)
            ans=pow(i,j)
print(ans)

Measured memory_bytes: 3060
N, _ = [int(x) for x in input().split()]
D = set(range(10)) - set([int(x) for x in input().split()])
n = [int(x) for x in list(str(N))]

i = 0
while i < len(n):
    if n[i] not in D:
        cand = {x for x in D if x > n[i]}
        if len(cand) > 0:
            n[i] = min(cand)
            for j in range(i + 1, len(n)):
                n[j] = 0
            i += 1
        elif i > 0:
                n[i - 1] += 1
                n[i] = 0
                i -= 1
        else:
            n = [1] + [0] * len(n)
    else:
        i += 1

print(''.join([str(x) for x in n]))


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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}

struct Edge{
    double cost;
    int to,used;
    bool operator>(const Edge &right)const{
        return cost > right.cost;
    }
};

int main(void){
    int n,m,p,a,b;
    while(cin>>n>>m>>p>>a>>b, m){
        a--,b--;
        int t[8];
        vector<vector<Edge>> g(m);
        rep(i,n) cin>>t[i];
        rep(i,p){
            int x,y;
            double z;
            cin>>x>>y>>z;
            x--,y--;
            g[x].push_back({z,y,0});
            g[y].push_back({z,x,0});
        }
        double dp[30][1<<8];
        Fill(dp, INF);
        priority_queue<Edge,vector<Edge>,greater<Edge>> qu;
        qu.push({dp[a][0] = 0, a,0});
        while(qu.size()){
            Edge cur = qu.top(); qu.pop();
            int v = cur.to;
            int used = cur.used;
            if(dp[v][used] < cur.cost) continue;
            for(Edge e : g[v]){
                rep(k,n){
                    if(used & bit(k)) continue;
                    if( dp[e.to][used|bit(k)] > dp[v][used] + e.cost/t[k]){
                        dp[e.to][used|bit(k)] = dp[v][used] + e.cost/t[k];
                        qu.push({dp[e.to][used|bit(k)], e.to, used|bit(k)});
                    }
                }
            }
        }
        double res = INF;
        rep(mask,1<<n){
            res = min(res, dp[b][mask]);
        }
        if(res == INF){
            cout<<"Impossible"<<endl;
        }else{
            printf("%.3f\n",res);
        }
    }
    return 0;
}



Measured memory_bytes: 4652
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    #define REVERSE(v) reverse(ALL(v))
    #define display(x) trav(a,x) cout<<a<<" ";cout<<endl
    #define debug cerr<<"bhau"<<endl
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        std::cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
 
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {  
        int n;cin>>n;
        //multiset<float> m;
        vector<double> m;
        for(int i=0;i<n;i++){
            double x;cin>>x;
            m.pb(x);
        }
        sort(all(m),greater<int>());
        for(int i=n-1;i>0;i--){
            m[i-1]=(m[i]+m[i-1])/2;
        }
        cout<<m[0];


       
        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()

score = 0
for k in range(K):
    if T[k]=='r':
        score += P
    elif T[k]=='s':
        score += R
    else:
        score += S
    odd = False
    for n in range(K+k, N, K):
        if T[n-K] == T[n] and not odd:
            odd = True
        else:
            if T[n]=='r':
                score += P
            elif T[n]=='s':
                score += R
            else:
                score += S
            odd = False

print(score)

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

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

    vector<int> res;
    res.push_back(a[0]);
    rep(i, 1, n)
    {
        vector<int>::iterator itr = lower_bound(res.begin(), res.end(), a[i]);
        if (itr == res.begin())
            res.insert(itr, a[i]);
        else
            res[itr - res.begin() - 1] = a[i];
    }
    cout << res.size() << endl;
    return 0;
}

Measured memory_bytes: 1276
# bit全探索
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
d = 10
status = []
for mask in range(1 << d):
    tmp = []
    for i in range(d):
        tmp.append((mask >> i) & 1)
    status.append(tmp)
# print(status)
ans = -10**12
for i in range(1, 1 << d):
    tmp = 0
    # print(status[i])
    # status[i]と同じところにビットが立っている個数をカウントする
    for j in range(N):
        cnt = 0
        for shop_status, joisino_status in zip(F[j], status[i]):
            if shop_status == 1 and joisino_status == 1:
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans, tmp)
print(ans)


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

int main()
{
    string a, b;
    cin >> a >> b;
    if(a.length()==b.length()){
        if(a==b) cout << "EQUAL" << endl;
        else if(a<b) cout << "LESS" << endl;
        else if(a>b) cout << "GREATER" << endl;
    }
    else if(a.length()>b.length()) cout << "GREATER" << endl;
    else cout << "LESS" << endl;
    return 0;

}


Measured memory_bytes: 384
import java.util.HashSet;
import java.util.Scanner;

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

        for(int i=0; i < N; i++){
            hs.add(sc.next());
        }

        System.out.println(hs.size());

        sc.close();
    }
}

Measured memory_bytes: 77012
COINS = [500, 100, 50]

a, b, c, x = readlines.map(&:to_i)

def comb_count(a, b, c, x)
  combs = a.product(b, c)
  values = combs.map { |counts| counts.zip(COINS).map { |n, v| n * v }.reduce(:+) }
  values.count(x)
end

p comb_count([*0..a], [*0..b], [*0..c], x)


Measured memory_bytes: 16252
while True:
    n, m, p = map(int, input().split())
    if n == 0:
        break
    players = [int(input()) for _ in range(n)]
    gold_div = sum(players) * (100 - p)
    winner = players[m - 1]
    print(int(gold_div / winner) if winner > 0 else 0)

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

LL k;
LL a[N];

int main()
{
	cin >> k;
	
	for (int i = 1; i <= 50; i ++ ) a[i] = k / 50LL + i;
	for (int i = 1; i <= 50LL - k % 50LL; i ++ ) a[i] -- ;
	
	puts("50");
	for (int i = 1; i <= 50; i ++ ) cout << a[i] << ' ';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
int INF = 1e9+7;

int main() {
    int N,Y;
    int x = 0;
    int y = 0;
    int z = 0;
    cin >> N >> Y;
    Y /= 1000;

    int can = 0;
    for (int i=0; i<=N; i++)
        for (int j=0; j<=N-i; j++) {
                int k = N-i-j;
                int sum = 0;
                sum = 1*i + 5*j + 10*k;
                if (sum==Y) {
                    can = 1;
                    x = k;
                    y = j;
                    z = i;
                    break;
                }
            }

    if (can) cout << x << ' ' << y << ' ' << z << endl;
    else cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      if(S - x - y <= K && S - x - y >= 0){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18+9
#define inf 1e9+9
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()

const int mod=1e9+7; 
const int nax=1e5+5; 
int dp[20][nax]; 

void solve(){
  int n;  cin>>n; 
  vector<int> x(n); for(int i=0;i<n;i++) cin>>x[i]; 
  int l,q; cin>>l>>q; 
  for(int i=0;i<n;i++){
    int j=upper_bound(all(x),x[i]+l)-x.begin(); 
    dp[0][i]=j-1; 
  }
  for(int i=1;i<20;i++){
    for(int j=0;j<n;j++){
      dp[i][j]=dp[i-1][dp[i-1][j]]; 
    }
  }
  for(int i=0;i<q;i++){
    int a,b; cin>>a>>b;  a--; b--; 
    if(a>b) swap(a,b); 
    int ans=0,j=19; 
    while(j>=0){
      if(dp[j][a]<b){
        ans^=(1<<j); 
        a=dp[j][a]; 
      }
      j--; 
    }
    cout<<ans+1<<endl; 
  }
}

int main()
{
	fast_io;
	clock_t beg=clock(); 
	solve(); 
	clock_t end=clock(); 
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
	return 0;
}

Measured memory_bytes: 9088
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;
#define PP pair<int, P>

LL C[2005][2005];
void init()
{
    C[1][1] = C[1][0] = C[0][0] = 1;
    for(int i = 2; i <= 2000; i++)
    {
        for(int j = 0; j <= i; j++){
            C[i][j] = C[i-1][j-1] + C[i-1][j];
            C[i][j] %= Mod;
        }
    }
}
int main()
{
    int n, k;
    init();
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        LL ans = C[k-1][i-1];
        ans *= (C[n-k+1][i] % Mod);
        ans %= Mod;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 30208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();

		long ans = 0;
		long total = A + B;

		if (A == 0) {
			System.out.println(0);
		} else {
			ans = ((N / total) * A) + Math.min(N % total, A);
			System.out.println(ans);
		}
	}

}


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

struct NODE{
	int src,dst,cap,weight;
};
bool operator < (const NODE &a,const NODE &b){
	return a.weight > b.weight;
}

int X[5],n;
map< multiset<set<int>> , long long> dp[5];

long long dfs(int p, multiset<set<int>> S ){
	if( p == n ){
		return 0;
	}
	int x = X[p];
	if( dp[p].count(S) ) return dp[p][S];
	long long ans = 1e12;
	vector< set<int> > uniq(S.begin(),S.end());
	uniq.erase(unique(uniq.begin(),uniq.end()),uniq.end());
	for(int j = 0 ; j < (1<<uniq.size()) ; j++){
		auto T = S;
		set<int> orS;
		int size = 0;
		for(int k = 0 ; k < uniq.size() ; k++){
			if( j >> k & 1 ){
				auto e = uniq[k];
				e.insert(p);
				T.erase(T.find(uniq[k]));
				T.insert(e);
				size += uniq[k].size();
				orS.insert(uniq[k].begin(),uniq[k].end());
			}
		}
		int c = __builtin_popcount(j);
		if( size == orS.size() && c <= x){
			for(int k = 0 ; k < min(5,x-c) ; k++){
				T.insert({p});
			}
			ans = min(dfs(p+1,T)+x-c,ans);
		}
	}
	return dp[p][S] = ans;
}

int main(){
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		cin >> X[i];
	}
	cout << dfs(0,{}) << endl;
}

Measured memory_bytes: 1548
#include <iostream>

using namespace std;
int main(void) {

    int a, b, c;
    cin >> a >> b >> c;
    
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= b && b >= c)
    {
        if (a <= c)
            cout << a << " " << c << " " << b << endl;
        else
            cout << c << " " << a << " " << b << endl;
    } else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else {
        if (b <= c)
            cout << b << " " << c << " " << a << endl;
        else 
            cout << c << " " << b << " " << a << endl;
    }

    return 0;
}



Measured memory_bytes: 3104
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/13 21:33:20
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

void run() {
    ll n; cin >> n;
    vector <ll> d;
    for (int i = 2; 1ll * i * i <= n; i++) {
        if (n % i == 0) {
            d.push_back(i);
            if (n / i != i) d.push_back(n / i);
        }
    }
    d.push_back(n);
    sort(all(d));
    --n;
    vector <ll> d2;
    for (int i = 2; 1ll * i * i <= n; i++) {
        if (n % i == 0) {
            d2.push_back(i);
            if (n / i != i) d2.push_back(n / i);
        }
    }
    if (n != 1) d2.push_back(n);
    ll ans = sz(d2);
    ++n;
    for (auto x : d) {
        ll now = n;
        while (now >= x && now % x == 0) {
            now /= x;
        }
        now %= x;
        if (now == 1) ++ans;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int a=0,b=0,ab=0,o=0;
	char str[10];
	while( scanf("%s",str) != EOF ){
		for(int i=0;;i++){
			if(str[i] == ','){
				if(str[i+1] == 'A'){
					if(str[i+2] == 'B') ab++;
					else a++;
				}
				if(str[i+1] == 'B') b++;
				if(str[i+1] == 'O') o++;
				break;
			}
		}
	}
	printf("%d\n",a);
	printf("%d\n",b);
	printf("%d\n",ab);
	printf("%d\n",o);
	return 0;
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, m;
    int d[200000], t[200000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> d[i];
    cin >> m;
    for (int i = 0; i < m; i++)
        cin >> t[i];

    map<int, int> m1, m2;
    for (int i = 0; i < n; i++)
        m1[d[i]]++;
    for (int i = 0; i < m; i++)
        m2[t[i]]++;

    for (auto itr = m2.begin(); itr != m2.end(); itr++)
    {
        // cout << itr->second << "," << m1[itr->first] << endl;
        if (itr->second > m1[itr->first])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 28416
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;

long long int a,b,n,k;
int main()
{
	cin>>n>>a>>b;
	k=b-a;
	n-=2;
	k=(b-a)*n+1;
	//cout<<max(0,((b-a)*n+1))<<endl;
	//cout<<max(0,k)<<endl;
	if(k<0)
		cout<<0<<endl;
	else
		cout<<k<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	const int m = 667, n = 2001, mod = 1e9 + 7;
	long long int s, t[m][n],ans[n];
	scanf("%lld", &s);
	for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) t[i][j] = 0;
	for (int j = 0; j < n; j++) ans[j] = 0;

	//i==1
	for (int j = 3; j < n; j++)t[1][j] = 1;

	for (int i = 2; i < m; i++) for (int j = 3 * i; j < n; j++) {
		int I = i - 1;
		for (int J = 3 * I; J <= j - 3; J++) {
			t[i][j] += t[I][J];
			t[i][j] = t[i][j] % mod;
		}
	}

	/*for (int i = 0; i < m; i++) {
		printf("\n%d\n",i); 
		for (int j = 0; j < n; j++)printf(" %d %d\n",j, t[i][j]); 
	}*/

	for (int j = 0; j < n; j++) {
		for (int i = 0; i < m; i++) {
			ans[j] += t[i][j];
			ans[j] = ans[j] % mod;
		}

	}
	printf("%lld\n",ans[s]);
	
	return 0;
}

Measured memory_bytes: 12176
#include<algorithm>
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n;string s;
	cin>>n>>s;
	char number[10]={'0','1','2','3','4','5','6','7','8','9'};
	int ans=0;
	int i[3];
	for(i[0]=0;i[0]<10;i[0]++){
		for(i[1]=0;i[1]<10;i[1]++){
			for(i[2]=0;i[2]<10;i[2]++){
				int count=0;
				for(int j=0;j<s.length();j++){
					if(s[j]==number[i[count]]){
						if(count==2){ans++;break;}
						else{count++;}
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    ll w,h,x,y; cin >> w >> h >> x >> y;
    bool b = y+0.0==(h+0.0)/2.0 && x+0.0==(w+0.0)/2.0;

    cout << setprecision(8) << (double) (h*w+0.0)/(2.0) << " " << b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main()
{
  while (1) {
    char ch;
    scanf("%c", &ch);
    if (isalpha(ch)) {
      if (isupper(ch)) printf("%c", tolower(ch));
      else printf("%c", toupper(ch));
    } else printf("%c", ch);
    if (ch=='\n') break;
  }
  return 0;
}



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


using namespace std;

#define MAXN 100010

int n;
int m;
int a[MAXN];
int prob[MAXN];
int pd[MAXN];

int main() {
    scanf("%d %d", &n, &m);
    int i, j;
    for (i=1; i<=m; i++) {
        scanf("%d", &a[i]);
        prob[a[i]]=1;
    }
    pd[n]=1;
    pd[n+1]=0;
    for (i=n-1; i>=0; i--) {
        if (prob[i]==1) {
            pd[i]=0;
        }
        else {
            pd[i]=pd[i+1]+pd[i+2];
        }
        pd[i]%=1000000007;
    }
    printf("%d\n", pd[0]);
    return 0;
}








Measured memory_bytes: 1408
//by xay5421 2449670833@qq.com
#include<set>
#include<map>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define int long long
#define debug(...) fprintf(stderr,__VA_ARGS__)
//#define debug(...) ((void)0)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;typedef unsigned long long ull;typedef std::pair<int,int> pii;
template<typename T>void rd(T&x){int f=0,c;while((c=getchar())<48||57<c)f^=!(c^45);x=(c&15);while(47<(c=getchar())&&c<58)x=x*10+(c&15);if(f)x=-x;}
template<typename T>inline void pt(T x){if(x<0)x=-x,putchar('-');if(x>9)pt(x/10);putchar(x%10+48);}
template<typename T>inline void pt(T x,int c){pt(x),putchar(c);}
template<typename T>inline T max(const T&x,const T&y){return x<y?y:x;}
template<typename T>inline T min(const T&x,const T&y){return x<y?x:y;}

const int N=200005,P=998244353;

int n,q[N],f[N];char s[N];

int biger(int x,int y,int len,int t){
	rep(i,1,len)if((s[x+i-1]^t)!=s[y+i-1])return (s[x+i-1]^t)>s[y+i-1]?1:-1;
	return 0; 
}

int solve(int x){
	bool flag=1;
	for(int i=1,t=0;i<=n;i+=x,t^=1){
		int tmp=biger(1,i,x,t);
		if(tmp==-1)break;
		if(tmp==1){flag=0;break;}
	}
	int k=0;
	rep(i,1,x){
		k=k*2+(s[i]&1);
		k%=P;
	}
	return (k+(flag==1))%P;
}

signed main(){
	rd(n);scanf("%s",s+1);
	rep(i,1,n){
		if(n%i==0&&n/i%2==1)q[++*q]=i;
	}
	rep(i,1,*q){
		f[i]=solve(q[i]);
	}
	int ans=0;
	rep(i,1,*q){
		rep(j,1,i-1){
			if(q[i]%q[j]==0&&q[i]/q[j]%2==1){
				(f[i]+=P-f[j])%=P;
			}
		}
		(ans+=q[i]*2%P*f[i]%P)%=P;
	}
	pt(ans,'\n');
	return 0;
}

Measured memory_bytes: 384
from collections import defaultdict
def prod(A,k,mod):
  ans = 1
  for i in range(k):
      ans *= A[i]
      ans %= mod
  return ans
def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  mod = 10**9+7
  ans = 1
  if K==N:
    return prod(A,N,mod)
  minus = len([a for a in A if a<0])
  if minus==N:
    if K%2==0:
      A.sort()
    else:
      A.sort(reverse=True)
    return prod(A,K,mod)
  if K==1:
    return max(A)
  A.sort(key=lambda x:-abs(x))
  if A[K]==0:
    return 0
  minus = len([a for a in A[:K] if a<0])
  flag = [1]*K+[0]*(N-K)
  d = defaultdict(lambda: -1)
  if minus%2==1:
    for i in range(K,N):
      if A[i]>=0:
        d['p2'] = i
        break
    for i in range(K,N):
      if A[i]<0:
        d['m2'] = i
        break
    for i in range(K-1,-1,-1):
      if A[i]>0:
        d['p1'] = i
        break
    for i in range(K-1,-1,-1):
      if A[i]<0:
        d['m1'] = i
        break
    if d['p2']==-1 or d['m1']==-1:
      flag[d['m2']],flag[d['p1']] = 1,0
    elif d['m2']==-1 or d['p1']==-1:
      flag[d['p2']],flag[d['m1']] = 1,0
    elif A[d['p2']]*A[d['p1']]>A[d['m1']]*A[d['m2']]:
        flag[d['p2']],flag[d['m1']] = 1,0
    else:
      flag[d['m2']],flag[d['p1']] = 1,0
    ans = 1
    for i in range(N):
      if flag[i]==1:
        ans *= A[i]
        ans %= mod
    return ans
  return prod(A,K,mod)
print(solve())


Measured memory_bytes: 33624
import java.util.Scanner;

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

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				System.out.print('D');
			} else {
				System.out.print(s.charAt(i));
			}
		}
		System.out.println();




		sc.close();
	}
}


Measured memory_bytes: 58424
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	new A().doIt();
    }
    class A{
    	int n3Y[] = {0,20,19,20,19,20,19,20,19,20,19}; 
    	int cntDay(int Y,int M,int D){
    		int result = 0;
    		for(int i = 1;i < Y;i++){
    			if(i % 3 == 0)result = result + 200;
    			else result = result + 195;
    		}
    		if(Y % 3 != 0){
    			for(int i = 1;i < M;i++)result = result + n3Y[i];
    		}else{
    			result = result + (20 * (M-1)); 
    		}
    		result = result + D;
    		return result;
    	}
    	void doIt(){
    		int n = sc.nextInt();
    		for(int i = 0;i < n;i++){
    			int Y = sc.nextInt(),M = sc.nextInt(),D = sc.nextInt();
    			int max = cntDay(1000,1,1);
    			int day = cntDay(Y,M,D);
        		System.out.println(max-day);
    		}
    	}
    }
}

Measured memory_bytes: 26608
require 'rexml/document'

class Panel
    def initialize(xml_node)
        @name = xml_node.name
        @x1, @y1, @x2, @y2 = xml_node.text.split(?,).map(&:to_i)
        @children = xml_node.elements.map {|c| Panel.new(c)}
    end

    def check(x, y)
        return nil if x < @x1 || @x2 < x || y < @y1 || @y2 < y

        if !@children.any? {|c| c.check(x, y)}
            puts "#{@name} #{@children.size}"
        end

        return true
    end
end

loop do
    n = gets.to_i
    break if n == 0
    xml = REXML::Document.new(gets.chomp)
    main_panel = Panel.new(xml.elements['/main'])

    n.times do
        x, y = gets.split.map(&:to_i)
        puts "OUT OF MAIN PANEL 1" if !main_panel.check(x, y)
    end
end

Measured memory_bytes: 10672
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-1-i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    int L = 0, R = mod;
    rep(i, M){
        int l, r; cin >> l >> r;
        L = max(L, l);
        R = min(R, r);
    }
    cout << max(0, R-L+1) << endl;
    return 0;
}

Measured memory_bytes: 256