akhauriyash/Code-Regression huggingface dataset:
class Dice:
    def __init__(self,num):
        self.num = num.copy()
        
    def east(self):
        temp = self.num.copy()
        self.num[1-1] = temp[4-1]
        self.num[4-1] = temp[6-1]
        self.num[6-1] = temp[3-1]
        self.num[3-1] = temp[1-1]

    def north(self):
        temp = self.num.copy()
        self.num[1-1] = temp[2-1]
        self.num[2-1] = temp[6-1]
        self.num[6-1] = temp[5-1]
        self.num[5-1] = temp[1-1]

    def south(self):
        temp = self.num.copy()
        self.num[1-1] = temp[5-1]
        self.num[5-1] = temp[6-1]
        self.num[6-1] = temp[2-1]
        self.num[2-1] = temp[1-1]

    def west(self):
        temp = self.num.copy()
        self.num[1-1] = temp[3-1]
        self.num[3-1] = temp[6-1]
        self.num[6-1] = temp[4-1]
        self.num[4-1] = temp[1-1]

num = list(map(int,input().split()))
dice = Dice(num)
command = input()
for c in command:
    if   c == 'E': dice.east()
    elif c == 'N': dice.north()
    elif c == 'S': dice.south()
    elif c == 'W': dice.west()
print(dice.num[0])
        



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define modulo M
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000
	int N,M;
int beki(long long a,long long b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};

int main(){
	

	cin>>N>>M;
	
	combi C(100000);
	
	N*=3;
	int offset = N;
	vector<vector<int>> dp(N+1,vector<int>(2*N+1,0));
	dp[0][offset] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=2*N;j++){
			if(dp[i][j]==0)continue;
			
			dp[i+1][j-1] = mod(dp[i+1][j-1] + dp[i][j]);
			
			if(i+2<=N){
				dp[i+2][j+1] = mod(dp[i+2][j+1] + mod(C.combination(N-1-i,1)*dp[i][j]));
			}
			if(i+3<=N){
				dp[i+3][j] = mod(dp[i+3][j] + mod(C.combination(N-1-i,2)*2*dp[i][j]));
			}
		}
	}
	
	int ans = 0;
	for(int i=0;i<dp.back().size();i++){
		int t = i-offset;
		if(t>0)break;
		if(abs(t)%3==0){
			ans = mod(ans + dp.back()[i]);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 285744
a = []
b = []
i = 0;

while true
   ln = gets
   if ln == nil
      break
   end
   a[i], b[i] = ln.chomp.split
   a[i], b[i] = a[i].to_i, b[i].to_i
   i = i + 1
end

for j in 0..(i - 1)
   cnt = 0
   sum = a[j] + b[j]
   while sum > 0
      cnt = cnt + 1
      sum = sum / 10
   end
   puts cnt
end


Measured memory_bytes: 6856
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int a,b;
	cin>>a>>b;
	cout<<setprecision(10)<<a*b/3.305785<<endl;

	return 0;
}



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

//数字の桁和を計算する
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
    res++;
    n /= 10;
    }
    return res;
}

signed main(){
    gearup;
    ll n; cin >> n;
    n++;
    string s = to_string(n);
    ll n1 = s[0]-'0';
    ll res = (digsum(n)-1)*9+(n1-1);
    out(res);
}

Measured memory_bytes: 256
def c_skip(N, X, Pos):
    from fractions import gcd
    from functools import reduce
    # 座標Xから各都市への距離を求め、それらの最大公約数が解
    ans = reduce(gcd, [abs(X - x) for x in Pos])
    return ans

N, X = [int(i) for i in input().split()]
Pos = [int(i) for i in input().split()]
print(c_skip(N, X, Pos))

