akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	string s; cin >> s;
	int n = s.size();
	vector<ll> sum(n + 1);
	for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + (s[i] == 'W');
	//for (int i = 0; i < n; i++) cout << sum[i] << " "; cout << endl;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'B') ans += sum[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb      push_back
#define all(v)  v.begin(),v.end()
#define see(x)  cout<<#x<<" : "<<(x)<<endl;
#define ya      cout<<"YES"<<endl;
#define no      cout<<"NO"<<endl;
#define ff      first
#define sc      second
typedef long long ll;
typedef pair<ll,ll> pii;


int main()
{

    ll n,i,j,k,ans=0;
    cin>>n;
    ll a[n];
    map<ll,ll>m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1; k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
                if(a[i]+a[j]>a[k])
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
map<string,int> cnt;
int n,maxx;
string a[200005];
int ss=0;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		++cnt[s];
		if(maxx==cnt[s])a[++ss]=s;
		else if(maxx<cnt[s])a[ss=1]=s,maxx=cnt[s];
	}
	sort(a+1,a+ss+1);
	for(int i=1;i<=ss;i++)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 26752
import numpy as np
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
p=np.array(acinput())

count=0

for i in range(N):
    if p[i]!=i+1:
        count+=1


if count<=2:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 21144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
    int n,k;
    cin >> n >> k;
    if(k==1){
      cout << 0 << endl;
      return 0;
    }
    n-=k;
    
    cout << n << endl;
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define y1 asdgh
#define int long long
#define double long double
#define endl '\n'
//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*------------------------------<Debugging Stuff>---------------------------------*/

template<class L, class R> ostream& operator<<(ostream &os, pair<L , R> P) {
      return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R , class M> ostream& operator<<(ostream &os, tuple<L , R , M> P) {
      return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
      os << "{ "; for(auto v : V) os << v << " "; return os << "}";
}

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

/*------------------------------</Debugging Stuff>--------------------------------*/
const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int) 1e9 + 9;
const int mod = (int) 1e9 + 7;
int n , dp[maxn][15] , r[maxn];
string s;

signed main() {
      
      fio;
      cin >> s; n = (int) s.length();
      r[0] = 1;
      for(int i = 1; i < n; i++) r[i] = r[i - 1] * 10 % 13;
      for(int i = 0; i <= 9; i++){
            if(s[0] == '?'){
                  dp[0][r[n - 1] * i % 13] = 1;
            } else {
                  if(s[0] - '0' == i){
                        dp[0][r[n - 1] * i % 13] = 1;
                  }
            }
      }
      
      for(int i = 1; i < n; i++){
            for(int prev_rem = 0; prev_rem < 13; prev_rem++){
                  if(s[i] != '?'){
                        int new_rem = (prev_rem + (r[n - i - 1] * (s[i] - '0') % 13)) % 13;
                        dp[i][new_rem] += dp[i - 1][prev_rem];
                        dp[i][new_rem] %= mod;
                        continue;
                  }
                  for(int dig = 0; dig <= 9; dig++){
                        // (prev_rem + (10^i * dig) % 13) % 13
                        int new_rem = (prev_rem + (r[n - i - 1] * dig % 13)) % 13;
                        dp[i][new_rem] += dp[i - 1][prev_rem];
                        dp[i][new_rem] %= mod;
                  }
            }
      }
      
      cout << dp[n - 1][5] << endl;

      
      
      return 0;
}

// IMPORTANT -:
// check base cases n = 0 , n = 1
// max / min questions - check for binary search
// difference array might be interesting


Measured memory_bytes: 15568
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
#define ull unsigned long long
#define pb push_back

map<ull, ull>ans;
vector<int>ma[100005];

ull dfs(int pos, int fa) {
    ull x = 1ull;
    int sz = ma[pos].size();
    for(int i = 0; i < sz; i ++){
        int to = ma[pos][i];
        if(to == fa) continue;
        x += (19 * dfs(to, pos));
    }
    ans[x] ++;
    return x;
}

int main () {
    int n, a, b;
    scanf("%d", &n);
    for(int i = 0; i < n - 1; i ++) {
        scanf("%d%d", &a, &b);
        ma[a].pb(b);
        ma[b].pb(a);
    }
    ans.clear();
    map<ull, ull> :: iterator it;
    dfs(1, -1);
    ull res = 0ull;
    for(it = ans.begin(); it != ans.end(); it ++) {
        ull tm = it -> second;
        res += tm * (tm - 1) / 2;
    }
    printf("%llu\n", res);
}

