akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	if (N < M) {
		swap(N, M);
	}
	for (int i = 0; i < N; i++)cout << M;
	cout << endl;
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int A, B; cin >> A >> B;
	for (int i = 0; i < 10000; i++) {
		if (i * 8 / 100 == A && i * 10 / 100 == B) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';

	return 0;
}


Measured memory_bytes: 256
def solve():
    p0, p1, p2 = 0, 1, 2
    best = 1
    succ = True
    while p0 < N-1:
        if not succ:
            p0 += 1
            while d[p2]- d[p1] > d[p1]- d[p0]:
                p2 -= 1

        succ = False

        while p1 - p0 < N - 1 and d[p1] - d[p0] <= best:
            p1 += 1
        d0 = d[p1] - d[p0]
        if d0 <= best:
            continue

        while p2 - p0 < N and d[p2] - d[p1] < d0:
            p2 += 1
        if d[p2] - d[p1] < d0:
            continue

        if L - (d[p2] - d[p0]) >= d0:
            best = d0
            if best >= L//3:
                return best
            succ = True

    return best

N = int(input())
A = [0] * N
L = 0
for i in range(N):
    A[i] = int(input())
    L += A[i]
d = [0] * (2*N)
for i in range(1, 2*N):
    d[i] = d[i-1] + A[(i-1)%N]

print(solve())

Measured memory_bytes: 21052
n,k = [int(x) for x in input().split()]
a = [int(x)-1 for x in input().split()]
ans = 0
cnt = 0

x = [-1] * n
y = -1

while cnt < k:
    if x[ans] == -1:
        x[ans] = cnt
        ans = a[ans]
        cnt += 1
    else:
        y = x[ans] + (k-cnt) % (cnt-x[ans])
        break

if y == -1:
    print(ans+1)
else:
    print(x.index(y) +1)

Measured memory_bytes: 32336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
   string s;cin>>s;
   int n=s.size();
   int b=-1,e=-1;
   rep(i,n){
       if(s[i]=='A'){
           b=i;break;
       }
   }
   rep(i,n){
       if(s[n-i-1]=='Z'){
           e=n-i-1;break;
       }
   }
   cout<<e-b+1<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

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

using namespace std;
using ll = long long;
using P = pair<ll, int>;

void Main() {
  int n;
	cin >> n;
  vector<int> A(n);
  vector<P> ord;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
    ord.emplace_back(A[i], i);
	}

  ll dp[n+1][n+1];
  memset(dp, 0, sizeof(dp));
	sort(ord.begin(), ord.end());
  rep(i, n) {
    rep(l, n - i + 1) {
			int r = l + i;
			const auto &[a, pos] = ord[i];
			dp[i+1][l] = max(dp[i][l] + a * abs(pos - r), dp[i][l + 1] + a * abs(pos - l));
		}
	}

  cout << dp[n][0] << endl;
}

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


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

int f(vector<vector<int>> &cum, bitset<16> b, int k)
{
    int h = cum.size();
    int w = cum.front().size();
    vector<vector<int>> x(b.count() + 1, vector<int>(w, 0));
    int prev = -1;
    int idx = 0;
    int ret = b.count();
    for (int i = 0; i < 16; i++)
    {
        if (b[i])
        {
            for (int j = 1; j < w; j++)
            {
                x[idx][j] = cum[i + 1][j] - cum[prev + 1][j];
            }
            prev = i;
            idx++;
        }
    }
    for (int i = 1; i < w; i++)
    {
        x.back()[i] = cum.back()[i] - cum[prev + 1][i];
    }

    int start = 0;
    while (start < w)
    {
        int l = start;
        int r = w - 1;
        bool flag = true;
        for (int i = 0; i < x.size(); i++)
        {
            if (x[i][r] - x[i][l] > k)
            {
                flag = false;
            }
        }
        if (flag)
        {
            break;
        }
        while (r - l > 1)
        {
            int c = (l + r) / 2;
            flag = true;
            for (int i = 0; i < x.size(); i++)
            {
                if (x[i][c] - x[i][start] > k)
                {
                    flag = false;
                }
            }
            if (flag)
            {
                l = c;
            }
            else
            {
                r = c;
            }
        }
        if (l == start)
        {
            return h + w;
        }
        if (l == w - 1)
        {
            break;
        }
        ret++;
        start = l;
    }
    return ret;
}

