akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      if (x == 0 && y == 0) {
        break;
      }
      if (x < y) {
        x = x + y;
        y = x - y;
        x = x - y;
      }
      int s = 1;
      for (;;) {
        x = x % y;
        x = x + y;
        y = x - y;
        x = x - y;
        if (y == 0) {
          System.out.printf("%d %d\n", x, s);
          break;
        } else {
          s++;
        }
      }
    }
  }
}

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

using namespace std;
// #define DEBUG
// #define TIME
/*
Learn : -
Problem Type : -
Source : -
*/
#pragma GCC optimize ("Ofast")
#define sint( a ) int a; qread(a);
#define sint2( a, b ) int a,b; qread(a),qread(b);
#define sint3( a, b, c ) int a,b,c; qread(a),qread(b),qread(c);
#define int1( a ) qread(a);
#define int2( a, b ) qread(a),qread(b);
#define int3( a, b, c ) qread(a),qread(b),qread(c);
#define mkp make_pair
#define mkt make_tuple
#define pb emplace_back
#define inf INT_MAX
#define all( x ) (x).begin(),(x).end()
#define F first
#define S second
#define sdouble( a ) double a; scanf("%lf",&a);
#define slong( a ) long long a; scanf("%lld",&a);
#define cstring( a, x ) char a[x]; scanf("%s",a);
#define sstring( a ) string a;cin>>a;
#define rev( s ) reverse(all(s));
#define FOR( a, b, c ) for(int a=b;a<c;a++)
#define ROF( a, b, c ) for(int a=b;a>c;a--)
#define pause system("pause")
#define endl printf("\n")
#define fastio {ios::sync_with_stdio(false);cin.tie(NULL);}
#define null NULL
#ifdef DEBUG
#define debug(x) cout<< #x << " = " << x;endl;
#else
#define debug( x )
#endif
#define OPEN freopen("input.txt","r",stdin)
#define SEND freopen("output.txt","w",stdout)
#ifdef COM
#define IN(x)
#define OUT(x)
#else
#define IN( x ) freopen(x,"r",stdin);
#define OUT( x ) freopen(x,"w",stdout);
#endif
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector <ii> vii;
typedef long long ll;

void qread( int &x )
{
	int neg = 1;
	x = 0;
	register char c = getchar();
	while(c < '0' || c > '9')
	{
		if(c == '-')neg = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9')x = 10 * x + c - '0', c = getchar();
	x *= neg;
}

void Wl( int x )
{
	printf("%d\n", x);
}

void Wl( double x )
{
	printf("%lf\n", x);
}

void Wl( string x )
{
	printf("%s\n", x.c_str());
}

void Wl( ll x )
{
	printf("%lld\n", x);
}

void W( int x )
{
	printf("%d ", x);
}

void W( double x )
{
	printf("%lf ", x);
}

void W( string x )
{
	printf("%s ", x.c_str());
}

void W( ll x )
{
	printf("%lld ", x);
}

int main()
{
    int target = 0 ;
    target += (1<<1);
    target += (1<<4);
    target += (1<<7);
    target += (1<<9);
    int tmp=0;
    for(int i=0;i<4;i++)
    {
        sint(x);
        tmp+=(1<<x);
    }
    if(tmp==target)printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.length() == 26){
        char c = s.at(25);
        int k = 25;
        while(s.at(k-1) > s.at(k)){
            k--;
            if(k == 0){
              cout << -1 << endl;
              return 0;
            }
        }
        for(int i = k; i < 26; i++)if(s.at(k-1) < s.at(i)) c = s.at(i);
        rep(i,k-1) cout << s.at(i);
        cout << c << endl;
    }
    else{
        vector<bool> c(26);
        rep(i,s.length()) c[s.at(i) - 'a'] = true;
        rep(i,26)if(!c[i]){
            cout << s << (char)('a' + i) << endl;
          return 0;
        }
    }
}

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

