akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=3e5+50;
const int l=10000;
const ll mod=1e9+7;
using namespace std;
int n,m,i,j,t,a[85][85],b[85][85],rs;
bitset<17000>f[81][81];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)cin>>a[i][j];
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)cin>>b[i][j];
	f[1][1][a[1][1]-b[1][1]+l]=f[1][1][b[1][1]-a[1][1]+l]=1;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(i==1 && j==1)continue;
			for(t=-6400;t<=6400;t++)
			{
				if(i>1)
				{
					if(f[i-1][j][t-(a[i][j]-b[i][j])+l])f[i][j][t+l]=1;
					if(f[i-1][j][t-(b[i][j]-a[i][j])+l])f[i][j][t+l]=1;
				}
				if(j>1)
				{
					if(f[i][j-1][t-(a[i][j]-b[i][j])+l])f[i][j][t+l]=1;
					if(f[i][j-1][t-(b[i][j]-a[i][j])+l])f[i][j][t+l]=1;
				}
			}
		}
	}
	rs=inf;
	for(t=-6400;t<=6400;t++)if(f[n][m][t+l])rs=min(rs,abs(t));
	cout<<rs<<endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n, 0);
  for (int i = 0; i < n; i++) cin >> p[i];
  int ans = 0;
  for (int j = 1; j < n-1; j++) {
    if (p[j-1] < p[j] && p[j] < p[j+1]) ans++;
    else if (p[j-1] > p[j] && p[j] > p[j+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
loop do
  n, x = gets.split.map(&:to_i)
  exit if n == 0 && x == 0
  cnt = 0
  (1..n-2).each do | i |
    (i+1..n-1).each do | j |
      (j+1..n).each do | k |
        cnt += 1 if i + j + k == x
      end
    end
  end
  puts cnt
end

Measured memory_bytes: 6108
#include<bits/stdc++.h>
using namespace std;
#define DIV (60*60*12)

int N;
int cTos[60][60][60];
vector<vector<int> > secs;
int times[100];
pair<int,int> dfs(int idx, int times[100]){
	if(idx == N){
		int mins= 60 * 60 * 12;
		int maxs = 0;
		for(int i = 0; i < N; i++){
			mins = min(mins,times[i]);
			maxs = max(maxs, times[i]);
		}
		return pair<int,int>(mins, maxs);

	}else{
		pair<int, int> ans(0, 60*60*12);
		for(auto s : secs[idx]){
			times[idx] = s;
			pair<int, int> ret = dfs(idx + 1, times);
			if(ret.second - ret.first < ans.second - ans.first ||
				(ret.second - ret.first == ans.second - ans.first && ret.first < ans.first)){
				ans = ret;
			}
		}
		return ans;
	}
}

void printtime(int s){
	printf("%02d:%02d:%02d", s/(60*60), s/60%60, s%60);
}

int main(){
	for(int i = 0; i < 60; i++){
		for(int j = 0; j < 60; j++){
			for(int k = 0; k < 60; k++){
				cTos[i][j][k] = -1;
			}
		}
	}
	int h = 0;
	int m = 0;
	int s = 0;
	for(int i = 0; i < 60*60*12; i++){
		cTos[h][m][s] = i;
		s++;
		if(s % 60 == 0){
			s = 0;
			m++;
			if(m % 12 == 0){
				h++;
				if(h % 60 == 0) h = 0;
				if(m % 60 == 0) m = 0;
			}
		}
	}
	while(cin >> N, N){
		secs.assign(N, vector<int>());
		for(int i = 0; i < N; i++){
			int v[3];
			cin >> v[0] >> v[1] >> v[2];
			int idx[3] = {0, 1, 2};
			do{
				for(int j = 0; j < 60; j++){
					int t = cTos[(v[idx[0]] + j) % 60][(v[idx[1]] + j) % 60][(v[idx[2]] + j) % 60];
					if(t != -1){
						secs[i].push_back(t);
					}
				}
			}while(next_permutation(idx, idx + 3));
			sort(secs[i].begin(), secs[i].end());
			secs[i].erase(unique(secs[i].begin(), secs[i].end()), secs[i].end());
		}
		int start=0, end=100000000;
		for(int i = 0; i < N; i++){
			for(int s : secs[i]){
				int mt = 0;
				for(int j = 0; j < N; j++){
					if(i == j) continue;
					int nt = 10000000;
					for(int t : secs[j]){
						nt = min(nt, (t - s + DIV) % DIV);
					}
					mt = max(mt, nt);
				}
				if(end - start > mt || (end - start == mt && start > s)){
					start = s;
					end = s + mt;
				}
			}
		}
		printtime(start);
		cout << " ";
		printtime(end % DIV);
		cout << endl;

	}
}

Measured memory_bytes: 4016
#include<iostream>
using namespace std;
const int MAX_INT=1000000010;
int A[500100];
long long cnt=0;

void merge(int A[],int l,int m,int r)
{
    int n1=m-l;
    int n2=r-m;
    int L[n1+1];
    int R[n2+1];

    for(int i=0;i<n1;++i)
    {
        L[i]=A[l+i];
    }
    for(int j=0;j<n2;++j)
    {
        R[j] =A[m +j];
    }

    L[n1]=MAX_INT;
    R[n2]=MAX_INT;
    int i=0;
    int j=0;

    for(int k=l;k<r;++k)
    {
        if(L[i]<=R[j])
        {
            A[k] = L[i];
            ++i;
        }
        else
        {
            A[k]=R[j];
            j++;
            cnt+= m + j - k -1;
        }
    }
}
void mergeSort(int A[],int l,int r)
{
    if(l+1<r)
    {
        int mid = (l+r)/2;
        mergeSort(A,l,mid);
        mergeSort(A,mid,r);
        merge(A,l,mid,r);
    }
}
int main()
{
    int n;cin >>n;
    for(int i=0;i<n;++i)
    {
        cin >> A[i];
    }
    mergeSort(A,0,n);
    cout << cnt << endl;

}


Measured memory_bytes: 4660
def main():
  N = int(input())
  a = [0] * N
  visited = [False] * N
  l = 0
  ans = 0


  for i in range(N):
    a[i] = int(input())

  visited[0] = True

  while(l != 1):
    l = a[l] - 1

    if(visited[l]):
      ans = -1
      break
    
    visited[l] = True
    ans += 1

  print(ans)

if __name__ == "__main__":
  main();

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0;
  string s;
  cin >> s;
  //vector<int> v(n), c(n);
  //if(1) {}
  //
  //for(int i = 0; i < n; i++){}
  cout << ((s == "AAA" || s == "BBB")? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    cin >> a >> b >> c;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int div = N / 111;
		for(int i = 0; i < 3; i++) {
			if(N % 111 == 0) {
				System.out.print(div);
			}else {
				System.out.print(div + 1);
			}
		}

	}
}

Measured memory_bytes: 21716
import sys
from collections import defaultdict

input = sys.stdin.readline

H, W, m = map(int, input().split())

hor = [0] * H
ver = [0] * W
f = defaultdict(int)
for _ in range(m):
    h, w = map(int, input().split())
    hor[h - 1] += 1
    ver[w - 1] += 1
    f[str(h - 1) + '|' + str(w - 1)] = 1

hmax = max(hor)
hs = [i for i, v in enumerate(hor) if v == hmax]
vmax = max(ver)
vs = [i for i, v in enumerate(ver) if v == vmax]


ans = hmax + vmax

if len(hs) * len(vs) > m:
    print(ans)
    exit()

for k1 in hs:
    for k2 in vs:
        if f[str(k1) + '|' + str(k2)] == 0:
            print(ans)
            exit()
print(ans - 1)


Measured memory_bytes: 198292
def fib(n, fib_memo=None):                                                                                                                                                    
    if fib_memo == None:                                                                                                                                                      
        fib_memo = [None]*n                                                                                                                                                   
    if n <= 1:                                                                                                                                                                
        return 1                                                                                                                                                              
    else:                                                                                                                                                                     
        if fib_memo[n-1] == None:                                                                                                                                             
            fib_memo[n-1] = fib(n-1, fib_memo)                                                                                                                                
        if fib_memo[n-2] == None:                                                                                                                                             
            fib_memo[n-2] = fib(n-2, fib_memo)                                                                                                                                
        return fib_memo[n-1] + fib_memo[n-2]                                                                                                                                  
                                                                                                                                                                              
                                                                                                                                                                              
if __name__ == '__main__':                                                                                                                                                    
    n = input()                                                                                                                                                               
    print(fib(int(n)))                                                                                                                                                        

Measured memory_bytes: 7732
import sys
input = sys.stdin.readline

def main():
    n, k = [int(i) for i in input().split()]
    s = input() + "3"
    s0 = []
    s1 = []
    cnt = 0
    start = 1
    for i in range(n+1):
        if start == 1 and s[i] != "1":
            s1.append(cnt)
            cnt = 1
            start = 0
        elif start == 0 and s[i] != "0":
            s0.append(cnt)
            cnt = 1
            start = 1
        else:
            cnt += 1

    #ans = max(s1)
    #for i in range(n // 2 +1):
    #    ans = max(ans, sum(s1[i:i+k+1]) + sum(s0[i:i+k]))

    ans = sum(s1[0:0+k+1]) + sum(s0[0:0+k])
    n_ans = ans

    for i in range(n):
        try:
            n_ans = n_ans + s1[k+1+i] + s0[k+i] - s1[i] - s0[i]
            ans = max(ans, n_ans)
        except:
            try:
                n_ans = n_ans + s0[k+i] - s1[i] - s0[i]
                ans = max(ans, n_ans)
            except:
                pass

    print(ans)
    #print(s1, s0)

main()

Measured memory_bytes: 45676
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using str = string;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    long int n, k;
    cin >> n >> k;
    long int ans = 0;
    ans = min(n%k, k - n%k);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int A, B, i = 0;
  cin >> A >> B;
  while (A <= B)
  {
    if(A % 10 == A / 10000 )
      if((A / 10) % 10 == (A /1000) % 10)
        i++;
      else{}
    else{}
    A++;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
mod = 10**9+7 

def main():
  n = int(input())
  a = list(map(int, input().split()))
  wa = sum(a)%mod
  ans = 0
  for i in range(n):
    wa -= a[i]%mod
    ans += (a[i]*wa)
    ans %= mod
  print(ans)
  
if __name__ == "__main__":
  main()

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

int main() {
	int A, B, Q;
	static long long S[100000] = {}, T[100000] = {};
	cin >> A >> B >> Q;
	for (int i = 0; i < A; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < Q; i++) {
		long long X, ans = 1000000000000;
		cin >> X;
		long long Sl = -1000000000000, Sr = 1000000000000, Tl = -1000000000000, Tr = 1000000000000;
		long long L = -1, R = A;
		while (R - L > 1) {
			long long mid = L + (R - L) / 2;
			if (S[mid] >= X) R = mid;
			else L = mid;
		}
		if (L != -1) Sl = S[L];
		if (R != A) Sr = S[R];
		L = -1, R = B;
		while (R - L > 1) {
			long long mid = L + (R - L) / 2;
			if (T[mid] >= X) R = mid;
			else L = mid;
		}
		if (L != -1) Tl = T[L];
		if (R != B) Tr = T[R];
		ans = min(ans, X - min(Sl, Tl));
		ans = min(ans, max(Sr, Tr) - X);
		ans = min(ans, max(X - Sl, Tr - X) + min(X - Sl, Tr - X) * 2);
		ans = min(ans, max(Sr - X, X - Tl) + min(Sr - X, X - Tl) * 2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  cout << (N+1)/2 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[])throws IOException  {

		Scanner in = new Scanner(System.in);
	int s=in.nextInt();
	if(s==25)
	{
		System.out.println("Christmas");
	}
	if(s==24)
	{
		System.out.println("Christmas Eve");
	}
	if(s==23)
	{
		System.out.println("Christmas Eve Eve");
	}
	if(s==22)
	{
		System.out.println("Christmas Eve Eve Eve");
	}
//		int n=in.nextInt();
//		int m=in.nextInt();
//		int[] a=new int[n+1];
//		long ans=0;
		
//		for(int i=1;i<=n;i++)
//		{
//			a[i]=in.nextInt();
//		}
		
		
//		while(in.hasNext())
//		{
//			
//			
//		}
//
//			
//		}
//		
	}	
	
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int x = 1;
  for (int i = 0; i < N; i++) {
    if (a.at(i) == x) x++;
  }
  
  if (x == 1) {
    cout << -1 << endl;
  } else {
    cout << N - x + 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
# your code goes here
import numpy as np
def main():
	x  = 1000000007
	buf = input().split()
	h = int(buf[0])
	w = int(buf[1])
	k = int(buf[2])
	
	dpp = np.zeros((w+1, 3), dtype="int")
	dpp[0][0] = 1
	dpp[0][2] = 1
	dpp[1][0] = 1
	dpp[1][2] = 1
	for i in range(2, w+1):
		dpp[i][0] = dpp[i-1][0]+dpp[i-1][1]
		dpp[i][1] = dpp[i-1][0]
		dpp[i][2] = dpp[i][0] + dpp[i][1]
	#print(dpp)
	
	dp = np.zeros((h+1, w+2), dtype="int")
	dp[0][1] = 1
	for row in range(1, h+1):
		for col in range(1, w+1):
			dp[row][col] = ((dp[row-1][col-1]*dpp[col-2][2]*dpp[w-col][2])%x + (dp[row-1][col]*dpp[col-1][2]*dpp[w-col][2])%x + (dp[row-1][col+1]*dpp[col-1][2]*dpp[w-col-1][2])%x)%x
	#print(dp)
	print(dp[h][k]%x)
	
	
	
	
	
main()

Measured memory_bytes: 12504
N,M = map(int,input().split())
if N == 1 or M == 1:
        if N*M == 1:
                print(1)
        elif N*M == 2:
                print(0)
        else:
                print(N*M-2)
else:
        if N == 2 or M == 2:
                print(0)
        else:
                print((N-2)*(M-2))

Measured memory_bytes: 3060
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1e9+7;
string st[1001];
ll dp[1001][1001],n,m;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	for(ll i=0;i<n;i++)
	{
		cin>>st[i];
	}
	//dp[0][0]=1;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
			if(i == 1 && j == 1)
			{
				dp[i][j]=1;
				continue;
			}
			if(st[i-1][j-1] == '#')
				dp[i][j]=0;
			else
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1]+mod)%mod;
			}
		}
	}
	cout<<dp[n][m]<<endl;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

string S;
int main(){
   cin >> S;
   if (S.size() < 26){
      REP(i, 26){
         if(S.find('a' + i) == -1){
            S.push_back('a' + i);
            cout << S << endl;
            return 0;
         }
      }
   }
   else if (S == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
   else{
      for(ll i = 25; i > 0; i--){
         if(S[i] - 'a' > S[i - 1] - 'a'){
            for(ll j = 25; j >= i; j--){
               if(S[i - 1] - 'a' < S[j] - 'a'){
                  S.insert(S.begin() + i - 1, S[j]);
                  S.erase(S.begin() + i, S.end());
                  cout << S << endl;
                  return 0;
               }
            }

         }
      }
   }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int L0 = 2;
        int L1 = 1;
        long Lucas = L1 + L0;
        long Lucas1 = L1;
        if(N == 1){
            System.out.println(L1);
            return;
        }
        for(int i = 2; i < N; i++){
            long temp = Lucas;
            Lucas = Lucas + Lucas1;
            Lucas1 = temp;
        }
        System.out.println(Lucas);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[2]={1,0};
int ny[2]={0,1};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main (){
    string s;
    string t;
    bool flag=true; 
    cin >> s;
    t=s;
    int n=s.length();
    int l=(n-1)/2;
    int r=(n+3)/2;
    for(int i=0;i<l;i++){
        if(s[i]!=s[l-1-i]) flag=false;
    }
    for(int i=r-1;i<n;i++){
        if(s[i]!=s[n-2-i+r]) flag=false;
    }
    reverse(t.begin(),t.end());
    if(s!=t) flag=false;
    if(flag) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}

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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll x;
    cin >> x;

    ll s = x / 11;
    ll m = x % 11;

    ll p = 0;
    if(m > 6)   p = 2;
    else if(m == 0) p = 0;
    else p = 1;



    ll ans = s * 2 + p;

    cout << ans << endl;

    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def comb_mod(a, b)
  return 0 if a < b
  return comb_mod(a, a - b) if b > a - b
  mul = div = 1
  b.times do |i|
    mul *= a - i
    div *= i + 1
    mul %= MOD
    div %= MOD
  end
  mul * pow_mod(div, MOD - 2) % MOD
end

def pow_mod(a, pow)
  if pow == 0
    1
  elsif pow.odd?
    a * pow_mod(a, pow - 1) % MOD
  else
    half = pow_mod(a, pow / 2)
    half * half % MOD
  end
end

x, y = gets.split.map(&:to_i)
if (x + y) % 3 != 0
  puts 0
  exit
end

# X = n + 2m
# Y = 2n + m
# 2x - y = 3m
# m = 2/3x - 1/3 x
m = (2 * x - y) / 3
n = x - 2 * m

if m < 0 || n < 0
  puts 0
  exit
end
m %= 10**9 + 7
n %= 10**9 + 7

puts comb_mod(n+m, n)


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

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - (i + 1);
        }
        Arrays.sort(a);
        int b = a[a.length / 2];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += Math.abs(a[i] - b);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 85852
#include <stdio.h>

int main()
{
  int i,v,j,num,N,k;

  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++)
    {
      scanf("%d",&num);
      A[i]=num;
    }
  for(i=1;i<N;i++)
    {
      for(k=0;k<N-1;k++)
	{
	  printf("%d ",A[k]);
	}
      printf("%d\n",A[N-1]);
      v=A[i];
      j=i-1;
      while(j>=0 && A[j]>v)
	{
	  A[j+1]=A[j];
	  j--;
	}
      A[j+1]=v;      
    }
 for(k=0;k<N-1;k++)
	{
	  printf("%d ",A[k]);
	}
      printf("%d\n",A[N-1]);
  return 0;
}



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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

constexpr auto inf = 1e9;

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

using ll = long long;

int main()
{
	int n;
	cin >> n;
	//0based
	vector<int> c(n-1), s(n-1), f(n-1);
	for (int i = 0; i < n-1; i++)
	{
		cin >> c[i] >> s[i] >> f[i];
	}
	
	auto time = [&](int i)
	{
		int index = i;

		for (int t = 0;; t++)
		{
			if (index == n-1)
			{
				return t;
			}

			if (s[index] <= t && t % f[index] == 0)
			{
				t += c[index];
				index++;
				t--;
			}
			else
			{
				
			}
		}
	};

	for (int i = 0; i < n; i++)
	{
		cout << time(i) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    vector<int> b;
    vector<int> c;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp - 1);
    }
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        b.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        int before = i > 0 ? a[i - 1] : -99999;
        int now = a[i];

        res += b[now];
        if (now == before + 1) {
            res += c[before];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input().rstrip()

wc = 0
arr = ["x"] * N
arr2 = ["x"] * N
cur = 0

while cur < N:
    if S[cur] == "x":
        cur += 1
        continue
    wc += 1
    arr[cur] = wc
    cur += C + 1

cur = N - 1
wc = K + 1
while cur >= 0:
    if S[cur] == "x":
        cur -= 1
        continue
    wc -= 1
    arr2[cur] = wc
    cur -= C + 1

for i, (a, b) in enumerate(zip(arr, arr2)):
    if a == b and a != "x":
        print(i + 1)


Measured memory_bytes: 20620
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
int main() {
  int a,b,c;
  cin >> a;
  vector<int> v(a);
  vector<int> v2(a,0);
  for (int i=0; i<a; i++){
    cin >> v.at(i);
    if (v.at(i) == 0) continue;
    b = v.at(i)-1;
    v2.at(b) += 1;
  }
  for (int i=0; i<a; i++){
    cout << v2.at(i) <<endl;
  }
}

Measured memory_bytes: 4832
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


s=input()
ans=0
cnt=0
for i in range(len(s)):
    if s[i]=="B":
        cnt+=1
    else:
        ans+=cnt
print(ans)

Measured memory_bytes: 71904
#include<stdio.h>

int main(){

  int n, data[11][11], i, j;


  
  while(1){

    scanf("%d",&n);
    
    if(n == 0) break;
    
    for(i = 0; i <= n; i++){
      data[n][i] = 0;
      data[i][n] = 0;
    }
    
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
	scanf("%d",&data[i][j]);
	data[i][n] += data[i][j];
	data[n][n] += data[i][j];
      }
    }
    
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
	data[n][i] += data[j][i];
      }
    }
    for(i = 0; i <= n; i++){
      for(j = 0; j <= n; j++){
	printf("%5d",data[i][j]);
      }
      printf("\n");

    }
    
  }

  return 0;
}