int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<int>> choco(H, vector<int>(W));
    string S;
    for (int i = 0; i < H; i++)
    {
        cin >> S;
        for (int j = 0; j < W; j++)
        {
            choco[i][j] = S[j] - '0';
        }
    }

    vector<vector<int>> cum(H + 1, vector<int>(W + 1, 0));
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            cum[i][j] = cum[i - 1][j] + cum[i][j - 1] - cum[i - 1][j - 1] + choco[i - 1][j - 1];
        }
    }

    int ans = H + W - 2;
    for (int i = 0; i < (1 << (H - 1)); i++)
    {
        bitset<16> b(i);
        ans = min(ans, f(cum, b, K));
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll binPow(ll a,ll b)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
return ans;
}


ll binPowMod(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
return ans%m;
}

ll modInv(ll x,ll m)
{
  return binPowMod(x,m-2,m);
}
ll NcrModpFermat(ll n ,ll r,ll m)
{
  ll fac1[r+1],fac2[r+1],i;
  for(i=0;i<=r;i++)
  {
    fac1[i]=fac2[i]=1;
  }
  for(i=1;i<=r;i++)
  {
    fac1[i]=fac1[i-1]*(n-r+i)%m;
  }

  for(i=1;i<=r;i++)fac2[i]=fac2[i-1]*i%m;

    

return fac1[r]*modInv(fac2[r],m);
}


int main()
{
   
    ll i,j,n,k,a,b,flag=0,temp1=0,temp3=0,temp2=0,m=1000000007,s1=0,s2=0;
   cin>>n>>a>>b;
   ll arr[n];

temp1 =binPowMod(2,n,m)%m;
temp1--;





temp2=NcrModpFermat(n,b,m)%m;



temp3=NcrModpFermat(n,a,m)%m;



temp1=(temp1-temp2-temp3+3*m)%m;

cout<<temp1<<endl;



 return 0;
  }

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	string line;
	cin >> line;
	vector<int> stack;
	vector<int> lakes;
	int all =0;
	int lake = 0;
	
	for (int i=0; i<line.length(); i++)
	{
		char c = line[i];
		if (c=='\\')
		{
			stack.push_back(i);
		}
		else if (c=='/')
		{
			if (stack.size() == 0) continue;
			auto end = stack.end() -1;
			lake += i - *end;
			stack.erase(end);
			if (stack.size() == 0)
			{
				all += lake;
				lakes.push_back(lake);
				lake = 0;
			}
		}
	}
	
	int mid = lakes.size();
	lake = 0;
	
	if (stack.size())
	{
		int end = stack[0];
		stack.clear();
		for (int i = line.length()-1; i >= end; i--)
		{
			char c = line[i];
			if (c=='/')
			{
				stack.push_back(i);
			}
			else if (c=='\\')
			{
				if (stack.size() == 0) continue;
				auto end = stack.end() -1;
				lake += *end - i;
				stack.erase(end);
				if (stack.size() == 0)
				{
					all += lake;
					lakes.push_back(lake);
					lake = 0;
				}
			}
		}
	}
	
	cout << all << endl;
	cout << lakes.size();
	for (int i=0; i<mid; i++)
	{
		cout << ' ' << lakes[i];
	}
	for (int i=lakes.size()-1; i>=mid;i--)
	{
		cout << ' ' << lakes[i];
	}
	cout << endl;
	
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    long double N, M, d;
    CINT(N, M, d);

    long double ans = (d == 0 ? 1.0 : 2.0) * (N - d) * (M - 1) / (N * N);
    COUT(ans);

    return 0;
}


Measured memory_bytes: 3800
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int mod=998244353;
typedef long long LL;
const int N=101;
int F[1<<26];
int getans(LL S,int n){
	LL SS=S+(1LL<<n);
	if(n<=25&&F[SS])return F[SS];
	int f[51];
	ref(i,0,n)f[i]=0;f[0]=1;
	ref(i,0,n-1)if(f[i]){
		(f[i+1]+=f[i])%=mod;
		if(S>>i&1)(f[i+1]+=f[i])%=mod;
		ref(j,1,n-i){
			LL s=(S>>i)&((1<<j)-1);
			for(int I=i+j;I+j<=n;I+=j){
				s=s&(S>>I);
				(f[I+j]+=1LL*f[i]*getans(s,j)%mod)%=mod;
			}
		}
	}
	if(n<=25)F[SS]=f[n];
	return f[n];
}
int n,f[101];LL num[101][51];char s[101];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	ref(i,1,n){
		num[i][0]=0;
		ref(j,1,min(50,n-i+1))
			num[i][j]=num[i][j-1]+((1LL*(s[i+j-1]-'0'))<<j-1);
	}
	f[0]=1;
	ref(i,0,n-1)if(f[i]){
		(f[i+1]+=f[i])%=mod;
		if(s[i+1]=='1')(f[i+1]+=f[i])%=mod;
		ref(j,1,n-i){
			LL s=num[i+1][j];
			for(int I=i+j;I+j<=n;I+=j){
				s=s&num[I+1][j];
				(f[I+j]+=1LL*f[i]*getans(s,j)%mod)%=mod;
			}
		}
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 225152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  while (true)
  {

    int a, b;
    string op;
    cin >> a >> op >> b;

    if (op == "?")
    {
      return 0;
    }
    if (op == "+")
    {
      cout << a + b << endl;
    }
    else if (op == "-")
    {
      cout << a - b << endl;
    }
    else if (op == "*")
    {
      cout << a * b << endl;
    }
    else if (op == "/")
    {
      cout << a / b << endl;
    }
  }
}



