akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#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()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m;
	cin>>n>>m;
	vvi in(n+3,vi(n+3));
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		in[a][b]++;
		in[a][b+1]--;
		in[a+c+1][b]--;
		in[a+c+1][b+c+2]++;
		in[a+c+2][b+1]++;
		in[a+c+2][b+c+2]--;
	}
	int co=0;
	rep(i,n+2)rep(j,n+2)in[i+1][j+1]+=in[i][j];
	rep(i,n+2)rep(j,n+3)in[i+1][j]+=in[i][j];
	rep(i,n+3)rep(j,n+2)in[i][j+1]+=in[i][j];
	rep(i,n+3)rep(j,n+3)if(in[i][j])co++;
	cout<<co<<endl;
}

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

using namespace std;

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



int main(){
    long int n, a, b;
    cin >> n >> a >> b;
    long int x[n];
    rep(i, n) cin >> x[i];
    long int ans = 0;
    rep(i, n - 1){
        if ((x[i+1] - x[i]) * a > b){
            ans += b;
        }else{
            ans += (x[i+1] - x[i]) * a;
        }
    }
    cout << ans << endl;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  int n, k;
  while (cin >>n, n) {
    map<char, char> m;
    range (c, 'a', 'z') m[c] = c;
    range (c, 'A', 'Z') m[c] = c;
    range (c, '0', '9') m[c] = c;
    rep (i, n) {
      char c, d; cin >> c >> d;
      m[c] = d;
    }
    cin >> k;
    rep (i, k) {
      char c; cin >> c;
      cout << m[c];
    } cout << endl;

  }

  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main()
{
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  REP(i,m) {
    int x, y, z;
    cin>>x>>y>>z;
    --x;--y;
    uf.merge(x,y);
  }
  set<int> s;
  REP(i,n) {
    s.insert(uf.root(i));
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 5376
X, Y, A, B, C = map(int, input().split(' '))

apples = []
for p in map(int, input().split(' ')):
    apples.append((p, 0))

for q in map(int, input().split(' ')):
    apples.append((q, 1))

for r in map(int, input().split(' ')):
    apples.append((r, 2))

apples.sort(reverse=True)

pq = []
r = []
x = X
y = Y

for d, t in apples:
    if t == 0:
        if x > 0:
            x -= 1
            pq.append(d)
        else:
            continue
    elif t == 1:
        if y > 0:
            y -= 1
            pq.append(d)
        else:
            continue
    else:
        r.append(d)

pq_len = len(pq)
for i in range(len(r)):
    if i >= pq_len:
        break

    if r[i] <= pq[-(i + 1)]:
        break

    pq[-(i + 1)] = r[i]

print(sum(pq))


Measured memory_bytes: 49648
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s[2], t[2];

	cin >> s[0] >> s[1];

	t[0] = s[1];
	t[1] = s[0];

	reverse(t[0].begin(), t[0].end());
	reverse(t[1].begin(), t[1].end());

	if (t[0] == s[0] && t[1] == s[1]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

void input(llong& rnNum)
{
  cin >> rnNum;
}

void calcNumToName(llong nNum)
{
  const int cnnDivisor = 26;
  vector<int> vnRemain;
  llong nDividend = nNum;

  while ( nDividend )
  {
    --nDividend;
    int nRemain = nDividend % cnnDivisor;
    vnRemain.push_back( nRemain );

    nDividend /= cnnDivisor;
  }
  reverse(begin(vnRemain), end(vnRemain));

  for (int nRemain : vnRemain)
    cout << (char)('a' + nRemain);

  cout << endl;
}
  
int main()
{
  llong nNum;
  input(nNum);
  calcNumToName(nNum);

  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
///////////////////////////////
#define int long long

void solve(){

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

	sort(a , a + n);
	reverse(a , a + n);
	int ans = 0;
	if(n==1){

		cout<<0<<endl;
		return;
	}
	for(int i = 0 ; i < n/2 ; ++i)
		ans += a[i];
	ans*=2;
	ans-=a[0];
	if((n&1))	
		ans += a[n/2];
	cout<<ans<<endl;
}
 
signed main(){
 
	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}


Measured memory_bytes: 5228
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int i, q;
  string str;
  cin >> str >> q;
  for (i=0; i<q; i++) {
    string f, g;
    int a, b;
    cin >> f >> a >> b;
    if (f=="replace") {
      cin >> g;
      str.replace(a, b-a+1, g);
    } else if (f=="reverse") {
      reverse(str.begin()+a, str.begin()+b+1);
    } else if (f=="print") {
      cout << string(&str[a], &str[b+1]) << endl;
    }
  }
}


Measured memory_bytes: 3216
# import sys
# input = sys.stdin.readline

def main():
    # input
    s = input()


    # calc
    temp = 1
    li = []
    if s[0]=='>':
        li.append(0)
    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            temp += 1
        else:
            li.append(temp)
            temp = 1
    li.append(temp)
    if s[-1]=='<':
        li.append(0)

    # ans
    ans = 0
    temp = 0
    while temp < len(li):
        large = max(li[temp], li[temp+1])
        short = min(li[temp], li[temp+1])
        ans += large*(large+1)//2 + short*(short-1)//2
        temp += 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6300
//AMBIKESH JHA
//NEPAL
//NEVER GIVE UP TRYING...
import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
	static final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static int tc;
	static final int MOD=1_000_000_007;
	public static long[] inputArray(String str){
		String[] s=str.split(" ");
		long[] array=new long[s.length];
		for(int i=0;i<s.length;i++) {
			array[i]=Long.parseLong(s[i]);
		}
		return array;
	}
		public static void main(String[] args)throws IOException {
		//tc=Integer.parseInt(br.readLine());
		tc=1;
		t:
		while(tc-->0) {
			int N=Integer.parseInt(br.readLine());
			int ans=1;
			for(int i=0;i<3;i++) {
				ans*=N;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
struct Edge {
    int from, to, len;
};
int main() {
    int L;
    cin >> L;
    vector<Edge> ans;
    int p = 1;
    for (int i = 0; i <= 16; i++) {
        ans.push_back({i, i + 1, 0});
        ans.push_back({i, i + 1, p});
        p *= 2;
    }
    // ~34本
    ans.push_back({17, 18, 0});
    ans.push_back({17, 18, p});
    ans.push_back({17, 18, 2 * p});
    // ~37本
    p *= 3;
    for(int i = 0; i < 2 && L >= p; i++) {
        L -= p;
        ans.push_back({18, 19, L});
    }
    // ~39本
    p /= 3;
    for(int i = 0; i < 2 && L >= p; i++) {
        L -= p;
        ans.push_back({17, 19, L});
    }
    // ~41本
    for(int i = 17; i >= 0; i--) {
        if (L >= p) {
            L -= p;
            ans.push_back({i, 19, L});
        }
        p /= 2;
    }
    // ~59本
    
    cout << 20 << " " << ans.size() << endl;
    for(auto x : ans) {
        cout << x.from + 1 << " " << x.to + 1 << " " << x.len << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
   
#define M 1100031
#define NIL (-1)
#define L 14
   
char H[M][L]; /* Hash Table */
   
int getChar(char ch){
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
}
   
/* convert a string into an integer value */
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
   
int h1(int key){ return key%M; }
int h2(int key){ return 1 + (key % (M - 1)); }
   
int find(char str[]){
    long long ii = getKey(str);
    int i,k;
    int hh1 = h1(ii);
    int hh2 = h2(ii);
    for (i = 0; i<M ; i++){
      k=(hh1 + i*hh2) % M;
      if (H[k][0] == '\0'){return 0;}
        else if (strcmp(H[k], str) == 0){ return 1; }
    }
    return 0;
    /* your task */
   
}
   
int insert(char str[]){
    long long ii = getKey(str);
    int hh1 = h1(ii);
    int hh2 = h2(ii);
    int i,k;
    for (i = 0; i<M; i++){
        k=(hh1 + i*hh2) % M;
        if (H[k][0]== '\0'){
            strcpy(H[k], str);
            return 0;
        }
    }
    return 0;
    /* your task */
   
}
   
int main(){
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
   
    scanf("%d", &n);
   
    for (i = 0; i < n; i++){
        scanf("%s %s", com, str);
   
        if (com[0] == 'i'){
            insert(str);
        }
        else {
            if (find(str)){
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
   
    return 0;
}

Measured memory_bytes: 15648
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&b>0){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int ans=0;
    int cnt=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            ans+=cnt-1;
            cnt=1;
        } 
        else cnt++;
    }
    ans+=cnt-1;

    cout<<min(n-1,ans+k*2)<<endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> pixel(H);
 
  cout << '#';
  for (int i = 0; i < W; i++) {
    cout << '#';
  }
  cout << '#' << endl;
  
  for (int i = 0; i < H; i++) {
    cout << '#';
    cin >> pixel.at(i);
    cout << pixel.at(i);
    cout << '#' << endl;
  }
  
  cout << '#';
  for (int i = 0; i < W; i++) {
    cout << '#';
  }
  cout << '#' << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  string s, fr, ba; cin >> s;
  int q; cin >> q;
  bool rev = 0;
  for(int i=0;i<q;i++) {
    int t, f;
    string c;
    cin >> t;
    if (t==1) {
      rev = !rev;
    }
    else {
      cin >> f >> c;
      f = 2-f;
      if (f^rev) fr+=c;
      else ba+=c;
    }
  }
  if (rev) {
    reverse(ba.begin(), ba.end());
    reverse(s.begin(), s.end());
    s = ba + s + fr;
  }
  else {
    reverse(fr.begin(), fr.end());
    s = fr + s + ba;
  }
  cout << s <<endl;

}


Measured memory_bytes: 1200
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1 && b==0 && c==0){
		printf("Close\n");
	}
	if(a==0 && b==1 && c==0){
		printf("Close\n");
	}
	if(a==0 && b==0 && c==0){
		printf("Close\n");
	}
	if(a==1 && b==1 && c==0){
		printf("Open\n");
	}
	if(a==0 && b==0 && c==1){
		printf("Open\n");
	}
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

typedef long long ll;

const int MAX_N = 4000;
const ll MOD = 1000000007;

int BIN[MAX_N + 5][MAX_N + 5];

void pre() {
    for(int n = 0; n <= MAX_N; n++) {
        for(int k = 0; k <= n; k++) {
            if(n == k || k == 0) {
                BIN[n][k] = 1;
            } else {
                BIN[n][k] = (BIN[n - 1][k] + BIN[n - 1][k - 1]) % MOD;
            }
        }
    }
}

// n - suma
// k - liczba elementów
int ile_sum(int n, int k) {
    return BIN[n + k - 1][k - 1];
}

int main() {
    pre();
    
//     cout << ile_sum(0, 2) << "\n";
    
    int n, k;
    cin >> n >> k;
    
    int red = n - k;
    
    for(int i = 1; i <= k; i++) {
        
        if(i == 1 && n == k) {
            cout << "1\n";
            continue;
        }
        
        if(i > 1 && red < i - 1) {
            cout << "0\n";
            continue;
        }
        
        ll niebieskie = ile_sum(k - i, i);
        ll wynik = 0;
        
        if(i > 1 && red >= i - 1) {
//             cout << "-> " << ile_sum(red - i + 1, i - 1) << endl;
            wynik = (wynik + ile_sum(red - i + 1, i - 1)) % MOD;
        }
        if(red >= i) {
//             cout << "-> " << ile_sum(red - i, i) << endl;
            wynik = (wynik + (2 * ile_sum(red - i, i)) % MOD) % MOD;
        }
        if(red >= i + 1) {
//             cout << "-> " << ile_sum(red - i - 1, i + 1) << endl;
            wynik = (wynik + ile_sum(red - i - 1, i + 1)) % MOD;
        }
        cout << (niebieskie * wynik) % MOD << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 48792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll mx=INT_MAX;
ll mn=INT_MIN;
const ll maxs = 1e3+5;

ll w[maxs];
ll val[maxs];
ll n,sz;
ll solve()
{
    ll dp[n+1][sz+1];
    memset(dp,0,sizeof dp);    
    for(ll i=1;i<=n;i++)
    {
         ll curr_w = w[i];
         ll curr_val = val[i];
        for(ll j=1;j<=sz;j++)
        {
            if(j<curr_w)
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                //dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j],max(dp[i][j-1] ,curr_val + dp[i-1][j-curr_w] ) );
                //dp[i][j] = max(dp[i-1][j], curr_val + dp[i-1][j-curr_w]);
            }
        }
    }
    
    /*for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=sz;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;    
    }*/
    
    return dp[n][sz];
}



int main(){
    cin>>n>>sz;
    for(ll i=1;i<=n;i++)
        cin>>w[i]>>val[i];
    std::cout << solve() << std::endl;
    return 0;
}

Measured memory_bytes: 79104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] h = new long[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextLong();
    }
    long[] dp = new long[n];
    for(int i = 1; i < n; i++) {
      dp[i] = Long.MAX_VALUE;
    }
    for(int i = 1; i < n; i++) {
      if(i > 1) dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
      dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1])); 
    }
    System.out.println(dp[n - 1]);
  }
}

Measured memory_bytes: 49220
import java.util.Scanner;

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

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

		for (int i = 0; i < n; i++) {
			x[i] = Math.abs(Integer.parseInt(sc.next()) - X);
		}

		int ans = x[0];
		if (n > 1)
			ans = gcd(x[0], x[1]);

		for (int i = 2; i < n; i++) {
			ans = gcd(ans, x[i]);
		}
		System.out.println(ans);

	}

	static int gcd(int a, int b) {
		int c = a;

		if (a < b) {
			a = b;
			b = c;
		}

		while (b != 0) {
			c = b;
			b = a % b;
			a = c;
		}
		return a;
	}
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;

int main()
{
  string S; cin >> S;
  int ret = 0, tmp = 0;
  
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T') {
      tmp++;
      ret = max(ret, tmp);
    } else {
      tmp = 0;
    }
  }
  cout << ret << endl;
  return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    i64 n, m;
    cin >> n >> m;
    vector<i64> a(n), b(n);
    vector<pair<i64,i64>> t;
    for(i64 i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        t.emplace_back(a[i], b[i]);
    }
    sort(t.begin(), t.end());
    i64 ans = 0;
    for(auto& p : t){
        i64 cou = min(p.second, m);
        ans += p.first * cou;
        m -= cou;
    }
    cout << ans << endl;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto& x : a) cin >> x;
	vector<vector<int>> f(k + 1, vector<int>(2));
	f[0][1] = 0;
	f[0][0] = 1;
	for (int x = 1; x <= k; x++) {
		for (int t = 0; t < 2; t++) {
			f[x][t] = 1 - t; //could not win
			for (int i = 0; i < n; i++) if (a[i] <= x) {
				if (f[x - a[i]][1 - t] == t) {
					f[x][t] = t; break;
				}
			}
		}
	}
	if (f[k][1]) cout << "First";
	else cout << "Second";
}

