akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define maxn 1000005
int n, m, ch[maxn][27], rt, cnt, is[1000005][27], ton[27], fa[1000005], pax, ans;
struct node {
    string c;
    int len;
}e[maxn];
il bool cmp(node a, node b) {
    return a.len > b.len;
}
il void insert(int &now, int pa, int x) {
    if(x == -1) return;
    if(!now) now = ++ cnt;
    pax = now;
    insert(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    fa[ch[now][e[pa].c[x] - 'a' + 1]] = now;
}
il int find(int now, int pa, int x) {
    if(x == 0) return is[now][e[pa].c[0] - 'a' + 1];
    if(ch[now][e[pa].c[x] - 'a' + 1]) return find(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    return 0;
}
signed main() {
	n = read();
    rep(i, 1, n) cin >> e[i].c, e[i].len = e[i].c.size();
    sort(e + 1, e + n + 1, cmp);
    rep(i, 1, n) {
        ans += find(rt, i, e[i].len - 1);
        insert(rt, i, e[i].len - 1);
        rep(j, 0, e[i].len - 1) {
            ton[e[i].c[j] - 'a' + 1] = 1;
            rep(k, 1, 26) is[pax][k] += ton[k];
            pax = fa[pax];
        }
        rep(i, 1, 26) ton[i] = 0;
    }
    cout << ans;
	return 0;
}

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

#define ll long long
#define sz 1000

void solve()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;

    ans += min(a, k);
    k-=a;
    k-=b;
    if(k>0)
    {
        ans -= min(k,c);
    }
    cout << ans << endl;

}

int main()
{
    int tc = 1;
    //cin >> tc;
    while(tc--)
    {
        solve();
    }

    return 0;
}




Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから


void solve(){
  ll n,k;
  cin>>n>>k;
  vector<vector<ll>>sum(2*k+1,vector<ll>(2*k+1));
  vector<vector<ll>>a(2*k,vector<ll>(2*k));
  rep(i,n){
    ll x,y;
    char c;
    cin>>x>>y>>c;
    if(c=='B')a[x%(2*k)][y%(2*k)]++;
    else a[(x+k)%(2*k)][y%(2*k)]++;
  }
  rep(i,2*k){
    rep(j,2*k){
      sum[i+1][j+1]=a[i][j]+sum[i+1][j]+sum[i][j+1]-sum[i][j];
    }
  }
  ll ans=0;
  rep(i,k){
    rep(j,k){
      //黒に統一したので黒の2つの正方形だけ数える
      ll tmp=sum[i+k][j+k]+sum[i][j]-sum[i][j+k]-sum[i+k][j];
      tmp+=sum[2*k][2*k]+sum[i+k][j+k]-sum[i+k][2*k]-sum[2*k][j+k];
      //以下余りの関係ではみ出たところ
      tmp+=sum[2*k][j]+sum[i+k][0]-sum[2*k][0]-sum[i+k][j];
      tmp+=sum[i][2*k]+sum[0][j+k]-sum[i][j+k]-sum[0][2*k];
      tmp+=sum[i][j]+sum[0][0]-sum[i][0]-sum[0][j];
      chmax(ans,n-tmp);//逆もやればK回ですむ
      chmax(ans,tmp);
    }
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 62976
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	int ans = 0;
	for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) ans += d[i]*d[j];
	cout << ans;

}

Measured memory_bytes: 256
#include <cstdio>
// C - Sqrt Inequality

using namespace std;

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

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

    if (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b))
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

ll N, A[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  set<ll> st;
  ll cnt = 0;
  REP(i, 0, N) {
    if(st.count(A[i])) cnt++;
    else st.insert(A[i]);
  }

  cout << N - (cnt + 1) / 2 * 2 << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    int a,b,c; cin>>a>>b>>c;
    int k=0;
    for(int i=a; i<=b; i++)
    	if(i%c==0) k++;
    cout<<k<<endl; 
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N;
   cin>>N;
   int L[N];
   int sum=0;
   int M=0;
   rep(i,N){
       cin>>L[i];
       M=max(M,L[i]);
       sum+=L[i];
   }
   sum-=M;
   if(M<sum){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
   
}

Measured memory_bytes: 3564
mod = 1000000007

N,M = map(int,input().split())

if abs(N-M)>1:
    print(0)
else:
    ans = 1
    for i in range(1,N+1): ans = (ans*i)%mod
    for j in range(1,M+1): ans = (ans*j)%mod
    if N==M: ans = (ans*2)%mod
    print(ans)

Measured memory_bytes: 3060
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
 
    ll i,j,ans=1000;
    ll m;
    cin>>m;
    ll a[m+2];

    for(i=0;i<m;i++) cin>>a[i];
    for(i=1;i<m;i++)
    {
    	if(a[i]>a[i-1])
    	{
    		ll ha = ans/a[i-1];
    		ans += (a[i]-a[i-1])*ha;
    	}
    }
    cout<<ans;

    
    
}