Measured memory_bytes: 3140
#Mixing experiment
#dp[x][a][b]=Nこの商品のうちx番目まで見て、Aをaグラム、Bをbグラム得るために必要なお金の最小費用。
N,Ma,Mb=map(int,input().split())
D=[tuple(map(int,input().split())) for _ in range(N)]
dp=[[[float("inf") for i in range(401)] for j in range(401)] for k in range(N+1)]
dp[0][0][0]=0
        
for i in range(N):
    a,b,c=D[i]
    for j in range(401):
        for k in range(401):
            if j>=a and k>=b:
                dp[i+1][j][k]=min(dp[i][j][k],dp[i][j-a][k-b]+c)
            else:
                dp[i+1][j][k]=dp[i][j][k]
ans=float("inf")
for i in range(1,401):
    if 0<Ma*i<=400 and 0<Mb*i<=400:
        ans=min(ans,dp[N][Ma*i][Mb*i])

if ans==float("inf"):
    print(-1)
else:
    print(ans)

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

int main(){
  int a,i,j,array[100]={};
  string s;
  cin>>a>>s;
  
  for(i=1;i<a;i++){
    int left[26]={},right[26]={};
    for(j=i;j<a;j++){
      right[s[j]-'a']=1;
    }
    for(j=0;j<i;j++){
      left[s[j]-'a']=1;
    }
    for(j=0;j<26;j++){
     array[i]+=(right[j]==1&&left[j]==1);
    }
  }
  sort(array,array+a);
  cout<<array[a-1]<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
X=0;Y=0
mod=10**9+7
for i in range(n-1):
  X+=(a[i+1]-a[i])*(i+1)*(n-i-1)
  X%=mod
for i in range(m-1):
  Y+=(b[i+1]-b[i])*(i+1)*(m-i-1)
  Y%=mod
print((X*Y)%mod)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define MAX_INT 2147483647
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

//#define int long long

inline int in(){int x;std::cin>>x;return x;}
struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;
template <class X> void print(X hoge){ cout << hoge<< '\n'; }

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  string a, b, c;

  cin >> a >> b >> c;

  cout << "A" << b[0] << "C" << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    string s, t;
    cin >> s >> t;

    ll cnt = 0;
    // 違うもの

    ll n = s.length();

    REP(i, n){
        if(s[i] != t[i]){
            cnt ++;
        }
    }
    cout << cnt << endl;

    return 0;
}




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