Measured memory_bytes: 14228
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll n; cin >> n;
    vvl G(n,vl(n));
    rep(i,n) rep(j,n) cin >> G[i][j];
    vvl a = G;
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(i==k || j==k) continue;
                if(G[i][j] > G[i][k] + G[k][j]){
                    puts("-1");
                    return 0;
                }else if(G[i][j] == G[i][k] + G[k][j]){
                    a[i][j] = -1;
                }
            }
        }
    }
    ll ans = 0;
    rep(i,n){
        REP(j,i+1,n){
            if(a[i][j] != -1) ans += a[i][j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1664
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int op1,op2,op3;
   string s;
   while(cin>>s)
   {
     int a=s[0]-'0';
     int b=s[1]-'0';
     int c=s[2]-'0';
     int d=s[3]-'0';
     int result;
     char ch[3];
     bool flag=false;
     for(int i=0;i<8;i++)
     {
       result=0;
       op1=i/4;
       op2=i/2%2;
       op3=i%2;
       if(op1==0) result=a+b;
       else if(op1==1) result=a-b;
       if(op2==0) result=result+c;
       else if(op2==1) result=result-c;
       if(op3==0) result=result+d;
       else if(op3==1) result=result-d;     
       if(result==7)
       {
         flag=true;             
       }    
       if(flag) break;
     }  
     if(op1==0) ch[0]='+';
     else if(op1==1) ch[0]='-';
     if(op2==0) ch[1]='+';
     else if(op2==1) ch[1]='-';
     if(op3==0) ch[2]='+';
     else if(op3==1) ch[2]='-';
     cout<<a<<ch[0]<<b<<ch[1]<<c<<ch[2]<<d<<"=7"<<endl;
   }
   return 0;
 }
 

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

using namespace std;

int countB(int a, int b){
    int res = 0;
    if(a == 0) return 1;
    while(a > 0){
        res++;
        a /= b;
    }
    return res;
}

int main(){
    int n, m;
    cin >> n >> m;
    cout << countB(n, m) << endl;
    return 0;
}

Measured memory_bytes: 256
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

/*============================ DEBUGGING =============================*/

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 deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)
#define Sort(a) sort(a.begin(),a.end())

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int n;cin>>n;
	rep(i,0,100000){
		if(int(i*1.08)==n){cout<<i;return 0;}
	}
	cout<<":(";
	return 0;
}


Measured memory_bytes: 256
dice = list(map(int, input().split()))
slist = input()
 
for s in slist:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")
 
    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n)-1]
 
    dice = tmp
 
print(dice[0])


Measured memory_bytes: 5600
#include <iostream>

using namespace std;
int main(){
    int A=0,B=0,C=0,D=0;
    cin >> A >> B >> C >> D;

    auto sum = [] (int x, int y) -> int {
        if(x<y){return x;}else return y;
    };

    
    cout << sum(A,B) + sum(C,D) << endl; // 1

    return 0;
}


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