Measured memory_bytes: 3636
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();
        long sum = 0;

        for (int i = 1; i <= input; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35768
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] nab = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = nab[0];
        long a = nab[1];
        long b = nab[2];

        long c = n / (a + b);
        long d = n % (a + b);

        long ans = 0;
        if (d <= a)
        {
            ans = (c * a) + d;
        }
        else
        {
            ans = c * a + a;
        }

        if (a == 0)
        {
            ans = 0;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import java.util.*;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int buf = 0;
    int ans = 0;

    for(int i = Math.min(a, b); i > 0; i--){
      if(a % i == 0 && b % i == 0){
        buf += 1;
        if(buf == k){
          ans = i;
        }
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
using System;
using System.Linq;

class Prog
{
  public static void Main()
  {
    var ipt = Console.ReadLine().Split(' ').Select(i=>Int32.Parse(i.ToString())).ToArray();
    if(ipt[2]-ipt[1]==ipt[1]-ipt[0])
    {
      Console.WriteLine("YES");
    }
    else
    {
      Console.WriteLine("NO");
    }
  }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n){
    cin >> p.at(i);
  }
  cout << accumulate(all(p), 0) - *max_element(all(p)) / 2;
}

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

int main(){
    int N;
    cin >> N;
    string S;
    int C[4] = {};
    for(int i=0; i<N; i++){
        cin >> S;
        if(S=="AC") C[0]++;
        else if(S=="WA") C[1]++;
        else if(S=="TLE") C[2]++;
        else if(S=="RE") C[3]++;
    }
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;

}

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

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

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

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

int memo[1000 + 5];
double d[MAX_N + 5];
double pp[MAX_N + 5];
double E[MAX_N + 5];

int su(int n) {
  if (memo[n] != inf) return memo[n];
  memo[n] = n + su(n - 1);
  return memo[n];
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  REP(i, N) cin >> pp[i];
  REP(i, 1000 + 5) memo[i] = inf;

  REP(i, N) {
    E[i] = (double)su(pp[i]) / (double)pp[i];
    // cout << "i: " << i << ", " << E[i] << endl;
  }
  // REP(i, N) cout << E[i] << ", ";
  // cout << endl;

  d[0] = 0.0;

  REP(i, N) { d[i + 1] = d[i] + E[i]; }
  // REP(i, N + 1) cout << d[i] << ", ";
  // cout << endl;
  // return 0;

  double ans = 0;
  int l = 0, r = 0;
  double sum = 0;
  // cout << l << N << endl;
  for (int i = 0; l <= N; l++) {
    if (l + K >= N + 1) break;
    ans = max(ans, d[l + K] - d[l]);
    // while (l < i) sum -= d[l++];
    // while (r < N && r - l <= K) {
    //   sum += d[r++];
    // }
    // ans = max(ans, sum / K);
  }
  printf("%.9f\n", ans);
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){

    string S;


    cin >> S;


    int imin = 1000;
    int tmp;
    for(int i = 0; i <= S.size() - 3; i++){
        
        tmp = stoi(S.substr(i,3));

        tmp = abs(753 - tmp);

        imin = min(imin, tmp);
    }


    cout << imin << endl;

}



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

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

const long long INF = 1LL << 60;
const int STONE = 1000000;

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

    int left, right;
    left = max(-STONE, X - K + 1);
    right = min(STONE, X + K - 1);

    for (int i = left; i < right; i++) {
        cout << i << " ";
    }

    cout << right << endl;
    return 0;
}

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

 

int dp[100001];

 
int goEasy( int i,int k, vector<int> &v ){
    int n = v.size();
    if( i == n-1 )return 0;
    if( dp[i] != -1 )return dp[i];
    int ans = LLONG_MAX;
    for( int j = i+1; j <= n-1 && j <= i+k; j++ ){
        ans = min(ans, goEasy(j,k,v) + abs(v[i] - v[j]));
    }
    return dp[i] = ans;
}

int32_t main(){
    int t,k;
    cin>>t>>k;
    memset(dp,-1,sizeof(dp));
    vector<int> h(t);
    for(int i=0;i<t;i++){
        cin>>h[i];
    }
    cout<<goEasy(0,k,h)<<endl;
}


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

int main() {
	int n, a[100000], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[a[i] - 1] != i + 1) continue;
		sum++;
	}
	cout << sum / 2 << endl;
}