int main(){
  int k,f=0;
  cin >> k;
  long long sum=0;
  for(int i=1;i<1000001;i++){
    sum=((sum*10)+7)%k;
    if(sum==0){
    cout << i <<endl ;
    f=1;
      break;
    }
  }
  if(!f)
    cout << -1 << endl;
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bool ans=false;
  for (auto x : G[0]){
    for (auto y :G[x]){
      if (y==N-1){
        ans=true;
        break;
      }
    }
  }
  if (ans){
    cout << "POSSIBLE" << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 12016
cards = [int(i) for i in input().split(" ")]

A = cards[0]
B = cards[1]
C = cards[2]

K = int(input())
beyondA = 0
beyondB = 0

while A >= B:
    B *= 2
    beyondA += 1

while B >= C:
    C *= 2
    beyondB += 1

if K < beyondA + beyondB:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);


int main(){

	IOS
	ll a,b,n;
	cin>>a>>b>>n;
	ll tmp;
	if(n<b){
		tmp=n;

	}
	else tmp=b-1;
	//tmp=3;
	ll ans=0;
	double t1=(double)a*tmp/b;
	ll t2=(ll)t1;
	//dbg(t1);
	ans+=t2;
	t1=(double)tmp/b;
	t2=(ll)t1;
	t2=t2*a;
	//dbg(t2);
	ans=ans-t2;
	cout<<ans<<endl;

}

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

// 1-indexed
// s[1...n]
class rolling_hash {
public:
    rolling_hash(std::string const& s)
        : n(s.size()),
          mod({999999937LL, 1000000007LL})
    {
        for(int i = 0; i < 2; ++i) {
            hs[i].resize(n + 1);
            p[i].resize(n + 1);
            hs[i][0] = 0;
            p[i][0] = 1;
            for(int j = 0; j < n; ++j) {
                hs[i][j + 1] = (hs[i][j] * base + s[j]) % mod[i];
                p[i][j + 1] = p[i][j] * base % mod[i];
            }
        }
    }

    // s[i...]
    long long query(int idx, int i) const {
        return hs[i][idx];
    }
    // s[l + 1...r]
    long long query(int l, int r, int i) const {
        return ((hs[i][r] - hs[i][l] * p[i][r - l]) % mod[i] + mod[i]) % mod[i];
    }

private:
    int n;
    std::vector<long long> hs[2];
    std::vector<long long> p[2];

    const std::array<long long, 2> mod;
    static const long long base = 29LL;
};

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    rolling_hash hs(s);
    int l = 0, r = 1;
    set<pair<long long, long long>> ss;
    for(int i = 0; i < m; ++i) {
        string q;
        cin >> q;
        if(q[0] == 'R') {
            if(q[1] == '+') {
                r++;
            } else {
                r--;
            }
        } else {
            if(q[1] == '+') {
                l++;
            } else {
                l--;
            }
        }
        ss.insert(make_pair(hs.query(l, r, 0), hs.query(l, r, 1)));
    }
    cout << ss.size() << endl;
}

Measured memory_bytes: 31264
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int t, n;
		cin >> t >> n;
		if (!t)break;
		vvi v(121, vi(121, 0));
		REP(i, n) {
			int x, y;
			cin >> x >> y;
			v[y + 60][x + 60] = 1;
		}
		int sx, sy;
		cin >> sx >> sy;
		vvi depth(121, vi(121, INF));
		depth[sy +60][sx + 60] = 0;
		queue<pii> q;
		q.push(make_pair(sx, sy));
		while (!q.empty()) {
			pii a = q.front(); q.pop();
			int x = a.first, y = a.second;
			REP(i, 6) {
				int nx = x + dx[i], ny = y + dy[i];
				if (ny <= 60 && nx <= 60 && nx >= -60 && ny >= -60 && v[ny + 60][nx + 60] == 0&&depth[ny+60][nx+60]==INF) {
					q.push(make_pair(nx, ny));
					depth[ny + 60][nx + 60] = depth[y + 60][x + 60] + 1;
				}
			}
		}
		int cnt = 0;
		REP(i, 121) {
			REP(j, 121) {
				if (depth[i][j] <= t)cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

int main(){
  int n;string s;cin>>n>>s;
  vector<int> r(n+1,0),g(n+1,0),b(n+1,0);
  REP(i,n){
      r.at(i+1)=r.at(i);
      g.at(i+1)=g.at(i);
      b.at(i+1)=b.at(i);
    if(s.at(i)=='R') r.at(i+1)++;
    else if(s.at(i)=='G') g.at(i+1)++;
    else b.at(i+1)++;
  }

  ll ans=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      if(s.at(i)!=s.at(j)){
        if(((s.at(i)=='R')&&(s.at(j)=='G'))||((s.at(i)=='G')&&(s.at(j)=='R'))){
          ans+=(ll)b.at(n)-b.at(j+1);
          if(2*j-i<n&&s.at(2*j-i)=='B') ans--;
        }
        if(((s.at(i)=='G')&&(s.at(j)=='B'))||((s.at(i)=='B')&&(s.at(j)=='G'))){
          ans+=(ll)r.at(n)-r.at(j+1);
          if(2*j-i<n&&s.at(2*j-i)=='R') ans--;
        }
        if(((s.at(i)=='B')&&(s.at(j)=='R'))||((s.at(i)=='R')&&(s.at(j)=='B'))){
          ans+=(ll)g.at(n)-g.at(j+1);
          if(2*j-i<n&&s.at(2*j-i)=='G') ans--;
        }
      }
    }
  }

  cout<<ans;
}


Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>
int main(void){
	int out=0,n;
	int d0=1,d1=0,d2=0,d3=0,pts[1000]={0};
	int i;
	char a[100000]={0};

	scanf("%d",&n);
	//for(i=0;;){
	    for(i=0;i<n;){

        scanf("%s",&a);
        if(strcmp(a,"HIT")==0){

            pts[i]+=d3;
            d3=d2;
            d2=d1;
            d1=d0;
        }
        else if(strcmp(a,"HOMERUN")==0){
           pts[i]=pts[i]+d3+d2+d1+d0;
           d3=0;
           d2=0;
           d1=0;
        }
        else if(strcmp(a,"OUT")==0){
            out++;
            if(out==3){
            out=0;
            i++;
            d1=d2=d3=0;
            }

        }
        //printf("%d",i);

	    }
    //}
    for(i=0;i<n;i++){
        printf("%d\n",pts[i]);
    }




	return 0;
}