int main() {
    string s, t, u;
    cin >> s >> t >> u;
    int a = 'A' - 'a';
    cout <<  (char)(s[0] + a) << (char)(t[0] + a) << (char)(u[0] + a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
int n;
     int dp[401][401];
   int arr[401];
int sum(int i,int j)
{int ans=0;
    for(int k=i;k<=j;k++)
    {
        ans+=arr[k];
    }
    return ans;
}
 
int memo(int i,int j)
{
     if(i>j)
     return 0;
     if(i==j)
     return 0;
     if(dp[i][j]!=-1)
     return dp[i][j];
    int s=sum(i,j);
    int cost=inf;
    for(int k=i;k<=j-1;k++)
    {
        cost=min(cost,memo(i,k)+memo(k+1,j)+s);
    }
    return dp[i][j]=cost;
}
int32_t main()
{
    c_p_c();
    
     
    cin>>n;
 
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    memset(dp,-1,sizeof(dp));
    cout<<memo(0,n-1);
    
    return 0;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

int a[N];
void solve() {
    ll n;
    cin >> n;

    if (n % 2 == 1){
        cout << 0;
        return;
    }

    ll y = 10;
    ll ans = 0;
    while (n >= y){
        ans += n/y;
        y *= 5;
    }

    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
vector<int> graph;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll n, k;
	cin >> n >> k;
	graph.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> graph[i];
		--graph[i];
	}
	vector<int> tt(n, -1);
	tt[0] = 0;
	int cur = 0;
	int t = 0;
	while (k != 0) {
		cur = graph[cur];
		--k;
		++t;
		if (tt[cur] != -1) {
			int cycle_length = t - tt[cur];
			k %= cycle_length;
			tt.assign(n, -1);
			tt[cur] = 0;
			t = 0;
			continue;
		}
		tt[cur] = t;
	}
	cout << cur + 1 << '\n';
 	return 0;
}


Measured memory_bytes: 4780
N,M = map(int,input().split())

ex = [1]
mod = 10**9+7
for i in range(1,10**5+1):
    ex.append((ex[-1]*i)%mod)
    
if abs(N-M) >= 2:
    print(0)
elif N==M:
    print((2*ex[N]**2)%mod)
else:
    print((ex[N]*ex[M])%mod)

Measured memory_bytes: 44784
#!/usr/bin/env python3

def main():
    from collections import Counter

    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    ans = [None] * Q
    Asum = sum(A)
    A_Counter = Counter(A)
    for q in range(Q):
        B, C = map(int, input().split())
        Asum = Asum + (C-B)*A_Counter[B]
        A_Counter[C] += A_Counter[B]
        A_Counter[B] = 0

        ans[q] = Asum

    print('\n'.join(map(str, ans)))


if __name__ == "__main__":
    main()


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

typedef long long ll;

using namespace std;
int main() {
	int N;
	double x,res = 0;
	string S;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> x >> S;
		if (S == "JPY") {
			res = res + x;
		}
		else if (S == "BTC") {
			res = res + (double)(x)* 380000.0;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	unsigned long long int **a, **b, **c;
	int n,m,l,i,j,k;

	scanf("%d" "%d" "%d", &n, &m, &l);

	a = (unsigned long long int **)malloc(n * sizeof(unsigned long long int *));
	b = (unsigned long long int **)malloc(m * sizeof(unsigned long long int *));
	c = (unsigned long long int **)malloc(n * sizeof(unsigned long long int *));

	/* unsigned long long int????????§????????????????????¢???????¢???? */

	for(i=0;i<n;i++){
		a[i] = (unsigned long long int *)malloc(m * sizeof(unsigned long long int));
		c[i] = (unsigned long long int *)malloc(sizeof(unsigned long long int) * l);
	}

	/* ????????????a c????????¨????????????????´? */

	for(i=0;i<m;i++){
		b[i] = (unsigned long long int *)malloc(sizeof(unsigned long long int) * l);
	}

	/* ????????????b????????¨????????????????´? */

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);		/* n??m?????????A?????\??? */
		}
	}

	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);		/* m??l?????????B?????\??? */
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			c[i][j] = 0;
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k =0;k<m;k++){						/* ????????????????????¨??§m?????????????????? */
				c[i][j] += (a[i][k] * b[k][j]);		/* ??????C??????????´?cij????????? */
			}
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j < l -1) printf("%llu ",c[i][j]);
			else printf("%llu\n",c[i][j]);		/* n??l?????????C???????´?cij????????? */
		}
	}

	free(a);
	free(b);
	free(c);

	/* ?????????????????¢???????§£??? */

	return 0;
}