Measured memory_bytes: 640
n=gets.to_i
a=Array.new(n,0)
x=Array.new(n).map{Array.new}
y=Array.new(n).map{Array.new}
n.times do |i|
  a[i]=gets.to_i
  a[i].times do |j|
    x[i][j],y[i][j]=gets.split.map(&:to_i)
  end
end
ans=0
can=true
[0,1].repeated_permutation(n).each do |bit|
  can=true
  n.times do |i|
    if bit[i]==1
      a[i].times do |j|
        if bit[x[i][j]-1]!=y[i][j]
          can=false
          break
        end
      end
    end
  end
  if can
    ans=[ans,bit.sum].max
  end
end
puts ans


Measured memory_bytes: 14680
N = int(input())

D = {}
for i in range(1,N+1):
  I = str(i)
  if (I[-1],I[0]) not in D:
    D[(I[-1],I[0])] = 1
  else:
    D[(I[-1],I[0])] += 1

ans = 0
for j in range(1,N+1):
  J = str(j)
  if (J[0],J[-1]) in D:
    ans += D[(J[0], J[-1])]    
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include <string.h>
#include<string>

using namespace std;

int main()
{
	/*long long h, a, attacks = 0;
	cin >> h >> a;
	while (h > 0)
	{
		attacks++;
		h -= a;
	}
	cout << attacks << endl;*/
	/*long long n;
	string s;
	cin >> n;
	getline(cin, s);
	getline(cin, s);
	char currentchar = s[0];
	int cnt = 1;

	for (int i = 1; i < s.size(); i++)
	{
		if (s[i] != currentchar)
		{
			currentchar = s[i];
			cnt++;
		}
	}

	cout << cnt << endl;*/

	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a!=b) || (b == c && b!=a))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	//system("pause");
	return 0;
}

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

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

  for (int i = 0; i < s.length(); ++i){
      if( (i+1) % 2 == 0){
          if(s[i] == 'R'){
            cout << "No" << endl;
            return 0;
          }
      }
      else{
          if(s[i] == 'L'){
            cout << "No" << endl;
            return 0;
          }
      }
  }
  cout << "Yes" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	static char prime[1000001];
	int i, j;
	int n;
	
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = 1;
	}
	prime[2] = 1;
	
	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = 0;
			}
		}
	}
	
	while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
		j = 0;
		for (i = n + 1; i <= 2 * n; i++){
			if (prime[i] == 1){
				j++;
			}
		}
		
		printf("%d\n", j);
	}
	
	return (0);
}

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