Measured memory_bytes: 704
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	////vector<Int> x(N), y(N), h(N);
	//vector<Int> x, y,h;
	//Int tempx, tempy, temph;
	//Int count = 0;
	//for (Int i = 0; i < N; i++) {
	//	cin >> tempx >> tempy >> temph;
	//	if (temph) {
	//		/*
	//		x[count] = tempx;
	//		y[count] = tempy;
	//		h[count] = temph;
	//		count++;
	//		*/
	//		x.push_back(tempx);
	//		y.push_back(tempy);
	//		h.push_back(temph);
	//		count++;
	//	}
	//}

	vector<Int> x(N), y(N), h(N);
	Int si=0;
	for (Int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0)si = i;
	}

	Int ansx, ansy, ansh;
	Int flag;
	for (Int i = 0; i <= 100; i++) {
		for (Int j = 0; j <= 100; j++) {
			flag = 0;
			ansx = i;
			ansy = j;
			ansh = h[si] + abs(x[si] - ansx) + abs(y[si] - ansy);
			for (Int k = 0; k < N; k++) {
				if ((h[k] > 0) && (ansh != h[k] + abs(x[k] - ansx) + abs(y[k] - ansy))) {
					flag = 1;
					break;
				}
				else if ((h[k] == 0) && (ansh - abs(x[k] - ansx) - abs(y[k] - ansy)) > 0) {
					flag = 1;
					break;
				}
			}
			if (flag == 0)break;
		}
		if (flag == 0)break;
	}

	cout << ansx << " " << ansy << " " << ansh << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<stack>
using namespace std;
 
int main(void) {
    string str;
    int number[1000],count = 0;
    stack<int> num;
    while(cin >> str) {
        if (str[0] == '+') {
            int a = num.top(); num.pop();
            int b = num.top(); num.pop();
            num.push(a + b);
        } else if (str[0] == '-') {
            int b = num.top(); num.pop();
            int a = num.top(); num.pop();
            num.push(a - b);
        } else if (str[0] == '*') {
            int a = num.top(); num.pop();
            int b = num.top(); num.pop();
            num.push(a * b);
        } else if (str[0] == ' ') {
        }else{
            num.push(atoi(str.c_str()));
        }
    }
    cout << num.top() << endl;
    return 0;
}

Measured memory_bytes: 1200
data_a,data_b,data_c,data_d = [int(x) for x in input().split()]


length_1 = abs(data_a - data_b)
length_2 = abs(data_b - data_c)
length_3 = abs(data_a - data_c)

if length_3 <= data_d:
    print('Yes')