Measured memory_bytes: 8744
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n:i32 = read();
    let an:Vec<Vec<i32>> = read_vec2(2);
    let ans = run(an,n,0,0);
    println!("{}",ans);
}

fn run(an:Vec<Vec<i32>>,n:i32,ans:i32,i:i32) -> i32 {
   
    if  i > n {
        return ans 
    }
    let a1_ans:i32 = an[0].iter().take((i + 1) as usize).sum::<i32>();
    let a2_ans:i32 = an[1].iter().skip(i as usize).sum::<i32>();
    if a1_ans + a2_ans < ans {
        run(an,n,ans,i+1)
    } else {
         run(an,n,a1_ans + a2_ans,i+1)
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  vec<int> a(5); cin>>a;
  int k; cin>>k;
  Cout(a[4]-a[0]<=k?"Yay!":":(");
}












Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    long long int n;
    cin >> n;
    long long int res = 11;
    for (long long int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            long long int l = max(to_string(i).size(), to_string(n / i).size());
            res = min(l, res);
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var A = cin.scanint;
        var dp = new int[N];
        for (int i = 0; i < N; i++)
        {
            dp[i] = int.MaxValue;
        }
        dp[0] = 0;
        for (int i = 1; i < N; i++)
        {
            dp[i] = dp[i - 1] + Math.Abs(A[i] - A[i - 1]);
            if (i > 1) chmin(ref dp[i], dp[i - 2] + Math.Abs(A[i] - A[i - 2]));
        }
        WriteLine(dp[N - 1]);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String str = sc.next();
		int q = sc.nextInt();
		
		SqrtDecompositionROQRUQ sq = new SqrtDecompositionROQRUQ(n);
		for(int i = 0; i < n; i++) {
			char c = str.charAt(i);
			sq.update(i, i + 1, 1 << (int)(c - 'a'));
		}
		
		for(int i = 0; i < q; i++) {
			int inst = sc.nextInt();
			
			if(inst == 1) {
				int index = sc.nextInt() - 1;
				char c = sc.next().charAt(0);
				sq.update(index, index + 1, 1 << (int)(c - 'a'));
			}
			else {
				int l = sc.nextInt() - 1;
				int r = sc.nextInt() - 1;
				
				long or = sq.getSum(l, r + 1);
				
//				System.out.printf("%x\n", or);
				int count = 0;
				while(or > 0) {
					if(or%2 == 1) {
						count++;
					}
					or /= 2;
				}
				System.out.println(count);
			}
//			for(int j = 0; j < n; j++) {
//				System.out.print(sq.get(j) + " ");
//			}
//			System.out.println();
		}

	}

}