long long int test(int *wgt, int *v, int n, int w){
	long long int**dp = new long long int*[n];
	for(int i = 0; i < n; i++){
		dp[i] = new long long int[w+1];
	}
	for(int i = 0; i < n; i++){
		dp[i][0] = 0;
	}
	for(int i = 1; i < w +1; i++){
		if(wgt[0]<=i){
			dp[0][i] = v[0];
		}
	}
	for(int i = 1; i < n; i++){
		for(int j = 1; j < w + 1; j++){
			if(wgt[i] <= j){
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-wgt[i]]+v[i]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	return dp[n-1][w];
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n, w, *wgt, *v;
	cin >> n >> w;
	wgt = new int[n]; v = new int[n];
	for(int i = 0; i < n; i++){
		cin >> wgt[i] >> v[i];
	}
	cout << test(wgt, v, n, w);
	return 0;
}	

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main ()
{
  	const long long INF = 1LL << 60;

	long long dp[100010];

  	for (int i = 0; i < 100010; i++)
	{
		dp[i] = INF;
	}

	dp[0] = 0;
	int n;
  	cin >> n;
  	vector<int> height(n);
  	for (int i = 0; i < n; i++)
    {
    	cin >> height[i];
    }
  	for (int i = 0; i < n; i++)
    {
    	chmin(dp[i+1], dp[i] + abs(height[i+1] - height[i]));
      	chmin(dp[i+2], dp[i] + abs(height[i+2] - height[i]));
    }
  	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1408
from math import sqrt

x = int(input()) - 1
if x in (1, 2):
    print(x+1)
    exit()

while True:
    x += 1
    
    if x % 6 != 1 and x % 6 != 5:
        continue
    
    x_sqrt = int(sqrt(x))
    if x % 2 != 0:
        for a in range(3, x_sqrt+1, 2):
            if x % a == 0:
                break
        else:
            print(x)
            break
    else:
        continue


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << 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) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

vector<int> divisor(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    return res;
}

void _main() {
    int N;
    cin >> N;
    int ans = INF;
    auto div = divisor(N);
    for (int d : div) {
        CHMIN(ans, d + N / d - 2);
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  string S;
  cin>>S;
  int a = 0,b=0,c=0,d=0;
  for(int i = 0;i<S.size();i++){
    if(S.at(i) == 'N'){
      a = 1;
    }
    else if(S.at(i) == 'W'){
      b = 1;
    }
    else if(S.at(i) == 'S'){
      c = 1;
    }
    else{
      d = 1;
    }
  }
  if((a+c) == 1 || (b+d) == 1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a = n;
	int m=0;
	int s = a % 10;
	while(a > 0)
	{
		a = a / 10;
		m = a - (a/10)*10;
		s = s+m;
	}
	if(n%s == 0)
	{
		printf("Yes \n");
	}
        else
        {
		printf("No \n");
	}
	return 0;
}

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

int main(){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  double maxP = -1.0;
  int maxSum;
  int maxSugar;
  for (int i = 0; 100 * A * i <= F; ++i){
    for (int j = 0; 100 * A * i + 100 * B * j <= F; ++j) {
      if (i == 0 && j == 0) continue;
      for (int k = 0; 100 * A * i + 100 * B * j + C * k <= F; ++k) {
	for (int l = 0; 100 * A * i + 100 * B * j + C * k + D * l <= F; ++l){
	  if (i == 0 && j == 0 && k == 0 && l == 0) continue;
	  int sugar = C * k + D * l;
	  int water = 100 * A * i + 100 * B * j;
	  int sum = water + sugar;
	  double p = (sugar * 100.0) / sum;
	  if (p <= 100.0 * E / (100.0 + E) && p > maxP){
	      maxP = p;
	      maxSum = sum;
	      maxSugar = sugar;
	  }
	}
      }
    }
  }
  cout << maxSum << " " << maxSugar << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[])throws IOException{
    int k=readI();
    if(k>=30){
      pl("Yes");
    }else{
      pl("No");
    }

  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;

  scanf("%d", &n);

  int i = 1;
  int a = 0;
  vector<int> v;
  while(a < n) {
    a += i;
    v.push_back(i);
    i++;
  }

  if (a != n) {
    v.erase(remove(v.begin(), v.end(), a - n), v.end());
  }
  REP (i, v.size()) printf("%d\n", v[i]);
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int taro = 0;
		int hanako = 0;
		for (int i=0; i<n; i++) {
			String t = sc.next();
			String h = sc.next();
			if (t.compareTo(h) < 0) {hanako += 3;}
			else if (t.compareTo(h) > 0) {taro += 3;}
			else {hanako++; taro++;}
		}
		System.out.println(taro+" "+hanako);
	}
}


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

const long long int DENOMI = 1000000007;

int main()
{
	int n;
	cin >> n;
	long long int ans = 1;
	for(auto i = 1; i <= n; ++i){
		ans = ans * i % DENOMI;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    map <int, int> cnt;
    int ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        ans += cnt[a[i] + i];
        ++cnt[i - a[i]];
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 27844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 3005;
ll a[maxn], dp[maxn][maxn];

int main() {
    int n;
    cin >> n;
    REP(i, n) cin >> a[i];
    REPP(i, 1, n + 1) REP(j, n + 1 - i) {
        dp[j][j + i] = max(a[j] - dp[j + 1][j + i], a[j + i - 1] - dp[j][j + i - 1]);
    }
    cout << dp[0][n] << endl;
    return 0;
}


Measured memory_bytes: 70016
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a == b && c == a) {
			System.out.println(1);
		} else if (a == b || b == c || a == c) {
			System.out.println(2);	
		} else {
			System.out.println(3);
		}
	}

}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
    int n,k,ans=0;
    cin>>n>>k;
    int p[n];

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

    sort(p,p+n);

    for(int j=0; j<k; j++){
        ans=ans+p[j];
    }
    cout<<ans<<endl;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
information=input()
first=information[:2]
second=information[2:]

monthlist=["01","02","03","04","05","06","07","08","09","10","11","12"]


if first in monthlist and second in monthlist:
    print("AMBIGUOUS")
elif first in monthlist:
    print("MMYY")
elif second in monthlist:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll k; cin >> k;

        ll ans =0;
        repA(a,1,k){
            repA(b,1,k){
                repA(c,1,k){
                    ll t = __gcd(b,c);
                    t = __gcd(t,a);
                    ans +=t;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3528
#include "bits/stdc++.h"
using namespace std;

int main(){

	string S;

	for (int i = 0 ; i < 4 ; i++){
		cin >> S[i];
	}

	int s;
	int t;

    s = (S[0]-'0')*10+(S[1]-'0');
	t = (S[2]-'0')*10+(S[3]-'0');

	if (s>=1 && s<=12){
		if (t>=1 && t<=12){
			cout << "AMBIGUOUS" << endl;
			return 0;
		}
		else{
			cout << "MMYY" << endl;
			return 0;
		}

	}else{
		if (t>=1 && t <=12){
			cout << "YYMM" << endl;
			return 0;
		}
	}
	cout << "NA" << endl;

	

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long a[200005],sum[200005];
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		sum[0]=0;
		for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
		long long minn=10000000000000000; 
		for(int i=2;i<=n;i++)
		{
			long long a=sum[i-1];
			long long b=sum[n]-sum[i-1];
			if(abs(a-b)<minn)minn=abs(a-b);
		}
		printf("%lld\n",minn);
	}
	return 0;
 } 

Measured memory_bytes: 3328
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<functional>

using namespace std;

typedef tuple<int, int, int, vector<int>> TP;;

char field[8][8];
int H = 8, W = 8;

int vy[8] = { -1,-1,0,1,1,1,0,-1 }, vx[8] = { 0,-1,-1,-1,0,1,1,1 };

bool isupdate = false;

//candidate of their choice.

auto Mami_ai = [](TP& a, TP& b) {
	if (get<0>(a) < get<0>(b))return false;
	else if (get<0>(a) > get<0>(b))return true;
	else {
		if (get<1>(a) < get<1>(b))return true;
		else if (get<1>(a) > get<1>(b))return false;
		else {
			if (get<2>(a) < get<2>(b))return true;
			else return false;
		}
	}
};

auto Witch_ai = [](TP& a, TP& b) {
	if (get<0>(a) < get<0>(b))return false;
	else if (get<0>(a) > get<0>(b))return true;
	else {
		if (get<1>(a) < get<1>(b))return false;
		else if (get<1>(a) > get<1>(b))return true;
		else {
			if (get<2>(a) < get<2>(b))return false;
			else return true;
		}
	}
};

void execute(bool type) {
	//type == false -> Mami  true -> Witch
	//line W
	
	vector<TP> candidate;

	char mytoken, opptoken;
	if (!type)mytoken = 'o', opptoken = 'x';
	else mytoken = 'x', opptoken = 'o';

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (field[i][j] != '.')continue;
			int cnt = 0;
			vector<int> place;
			for (int k = 0; k < 8; k++) {
				place.push_back(0);
				int nx = i + vx[k], ny = j + vy[k];
				bool flg = false;
				bool flg2 = true;
				int C = 0;
				while (1) {
					C++;
					if (nx < 0 || ny < 0 || nx >= H || ny >= W) {
						break;
					}
					if (!flg && field[nx][ny] == opptoken) {
						flg = true;
					}
					else if(!flg && field[nx][ny] != opptoken){
						break;
					}
					else if (flg && field[nx][ny] == mytoken) {
						
						cnt += (C - 1);
						place[k] = C - 1;
						break;
					}
					else if (flg && field[nx][ny] == '.') {
						break;
					}
					nx += vx[k], ny += vy[k];
				}
			}
			
			if (cnt != 0)candidate.push_back(make_tuple(cnt, i, j, place));
		}

	}

	if (candidate.size() != 0)isupdate = true;
	else return;

	if (!type) {
		//Mamiの思考ルーチン通りにソートしておく
		sort(candidate.begin(), candidate.end(), Mami_ai);
	}
	else {
		sort(candidate.begin(), candidate.end(), Witch_ai);
	}

	int i = get<1>(candidate[0]), j = get<2>(candidate[0]);

	field[i][j] = mytoken;

	for (int k = 0; k < 8; k++) {
		if (get<3>(candidate[0])[k] == 0)continue;
		int nx = i + vx[k], ny = j + vy[k];
		int ct = 0;
		while (1) {
			if (ct == get<3>(candidate[0])[k])break;
			field[nx][ny] = mytoken;
			
			nx += vx[k], ny += vy[k];
			ct++;
		}
	}

}

int main() {
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			cin >> field[i][j];
		}
	}

	while (1) {
		isupdate = false;
		//Tomoe Mami's turn
		execute(0);

		//Witch's turn
		execute(1);

		if (!isupdate) {
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					cout << field[i][j];
				}
				cout << endl;
			}
			break;
		}

	}

	return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    int n, k;
        cin >> n >> k;
    int cnt=0;
    for(int i=0; i<n; i++){
        int a;
            cin >> a;
        if(a<k) continue;
        cnt += 1;
    }
    cout << cnt << endl;
}


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