Measured memory_bytes: 22784
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int n;
long double x[50],y[50];
long double dis(long double a,long double b)
{
   long double mx=0;
   for(int i=0;i<n;i++)
   {
      mx=max(mx,sqrt(pow(a-x[i],2)+pow(y[i]-b,2)));
   }
   return mx;
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   cin>>n;
   int a,b;
   for(int i=0;i<n;i++)
   {
      cin>>a>>b;
      x[i]=a;
      y[i]=b;
   }
   long double l=0,r=1e3;
   long double eps=1e9;
   eps=1/eps;
   long double ans=1e18;
   while(r-l>eps)
   {
      long double x1=(2*l+r)/3,x2=(l+2*r)/3;
      long double ll=0,rr=1e3;
      long double mn1=1e18,mn2=1e18;
      while(rr-ll>eps)
      {
         long double y1=(2*ll+rr)/3,y2=(ll+2*rr)/3;
         long double f1=dis(x1,y1);
         long double f2=dis(x1,y2);
         mn1=min(mn1,min(f1,f2));
         if(f1<f2)
         {
            rr=y2;
         }        
         else
         {
            ll=y1;
         }         
      }
      ll=0;
      rr=1e3;
      while(rr-ll>eps)
      {
         long double y1=(2*ll+rr)/3,y2=(ll+2*rr)/3;
         long double f1=dis(x2,y1);
         long double f2=dis(x2,y2);
         mn2=min(mn2,min(f1,f2));
         if(f1<f2)
         {
            rr=y2;
         }        
         else
         {
            ll=y1;
         }         
      }
      if(mn1<mn2)
      {
         r=x2;
      }
      else
      {
         l=x1;
      }
      ans=min(ans,min(mn1,mn2));
   }
   cout<<fixed<<setprecision(10)<<ans;
   // cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	static int N;
	static int[]Ary;
	static int Base;
	static String ans="Yes";
	

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		Ary = new int[N+1];
		for(int i=1;i<=N;i++){
			Ary[i] = sc.nextInt();
		}

		Base=Ary[1];
		for(int i=1;i<=N;i++){
			
			if (Base<=Ary[i]) {
				Base=Ary[i];


			}
			else{
				if ((Base-Ary[i])>=2) {
					ans="No";
				}
			}
		}
		System.out.println(ans);
		//System.out.print(ans);
    }
    //関数定義
	//public static int funk(long X,long A) {
    //    return ;    
    //}
}				

Measured memory_bytes: 59560
n, k = map(int, input().split())
s = []
for i in range(k):
    l, r = map(int, input().split())
    s.append([l, r])

mod = 998244353
dp = [0] * (n+1)
cumsum = [0] * (n+1)

dp[1] = 1
s = sorted(s)
counter = 0
for i in range(1, n+1):
    counter += cumsum[i]
    dp[i] += counter
    dp[i] %= mod
    for l, r in s:
        if i+l <= n:
            cumsum[i+l] += dp[i]
        if i+r+1 <= n:
            cumsum[i+r+1] -= dp[i]
print(dp[n] % mod)

Measured memory_bytes: 76884
#include <iostream>

using namespace std;

int main()
{
    int a , b, c;
    
    cin >> a >> b >> c;
    
    if(a < b && b < c)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
  
    
    
   
   
   return 0;
}


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

using namespace std;