Measured memory_bytes: 844
n=int(input())
li=list(map(int,input().split()))
dp=[[0]*n for _ in range(n)]
for l in range(n-1,-1,-1):
    for r in range(l,n):
        if l==r:
            dp[l][r]=li[l]
        else:
            dp[l][r]=max(li[l]-dp[l+1][r],li[r]-dp[l][r-1])
print(dp[0][-1])

Measured memory_bytes: 111836
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 11:46-

            // 11:46-

            int n = sc.nextInt();
            double sum = 0.0;
            for (int i = 0; i < n; i++) sum += 1 / sc.nextDouble();

            out.println(1 / sum);

        }
    }

}


Measured memory_bytes: 24788
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;
    ll a,b;
    ll x,y;
    x=y=1LL;
    rep(i,0,n){
        cin>>a>>b;
        ll n=max((x+a-1)/a,(y+b-1)/b);
        x=n*a; y=n*b;
    }
    cout<<x+y<<endl;

}


/*

*/


Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        String strN = sc.next();
        int N = Integer.parseInt(strN);
        System.out.println( N % S(strN) == 0 ? "Yes" : "No" );
        
    }
    
    static int S(String n){
        int ret = 0;
        for(int i = 0; i < n.length(); i++){
            ret += n.charAt(i) - '0';
        }

        int N = Integer.parseInt(n);
        
        return ret;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>

int main() {
	std::vector <int> a(50), b(50), c(50), d(50), ans(50);
	int n, m;
	for (int i = 0; i < 50; ++i) { ans[i] = 400000000; }
	std::cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		std::cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; ++i) {
		std::cin >> c[i] >> d[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			ans[j]=abs(a[i] - c[j]) + abs(b[i] - d[j]);
		}
		for (int j = 0; j < m; ++j) {
			if (ans[j] == *std::min_element(ans.begin(), ans.end())) {
				std::cout << j + 1 << std::endl; break;
			}
		}
	}
}