elif length_1 <= data_d and length_2 <= data_d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9136
#include<iostream>
using namespace std;
long N;int A,B;
main()
{
    cin>>N>>A>>B;
    N%=12;
    for(int i=0;i<N;i++)
    {
        if(i%2==0)A-=B;
        else B+=A;
    }
    cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define fr first
#define sc second

typedef long long ll;
const ll INF=100000000;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
using namespace std;

struct Spell {
    ll mp,target,damage;
    Spell(ll mp=0,ll target=0,ll damage=0) :
        mp(mp),target(target),damage(damage){}

};

struct State {
    ll cost;
    vector<int> HP;
    State(ll cost=0,const vector<int> &HP=vector<int>()):
        cost(cost),HP(HP){}
    bool operator<(const State& rhs) const {
        return cost>rhs.cost;
    }
};

ll N;
vector<int> HP;
ll M;
Spell spells[102];
ll dp1[1000006],dp2[1000006];

ll solve() {
    ll ret=INF;
    rep(i,1000006) dp1[i]=dp2[i]=INF;
    dp1[0]=dp2[0]=0;
    rep(i,M) rep(j,1000006) {
        if(j+spells[i].damage>=1000006) continue;
        if(spells[i].target==0) {
            dp1[j+spells[i].damage]=min(dp1[j+spells[i].damage],dp1[j]+spells[i].mp);
        }
        else {
            dp2[j+spells[i].damage]=min(dp2[j+spells[i].damage],dp2[j]+spells[i].mp);
        }
    }
    for(ll i=1000005;i>=1;i--) {
        dp2[i-1]=min(dp2[i],dp2[i-1]);
        dp1[i-1]=min(dp1[i],dp1[i-1]);
    }

    rep(i,1000006) {
        ll s=dp2[i];
        rep(j,N) {
            s+=dp1[max(0,HP[j]-i)];
        }

        //printf("%d %d\n",i,s);
        ret=min(ret,s);
    }

    return ret;
}

int main() {
    while(cin>>N) {
        HP.clear();
        if(!N) break;
        HP.resize(N);
        rep(i,N) cin>>HP[i];
        cin>>M;
        rep(i,M) {
            string s1,s2;
            ll mp,damage;
            cin>>s1>>mp>>s2>>damage;
            ll t=0;
            if(s2=="All") t=1;
            spells[i]=Spell(mp,t,damage);
        }
        cout<<solve()<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;

  int i,n;
  int flag = 0;
  int before = 0,after = 0;
  int count = 0;
  int tmp = N;
  N-= K;
  count++;
  for(i = 1;i <= tmp;i++){
    cin >> n;
  }
  if (tmp == K){
    cout << 1 << endl;
    return 0;
  }
  
  if(N % (K -1) == 0)
    count += (N / (K -1));
  else
    count += (N /(K -1)) + 1;
    cout << count << endl;

    return 0;


}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	for( int i = 0; i < 5; i++){
        	int a = sc.nextInt();
          
          	if(a == 0)
              System.out.print(i + 1);
        }
    }
}


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

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<long long> rap,gap,tap;
    for(int i=0;i<a;++i){
        long long r;
        cin>>r;
        rap.push(r);
    }
    for(int i=0;i<b;++i){
        long long g;
        cin>>g;
        gap.push(g);
    }
    for(int i=0;i<c;++i){
        long long t;
        cin>>t;
        tap.push(t);
    }

    for(int i=0;i<x;++i){
        tap.push(rap.top());
        rap.pop();
    }
    for(int i=0;i<y;++i){
        tap.push(gap.top());
        gap.pop();
    }

    long long res=0;
    for(int i=0;i<x+y;++i){
        res+=tap.top();
        tap.pop();
    }

    cout<<res<<endl;
}

Measured memory_bytes: 8976
def main01():
    data = input().split()
    num = []

    for i in range(3):
        num.append(int(data[i]))
    densya = num[0] * num[1]
    if densya > num[2]:
        print(num[2])
    else:
        print(densya)


if __name__ == "__main__":
    main01()

Measured memory_bytes: 3060
n = int(input())

itv = []
for i in range(n):
    x,l = map(int,input().split())
    itv.append([x+l-0.1,x-l+0.1])
itv.sort()

ass = 0
tt = -float("inf")
for i in range(n):
    if tt < itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)

Measured memory_bytes: 18540
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

get_numbers_2(0, _, []).
get_numbers_2(N1, N2, [X|Xs]) :- 
    get_numbers(N2, X), 
    N12 is N1 - 1, 
    get_numbers_2(N12, N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)

    include(f, Xs, Ys) : filter f
*/

cu(Xs, Zs) :- cu(Xs, 0, Zs).
cu([], C, [C]).
cu([X|Xs], C, [C|Zs]) :- C2 is C + X, cu(Xs, C2, Zs).

include_cmp_x([], _, _, []).
include_cmp_x([X|Xs], F, Y, Zs) :- call(F, X, Y), !, include_cmp_x(Xs, F, Y, Zs2), Zs = [X|Zs2].
include_cmp_x([_|Xs], F, Y, Zs) :- include_cmp_x(Xs, F, Y, Zs).

f(Y, X) :- Y =< X.

main :-
    get_number(N, X),
    get_numbers(N, Xs),
    cu(Xs, Xs_cu),
    include_cmp_x(Xs_cu, f, X, Xs_cu_f),
    length(Xs_cu_f, L),
    writeln(L).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8300