long long N, A, B;
int main(){
	cin >> N >> A >> B;
	if(A > B){
		cout << 0 << endl;
		return 0;
	}
	if(N == 1 && A != B){
		cout << 0 << endl;
		return 0;
	}



	long long mini = A * (N - 1) + B;
	long long maxi = A + B * ( N - 1);
	cout << maxi - mini + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define ll long long int
#define endl "\n"
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fb(i, a, b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector <int>
#define vl vector <long long>
#define pi pair <int, int>
#define sz(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define M 100005
#define mod 1000000007
using namespace std;

void solve()
{
	ll a,b , c, k;
	cin>>a>>b>>c>>k;
	if(k <= a) cout<<k<<endl;
	else if(k > a && k <= a+b) cout<<a<<endl;
	else cout<<a-(k-(a+b))<<endl;
}

int main()
{
    IOS
    int t = 1;
    //cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

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

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int ans = 0;
    int n;cin>>n;
    ans=n*800-(n/15)*200;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
vector<int> v[100010];
vector<int> u[100010];
bool vis[100010][2];
void DFS(int x,int t){
	if(vis[x][t]==true)return;
	vis[x][t]=true;
	lol(i,v[x].size()){
		DFS(v[x][i],1-t);
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	lol(i,m){
		int a,b;
		cin>>a>>b;a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	DFS(0,0);
	
	ll a=0,b=0,cnt=0;
	lol(i,n){
		if(vis[i][0]&&vis[i][1])cnt++;
		else if(vis[i][0]==true)a++;
		else b++;
	}
	
	cout<<a*(b+cnt)+b*cnt+cnt*(cnt-1)/2-m<<endl;
	return 0;
}


Measured memory_bytes: 10240
//Name : Rupa Dey
  //Date : 05 September 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n0 cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gp ' ';
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,k,i,j,lol=0,cnt=0,c=0,p=0;
    cin>>a>>b>>k;
    //cout<<b-(k-a)<<nd;

        if(a==k) {c = 0; p=b;
        cout<<c<<" "<<p<<nd;
        }
         if(a>k) {c=a-k; p=b;
         cout<<c<<" "<<p<<nd;
         }
        else if(a<k) {c=0; p=(b-(k-a));
      cout<<c<<" "<<max(0ll,p)<<nd;}
    }


//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


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

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline T gcd(T m, T n) {
  if (n == 0)
    return m;
  else
    return gcd(n, std::abs(m) % std::abs(n));
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  IOS;
  constexpr char endl = '\n';

  int N;
  string S;
  cin >> N >> S;
  ll total = count(all(S), 'R') * count(all(S), 'G') * count(all(S), 'B');

  int cnt = 0;
  FOR(i, 0, N - 2) FOR(j, i + 1, N - 1) {
    int k = 2 * j - i;
    if (k <= j || N <= k) continue;
    if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) cnt++;
  }

  cout << total - cnt << endl;
}

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

int main(){
  ll n; cin>>n;
  for(ll i=1;i<3501;i++){
    for(ll j=1;j<3501;j++){
      if(4*i*j>(i+j)*n){
        if((n*i*j)%(4*i*j-(i+j)*n)==0){
          cout<<i<<' '<<j<<' '<<(n*i*j)/(4*i*j-(i+j)*n)<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 384
// arc071_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S, T;
    cin >> S >> T;
    int q;
    cin >> q;

    vector<int> cumsum_s_a(S.size()+1);
    vector<int> cumsum_s_b(S.size()+1);
    REP(i, S.size()){
        cumsum_s_a[i+1] = cumsum_s_a[i] + (S[i] == 'A');
        cumsum_s_b[i+1] = cumsum_s_b[i] + (S[i] == 'B');
    }

    vector<int> cumsum_t_a(T.size()+1);
    vector<int> cumsum_t_b(T.size()+1);
    REP(i, T.size()){
        cumsum_t_a[i+1] = cumsum_t_a[i] + (T[i] == 'A');
        cumsum_t_b[i+1] = cumsum_t_b[i] + (T[i] == 'B');
    }

    while (q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;

//        print(S.substr(a, b-a+1), T.substr(c, d-c+1));

        int s_a = cumsum_s_a[b+1] - cumsum_s_a[a];
        int s_b = cumsum_s_b[b+1] - cumsum_s_b[a];

        int t_a = cumsum_t_a[d+1] - cumsum_t_a[c];
        int t_b = cumsum_t_b[d+1] - cumsum_t_b[c];

        int x = s_a + 2 * s_b;
        int y = t_a + 2 * t_b;

        if (x % 3 == y % 3){
            print("YES");
        } else {
            print("NO");
        }

    }


    return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  
  for(int i = 0;i < w + 2;i++){
    cout << '#';
  }
  cout << endl;
  
  for(int i = 0; i < h; i++){
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  
  for(int i = 0;i < w + 2;i++){
    cout << '#';
  }
  cout << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string.h>
#include <string>
#include <cstring>
using namespace std;

int main(){
	string x;
	cin >> x ;

	int le;
	le = x.length();

	int flag=0;
	if(le<4){
		cout << "No" << endl;
	}else{
		if(x[0]=='Y'&&x[1]=='A'&&x[2]=='K'&&x[3]=='I'){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	
	}
	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Three-letter acronym
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < 3; i++) {
    string s;
    cin >> s;
    putchar(s[0] - 'a' + 'A');
  }
  putchar('\n');

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;



signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    string s;
    cin >> s;
    string t = "", prev = "";
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
    	t += s[i];
    	if (t != prev) {
    		prev = t;
    		t = "";
    		ans++;
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N),b(N);
    REP(i,N) cin>>a[i];
    REP(i,N) cin>>b[i];

    for(int i=1;i<N;i++) a[i]+=a[i-1];
    for(int i=N-2;i>=0;i--) b[i]+=b[i+1];
    
    int ans=0;
    REP(i,N) ans=max(ans,a[i]+b[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Khela_Sesh ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
//const int sz=1e5+100;
const int inf=1e9+10;
int main()
{
    Khela_Sesh
    int i,j,k,q,p,x,y,sum,ct,ct1,m,l,r,len,x1,y1,mn,t,mx,W,n;
    char ch;
    double d;
    string str1,str2;
    bool bl,bl1;
    while(cin>>n>>W)
    {
        int val[n+1],w[n+1];
        sum=0;
        for(i=1;i<=n;i++)  {
            cin>>w[i]>>val[i];
            sum+=val[i];
        }
        int table[sum+2][n+2];
        for(i=0;i<=sum;i++) for(j=0;j<=n;j++) table[i][j]=inf;
        table[0][0]=0;
        for(i=0;i<=sum;i++)
        {
            for(j=1;j<=n;j++){
                if(i-val[j]>=0) table[i][j]=min(table[i][j-1],w[j]+table[i-val[j]][j-1]);
                else table[i][j]=table[i][j-1];
            }
        }
        mx=0;
        for(i=1;i<=sum;i++)
        {
            if(table[i][n]<=W) mx=max(mx,i);
        }
        pf("%d\n",mx);
    }

}



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

int main()
{
    int n;
    cin>>n;
    
    int x=n%100;
    int y=n/100;
    
    if(x>=1 && x<=12 )
    {
        if(y>12 || y==0)
        {
            cout<<"YYMM"<<endl;
        }
        
        else
        {
            cout<<"AMBIGUOUS"<<endl;
        }
    }
    
    else if(y>=1 && y<=12)
    {
        if(x>12 || x==0)
        {
            cout<<"MMYY"<<endl;
        }
    }
    
    else
    {
        cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
   int n;
   cin>>n;
   pair<pair<string,int>,int> mp[110];
   rep(i,n){
       int a;
       string s;
       cin >>s >>a;
       pair<string,int> p(s,-a);
       mp[i] = pair<pair<string,int>,int>(p,i+1);
   }
   sort(mp,mp+n);
   rep(i,n)cout<<mp[i].second<<endl;
   return 0;
}


Measured memory_bytes: 3580
x,y=map(int,input().split())
if(x==2):
  x=3
elif(x==4 or x==6 or x==9 or x==11):
  x=2
else:
  x=1
if(y==2):
  y=3
elif(y==4 or y==6 or y==9 or y==11):
  y=2
else:
  y=1

if(x==y):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
    sort(vec.begin(),vec.end());
    if (vec.at(0) == 5 && vec.at(1) == 5 && vec.at(2) == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main (String[] argv){

        Scanner scan = new Scanner (System.in);

        String original = scan.nextLine();
        String inverse  = scan.nextLine();

        if (isInverse(original, inverse)){
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }

    public static boolean isInverse (String s1, String s2){
        if (s1.length() != s2.length()) return false;

        for (int i = 0; i < s1.length(); i++){
            if (s1.charAt(i) != s2.charAt(s2.length() - 1 - i)) return false;
        }
        return true;
    }

}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567891
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL H, W;
LL pt1 = INF, pt2 = INF, pt3 = INF;

int main()
{
	in >> H >> W;

	if (H % 3 == 0 || W % 3 == 0) { out << 0 << std::endl; }
	else
	{
		if (H > 3) { pt1 = std::min(H, W); }
		for (LL i = 1; i < W; ++i)
		{
			LL res1, res2, res3;
			res1 = i*H;
			res2 = (W - i)*(H / 2);
			res3 = H*W - (res1 + res2);
			pt2 = std::min(pt2, std::max({ res1,res2,res3 }) - std::min({ res1,res2,res3 }));
		}
		for (LL i = 1; i < H; ++i)
		{
			LL res1, res2, res3;
			res1 = i*W;
			res2 = (H - i)*(W / 2);
			res3 = H*W - (res1 + res2);
			pt3 = std::min(pt3, std::max({ res1,res2,res3 }) - std::min({ res1,res2,res3 }));
		}
		out << std::min({ pt1,pt2,pt3 }) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *left, *right, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }    
    }

    z->parent = y;

    if (y == NIL) {
        root = z;
    }
    else if (z->key < y->key) {
        y->left = z;
    }
    else {
        y->right = z;
    }

}

void inorder(Node *u) {
    if (u == NIL) {
        return;
    }
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) {
        return;
    }
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            cin >> x;
            insert(x);
        }
        else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}

Measured memory_bytes: 26588