Measured memory_bytes: 0
x,n=map(int,input().split())
a = list(map(int,input().split()))

flag=True
k = 0

while(True):
    b = x - k
    c = x + k
    if(not(b in a)):
        print(b)
        flag = False
        break
    elif(not(c in a) and flag):
        print(c)
        break
    k = k + 1

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
     int n,r,flag=0;
     cin>>n;
     while(n!=0)
     {
          r=n%10;
          if(r==7)
               flag=1;
          n/=10;
     }
     if(flag)
          cout<<"Yes"<<e;
     else
          cout<<"No"<<e;
}





Measured memory_bytes: 3636
n,k=map(int,input().split())

#a=b*x+kk  (k<kk<b)

if k==0:
    print(n**2)
    exit()

cnt=0
for b in range(k+1,n+1):
    ux=n//b
    if n%b==0:
        umod=0
    else:
        umod=max(0,n%b-k+1)
    dmod=max(0,b-k)
    #print(b,"##############")
    #print(umod,dmod)

    cnt+=umod+dmod*(ux)

print(cnt)
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int main(){
    int h,w,i,j,k,l,count;
    cin >> h >> w;
    int S[h+2][w+2];
    char ans[h][w];
    string s;
    for(i=0;i<h+2;i++){
        if(i==0 || i==h+1){
            for(j=0;j<w+2;j++) S[i][j] = 0;
        }
        else{
            S[i][0]=0;
            S[i][w+1]=0; 
            cin >> s;
            for(j=0;j<w;j++){
                if(s.at(j)=='#') S[i][j+1]=1;
                else S[i][j+1] = 0;
            }
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(S[i+1][j+1]==1) ans[i][j]='#';
            else{
                count = 0;
                for(k=-1;k<=1;k++){
                    for(l=-1;l<=1;l++){
                        count += S[i+1+k][j+1+l];
                    }
                }
                ans[i][j]='0'+count;
            }
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	int N,v[100];
	double ans;
	cin>>N;
	for(int i=0; i<N; i++)cin>>v[i];
	for(int i=N-1; i>0; i--){
		for(int j=0; j<i; j++){
			if(v[j]>v[j+1]){int t=v[j];v[j]=v[j+1];v[j+1]=t;}
		}
	}
	ans = v[0]+v[1];
	ans /= 2;
	for(int i=2; i<N; i++){
		ans += v[i];
		ans /= 2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Monad

main = do
    n  <- read <$> getLine
    xy <- forM [1 .. n] $ \i -> do
        a <- read <$> getLine
        forM [1 .. a] $ \j -> do
            [x, y] <- map read <$> words <$> getLine
            return (x, y)
    putStrLn $ show $ solve n xy

solve :: Int -> [[(Int, Int)]] -> Int
solve n xy = maximum $ map sum $ filter (ok 0) $ masks n
  where
    masks 0 = [[]]
    masks n = do
        m <- masks $ n - 1
        [0 : m, 1 : m]
    ok i mask | i == n    = True
              | otherwise = (mask !! i == 0 || all ok2 (xy !! i)) && ok (succ i) mask
      where
        ok2 (x, y) = mask !! (x - 1) == y


Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10;
int arr[maxN];
int nxt[2][maxN],pre[2][maxN];
vector<int> g[maxN];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	cin >> n;
	memset(nxt,-1,sizeof(nxt));
	memset(pre,-1,sizeof(pre));
	vector<int> s;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		while (not s.empty() and arr[s.back()] < arr[i]) {
			s.pop_back();
		}
		if (not s.empty()) {
            pre[0][i]=s.back();
			g[s.back()].push_back(i);
		}
		s.push_back(i);
	}
	s.clear();
	for (int i = 1; i <= n; ++i) {
		for (int v : g[i]) {
			while (not s.empty() and arr[s.back()] < arr[v]) {
				s.pop_back();
			}
			if (not s.empty()) {
				pre[1][v] = s.back();
			}
			s.push_back(v);
		}
		while (not s.empty() and arr[s.back()] < arr[i]) {
			s.pop_back();
		}
		s.push_back(i);
	}
	reverse(arr+1,arr+1+n);
	s.clear();
	for(int i=1;i<=n;i++)
        g[i].clear();
	for (int i = 1; i <= n; ++i) {
	//	cin >> arr[i];
		while (not s.empty() and arr[s.back()] < arr[i]) {
			s.pop_back();
		}
		if (not s.empty()) {
            nxt[0][n-i+1]=n-s.back()+1;
			g[s.back()].push_back(i);
		}
		s.push_back(i);
	}
	s.clear();
	for (int i = 1; i <= n; ++i) {
		for (int v : g[i]) {
			while (not s.empty() and arr[s.back()] < arr[v]) {
				s.pop_back();
			}
			if (not s.empty()) {
				nxt[1][n-v+1] = n-s.back()+1;
			}
			s.push_back(v);
		}
		while (not s.empty() and arr[s.back()] < arr[i]) {
			s.pop_back();
		}
		s.push_back(i);
	}
	reverse(arr+1,arr+1+n);
    long long a=0;
    int l,r,ll,rr;
    for(int i=1;i<=n;i++){
        r=nxt[0][i];
        l=pre[0][i];
        ll=pre[1][i];
        rr=nxt[1][i];
      //  printf("%d %d %d %d\n",l,r,ll,rr);
        if(r==-1 && l==-1)continue;
        if(r!=-1){
        a += (1LL) * arr[i] * ((rr==-1 ? n+1:rr)-(r)) * (l==-1 ? i : i-l);
        }
        if(l!=-1){
        a += (1LL) * arr[i] *(ll==-1 ? l: l-ll) * (r==-1 ? n-i+1: r-i);
        }
    }
    cout<<a<<'\n';

	return 0;
}


Measured memory_bytes: 7928
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

B = [0] * (N + 1)
for i in range(N):
    B[i + 1] = (B[i] + A[i]) % MOD

ans = 0
tmp = B[-1]
for i in range(N):
    ans += (A[i] * (tmp - B[i + 1])) % MOD
    ans %= MOD

print (ans)

Measured memory_bytes: 31552
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4],B=0;
    rep(i,2){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << max(A[0]-A[1],B) << endl;
}


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

int main() {
  int M,D,count=0;
  cin >> M >> D;
  
  while(M>=1) {
    while(D>=22) {
      int d1 = D %10;
      int d10 = D /10 %10;
      if(M >= d1 * d10 && d1 >=2 && d10 >=2) count++;
      D -=1;
    }
    M -=1;
  }
  cout << count << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  cout << n * n * n << endl;
  compute();
  return 0;
}


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

int func(int c, int k, vector<vector<int>>&dp, vector<int>&arr, int n, int minele){
    if(k<minele)return 0;
    if(dp[k][c]!=-1){
        return dp[k][c];
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        if(k-arr[i]>=0)
            ans = ans || !func(!c, k-arr[i], dp, arr, n, minele);
    }
    dp[k][c]=ans;
    return ans;
}

int main(){
    int n, k;
    cin>>n>>k;
    vector<int>arr(n);
    int minele = INT_MAX;
    for(int i = 0 ; i < n ; i++){
        cin>>arr[i];
        minele = min(minele, arr[i]);
    }
    vector<vector<int>>dp(k+1, vector<int>(2, -1));
    func(0, k, dp, arr, n, minele);
    if(dp[k][0]){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
}

Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	ll N; cin >> N;
	ll digit = 1;
	while (1) {
		ll m = pow(26, digit);
		if (N <= m) {
			N--;
			vector<ll> ans(digit);
			for (int i = digit - 1; i >= 0; i--) {
				ans[i] = N % 26;
				N /= 26;
			}
			for (int i = 0; i < digit; i++) {
				char c = 'a' + ans[i];
				cout << c;
			}
			cout << endl;
			return 0;
		}
		N -= m;
		digit++;
	}
	return 0;
}

Measured memory_bytes: 3508
import java.util.Scanner;

public class Main {

    static int a;
    static int b;
    static int c;
    static int d;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();

        solve();
    }

    static void solve() {
        if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
s=input()
n = len(s)
op_list = ['-'] *(n-1)
for bit in range(1 << (n-1)):
  op_list = ['-'] *(n-1)
  for i in range(n-1):
    if bit & (1 << i):
      op_list[i] = '+'
  op=s[0]+op_list[0]+s[1]+op_list[1]+s[2]+op_list[2]+s[3]
  if eval(op)==7:
    break
text = op+"=7"
print(text)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
char s1[15], s2[15], s3[15];
int main()
{
    scanf("%s%s%s", s1, s2, s3);
    printf("%c%c%c\n", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

#初期値が0の辞書
from collections import defaultdict
tree = defaultdict(lambda: []) 

for _ in range(m):
    a,b=map(int,input().split())

    tree[a].append(b)
    tree[b].append(a)

for item in tree[1]:
    if n in tree[item]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

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

typedef long long ll;
typedef pair<ll,ll> pll;

ll N, C;
vector<pll> A;
vector<ll> CW[2], CCW[2];

void printAll(){
  cout << "A[0]: ";
  for(int i=0; i<N; i++){
    cout << A[i].first << " ";
  }
  cout << endl;
  cout << "A[1]: ";
  for(int i=0; i<N; i++){
    cout << A[i].second << " ";
  }
  cout << endl;
  cout << "CW[0]: ";
  for(int i=0; i<=N; i++){
    cout << CW[0][i] << " ";
  }
  cout << endl;
}

int main(){
  cin >> N >> C;
  //cout << N << ", " << C << endl;
  A.resize(N);
  for(int i=0; i<2; i++){
    CW[i].resize(N+1);
    CCW[i].resize(N+1);
  }
  for(int i=0; i<N; i++){
    cin >> A[i].first >> A[i].second;
  }

  sort(A.begin(), A.end());
  for(int i=0; i<N; i++){
    CW[0][i+1] = CW[0][i] + A[i].second;
    CW[1][i+1] = CW[0][i+1];
  }
  //printAll();
  for(int i=0; i<N; i++){
    CW[0][i+1] -= A[i].first;
    CW[1][i+1] -= 2*A[i].first;
  }
  //printAll();
  for(int i=0; i<N; i++){
    CW[0][i+1] = max(CW[0][i+1], CW[0][i]);
    CW[1][i+1] = max(CW[1][i+1], CW[1][i]);
  }
  //printAll();

  for(int i=0; i<N; i++){
    CCW[0][i+1] = CCW[0][i] + A[N-i-1].second;
    CCW[1][i+1] = CCW[0][i+1];
  }
  for(int i=0; i<N; i++){
    CCW[0][i+1] -= (C-A[N-i-1].first);
    CCW[1][i+1] -= 2*(C-A[N-i-1].first);
  }
  for(int i=0; i<N; i++){
    CCW[0][i+1] = max(CCW[0][i+1], CCW[0][i]);
    CCW[1][i+1] = max(CCW[1][i+1], CCW[1][i]);
  }

  ll best = 0;
  for(int i=0; i<=N; i++){
    best = max(best, CW[0][i] + CCW[1][N-i]);
    best = max(best, CW[1][i] + CCW[0][N-i]);
  }
  cout << best << endl;

  return 0;
}

Measured memory_bytes: 5120
s='#';n,*a=open(0).readlines();n=int(n);f=sum(n==t.count(s)for t in zip(*a));print(-all(t.count(s)<1for t in a)or min(n*2-f-a[i].count(s)+all(s<a[j][i]for j in range(n))for i in range(n)))

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

long long M,N,K,ans;
long long A[200002],B[200002];

int main()
{
    cin >> N>>M>>K;
    long long i,j;
    rep0(i,N) {cin>>j; A[i+1]=j+A[i];}
    rep0(i,M) {cin>>j; B[i+1]=j+B[i];}
    
    j=M;
    rep0(i,N+1) {
        if(A[i]>K) break;
        while(A[i]+B[j]>K) --j;
        ans=max(ans,i+j);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6716
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
int a,b,c,d,e,f,n,m,ans;
string s,t,u;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
template<typename T,typename U>
void fin(T a,U b){
  cout<<a<<" "<<b<<endl;
  exit(0);
}
template<typename T,typename U,typename S>
void fin(T a,U b,S c){
  cout<<a<<" "<<b<<" "<<c<<endl;
  exit(0);
}

signed main(){
cin>>s>>t;cout<<t<<s<<endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
numbers = [i for i in range(N+1)]
min = [0] * (N+1)
for i in range(N):
    min[i+1] = min[i] + numbers[i+1]
max = [0] * (N+1)
max[0] = numbers[N]
for i in range(N):
    max[i+1] = max[i] + numbers[N-i-1]

ans = 0
for i in range(K-1,N+1):
    ans += max[i] - min[i] + 1

print(ans % (10**9+7))

Measured memory_bytes: 38408
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

a, c, b = map(int, input().split())
if a <= b <= c or c <= b <= a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 64748
#include <bits/stdc++.h>
#define sqr(a) ((a) * (a))
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)
#define fe(i, a, b) for (int i = a; i < b; i++)
#define ii pair <int, int>
#define fi first
#define se second
#define sz(a) a.size()
#define RESET(a, b) memset((a), (b), sizeof (a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9 + 7;
const int maxN = 1e4 + 9;
const int maxK = 11;

int N, K, N_digit = 0;
ll res = LONG_LONG_MAX;
int a[maxK], ans[maxN];
bool digit[maxK], d[maxK];

void enter()
{
   cin >> N >> K;
   int v;
   ff(i, 1, K) {
      cin >> v;
      d[v] = true;
   }
}

bool check(int n)
{
   while (n) {
      if (d[n % 10]) return false;
      n /= 10;
   }
   return true;
}

void process()
{
   while (1) {
      if (check(N)) {
         cout << N;
         return;
      }
      N++;
   }
}

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL);
   //freopen("C_AtCoderBeginnerContest042.inp", "r", stdin);
   //freopen("template.out", "w", stdout);

   enter();
   process();

   return 0;
}


Measured memory_bytes: 256
ans = [0 for i in range(51)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                ans[i+j+k+l] += 1
#for i in range(50+1):
#   print(i, ans[i])
     
while True:
    try:
        print(ans[int(input())])
    except EOFError:
        break


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define int long long
main()
{
  int n;
  cin>>n;
  int jumps[n];
  for(int i=0;i<n;i++)
    cin>>jumps[i];
  vector<int> dp(n,0);
  dp[0]=0;
  dp[1]=abs(jumps[1]-jumps[0]);
  for(int i=2;i<n;i++)
            {
              dp[i]=min(dp[i-1]+abs(jumps[i]-jumps[i-1]),dp[i-2]+abs(jumps[i]-jumps[i-2]));
            }
            cout<<dp[n-1]<<endl;
            }

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200100];
int main()
{
    ll i,j,k,m,n;
    ll T;
    ll cnt=0;
    cin>>n>>T;
    cin>>a[1];
    for(i=2;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]-a[i-1]>T)
            cnt+=T;
        else
            cnt+=(a[i]-a[i-1]);
    }
    cout<<cnt+T<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);
struct edge{int from,to;};

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

struct UnionFind {
    private:
    vector<int> par,rank;
    vector<ll> Size;
    public:
    UnionFind(int n){
        par.resize(n);
        rank.resize(n,0);
        Size.resize(n,1);
        rep(i,n){
            par[i]=i;
        }
    }
    int root(int x){
        if (par[x]==x){
            return x;
        }
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x);
        y=root(y);
        if (x==y){
            return false;
        }
        if (rank[x]<rank[y]){
            swap(x,y);
        }
        if (rank[x]==rank[y]){
            ++rank[x];
        }
        par[y]=x;
        Size[x]+=Size[y];
        return true;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    ll size(int x){
        return Size[root(x)];
    }
};

const int MAX=100010;

int N,M;
vector<int> cnt(MAX,0);
vector<vector<int>> G(MAX);
vector<edge> es;

void dfs(int v,int p){
    for (auto nv:G[v]){
        if (nv==p) continue;
        dfs(nv,v);
    }
    if (p==-1) return;
    if (cnt[v]%2==0){
        es.push_back(edge{p,v});
        ++cnt[p];
    }
    else {
        es.push_back(edge{v,p});
        ++cnt[v];
    }
}

int main(){
    cin >> N >> M;
    if (M%2==1){
        cout << -1 << endl;
        return 0;
    }
    UnionFind uf(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        --a,--b;
        if (uf.same(a,b)){
            es.push_back(edge{a,b});
            cnt[a]++;
        }
        else {
            uf.merge(a,b);
            G[a].push_back(b);
            G[b].push_back(a);
        }
    }
    dfs(0,-1);
    rep(i,M){
        cout << ++es[i].from << ' ' << ++es[i].to << endl;
    }
}

Measured memory_bytes: 15092