Measured memory_bytes: 256
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n"
#define int ll 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =2e5+2 ;
ll a[mxN] ;
void solve(){
  ll n,k ; cin >> n >> k ;
  Rep(i,n){
    cin >> a[i] ;
  }
  int x =1 ;
  int cnt =0 ,steps=1;
  map<int,int> check;
  check[x]=steps ;
  int cyc =0 ;
  vector<int>pos={x} ;
  
  while(1){
    //cout << "iteration  " << steps <<" " << x << endl ;
    if(check[a[x]]!=0){
      //cout << check[a[x]] << endl ;
      ++steps ;
      cyc = steps-check[a[x]] ;
      break ;
    }
    ++steps ;
    x=a[x] ;
    check[x]=steps ;
    pos.pb(x) ;
  }
  vi cycle ;
  while(sz(cycle)!=cyc){
    cycle.pb(pos.back()) ;
    pos.pop_back() ;
  }
  reverse(all(cycle)) ;
  if(k<sz(pos)){
    cout << pos[k] << endl ;
    return ;
  }
  k-=sz(pos) ;
  ll rem= k%cyc ;
  cout << cycle[rem] << endl ;
  
  // for(int x:pos)pff(x) ;
  // cout << endl ;
  // // cout << steps << endl ;
  // cout << cyc << endl ;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}
// if(s.count()){
    //   ++steps ;
    //   break ;
    // }
    // ++steps ;
    // x=a[x] ;


Measured memory_bytes: 20680
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> v(n);  // subarray from a
  rep(i, n) {
    ll sum = 0;
    for (int j = i; j < n; ++j) {
      sum += a[j];
      v.push_back(sum);
    }
  }

  for (ll i = 50; i >= 0; --i) {
    vector<ll> t;
    ll cnt = 0;
    for (ll value : v) {
      if (value>>i&1) {
        cnt++;
        t.push_back(value);
      }
    }

    if (cnt >= k) {
      v = t;
    }
  }

  ll ans = 0;
  if (v.size() >= k) {
    ans = v[0];
    rep(i, k) ans &= v[i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 6316
fun main(args: Array<String>) {
    val line = readLine()!!.split(" ")

    fun countIndex(num: List<String>, counter: Int = 1): Int {
        return if (num[0] == "0") counter else countIndex(num.takeLast(num.size - 1), counter + 1)
    }
    println(countIndex(line))
}


Measured memory_bytes: 36344
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll  n;
	cin >> n;
	string s;
	cin >> s;

	ll cntr = 0, cntw = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			cntr++;
		if (s[i] == 'W')
			cntw++;
	}
	if (cntr == 0 || cntw == 0)
	{
		cout << 0 << endl;
		ret;
	}
	ll left = 0, right = n - 1;
	ll ans = 0;
	while (right-left>0)
	{
		if (s[left] == 'W' && s[right] == 'R')
		{
			ans++;
			left++; right--;
			continue;
		}
		if (s[left] == 'R')
			left++;
		if (s[right] == 'W')
			right--;

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    string s;
    getline(cin,s);
    ll res=0,i;
    for(i=0;i<s.size();i++){
        res=(res+(s[i]-'0'))%9;
    }
    if(res==0) cout<<"Yes"; else cout<<"No";
    return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();

    // テーブルを作成
    int[] c = new int[n];
    int[][] a = new int[n][m];
    for (int i = 0; i < n; i++) {
      c[i] = sc.nextInt();
      for (int j = 0; j < m; j++) {
        a[i][j] = sc.nextInt();
      }
    }

    int answer = Integer.MAX_VALUE;
    for (int i = 0; i < (Math.pow(2, n)); i++) {
      int[] score = new int[m];
      int amount = 0;
      for (int j = 0; j < n; j++) {
        if ((1 & i >> j) == 1) {
          amount += c[j];
          for (int k = 0; k < m; k++) {
            score[k] += a[j][k];
          }
        }
      }

      boolean b = true;
      for (int s : score) {
        if (s < x) {
          b = false;
          break;
        }
      }
      if (b && amount < answer) {
        answer = amount;
      }
    }

    System.out.println(answer == Integer.MAX_VALUE ? -1 : answer);
  }
}


Measured memory_bytes: 37396
#include<cstdio>

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	while(a + 1 || b + 1 || c + 1){
		if(a + 1 && b + 1){
			if(a + b  > 79){
				printf("A\n");
			}else if(a + b > 64){
				printf("B\n");
			}else if(a + b > 49){
				printf("C\n");
			}else if(a + b > 29){
				if(c > 49){
					printf("C\n");
				}else{
					printf("D\n");
				}
			}else{
				printf("F\n");
			}
		}else{
			printf("F\n");
		}
		scanf("%d %d %d", &a, &b, &c);
	}
	return 0;
}

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

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e15+7;