int main(){
    int D, G;
    cin >> D >> G;
    int p[D], c[D];
    
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
    
    vector<int> comp;
    for(int i = 0; i < D; ++i){
        int tmp = 100 * (i + 1) * p[i] + c[i];
        comp.push_back(tmp);
    }
    
    int ans = 1000;
    for(int i = 0; i < (1 << (D)); ++i){
        int rem = G;
        int cnt = 0;
        for(int j = 0; j < D; ++j){
            if((i >> j) & 1){
                rem -= comp[j];
                cnt += p[j];
            }
        }
        if(rem > 0){
            for(int j = D - 1; j >= 0; --j){
                if(!((i >> j) & 1)){
                    int sur = (rem / 100 - 1) / (j + 1) + 1;
//                    cout << (j + 1) << " " << sur << endl;
                    
                    if(sur >= p[j]){
                        cnt = 1000;
                        break;
                    } else {
                        cnt += sur;
                        break;
                    }
                    
                }
            }
        }
        ans = min(ans, cnt);
//        cout << i << " " << rem << " " << cnt << endl;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
const ll infll = (1ll<<60);
using namespace std;

const int ny = 0, d = 1, s = 2, t = 3, u = 4;
ll dp[200010][5];

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	for( int i = 0; i < n; ++i ){
		dp[i+1][ny] = dp[i][ny] + a[i];
		dp[i+1][d] = min(
							dp[i][ny] + a[i],
							dp[i][d] + ( a[i] == 0 ? 2 : a[i]%2 )
						);
		dp[i+1][s] = min({
							dp[i][ny] + a[i],
							dp[i][d] + ( a[i] == 0 ? 2 : a[i]%2 ),
							dp[i][s] + (a[i]+1)%2
						});
		dp[i+1][t] = min({
							dp[i][ny] + a[i],
							dp[i][d] + ( a[i] == 0 ? 2 : a[i]%2 ),
							dp[i][s] + (a[i]+1)%2,
							dp[i][t] + ( a[i] == 0 ? 2 : a[i]%2 )
						});
		dp[i+1][u] = min({
							dp[i][ny] + a[i],
							dp[i][d] + ( a[i] == 0 ? 2 : a[i]%2 ),
							dp[i][s] + (a[i]+1)%2,
							dp[i][t] + ( a[i] == 0 ? 2 : a[i]%2 ),
							dp[i][u] + a[i]
						});
	}
	cout << dp[n][u] << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
 
typedef long long ll;
const int N = 22;

int mvx[4] = {0,1,0,-1};
int mvy[4] = {1,0,-1,0};

int n,m;
char grid[N][N];
int dst[N][N];
bool vstd[N][N];

bool check(int x,int y){
	return x < 1 || y < 1 || x > n || y > m || grid[x][y] == '#' || vstd[x][y];
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>grid[i][j];
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(grid[i][j] != '#'){
				memset(dst,0x7f,sizeof dst);
				memset(vstd,false,sizeof vstd);
				dst[i][j] = 0;
				vstd[i][j] = true;
				queue<pair<int,int> > q;
				q.push({i,j});
				while(!q.empty()){
					int x = q.front().first,y = q.front().second;
					q.pop();
					for(int k=0;k<4;k++){
						int nx = x + mvx[k],ny = y + mvy[k];
						if(check(nx,ny))continue;
						dst[nx][ny] = dst[x][y] + 1;
						ans = max(ans,dst[nx][ny]);
						vstd[nx][ny] = true;
						q.push({nx,ny});
					}
				}
			}
		}
	}
	
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int r, c, p;

int main() {
  while((c = getchar_unlocked()) != '\n') {
    if(p == 1) {
      r += 1;
      p = 0;
    }
    else if (c == p) {
      p = 1;
    }
    else {
      r += 1;
      p = c;
    }
  }
  printf("%d\n", r);
}


Measured memory_bytes: 128
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String s=sc.nextLine();

    	String pre=s.substring(0,4);
    	String sub=s.substring(4);

    	String result=pre+" "+sub;

    	System.out.println(result);


    }
}



Measured memory_bytes: 23380
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second < secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
ll GCD(ll a, ll b) {
  if (b == 0)
    return a;
  return GCD(b, a % b);
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  string N = "";
  string y = "";
  string m = "";
  string d = "";
  cin >> N;
  REP(i, N.size()) {
    string c = N.substr(i, 1);
    if (i < 4)
      y += c;
    else if (i == 5 || i == 6) {
      m += c;
    } else if (i == 8 || i == 9) {
      d += c;
    }
  }
  if (atoi(y.c_str()) < 2019)
    cout << "Heisei" << endl;
  else if (atoi(y.c_str()) == 2019 && atoi(m.c_str()) < 4)
    cout << "Heisei" << endl;
  else if (atoi(y.c_str()) == 2019 && atoi(m.c_str()) == 4 &&
           atoi(d.c_str()) <= 30)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;

  return 0;
}


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

int main()
{
    int r, D, x1, xn, xi;
    cin >> r>>D>>x1;

    xn = (r * x1 - D);
    xi = xn;
    cout << xn << endl;

    for (int i = 0; i < 9; i++)
    {
        xn = (r * xi - D);
        xi = xn;
        cout << xn << endl;
    }


}


Measured memory_bytes: 256
n = int(input())
ab=[]
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
ans = 0
for i in range(n-1,-1,-1):
        c = (ab[i][0]+ans)%ab[i][1]
        if c!=0:
            ans += ab[i][1]-c
print(ans)