int main(){
    long long n;
    cin >> n;
    string s;
    cin >> s;
    /*R,G,Bそれぞれの数を数える*/
    //vector<int> r(n),g(n),b(n);
    long rcount = 0,gcount = 0,bcount = 0;
    for(int i = 0;i < n;i++){
        switch(s.at(i)){
            case 'R':
            //r.at(rcount) = i;
            rcount++;
            break;
            case 'G':
            //g.at(gcount) = i;
            gcount++;
            break;
            case 'B':
            //b.at(bcount) = i;
            bcount++;
            break;
        }
    }
    /*配列順の差が等しいとき、異なる文字が入ってるか調べる*/
    long rest = 0;
    
    for(int i = 1;i <= (n - 3)/2 + 1;i++){
       // cout << "差分" << i << endl;
        for(int j = 0;j + i*2< n;j++){
            //cout << j << " " << j + i << " " << j + i*2 << endl;
            if((s.at(j) != s.at(j + i))&&(s.at(j) != s.at(j + 2*i))&&(s.at(j + i) != s.at(j + i*2))){
                rest++;
            }
        }
        
    }
    
    //cout << "rest" << rest << endl;

    /**/
    long long ans = bcount*rcount*gcount - rest;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, k;
	cin >> n >> k;
	Vi P(n);
	Vl C(n);
	rep(i, n) {
		int t;
		cin >> t;
		t--;
		P[i] = t;
	}
	rep(i, n)  cin >> C[i];



	ll ansmincase = -1e17;
	for (int i = 0; i < n; i++) {
		int u = i;
		ll sum = 0;
		for (int j = 0; j < min(k, 5000); j++) {
			sum += C[P[u]];
			u = P[u];
			ansmincase = max(ansmincase, sum);
		}
	}
	if (k < 5000) {
		cout << ansmincase << endl;
		return 0;
	}

	ll ans = -1e17;
	for (int i = 0; i < n; i++) {
		int u = i;
		ll cirsum = 0;
		ll pathcnt = 0;
		while (1) {
			cirsum += C[P[u]];
			u = P[u];
			pathcnt++;
			if (u == i) break;
		}
		if (cirsum < 0) continue;
		ll tmp = k / pathcnt;
		tmp--;
		ll sum = cirsum * tmp;
		tmp = k % pathcnt;
		int s = i;
		ll tsum = sum;
		for (int c = 0; c < tmp + pathcnt; c++) {
			tsum += C[P[s]];
			s = P[s];
			sum = max(sum, tsum);
		}
		ans = max(ans, sum);
	}
	cout << max(ans, ansmincase) << endl;
	return 0;
}


Measured memory_bytes: 3672
n = int(input())
job = [list(map(int, input().split())) for _ in range(n)]

#print(job)
job.sort(key=lambda x: x[1])

#print(job)
time = 0

for i in range(n):
  time += job[i][0]
  #print("time  " + str(time) +  "  jobnumber " + str(i+1))
  if time > job[i][1]:
    print("No")
    quit()
print("Yes")
  