signed main(){
	int n;
	cin >> n;
	int c, b, a;
	cin >> c >> b >> a;
	vector<int> v(n);
	for(auto& x : v)
		cin >> x;

	vector<int> sum(1 << n, 0);
	for(int i = 0; i < (1 << n); ++i)
		for(int j = 0; j < n; ++j)
			if(i & (1 << j))
				sum[i] += v[j];

	i64 ret = INF;
	for(int i = 0; i < (1 << n); ++i){
		for(int j = 0; j < (1 << n); ++j){
			for(int k = 0; k < (1 << n); ++k){
				bool flag = true;
				for(int l = 0; l < n; ++l){
					int c = (i & (1 << l) ? 1 : 0);
					c += (j & (1 << l) ? 1 : 0);
					c += (k & (1 << l) ? 1 : 0);
					if(c >= 2){
						flag = false;
						break;
					}
				}
				if(!flag || !i || !j || !k)
					continue;
				i64 ans = 0;
				ans += 10 * (__builtin_popcount(i) - 1);
				ans += 10 * (__builtin_popcount(j) - 1);
				ans += 10 * (__builtin_popcount(k) - 1);
				ans += abs(a - sum[i]);
				ans += abs(b - sum[j]);
				ans += abs(c - sum[k]);
				ret = min(ret, ans);
			}
		}
	}
	cout << ret << endl;
}


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

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

  sort(d.begin(),d.end());


  int layermax,layernow;
  layermax = layernow = 1;
  int idx = 0;
  for(int i = 1;i < n;i++){
    if(d[idx] < d[i]){
      layernow++;
      idx = i;
    }
    if(layermax < layernow)
      layermax = layernow;
  }
  


  cout << layermax << endl;
  



}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef struct {
	int m[6];
} Dice;

Dice D[100], d[2];
int n;
string s = "NNENN", w = "HHHH";