class SqrtDecompositionROQRUQ {
	int N, K;
	long[] data;
	long[] bucketOr;
	long[] bucketLazyUpdate;
	static final int sqrtN = 512;
	static final int NIL = Integer.MIN_VALUE;

	public SqrtDecompositionROQRUQ(int n) {
		N = n;
		K = (N + sqrtN - 1) / sqrtN;
		data = new long[K * sqrtN];
		bucketLazyUpdate = new long[K];
		Arrays.fill(bucketLazyUpdate, NIL);
		bucketOr = new long[K];
	}

	// [s, t)
	void update(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketLazyUpdate[k] = x;
				bucketOr[k] = x;
			} else {
				if(bucketLazyUpdate[k] != NIL){
					for(int i = l; i < r; i++){
						data[i] = bucketLazyUpdate[k];

					}
					bucketLazyUpdate[k] = NIL;
				}
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					data[i] = x;
				}
				bucketOr[k] = 0;
				for(int i = l; i < r; i++){
					bucketOr[k] |= data[i];
				}
			}
		}
	}

	//[s,t)
	long getSum(int s, int t) {
		long result = 0;
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				result |= bucketOr[k];
			}
			else {
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
					if(bucketLazyUpdate[k] != NIL){
						result |= bucketLazyUpdate[k];
					}
					else {
						result |= data[i];
					}
				}
			}
		}

		return result;
	}

	long get(int s) {
		int k = s / sqrtN;
		if(bucketLazyUpdate[k] != NIL){
			return bucketLazyUpdate[k];
		}
		else {
			return data[s];
		}
	}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var tp = new Tuple<string, int, int>[n];
            for (int i = 0; i < n; i++)
            {
                var a = Reads();
                tp[i] = Tuple.Create(a[0], 100 - int.Parse(a[1]), i + 1);
            }

            Array.Sort(tp);

            for (int i = 0; i < n; i++)
            {
                WriteLine(tp[i].Item3);
            }
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int a,b,c;
	read(a),read(b),read(c);
	if(a==b&&a==c) puts("No");
	else if(a!=b&&a!=c&&b!=c) puts("No");
	else puts("Yes");
	return 0;
}

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