Measured memory_bytes: 19624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    
    auto divisors = getdivisor(N);
    
    res = LINF;
    for(auto divisor:divisors){
        res = min(res,divisor + N/divisor - 2);
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fo(i, n) for(int i = 0; i < n; ++i)
#define ll long long int
#define fok(i, k, n) for(int i = k; i < n; ++i)
#define MOD 1000000000+7
#define all(X) X.begin(), X.end()
#define pb push_back
#define present(a, x) (a.find(x)!=a.end())
using namespace std;

map <int, set <int> > m;

int main(){
  int n,m;
  cin>>n>>m;
  int a[m];
  ll sum=0;
  for(int i=0;i<m;i++){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>n) cout<<-1;
  else cout<<n-sum;
   // cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
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 lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(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 unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int dev(int n){
    if(n%4==0){
        return 2;
    }elif(n%4==2){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int n;
    int n0=0,n1=0,n2=0;
    cin >> n;
    vi a(n);
    rp(i,n){
        cin >> a[i];
        a[i]=dev(a[i]);
        if(a[i]==0){
            n0++;
        }elif(a[i]==1){
            n1++;
        }elif(a[i]==2){
            n2++;
        }
    }
    if(n1==0){
        if(n0-1<=n2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(n0-1<n2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int L[2000];
int y[2001];
int main(){
  int i;
  long long res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(L[Lj4PdHRW]);
    }
  }
  res = (long long) N * (N-1) * (N-2) / 6;
  for(i=(0);i<(N);i++){
    int j;
    for(j=(i+1);j<(N);j++){
      y[L[i]+L[j]]++;
    }
  }
  for(i=(1);i<(2001);i++){
    y[i] += y[i-1];
  }
  for(i=(0);i<(N);i++){
    res -= y[L[i]];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191012-1

// --- original code ---
// int N, L[2000];
// int y[2001];
// {
//   ll res;
//   rd(N,L(N));
//   res = (ll) N * (N-1) * (N-2) / 6;
//   rep(i,N) rep(j,i+1,N) y[L[i]+L[j]]++;
//   rep(i,1,2001) y[i] += y[i-1];
//   rep(i,N) res -= y[L[i]];
//   wt(res);
// }


Measured memory_bytes: 256
n,m=map(int,raw_input().split())
A,B=[],[]
c=0
A=[map(int,raw_input().split()) for _ in [0]*n]
B=[int(raw_input()) for _ in [0]*m]
for i in xrange(n):
	print sum([A[i][j]*B[j] for j in xrange(m)])

Measured memory_bytes: 6560
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S;
    cin >> S;
    int L = S.size(), H = S.front() - '0';
    bool nine = true;
    for (int i = 1; i < S.size(); ++i) {
        if (S[i] != '9') nine = false;
    }

    cout << H + (L - 1) * 9 - (nine ? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 256
def cross(a,b):
  return a.real*b.imag-a.imag*b.real

n=int(input())

A=[]
for _ in range(n):
  x,y=map(int,input().split())
  A.append(x+y*1j)

flag=0
for i in range(n-1):
  for j in range(i+1,n):
    if cross(A[i]-A[i-1],A[j]-A[i-1])<0 or cross(A[i+1]-A[i],A[j]-A[i])<0:
      print("0")
      flag=1
      break
  if(flag==1):
    break

if(flag==0):
  print("1")



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
const int MAXN = 1e6+20;
const long long INF = 1e16;
using namespace std;

long long a,b,ans;
int main()
{
 
	ios_base::sync_with_stdio(0);
 
//	freopen("longpath.in", "r", stdin);
//	freopen("longpath.out", "w", stdout);


	cin>>a>>b;

	if (b==1)
	{
		cout<<0<<endl;
		return 0;
	}
	for (int i=1; i<=100000; i++)
	{
		ans = (i-1) * (a-1) + a;
		if (ans>=b) 
		{
			cout<<i<<endl;
			return 0;
		}
	}
	
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
typedef long double ld;

int main(){
  ll x;std::cin >> x;
  ld now = 100, eps = 1e-6;
  ll ans = 0;

  while(now + eps < x){
    ll add = now/100;
    now += add;
    ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double x;
    if(n==1)
    {x=n;
    cout<<setprecision(12)<<x<<endl;
    }
    else if(n%2==0)
    {x=n/2*1.0/n;
    cout<<setprecision(12)<<x<<endl;
    }
    else
    {   x=(n/2+1)*1.0/n;
        cout<<setprecision(12)<<x<<endl;
    }
    
}

Measured memory_bytes: 3728
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    if s[-1] == "s":
        print(s + "es")
    else:
        print(s + "s")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL printf("\n")
#define debug 1
ld n,a;
ld s;
ll k,m,res;
int main()
{
	IO;
	cin>>m>>k;
	FOR(i,1,m)
	{
	      ll x; cin>>x;
	      if(x>=k) res++;
	}
	cout<<res;
      if((int)n%2==0) a=(int)n/2;
      else a=((int)n+1)/2;
      //cout<<setprecision(10)<<fixed<<a/n;
	return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define eps 0.000000000001
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
int H,W;
const int maxH = 1000 + 2, maxW = 1000 + 2;
vector<string> grid;
ll dp[maxH][maxW];

int main () {
	//FIN

	cin >> H >> W;
	grid = vector<string>(H);
	F0(i,H) cin >> grid[i];
	F0(i,H) F0(j,W) dp[i][j] = 0;
	dp[0][0] = 1;
	F0(i,H) F0(j,W) {
		if (grid[i][j] == '#') continue;
		dp[i+1][j] += dp[i][j]; dp[i+1][j] %= mod;
		dp[i][j+1] += dp[i][j]; dp[i][j+1] %= mod;
	}
	cout << dp[H-1][W-1] << "\n";

	return 0;
}










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

int main()
{
    long long n;
    cin>>n;
    long long i,j,k,flag,l,r,T;
    vector<long long>v(n+2);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cin>>T;
    while(T--)
    {
        int cnt=0;
        cin>>l>>r>>k;
        for(i=l;i<r;i++)
        {
            if(k==v[i])
                cnt++;
        }
        cout<<cnt<<endl;
    }

    return 0;
}



Measured memory_bytes: 3116
a = gets.chomp
b = gets.to_i
c = []
for i in 1..b
  for j in 0..(a.length - 1)
    c.push(a[j, i])
  end
end
c = c.uniq
c.sort!
#c.sort_by {|array| array.size}
#puts c
#puts "end"
puts c[b - 1]
 
#p a
#p b
 

Measured memory_bytes: 4604
s = int(input())
l = list(int(x) for x in input().split())
count = 0
for i in range(1,s-1):
  if (l[i-1] < l[i] and l[i] < l[i+1]) or (l[i-1] > l[i] and l[i] > l[i+1]):
    count += 1
print(count)
  

Measured memory_bytes: 38496
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int H=gi();
	    int W=gi();
	    char[][] C=new char[H][W];
	    List<Edge>[] E=new ArrayList[H*W];
	    int wc=0;
	    for(int i=0; i<H;i++) {
	    	String s=gs();
	    	for (int j=0; j<W;j++) {
	    		C[i][j]=s.charAt(j);
	    		if(C[i][j]=='.')wc++;
	    	}
	    }

	    for(int i=0; i<H*W;i++) {
	    	E[i]=new ArrayList<Edge>();
	    }
	    for(int i=0; i<H;i++) {
	    	for (int j=0; j<W;j++) {
	    		if(C[i][j]=='.') {
	    			if(i-1>=0 && C[i-1][j]=='.') E[i*W+j].add(new Edge(i*W+j, (i-1)*W+j, 1));
	    			if(i+1<H && C[i+1][j]=='.') E[i*W+j].add(new Edge(i*W+j, (i+1)*W+j, 1));
	    			if(j-1>=0 && C[i][j-1]=='.') E[i*W+j].add(new Edge(i*W+j, i*W+j-1, 1));
	    			if(j+1<W && C[i][j+1]=='.') E[i*W+j].add(new Edge(i*W+j, i*W+j+1, 1));
	    		}
	    	}
	    }

	    long[] d=new long[H*W];
	    for(int i=0; i<H*W;i++) {
	    	d[i]=Integer.MAX_VALUE;
	    }
	    d[0]=0;

	    PriorityQueue<Pair<Long, Integer>> que=new PriorityQueue<Pair<Long, Integer>>();
	    que.add(new Pair<Long, Integer>(0l,0));

	    while(!que.isEmpty()) {
	    	Pair<Long, Integer> p=que.poll();
	    	int v=p.getValue();
	    	long cost=p.getKey();
	    	if(d[v]<cost)continue;
	    	for(int i=0; i<E[v].size();i++) {
	    		Edge e=E[v].get(i);
	    		if(d[e.from]!=Integer.MAX_VALUE && e.cost !=Integer.MAX_VALUE && d[e.to] > d[e.from]+e.cost) {
	    			d[e.to]=d[e.from]+e.cost;
	    			que.add(new Pair<Long, Integer>(d[e.to], e.to));
	    		}
	    	}
	    }

	    if(d[H*W-1]!=Integer.MAX_VALUE) {
            System.out.println(wc-d[H*W-1]-1);
	    } else {
	    	System.out.println(-1);
	    }
	}

	public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
		/** serialVersionUID. */
	    private static final long serialVersionUID = 6411527075103472113L;

	    public Pair(final K key, final V value) {
	        super(key, value);
	    }

		@Override
		public int compareTo(Pair<K, V> o) {

			Comparable key = (Comparable)this.getKey();
			Comparable key2 = (Comparable)o.getKey();

			return key.compareTo(key2);
		}

	}

	public static class Edge {
	    private int from;
	    private int to;
	    private long cost;

	    public Edge(int f, int t, long c) {
	    	this.from=f;
	    	this.to=t;
	    	this.cost=c;
	    }
	}


	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 36464
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0


int main(){
  int n,m,deg[100010]={},i,a;
  scanf("%d%d",&n,&m);
  for(i=0;i<2*m;i++){
    scanf("%d",&a);
    deg[a]++;
  }
  int flag=1;
  for(i=0;i<n;i++){
    if(deg[i]%2)flag=0;
  }

  printf("%s",flag?"YES":"NO");
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#define BUFSIZE         (1024)

char buf[BUFSIZE];

long
readnum()
{
    long        ret;
    char        *bp;

    bp = fgets(buf, BUFSIZE, stdin);
    if (bp == NULL) goto err;
    ret = atol(buf);
    return ret;

  err:
    perror("error fgets");
    exit(EXIT_FAILURE);
}

void
print_arr(int *arr, int sz)
{
    int idx;

    printf("%d", arr[0]);    
    for (idx = 1; idx < sz; ++idx) {
        printf(" %d", arr[idx]);
    }
    puts("");
}


#define MAX(a, b)       ((a) < (b) ? (b) : (a))
#define MIN(a, b)       ((a) > (b) ? (b) : (a))

int
main()
{
    long        num;
    int         na[100];
    long        tn;
    int         idx;
    char        *rp;
    char        *nrp;
    int         ic;
    int         rv;
    
    tn = readnum();

    rp = fgets(buf, BUFSIZE, stdin);
    for (idx = 0; idx < tn; ++idx) {
        num = strtol(rp, &nrp, 10);
        na[idx] = num;
        if (rp == nrp) goto err;
        rp = nrp;
    }
    print_arr(na, tn);

    for (ic = 1; ic < tn; ++ic) {
        rv = na[ic];
        for (idx = ic; 0 < idx; --idx) {
            if (na[idx - 1] < rv) break;
            na[idx] = na[idx - 1];
        }
        na[idx] = rv;
        print_arr(na, tn);
    }
    exit(EXIT_SUCCESS);

  err:
    exit(EXIT_FAILURE);
}



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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

signed main() {
  int A, B;
  cin >> A >> B;

  int C = gcd(A, B);

  map<int, int> mp = prime_factor(C);

  cout << mp.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007
const int maxn=1000000;
void solve() {
    int n;
    cin>>n;
    vector<int> a,b;
    int x,y;
    for(int i=0;i<n;++i){
        cin>>x>>y;
        a.push_back(x+y);
        b.push_back(x-y);
    }
    cout<<max(abs(*min_element(all(a))-*max_element(all(a))),abs(*min_element(all(b))-*max_element(all(b))));

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 6700
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);;
        int n = Integer.parseInt(scanner.nextLine().trim());
        List<String> strings = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            strings.add(scanner.nextLine().trim());
        }
        poll(strings).forEach(System.out::println);
    }

    public static List<String> poll(Collection<String> strings){
        Map<String, Long> map = strings.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        long maxCount = map.values().stream().max(Long::compareTo).get();
        return map.entrySet().stream().filter(entry->entry.getValue().equals(maxCount))
                .map(Map.Entry::getKey).sorted(String::compareTo)
                .collect(Collectors.toList());
    }
}


Measured memory_bytes: 182652
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define N 2000
#define mdn 1000000007
using namespace std;

int f[N+10][N+10],sum[N+10][N+10],C[N+10][N+10];

void prework()
{
	C[0][0]=C[1][0]=C[1][1]=1;
	//f[0][0]=sum[0][0]=1;
	for(int i=2;i<=N+1;i++)
	{
		C[i][0]=C[i][i]=1; 
		for(int j=1;j<i;j++)	C[i][j]=(C[i-1][j-1]+C[i-1][j])%mdn;
	}
	for(int i=0;i<=N+1;i++)
	{
		f[i][0] = C[i][0];
		for(int j=1;j<=N+1;j++)
			f[i][j] = (f[i][j-1] + C[i][j])%mdn;
	}
	for(int i=0;i<=N+1;i++)
	{
		sum[i][0] = f[i][0];
		for(int j=1;j<=N+1;j++)
			sum[i][j]=(sum[i][j-1] + f[i][j])%mdn;
	}
}
int a,b;
void work()
{
	int ans=0;
	prework();
	for(int t=1;t<=a+1;t++)
	{
		ans++;
		for(int i=1;i<=min(t-1,b-1);i++)
		{
			ans += (ll)C[b-1][i]*sum[i-1][t-i-1]%mdn;
			ans %= mdn;
		}
	}
	printf("%d\n",ans);
}

int main()
{
	scanf("%d%d",&a,&b);
	work();
	return 0;
}

Measured memory_bytes: 46592
import sys

X,N = map(int, input().split())
p = list(map(int,input().split()))

if(N == 0):
    print(X)
    sys.exit()
    
min = 0
plu = 0
ans = 200
a = [1] * 102 # 0と101を入れている

for i in range(N):
    a[p[i]] = 0

if(a[X] == 1):
    ans = X
    print(ans)
    sys.exit()


for k in range(100):
    min = X - (k+1)
    plu = X + (k+1)

    if(a[plu] == 1):
        ans = plu
    if(a[min] == 1):
        ans = min
    
    if(ans < 200):
        break

print(ans)
    
    

Measured memory_bytes: 9100
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int sz;
  scanf("%d", &sz);
  int i;
  vector<int> n;
  while(cin >> i) {
    n.push_back(i);
  }

  int s = n.size();

  for(i = 0; i < s; i++) {
    printf("%d", n[s - i - 1]);
    if(i < s - 1) printf(" ");
  }
  printf("\n");
  return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = 3;
  if (a == b || b == c || c == a)
  {
    ans--;
    if (a == b && c == a)
    {
      ans--;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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


public class Main {

  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    for(int i =1; i<=N; i++){
      int ai = sc.nextInt();
      for(int d = 1; d<=D; d+=ai){
         X++;
      }
    }
    System.out.println(X);
  }
}


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

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int arrayToInt(int *array, int size) {
  int result = 0;
  for(int i = size-1; i >= 0; i--) {
    result += array[i] * pow(10, size - i - 1);
  }
  return result;
}

void strToArray(string str, int l, int *num, int *rnum) {
  for(int i = l-1; i >= 0; i--) {
    if(i-(l-str.size()) >= 0) {
      num[i] = rnum[i] = ctoi(str[i-(l-str.size())]);
    } else {
      num[i] = rnum[i] = 0;
    }
  }
}

int main() {
  while(1) {
    vector<int> a;
    int l;
    string str;
    cin >> str >> l;
    int num[l];
    int rnum[l];
    strToArray(str, l, num, rnum);
    if(arrayToInt(num, l) + l == 0) return 0;
    a.push_back(arrayToInt(num, l));
    sort(num, num+l);
    sort(rnum, rnum+l, greater<int>());

    int result;
    while(1) {
      result = arrayToInt(rnum, l) - arrayToInt(num, l);
      if(find(a.begin(), a.end(), result) != a.end()) break;
      else a.push_back(result);
      string temp = to_string(result);
      strToArray(temp, l, num, rnum);
      sort(num, num+l);
      sort(rnum, rnum+l, greater<int>());
    }

    int i = a.size();
    for(int j = 0; j < a.size(); j++) {
      if(a[j] == result) {
        cout << j << " " << result << " " << i - j << endl;
        break;
      }
    }
  }
}



Measured memory_bytes: 3408
n = int(input())
s = input()

w = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    w[i] = w[i + 1]
    if s[i] == '.':
        w[i] += 1

ans = 0
for i in range(n - 2, -1, -1):
    if s[i] == '#':
        ans = min(ans + 1, w[i + 1])

print(ans)


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

int count_div2(int num){
  int n = num;
  int count = 0;
  while(n > 1){
    if(n % 2 == 1) break;

    n = n / 2;
    count++;
  }

  return count;
}

int main(){
  int n;
  
  while(cin >> n){
    int max = -1;
    int max_num = 0;
    
    for(int i = 1; i <= n; i++){
      int r = count_div2(i);
      if (r > max) {
	max = r;
	max_num = i;
      }
    }

    cout << max_num << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int S[1000000];
  int T[50000];
  int n,m; 
  cin>>n;
  for(int i=0;i<n;i++) cin>>S[i];
  cin>>m;
  for(int i=0;i<m;i++)cin>>T[i];
  int a, i,R,L,count=0;
  for(int i=0;i<m;i++){ R=n,L=0,a=n/2;
    while(L<R){
	if(T[i]>S[a])L=a+1;
      else R=a;
	a=(R+L)/2;
    }
    if(S[a]==T[i]) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 5256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,t[N<<2],t1[N<<2],t2[N<<2];
void update(int l,int r,int k)
{
    t1[k]=t[k]+r-l;t2[k]=t[k];
    if(l!=r)
    {
        int m=l+r>>1;
        t[k<<1]=t[k];t[k<<1|1]=t[k]+m+1-l;
    }
    t[k]=0;
}
int query(int l,int r,int k,int x)
{
    if(t[k]) update(l,r,k);
    if(l>x) return m+1;
    if(r<=x) return t1[k];
    int m=l+r>>1;
    int a=query(l,m,k<<1,x),b=query(m+1,r,k<<1|1,x);
    if(x<=r) a+=x>=m?x-m:0;
    else a+=r-m;
    t2[k]=min(t2[k<<1],t2[k<<1|1]);
    t1[k]=min(t1[k<<1]+r-m,t1[k<<1|1]);
    return min(a,b);
}
void update(int l,int r,int k,int x,int y,int d)
{
    if(t[k]) update(l,r,k);
    if(r<x||l>y) return;
    if(l>=x&&r<=y)
    {
        t[k]=d+l-x;
        update(l,r,k);
        return;
    }
    int m=l+r>>1;
    update(l,m,k<<1,x,y,d);update(m+1,r,k<<1|1,x,y,d);
    t2[k]=min(t2[k<<1],t2[k<<1|1]);
    t1[k]=min(t1[k<<1]+r-m,t1[k<<1|1]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,a,b,d;i<=n;i++)
    {
        scanf("%d%d",&a,&b);
        d=min(m+1,query(1,m,1,a-1)+1);
        update(1,m,1,a,b,d);
        printf("%d\n",t2[1]>=m?-1:t2[1]+i);
    }
}


Measured memory_bytes: 9836
package main

import (
	"fmt"
	//"math"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	str := strings.Split(s,"")
	flag := false

	for i,v := range str{
		if (i+1) % 2 == 0 {
			if v == "R"{
				flag = true
			} 
		}else{
			if v == "L"{
				flag = true
			} 
		}
	}
	if flag{
		fmt.Println("No")
	}else{
		fmt.Println("Yes")
	}
}

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

main() {
  int N,sum=0;
  cin >> N;
  
  for (int i=0; i<N; i++) {
    int l,r;
    cin >> l >> r;
    sum += r-l+1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
B=[(i+1)/2 for i in A]
m=M=sum(B[:k])
for i in range(n-k):
    m=m-B[i]+B[k+i]
    M=max(M,m)
print(M)
    

Measured memory_bytes: 24804
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

struct block{
	llint w, s, v;
	block(){};
	bool operator<(const block &obj)const{
		return w+s < obj.w+obj.s;
	}
};

llint n;
block b[1005];
llint dp[1005][20005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> b[i].w >> b[i].s >> b[i].v;
	}
	sort(b+1, b+n+1);
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 20005; j++){
			dp[i][j] = dp[i-1][j];
			if(j-b[i].w >= 0 && b[i].s >= j-b[i].w){
				dp[i][j] = max(dp[i][j], dp[i-1][j-b[i].w] + b[i].v);
			}
		}
	}
	
	llint ans = 0;
	for(int i = 0; i < 20005; i++) ans = max(ans, dp[n][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n, 0);
    rep1(i, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<ll>());
    ll ans = 0;
    for (ll i=k; i<(n); i++) ans += h[i];
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4852
#include <iostream>

using namespace std;

int main() {
    int N, a;

    cin >> N;

    a = (N % 100) % 10;

    if (a == 3) cout << "bon " << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "hon" << endl;


    return 0;
}

Measured memory_bytes: 3640
N,M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

good = [True]*N
for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    if H[a] >= H[b]:
        good[b] = False
    if H[b] >= H[a]:
        good[a] = False

ans = 0
for i in range(N):
    if good[i]:
        ans += 1
print(ans)


Measured memory_bytes: 93416
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n , m;
	cin >> n >> m;
	set<int> s;
	int lcm = 2;
	int a[n];
	forr(i,n) cin >> a[i];
	forr(i,n){
		int c = 0;

		int x = a[i];

		while(x % 2 == 0){
			x = x/2;
			c++;
		}
		s.insert(c);
		lcm = lcm * a[i]/__gcd(lcm,a[i]);
		if(s.size() > 1 || lcm > 2*m){
			cout << 0;
			return 0;
		}
	}
	cout << (2 * m / lcm + 1) /2;
}

Measured memory_bytes: 4420