void roll(char c, Dice *d) {
	switch (c) {
	case 'N':
		swap(d->m[0], d->m[1]);
		swap(d->m[1], d->m[5]);
		swap(d->m[5], d->m[4]);
		break;
	case 'S':
		swap(d->m[0], d->m[4]);
		swap(d->m[4], d->m[5]);
		swap(d->m[5], d->m[1]);
		break;
	case 'E':
		swap(d->m[0], d->m[3]);
		swap(d->m[3], d->m[5]);
		swap(d->m[5], d->m[2]);
		break;
	case 'W':
		swap(d->m[0], d->m[2]);
		swap(d->m[2], d->m[5]);
		swap(d->m[5], d->m[3]);
		break;
	case 'H':
		swap(d->m[1], d->m[2]);
		swap(d->m[2], d->m[4]);
		swap(d->m[4], d->m[3]);
		break;
	}
}
bool isDifferent(Dice *d, Dice *e) {
	for (unsigned i = 0; i < s.size() + 1; i++) {
		for (unsigned j = 0; j < w.size(); j++) {
			for (int k = 0; k < 6; k++) {
				if (d->m[k] != e->m[k]) break;
				if (k == 5) return false;
			}
			roll(w[j], d);
		}
		if (i < s.size()) roll(s[i], d);
	}
	return true;
}
int main() {
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) for (int j = 0; j < 6; j++) cin >> D[i].m[j];
	for (int i = 0; i < n - 1; i++) {
		d[0] = D[i];
		for (int j = i + 1; j < n; j++) {
			d[1] = D[j];
			if (!isDifferent(&d[0], &d[1])) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


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

#define ll long long
#define mod 1000000007
#define debug1(x) cerr<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("input.txt", "rt" , stdin);
//    freopen("output.out", "wt",stdout);


int main() {
    IOS;
    double n,x,t;
    cin>>n>>x>>t;
    ll ans=ceil(n/x)*t;
    cout<<ans<<endl;
    return 0 ;
}


Measured memory_bytes: 3728
#include <iostream>
using namespace std;
 int main(void){
	int a,b;
	cin >> a >> b;
	
	if(a > b){
		cout << "a > b" << endl;
	}else if( a < b){
		cout << "a < b" << endl;
	}else{
		cout << "a == b"<< endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<vector<pii> > a(n);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            pii p;
            cin >> p.F >> p.S;
            --p.F;
            a[i].eb(p);
        }
    }
    
    int ans = 0;
    rep(i, 1 << n) { // 正直者
        [&]() {
            rep(j, n) {
                if (i & (1 << j)) { // jは正直者
                    rep(k, sz(a[j])) {
                        int l = !!(i & (1 << a[j][k].F));
                        if (l != a[j][k].S) return;
                    }
                }
            }
            chmax(ans, __builtin_popcount(i));
        }();
    }
    cout << ans << endl;
}


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

class SegmentTree():
    def segfunc(self, x, y):
        return max(x, y)
        
    def __init__(self, ide_ele, n, l, target):
        # n以上の最小の2のべき乗、一番下の段はここからスタートになる
        self.ide_ele = ide_ele
        self.num =2**(n-1).bit_length()
        self.tree = [ide_ele]*self.num*2
        # 一番下の段
        for i in range(n):
            if l[i] == target:
                self.tree[i+self.num-1] = 1
        # 
        for i in range(self.num-2, -1, -1):
            self.tree[i] = self.segfunc(self.tree[2*i+1], self.tree[2*i+2])
    
    def update(self, k, add):
        k += self.num-1
        if add:
            self.tree[k] = 1
        else:
            self.tree[k] = 0
        while k:
            k = (k-1)//2
            self.tree[k] = self.segfunc(self.tree[k*2+1], self.tree[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele

        # [p, q)
        p += self.num - 1
        q += self.num - 2
        res = self.ide_ele
        while q-p>1: # まだ隣同士の節点ではないなら
            # &で偶奇判定->中途半端な位置にいるなら寄せる
            if p&1 == 0: #左なのに右端
                res = self.segfunc(res, self.tree[p])
            if q&1 == 1: #右なのに左端
                res = self.segfunc(res, self.tree[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p==q:
            res = self.segfunc(res, self.tree[p])
        else:
            res = self.segfunc(self.segfunc(res, self.tree[p]), self.tree[q])
        return res

    # 閉区間になってる
    def rec_query(self, p, q, k, l, r):
        #q -= 1 [)の場合
        #print(p, q, k, l, r)
        if r < p or q < l: # out of range
            return self.ide_ele
        if p <= l and r <= q:
            return self.tree[k]
        else:
            vl = self.rec_query(p, q, k*2+1, l, (l+r)//2)
            vr = self.rec_query(p, q, k*2+2, (l+r)//2+1, r)
        #print(vl, vr)
        return self.segfunc(vl, vr)



N = int(input())
S = input()
Q = int(input())

result = ""

d = {}
for i in range(26):
    d[chr(ord("a")+i)] = SegmentTree(0, N, S, chr(ord("a")+i))

S = list(S)

for q in range(Q):
    case, p, q = (i for i in input().split())
    #print(case, p, q)
    p = int(p)-1
    case = int(case)
    if case==1:
        #print(p)
        d[S[p]].update(p, False)
        d[q].update(p, True)
        S[p] = q
    else:
        ans = 0
        for c in range(26):
            #print(d[chr(ord("a")+c)].tree)
            ans += d[chr(ord("a")+c)].query(p, int(q))
        result += str(ans)+"\n"

#print(S)
print(result[:-1])


Measured memory_bytes: 371348
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,m,a[105];
int get(vector<int>&v){
	int ret=v.back();v.pop_back();return ret;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>a[i];
	vector<int>odd,even;
	for(int i=1;i<=m;i++){
		if(a[i]&1)odd.push_back(a[i]);
		else even.push_back(a[i]);
	}
	if(odd.size()>2){
		puts("Impossible");
		return 0;
	}
	vector<int>A,B;
	if(odd.size())A.push_back(get(odd));
	for(auto v:even)A.push_back(v);
	if(odd.size())A.push_back(get(odd));
	B.push_back(A[0]-1);
	for(int i=1;i<A.size();i++){
		B.push_back(A[i]);
	}
	B.back()++;
	if(m==1){
		B.clear();
		B.push_back(a[1]-1);
		B.push_back(1);
	}
	for(auto v:A)cout<<v<<" ";cout<<endl;
	int tot=0;
	for(auto v:B){
		if(v)tot++;
	}
	cout<<tot<<endl;
	for(auto v:B)if(v)cout<<v<<" ";cout<<endl;
	return 0;
}

Measured memory_bytes: 3484
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;
ll factorize(ll n) {
    ll res=1;
    for (ll i = 2; i * i <= n; i++) {
      ll cnt=0;
        if (n % i != 0) continue;
        
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        res*=cnt+1; 
    }
    if (n != 1) res*=2;
    return res;
}
int main(){
  ll n,ans=0;cin>>n;
  rep(i,1,n){
    ans+=factorize(i);
  }
  out(ans);
}






Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main(){
  char c;
  cin >> c;
  
  if(c == 'a'){
	cout << "vowel" << endl;
  }
  else if(c == 'i'){
    cout << "vowel" << endl;
  }
  else if(c == 'u'){
    cout << "vowel" << endl;
  }
  else if(c == 'e'){
    cout << "vowel" << endl;
  }
   else if(c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
  
  return 0;
}


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

namespace B___Shift_only
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Ai = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var cnt = 0;

            while (Ai.All(x => x % 2 == 0))
            {
                Ai = Ai.Select(x => x / 2).ToArray();
                cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13396
MOD = int(1e9) + 7
MAXN = 2000
comb = [[0 for i in range(MAXN)] for j in range(MAXN)]

# 組み合わせ(1e9+7で割る場合)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

for i in range(MAXN):
    for j in range(MAXN):
        comb[i][j] = cmb(i, j, MOD)

N, K = map(int, input().split())
ans = 0
for i in range(1, K+1):
    rest = K - i
    val = comb[K][i] * pow(rest, N, MOD) % MOD
    if i % 2 == 1:
        ans = (ans + val) % MOD
    else:
        ans = (ans - val + MOD) % MOD
ans = (pow(K, N, MOD) - ans + MOD) % MOD
print(int(ans))


Measured memory_bytes: 101672
#include<cstdio>
#include<vector>
#include<algorithm>
const int MaxN=200010,mod=1000000007;
int n,vs[MaxN],left[MaxN],right[MaxN];
struct item{int x,v;bool operator<(const item&it)const{return x<it.x;}}a[MaxN];
bool cmp(int i,int j){return a[i].v<a[j].v;}
std::vector<int>lst[MaxN];
int f[MaxN];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i].x,&a[i].v);
		vs[i]=i;
	}
	std::sort(vs,vs+n,cmp);
	for(int i=0;i<n;i++)a[vs[i]].v=i;
	std::sort(a,a+n);
	for(int i=n;i--;){
		left[i]=i<n-1?left[i+1]:a[i].v;
		if(a[i].v<left[i])left[i]=a[i].v;
	}
	for(int i=0;i<n;i++){
		right[i]=i?right[i-1]:a[i].v;
		if(a[i].v>right[i])right[i]=a[i].v;
		lst[right[i]+1].push_back(left[i]);
	}
	int c=*f=1,pos=0,sum=0,sums=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<lst[i].size();j++){
			int l=lst[i][j];
			for(;pos<l;pos++)(sum+=f[pos])%=mod;
			(sums+=sum)%=mod;
			(sum*=2)%=mod;
			c=c*2%mod;
		}
		f[i]=(c+mod-sums)%mod;
		(sums+=f[i])%=mod;
	}
	printf("%d\n",f[n]);
}

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	char ch;
	cin >> ch;
	cout << (isupper(ch) ? "A" : "a") << '\n';
	
	return 0;
}






Measured memory_bytes: 3636
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const foo = (str) => str.split(' ').map(v => parseInt(v, 10));

const numbers1 = foo(inputs[0]);
const numbers2 = foo(inputs[1]);

numbers2.sort((a, b) => a - b);

let price = 0;
for (let i = 0 ; i < numbers1[1] ; ++i) {
  price += numbers2[i];
}

console.log(price);

Measured memory_bytes: 29760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define INT long long
#define MOD 1000000007
#define oo 987654321
using namespace std;

INT n, ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    ans = n/11;
    ans<<=1;
    n = n%11;
    if( n == 0 ) cout<<ans<<endl;
    else if( n < 7 ) cout<<ans+1<<endl;
    else cout<<ans+2<<endl;
    return 0;
}


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

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import math
import sys
input = sys.stdin.readline

D, G = map(int, input().split())
# print(D, G)
P = []
C = []
for i in range(D):
    p,  c = map(int, input().split())
    P.append(p)
    C.append(c)

INF = 10**15


def F(i, n, GetPoint):
    if i == D:
        if GetPoint >= G:
            return n, GetPoint
        else:
            return INF, INF

    PerPoint = (i+1)*100

    if GetPoint < G:
        ANS = INF, INF
        # ALL
        N, GP = F(i+1, n+P[i], GetPoint+PerPoint*P[i] + C[i])
        if N < ANS[0]:
            ANS = N, GP
        # through
        N, GP = F(i+1, n, GetPoint)
        if N < ANS[0]:
            ANS = N, GP

        # part
        # 上位合計
        PupperAll = sum([(j+1)*100*P[j] + C[j] for j in range(i+1, D)])
        rN = math.ceil((G - GetPoint - PupperAll)/PerPoint)
        if 0 < rN < P[i]:
            GP = GetPoint + PerPoint*rN + PupperAll
            N = n + rN + sum(P[i+1:])
            if N < ANS[0]:
                ANS = N, GP

        return ANS
    else:
        return n, GetPoint


print(F(0, 0, 0)[0])


Measured memory_bytes: 9192
n,k,q=map(int,input().split())
a= []
for _ in range(q):
    a.append(int(input()))
ans=[0]*n
for i in range(q):
    ans[a[i]-1]=ans[a[i]-1]+1
for i in range(n):
    if ans[i]>q-k:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8636
n = int(input())
li = [0 for i in range(n)]

def call(num):
    print(num,flush=True)

def responce(num):
    res = input()
    if res == "Vacant":
        exit()
    elif res == "Male":
        li[num] = 1
    else:
        li[num] = 2
    
call(0)
responce(0)
call(n-1)
responce(n-1)
l = 0
r = n-1
while True:
    m = (r+l)//2
    call(m)
    responce(m)
    if ((m-l+1)%2 == 1 and li[m] != li[l]) or ((m-l+1)%2 == 0 and li[m] == li[l]):
        r = m
    else:
        l = m

Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

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

    cout << lcm(a, b) << endl;
}



Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def calc_div(N):
    sq = int(N**.5 + 10)
    x = np.arange(1, sq)
    x = x[N % x == 0]
    x = np.concatenate((x, N // x))
    return np.unique(x)

def main(N):
    N *= 2
    div = calc_div(N).tolist()
    for a in div:
        a = int(a)
        b = N // a
        if np.gcd(a, b) != 1:
            continue
        # b | an + 1
        n = (-pow(a,-1,b)) % b
        k = a * n
        if k == 0:
            k += N
        assert k * (k + 1) % N == 0
        yield k

N = int(read())
print(min(main(N)))


Measured memory_bytes: 766792
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	vector<int>data(N);
	int ans = 0;
	int m = INT_MAX;
	for (int i = 0; i < N; i++) {
		cin >> data[i];
		if (data[i] % 10 != 0) {
			chmin(m, data[i]);
		}
		ans += data[i];
	}
	if(m == INT_MAX) {
		cout << 0 << endl;
	}
	else if(ans % 10 == 0){
		cout << ans - m << endl;
	}
	else {
		cout << ans << endl;
	}
}


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

using namespace std;

ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow != 0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

ll lt[1234][1234], rt[1234][1234], upper[1234][1234], lower[1234][1234];

int dist(int x1, int y1, int x2, int y2){
    return abs(x1-x2)+abs(y1-y2);
}

int pre[123456];

int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    int r, g;
    cin >> r >> g;
    cout << 2*g -r;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int d = 1;
        int N = cin.nextint;
        while ((d + 1) * (d + 1) <= N) d++;
        WriteLine(d * d);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220