#include<iostream>
using namespace std;
int main(){
	int a[2];
	while(cin>>a[0]>>a[1]){
	int sum=a[0]+a[1];
	int  i=0;
	while(1){
		i++;
	if(sum>=0&&9>=sum)break;
	sum/=10;
	}
	cout<< i<<endl;
	}
	return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	if(n%2 == 0){
		if(k <= n/2){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}else{
		if(k <= (n+1)/2){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

long long n, a[500005], s, p, q, r;
long long prv;

int main()
{
    

    int n, x[105];
    long long minm, temp, a[105];

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

    minm = LONG_LONG_MAX;
    for(int p=1; p<=100; p++)
    {
        temp = 0;
        for(int j=0; j<n; j++)
        {
            temp += abs(a[j]-p) * abs(a[j]-p);
        }
        minm = min( minm, temp  );
    }

    cout << minm << "\n";


    return 0;    

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAX 200000
typedef long long ll;
int main()
{
	ll x,sum[MAX],tot,MIN;
	int n;
    scanf("%d",&n);
    sum[0]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        sum[i]=sum[i-1]+x;
    }
    tot=sum[n];
    MIN=abs(tot-2*sum[1]);
    for(int i=2;i<=n-1;i++)
    {
        MIN=min(MIN,abs(tot-2*sum[i]));
    }
    printf("%lld",MIN);
    return 0;
}

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

#define range(i, l, r) for (int i = (l); i < (r); ++(i)) 
#define rrange(i, l, r) for (int i = (r - 1); i >= (l); --(i))

int main() {
  int c, n, m;
  cin >> c >> n >> m;

  vector< int > ss(n), ps(n);
  range(i, 0, n) cin >> ss[i] >> ps[i];

  vector< int > dp(c + 1, 0);
  range(i, 0, n) rrange(j, ss[i], c + 1) {
    dp[j] = max(dp[j], dp[j - ss[i]] + ps[i]);
  }
  
  range(i, 1, m + 1) {
    cout << i * dp[c / i] << endl;
  }
}



Measured memory_bytes: 3212
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int group(int x){
  switch(x){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
    return 1;
    break;
    case 2:
    return -1;
    break;
    default:
    return 2;
    break;
  }
}

int main(){
  cin >> n >> m;
  if(group(n) == group(m))puts("Yes");
  else puts("No");
  return 0;
}

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

const long long MOD = 1000000000LL + 7;

long long modPow(long long v, long long p) {
    if (p == 0) {
        return 1;
    }

    long long hp = modPow(v, p/2);

    if (p%2) {
        return (hp*hp) % MOD * v % MOD;
    }
    return (hp*hp) % MOD;
}

int main() {
    // 10^N - 2 * 9^N + 8^N
    long long N;
    cin >> N;

    long long res = modPow(10, N) - 2*modPow(9, N) + modPow(8, N);
    res %= MOD;
    res += MOD;
    res %= MOD;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
S = input()
F = int(S[0] + S[1])
B = int(S[2] + S[3])
if min(F, B) > 12 or max(F, B) == 0 or min(F,B) == 0 and max(F, B) > 12:
  print('NA')
elif min(F, B) != 0 and max(F, B) <= 12:
  print('AMBIGUOUS')
elif F <= 12 and F != 0:
  print('MMYY')
else:
  print('YYMM')

Measured memory_bytes: 3064
#include<stdio.h>
#include<utility>
#include<algorithm>

using namespace std;

int A[2000001];
int n;

void maxHeapify(int i){
    int l = 2 * i;
    int r = 2 * i + 1;

    int largest;
    if(l <= n && A[l] > A[i]){
        largest = l;
    }
    else{
        largest = i;
    }
    if(r <= n && A[r] > A[largest]){
        largest = r;
    }

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void insert(int key){
    A[++n] = key;
    int i = n;
    while(i / 2 >= 1 && A[i] > A[i / 2]){
        swap(A[i], A[i / 2]);
        i /= 2;
    }
}

int extract(){
    int max = A[1];
    swap(A[1], A[n]);
    n--;
    maxHeapify(1);
    return max;
}

int main(){
    while(true){
        char com[8];
        scanf("%s", com);
        if(com[0] == 'i'){
            int key;
            scanf("%d", &key);
            insert(key);
        }
        else if(com[0] == 'e' && com[1] == 'x'){
            printf("%d\n", extract());
        }
        else{
            break;
        }
    }
}


Measured memory_bytes: 6500
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String taro, hanako;
		int countT = 0, countH = 0;
		// int wordLength;
		for (int i = 0; i < n; i++) {
			taro = sc.next();
			hanako = sc.next();
			/*
			if(taro.length() >= hanako.length()){
				wordLength = taro.length();
			}else{
				wordLength = hanako.length();
			}
			for (int j = 0; j < wordLength; j++) {
				if (taro.charAt(j) > hanako.charAt(j)) {
					countT += 3;
					break;
				} else if (taro.charAt(j) < hanako.charAt(j)) {
					countH += 3;
					break;
				} else if (taro.length() - 1 == j || hanako.length() - 1 == j) {
					if (hanako.length() > taro.length()) {
						countH += 3;
						break;
					} else if (taro.length() > hanako.length()) {
						countT += 3;
						break;
					} else {
						countT++;
						countH++;
					}
				}
			}
			*/
			if(taro.compareTo(hanako) > 0){
				countT += 3;
			}else if(taro.compareTo(hanako) < 0){
				countH += 3;
			}else{
				countT++;
				countH++;
			}
		}
		System.out.println(countT + " " + countH);
		sc.close();
	}
}


Measured memory_bytes: 29388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

int main(void){
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a),greater<ll>());
    int res = p;
    ll acm = a[p-1];
    ll k = 1;
    for (int i = p; i < n; i++){
        if (a[i]+m < a[p-1]) break;
        ll cap = (a[i]+m)*k - acm + (n-p-k)*m;
        ll rem = (v-p)*m;
        if (cap >= rem) res++;
        k++;
        acm += a[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,w[105];
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&w[i]);
    int s1=0,s2=0;
    int l=1,r=n;
    while(l<=r)
    {
        if(s1<=s2)
            {
                s1+=w[l];
                l++;
            }
        else if(s1>s2)
            {
                s2+=w[r];
                r--;
            }
    }
    if(s1>s2)
    printf("%d\n",s1-s2);
    else
        printf("%d\n",s2-s1);


    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int ans = (int) Math.ceil((a + b) / 2.0);
        System.out.println(ans);
    }
}

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

using namespace std;

ifstream fin("jocul.in");
ofstream fout("jocul.out");

long long n,g;
long long v[105],w[105];
long long dp[100005];

int main(){
    long long i,j,sum=0,sum1=0,answer;

    cin>>n>>g;

    for(i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        sum1+=v[i];
    }

    for(i=1;i<=sum1;i++)
        dp[i]=100000000005;


    dp[0]=0;

    for(i=1;i<=n;i++){
        sum+=v[i];
        for(j=sum;j>=v[i];j--)
            if(dp[j-v[i]]!=100)
                dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
    }

    for(i=1;i<=sum1;i++)
        if(dp[i]<=g)
            answer=i;

    cout<<answer;

    return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
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() {
    int N; cin >> N;
    int res = 0;
    for (int i = 1; i < N; ++i) res += (N - 1) / i;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
n,k=map(int,input().split())
ans=[]
if n%2==1:
  a=1
  b=n
  for _ in range(k):
    ans.append([a,b])
    a+=1
    b-=1
else:
  a=1
  b=n
  s=set()
  for _ in range(k):
    s.add(abs(a-b))
    s.add(abs(n+a-b)%n)
    ans.append([a,b])
    a+=1
    b-=1
    if abs(a-b) in s or abs(n+a-b)%n in s or abs(a-b)==abs(n+a-b):
      b-=1
for i in range(k):
  print(*ans[i])

Measured memory_bytes: 27828
import itertools

l,r = map(int,input().split())

if r-l >= 2019:
    print(0)
else:
    mods = []
    nums = list(range(l,r+1))
    for v in itertools.combinations(nums,2):
        mods.append(v[0]*v[1]%2019)
    print(min(mods))

Measured memory_bytes: 75460
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int unsigned long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    long double b;
    int a;
    cin>>a>>b;
    
    int x = a;
    int y = round(b*100);
    // cout<<y<<endl;
    cout<<(x*(y))/100<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

int main(){
    ll k;
    cin >> k;
    if(k%2==0){
        cout << -1 << endl;
    }
    else{
        ll ans=1;
        ll ama=k;
        ama=7%k;
        while(ama!=0){
            ama*=10;
            ama+=7;
            ama=ama%k;
            ++ans;
            if(ans==(k+1)){
                
                ans=-1;
                break;
            }
        }

        cout << ans << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#define ll long long
#define fi first
#define se second
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
const int INF=0x7fffffff;
const double EPS=1e-6;
const int MAX_N=1000000+5;
string s;
int main (void)
{
    int i;
    double a,b;
    cin>>a>>b;
    for(i=1; i<=2000; i++)
    {
        double aa=1.0*i*0.08;
        double bb=0.1*i;
        if((int)aa==a&&(int)bb==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
		int tmpa = (b + c) / 2;
		int tmpb = (a + c) / 2;
		int tmpc = (a + b) / 2;
		if(a == tmpa && b == tmpb && c == tmpc){
			cout << "-1" << endl;
			return 0;
		}
		a = tmpa;
		b = tmpb;
		c = tmpc;
		ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int x,y;
      cin>>x>>y;
      map<int,int> ma;
      ma[x]++;
      ma[y]++;
      for(int i=1;i<=3;i++)
      {
        if(ma[i]==0) cout<<i;
      }

} 
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;



signed main()
{
    string s;

    cin >> s;
    cout << s[0] << s.length() - 2 << s[s.length()-1] << endl;
}


Measured memory_bytes: 256