int main(void) {
	int N;
	int X[100];
	scanf("%d", &N);
	int minx = 100, maxx = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &X[i]);
		minx = min(minx, X[i]);
		maxx = max(maxx, X[i]);
	}
	int ans = 20000000;
	for (int i = minx; i <= maxx; i++) {
		int sum = 0;
		for (int j = 0; j < N; j++) {
			sum += (X[j] - i) * (X[j] - i);
		}
		ans = min(ans, sum);
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3820
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  ll ans;
  if (x % 11 <= 6) {
    ll a = floor((x + 5.0) / (double)11);
    ll b = ceil((x - 6.0 * a) / 5.0);
    ans = a + b;
  } else {
    ll a = floor((x) / (double)11);
    ll b = ceil((x - 6.0 * a) / 5.0);
    ans = a + b;
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
  int n, m, l;
  cin >> n >> m >> l;
  long int a[n][m], b[m][l], c[n][l];
  //配列cを初期化
  for (int a=0; a<n; a++) {
    for (int b=0; b<l; b++) {
      c[a][b] = 0;
    }
  }
  //初期化終了
  //a入力開始
  for (int f=0; f<n; f++) {
    for (int g=0; g<m; g++) {
      cin >> a[f][g];
    }
  }
  //a入力終了
  //b入力開始
  for (int h=0; h<m; h++) {
    for (int o=0; o<l; o++) {
      cin >> b[h][o];
    }
  }
  //b入力終了
  //処理開始
  for (int i=0; i<n; i++) {
    for (int j=0; j<l; j++) {
      for (int k=0; k<m; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  //処理終了
  //出力開始
  for (int d=0; d<n; d++) {
    for (int e=0; e<l; e++) {
      cout << c[d][e];
      if (e!=l-1) {
        cout << ' ';
      }
    }
    cout << endl;
  }
  //出力終了
}



Measured memory_bytes: 3348
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r,c,k;
    cin >> r >> c >> k;
    vvll rc(r,vll(c,0));
    vector<vector<vector<ll> > > dp(r+1,vvll(c+1,vll(4,0)));
    REP(i,k){
        ll ri,ci,v;
        cin >> ri >> ci >> v;
        ri--; ci--;
        rc[ri][ci] = v;
    }
    REP(i,c){
        REP(j,r){
            dp[j+1][i+1][0] = max({dp[j+1][i][0], dp[j][i+1][0], dp[j][i+1][1], dp[j][i+1][2],dp[j][i+1][3]});
            dp[j+1][i+1][1] = dp[j+1][i][1];
            dp[j+1][i+1][2] = dp[j+1][i][2];
            dp[j+1][i+1][3] = dp[j+1][i][3];
            if(rc[j][i]>0){
                for(ll k=2;k>=0;--k){
                    dp[j+1][i+1][k+1] = max(dp[j+1][i+1][k+1], dp[j+1][i+1][k]+rc[j][i]);
                }
            }
        }
    }
    ll ans = 0;
    REP(i,4){
        ans = max(ans, dp[r][c][i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 707240
n = int(input())
l = sorted(map(int, input().split()))[::-1]

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[k] < l[j] < l[i] < l[k] + l[j]:
                ans += 1
print(ans)


Measured memory_bytes: 67988
N = int(input())
flag = True
ans = 0
c_A = 0
c_B = 0
for i in range(N):
    S = input()
    for i in range(len(S)-1):
        if S[i:i+2] == 'AB':
            ans += 1
    if S[0] == 'B':
        c_B += 1
        if not(S[-1] == 'A'):
            flag = False
    if S[-1] == 'A':
        c_A += 1
        if not(S[0] == 'B'):
            flag = False
if c_B == 0 or c_A == 0:
    flag = False
print(ans + min(c_A,c_B) - flag)


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

int main () {
  long long X;
  cin >> X;
  long long money = 100;
  int ans = 0;
  while (money < X) {
    long long m = money;
    money += m/100;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 3

void solver(int a, int b, int c) {
	int d = a - c;
	int e = b - c;

	if (d * e < 0) {
		printf("Yes\n");
		return;
	}

	printf("No\n");
}

int main() {
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	solver(a, b, c);
	return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    t = t.substr(0, s.length());
    if (s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#define Oo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
typedef long long ll;
int main()
{
      Oo
   int t;cin>>t;
   if (t==0)cout << 1;
   else cout << 0 ;
	return 0;
}


Measured memory_bytes: 3632
N = 3
C = [list(map(int, input().split())) for i in range(N)]
f = True
for i in range(N - 1):
    a = C[i][0] - C[i + 1][0]
    b = C[i][1] - C[i + 1][1]
    c = C[i][2] - C[i + 1][2]
    if a == b == c:
        continue
    else:
        f = False
for j in range(N - 1):
    a = C[0][j] - C[0][j + 1]
    b = C[1][j] - C[1][j + 1]
    c = C[2][j] - C[2][j + 1]
    if a == b == c:
        continue
    else:
        f = False
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int min3(int a,int b,int c){return min(min(a,b),c);}
int max3(int a,int b,int c){return max(max(a,b),c);}
int gcd(int x, int y){if(y==0)return x;return gcd(y, x%y);}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int maxn=1e6+6;
typedef long long ll;
const int mod=1e9+7;
ll a[maxn];
int main()
{
    ll n,c,k;
    scanf("%lld%lld%lld",&n,&c,&k);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    ll last=a[1];
    ll cnt=0;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=last+k)
        {
            cnt++;
            if(cnt>c)cnt=1,ans++,last=a[i];
        }
        else
        {
            cnt=1;
            last=a[i];
            ans++;
        }
    }
    printf("%lld\n",ans+1);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <functional>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int d ;
    cin >> d ;
    vector<int> c (26,0) ;
    for (int i = 0; i < 26; i++)
    {
        cin >> c.at(i) ;
    }
    vector<vector<int> > s(d,vector<int>(26)) ;
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < 26 ; j++)
        {
            cin >> s.at(i).at(j) ;
        }
        
    }
    vector<int> sc(d) ;
    for (int i = 0; i < d; i++)
    {
        cin >> sc.at(i) ;
    }
    
    vector<int>ans(0) ;
    vector<int64_t> score(0) ;
    int64_t snow = 0 ;
    vector<int> last(26,-1) ;
    for (int i = 0; i < d; i++)
    {
        int num = sc.at(i) ;
        ans.push_back(num) ;
        snow += s.at(i).at(num-1) ;
        last.at(num-1) = i ;
        for (int j = 0; j < 26; j++)
        {
            snow -= c.at(j) * (i - last.at(j)) ;
        }
        score.push_back(snow) ;
    }
    /*
    for (int i = 0; i < d; i++)
    {
        cout << ans.at(i) << endl ;
    }
    */
    for (int i = 0; i < d; i++)
    {
        cout << score.at(i) << endl ;
    }
    
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string S[50];
    rep(i, n) {
        cin >> S[i];
    }
    int d[26];
    rep(i, 26) {
        d[i] = 3000;
    }

    int t = 0;
    for(char c = 'a'; c <= 'z'; c++) {
        rep(i, n) {
            rep(j, S[i].size()) {
                if(S[i][j] == c) {
                    t++;
                }
            }

            d[c - 'a'] = min(d[c - 'a'], t);
            t = 0;
        }
    }

    for(char c = 'a'; c <= 'z'; c++) {
        rep(i, d[c - 'a']) {
            cout << c;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    int n,h,w,ans=0;
    cin >> n >> h >> w;
    vi a(n),b(n);
    rp(i,n){
        cin >> a[i] >> b[i];
        if(a[i]>=h&&b[i]>=w)    ans++;
    }
    cout << ans << endl;
    return 0;
}

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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int X[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int Y[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    while(true){
    int H, W;
    cin >> W >> H;
    if(H == 0 && W == 0)break;
    vector<vector<bool>> F(H, vector<bool>(W));
    UnionFind uf(H * W);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int a;cin >> a;
            if(a == 0)F[i][j] = false;
            else F[i][j] = true;
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(F[i][j]){
                for(int X = -1; X <= 1; X++){
                    for(int Y = -1; Y <= 1; Y++){
                    int x = j + X;
                    int y = i + Y;
                    if(x < 0 || W <= x || y < 0 || H <= y)continue;
                    else if(F[y][x])uf.unionSet(i * W + j, y * W + x);
                    }
                }
            }
        }
    }
    /*
    set<int> R;
    for(int i = 0; i < H * W; i++)R.insert(uf.root(i));
    //cout << uf.root(2) << endl;
    int ans = R.size();
    //cout << ans << endl;
    */
    int ans = uf.size();
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(F[i][j])continue;
            else ans--;
        }
    }
    
    cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3008
import sys
input = sys.stdin.readline
n=int(input())
T=[]
append=T.append
for i in range(n):
  a,b=map(int,input().split())
  append([a,b])
T.sort(key=lambda x:x[1])
chk=True
t=0
for i in range(n):
  a,b=T[i]
  t+=a
  if t>b:
    chk=False
print("Yes" if chk==True else "No")


Measured memory_bytes: 78940
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]

import fractions
rgcd = [0]
lgcd = [0]
for i in range(N) :
    rgcd.append(fractions.gcd(rgcd[i], A[i]))
for i in range(N) :
    lgcd.append(fractions.gcd(lgcd[i], A[-1-i]))

lgcd.reverse()
ans = []
for i in range(N) :
    ans.append(fractions.gcd(rgcd[i], lgcd[i+1]))

print(max(ans))


Measured memory_bytes: 14076
A = input()
B = input()

LA = len(A)
LB = len(B)

if LA > LB:
    ans = 'GREATER'
elif LA < LB:
    ans = 'LESS'
else:
    for a, b in zip(A, B):
        if a > b:
            ans = 'GREATER'
            break
        elif a < b:
            ans = 'LESS'
            break
    else:
        ans = 'EQUAL'

print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		try
		{
			int n, r, p, c, count;
			Scanner sc = new Scanner(System.in);
			String input;

			while(true)
			{
				n = sc.nextInt();
				r = sc.nextInt();

				int[] deck = new int[n];
				int[] ndeck = new int [n];

				for(int i = n; i > 0; i--)
				{
					deck[n - i] = i;
					ndeck[n - i] = deck[n - i];
				}

				if(n == 0 && r == 0)
				{
					break;
				}

				while(r > 0)
				{
					count = 0;
					p = sc.nextInt();
					c = sc.nextInt();

					for(int i = p - 1; i < p - 1 + c; i++)
					{
						ndeck[count] = deck[i];
						count++;
					}

					for(int i = 0; i < p - 1; i++)
					{
						ndeck[count] = deck[i];
						count++;
					}

					for(int i = 0; i < n; i++)
					{
						deck[i] = ndeck[i];
					}

					r--;
				}

				System.out.println(ndeck[0]);
			}

		}
		catch(InputMismatchException e)
		{
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 37204