Measured memory_bytes: 53600
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll N;
    cin >> N;
    ll sum = 0;
    for(int i = 1; i < N; i++){
        sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __
.' ____ \ [  |      (_)                [  |
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |,
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string w;
  int f[30] = {0};

  cin >> w;
  REP(i, w.size()) {
    f[w[i] - 'a']++;
  }
  REP(i, 30) {
    if (f[i] % 2 != 0) {
      print("No");
      return 0;
    }
  }
  print("Yes");

  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, K;
    cin >> N >> K;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = K; i < N; i++) {
        if (A[i - K] < A[i]) {
            prints()("Yes");
        }
        else {
            prints()("No");
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 4780
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,k;
    cin>>n>>k;
    int cnt=1;
	while(pow(k,cnt)<=n)cnt++;
	cout<<cnt<<endl;
	return 0;
}
int main(){
    waste;
    int t;
//    cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;

        ans += 2*min(abs(x - 0), abs(x - K));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define endl "\n"

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

void solve() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int left = h1 * 60 + m1;
	int right = h2 * 60 + m2;

	int diff = right - left - k;
	if (diff < 0)
		diff = 0;
	cout << diff << endl;
}

signed main() {
	crap;

	solve();

	return 0;
}

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

using namespace std;

const int N = 1e7 + 5;
int _w;

int son[N][3] , nidx , val[N] , n , m , rev[N] , bin[13] , rmp[N];
char str[N];

void pre( int u , int now , int dep ) {
  if( dep == n ) {
    val[u] = now;
    return;
  }
  for( int i = 0 ; i < 3 ; ++i ) {
    son[u][i] = ++nidx;
    pre( son[u][i] , now + i * bin[dep] , dep + 1 );
  }
}

void dfs( int u , int dep ) {
  if( dep == n ) return;
  if( rev[u] ) {
    swap( son[u][1] , son[u][2] );
    rev[son[u][1]] ^= 1;
    rev[son[u][2]] ^= 1;
    rev[son[u][0]] ^= 1;
    rev[u] = 0;
  }
  dfs( son[u][2] , dep + 1 );
  int t = son[u][2];
  son[u][2] = son[u][1]; son[u][1] = son[u][0];
  son[u][0] = t;
}

void ans( int u , int now , int dep ) {
  if( dep == n ) {
    rmp[val[u]] = now;
    return;
  }
  if( rev[u] ) {
    swap( son[u][1] , son[u][2] );
    rev[son[u][2]] ^= 1;
    rev[son[u][1]] ^= 1;
    rev[son[u][0]] ^= 1;
    rev[u] = 0;
  }
  for( int i = 0 ; i < 3 ; ++i )
    ans( son[u][i] , now + i * bin[dep] , dep + 1 );
}

int main( void ) {
  _w = scanf("%d",&n); 
  bin[0] = 1;
  for( int i = 1 ; i <= n ; ++i )
    bin[i] = bin[i - 1] * 3;
  pre( 0 , 0 , 0 );
  _w = scanf("%s",str+1);
  m = strlen( str + 1 );
  for( int i = 1 ; i <= m ; ++i ) 
    if( str[i] == 'S' )
      rev[0] ^= 1;
    else 
      dfs( 0 , 0 );
  ans( 0 , 0 , 0 );
  for( int i = 0 ; i < bin[n] ; ++i )
    printf("%d ",rmp[i]);
  return 0;
}


Measured memory_bytes: 21948
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int s = d.size() / 2;
    printf("%d\n", d[s] - d[s-1]);

    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int extgcd(int a, int b, int& x, int& y){ //ax + by = gcd(a, b)
    int d = a;
    if(b){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int main(){
    int a, b, x, y; cin >> a >> b;
    extgcd(a, b, x, y);
    cout << x << " " << y << endl;
    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>

int main(int argc, char const *argv[]) {
	char str[101];
	int n, m, X, Y;
	int x[100];
	int y[100];

	fgets(str, 100, stdin);
	sscanf(str, "%d %d %d %d\n", &n, &m, &X, &Y);

	int i, j;
	for (i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}

	for (i = 0; i < m; i++) {
		scanf("%d", &y[i]);
	}

	if (Y < X) {
		printf("War\n");
		return 0;
	}

	int max_x, min_y;

	max_x = x[0];
	for (i = 1; i < n; i++) {
		max_x = x[i] > max_x ? x[i] : max_x;
	}

	min_y = y[0];
	for (i = 0; i < m; i++) {
		min_y = y[i] < min_y ? y[i] : min_y;
	}

	if (min_y < max_x) {
		printf("War\n");
		return 0;
	}

	for (i = max_x+1; i <= min_y; i++) {
		if (X < i && i <= Y) {
			printf("No War\n");
			return 0;
		}
	}

	printf("War\n");


	return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v = Vec::with_capacity(n);
    for _ in 0..n {
        let (a, b) = get!(i64, i64);
        let c = a + b;
        v.push((a, b, c));
    }
    v.sort_by(|x, y| y.2.cmp(&x.2));
    let mut ans: i64 = 0;
    for i in 0..n {
        if i % 2 == 0 {
            ans += v[i].0;
        } else {
            ans -= v[i].1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<unsigned long int> a(n+1);
    vector<unsigned long int> b(n);
    for(int i = 0; i < n+1; i++){
        cin>>a[i];
    }
    for(int i = 0; i < n; i++){
        cin>>b[i];
    }
    unsigned long int total = 0;

    for(int i = 0; i < n + 1; i++){
        if(i == 0){
            if(a[i] > b[i]){
                a[i] = a[i] - b[i];
                total += b[i];
                b[i] = 0;
            } else{
                total += a[i];
                b[i] = b[i] - a[i];
                a[i] = 0;
            }
        }
        else if(i == n){
            if(a[i] > b[i-1]){
                total += b[i-1];
                a[i] = a[i] - b[i-1];
                b[i-1] = 0;
            } else{
                total += a[i];
                b[i-1] = b[i-1] - a[i];
                a[i] = 0;
            }
        }
        else {
            if(a[i] > b[i-1]){
                total += b[i-1];
                a[i] = a[i] - b[i-1];
                b[i-1] = 0;
            } else{
                total += a[i];
                b[i-1] = b[i-1] - a[i];
                a[i] = 0;
            }
            if(a[i] > b[i]){
                total += b[i];
                a[i] = a[i] - b[i];
                b[i] = 0;
            } else{
                total += a[i];
                b[i] = b[i] - a[i];
                a[i] = 0;
            }

        }
    }
    cout<<total;
    return 0;
}


Measured memory_bytes: 1792
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            num = 0
            if i != 0 and s[i-1][j] == '#':
                num += 1
            if j != 0 and s[i][j-1] == '#':
                num += 1
            if i != h-1 and s[i+1][j] == '#':
                num += 1
            if j != w-1 and s[i][j+1] == '#':
                num += 1
            if i != 0 and j != 0 and s[i-1][j-1] == '#':
                num += 1
            if i != h-1 and j != w-1 and s[i+1][j+1] == '#':
                num += 1
            if i != h-1 and j != 0 and s[i+1][j-1] == '#':
                num += 1
            if i != 0 and j != w-1 and s[i-1][j+1] == '#':
                num += 1

            s[i][j] = str(num)

for i in range(h):
    print("".join(s[i]))


Measured memory_bytes: 3188
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int x;
  cin>>x;
  int a=x%11,b=x/11;
  if(a==0)cout<<2*b<<endl;
  else if(a<7)cout<<2*b+1<<endl;
  else cout<<2*b+2<<endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;


int main() {
   
   string S, S2;
   cin >> S;

   if (S.size() == 2) cout << S << endl;
   else {
      for (int i = 0; i < S.size(); i++) {
         S2 = S[i] + S2;
      }
      cout << S2 << endl;
   }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    char m = 'z';
    for (int i = 0; i < n; ++i) {
        m = min(m, s[i]);
    }
    vector<int> cnt(n, 0);
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        if (i)
            cnt[i] += cnt[i - 1];
        if (s[i] == m)
            cnt[i]++;
        else
            cnt[i] = 0;
        mx = max(cnt[i], mx);
    }
    mx      = max(mx, cnt[n - 1] * 2);
    lint mm = mx;
    for (int i = 1; i < k - 1; ++i) {
        if (mm >= n) {
            cout << string(n, m) << "\n";
            return 0;
        }
        mm *= 2;
    }
    string ret(n, 'z');
    if (k == 1) {
        string tt = s;
        reverse(tt.begin(), tt.end());
        string temp = s + tt;
        for (int j = 0; j < n; ++j) {
            if (cnt[j] == mx) {
                ret = min(ret, temp.substr(j - mx + 1, n));
            }
        }
        ret = min(ret, temp.substr(n - 1 - mx / 2 + 1, n));
        cout << ret << "\n";
        return 0;
    }
    for (int i = 0; i < n - 1; ++i) {
        if (mx == cnt[i]) {
            string tt = s;
            reverse(tt.begin(), tt.end());
            string temp = s + tt;
            string ss   = temp.substr(2 * n - (i - mx + 1) - n, n);
            int len     = mx;
            for (int j = 1; j < k - 1; ++j) {
                tt = ss;
                reverse(tt.begin(), tt.end());
                temp = ss + tt;
                ss   = temp.substr(len, n);
                len *= 2;
            }
            tt = ss;
            reverse(tt.begin(), tt.end());
            temp = ss + tt;
            ss   = temp.substr(max(0LL, n - len), n);
            ret  = min(ret, ss);
        }
    }
    if (mx == cnt[n - 1] * 2) {
        string ss = s;
        string tt;
        string temp;
        int len = mx / 2;
        for (int j = 0; j < k - 1; ++j) {
            tt = ss;
            reverse(tt.begin(), tt.end());
            temp = ss + tt;
            ss   = temp.substr(len, n);
            len *= 2;
        }
        tt = ss;
        reverse(tt.begin(), tt.end());
        temp = ss + tt;
        ss   = temp.substr(max(0LL, n - len), n);
        ret  = min(ret, ss);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())
if k > (n -1) * (n - 2) // 2:
    print(-1)
else:
    m = (n - 1) + ((n - 1) * (n - 2) // 2 - k)
    print(m)
    for i in range(n - 1):
        print(i + 1, n)
    e = m - n + 1
    j = 1
    while e > 0:
        if e <= n - j - 1:
            for i in range(e):
                print(j, j + i + 1)
            e = 0
        else:
            for i in range(n - j - 1):
                print(j, j + i + 1)
            e -= (n - j - 1)
            j += 1

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}



int main(void){
    ll a,b,n;
    cin>>a>>b>>n;

    cout<<floorl(a*min(b-1,n)/b)-a*floorl(min(b-1,n)/b)<<endl;
    return 0;

}

Measured memory_bytes: 3752
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;
const int N=500005;
char s[N];
int l[N];
int main(){
	scanf("%s",s);
	int n=strlen(s)+1;
	l[n]=0;
	for (int i=n-1;i;i--)
		if (s[i-1]=='<')l[i]=0;
		else l[i]=l[i+1]+1;
	int now=l[1];long long ans=now;
	for (int i=2;i<=n;i++)
		if (s[i-2]=='<')now=max(now+1,l[i]),ans+=now;
		else now=l[i],ans+=now;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2816
program main
implicit none
	integer(8)::n,i,ac,wa,tle,re
    character::ch
    ac=0
    wa=0
    tle=0
    re=0
    read(*,*) n
    do i=0,n-1
    	read(*,*) ch
        if (ch=='A')then
        	ac=ac+1
        else if (ch=='W')then
        	wa=wa+1
        else if (ch=='T')then
        	tle=tle+1
        else if (ch=='R')then
        	re=re+1
        end if
    end do
    write(*,*) 'AC x ',ac
    write(*,*) 'WA x ',wa
    write(*,*) 'TLE x ',tle
    write(*,*) 'RE x ',re
end program main
    

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

int main(){
    string w;
    cin >> w;
    int cnt = 0;
    while (true){
        string s;
        cin >> s; 
        if (s == "END_OF_TEXT") break;
        for (int i = 0; i < s.size(); i++){
            if (isalpha(s[i]) && isupper(s[i])) s[i] = tolower(s[i]);
        }
        if (s == w) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3128
#include<cstdio>


using ll=long long;


int ask(ll n)
{
	char r[1+2];

	printf("? %lld\n", n);
	fflush(stdout);
	scanf("%1s", r);

	return r[0]=='Y';
}


int search_one(ll offset, int s_initial)
{
	int s, e, c, r, ans=0;

	s=s_initial;
	e=9;
	for(;s<=e;)
	{
		c=(s+e)/2;
		r=ask(c+offset);

		if(r)
		{
			s=c+1;
			ans=c;
		}
		else
		{
			e=c-1;
		}
	}
	return ans;
}


int search_last(ll offset)
{
	int s, e, c, r, ans=0;
	ll v;

	s=0;
	e=9;
	for(;s<=e;)
	{
		c=(s+e)/2;
		v=c+offset;
		r=ask(v*10);

		if(!r)
		{
			s=c+1;
		}
		else
		{
			e=c-1;
			ans=c;
		}
	}
	return ans;
}



int main(void)
{
	ll n, offset;
	int d;

	if(!ask(1000000000))
	{
		for(d=1,n=10;d<10;d++,n*=10)
		{
			if(!ask(n)) break;
		}
	}
	else
	{
		n=999999999;
		for(;n;n/=10)
		{
			if(!ask(n))
			{
				printf("! %lld\n", n+1);
				return 0;
			}
		}
		printf("! 1\n");
		return 0;
	}

	offset=0;
	for(int i=0;i+1<d;i++)
	{
		offset+=search_one(offset, i==0);
		offset*=10;
	}

	ll ans=offset+search_last(offset);

	printf("! %lld\n", ans);
	fflush(stdout);

	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    char a;
    cin >> a;
    if ('a' <= a && a <= 'z') {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){


    int K;
    cin >>K;
    int N;
    cin >>N;

    int A[N];
    int L[N];
    int maxL=0;
    int maxni;
    rep(ni,N){
        cin >> A[ni];
    }
    for( int ni = 1 ; ni <N ; ni++ ){
        L[ni] = A[ni] - A[ni-1];
        if(L[ni]>maxL){
            maxni=ni;
            maxL=L[ni];
        }
    }
    L[0] = A[0] + (K - A[N-1]);
    if(L[0]>maxL){
        maxni=0;
        maxL=L[0];
    }
    cout << K - maxL << endl;

    

}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int A, B;
  std::cin >> A >> B;
  int max = A + B;
  chmax(max, A - B);
  chmax(max, A * B);
  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 256