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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for(int i=0; i<n; i++) {
            l[i] = sc.nextInt();
        }
        sc.close();

        int cnt = 0;
        for(int i=0; i<n; i++) {
            for(int j=i; j<n; j++) {
                if(l[i] == l[j]) continue;
                for(int k=j; k<n; k++) {
                    if((l[i] != l[k] && l[j] != l[k]) &&
                        l[i] < l[j] + l[k] && l[j] < l[i] + l[k] && l[k] < l[i] + l[j]) {
                        cnt++;
                        //System.out.println("i: " + l[i] + " j: " + l[j] + " k: " + l[k]);
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35844
import java.util.*;

public class Main{
	static int N;
	static int[] bs = new int[10];
	static ArrayList<Integer> left = new ArrayList<Integer>();
	static ArrayList<Integer> right = new ArrayList<Integer>();
	static boolean ans;
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int N = s.nextInt();
		while(N-->0){
			for(int i = 0; i < 10; i++){
				bs[i] = s.nextInt();
			}
			
			left.clear();
			right.clear();
			left.add(bs[0]);
			for(int i = 1; i < 10; i++){
				if(bs[i] > left.get(left.size()-1)){
					left.add(bs[i]);
				}else{
					right.add(bs[i]);
				}
			}
			
			ans = true;
			for(int i = 0; i < right.size()-1; i++){
				if(right.get(i) >= right.get(i+1)){
					ans = false;break;
				}
			}			
			if(ans) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 18148
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std;
const int MAXN=1005,MAXM=200005;
int n,m;
int ex[MAXM],ey[MAXM];
vector<int> ver[MAXN];
bool ok[MAXN][MAXN];
void dfs(int u,bool tag[]) {
	tag[u]=1;
	for(int v:ver[u])
		if(!tag[v]) dfs(v,tag);
}
int a[MAXN][MAXN],b[MAXN][MAXN];
void mak_tag(int u,int tag[],int id) {
	tag[u]=id;
	for(int v:ver[u]) if(!tag[v])
		mak_tag(v,tag,id);
}

int main() {
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++) {
		scanf("%d%d",&x,&y);
		ver[x].push_back(y);
		ex[i]=x,ey[i]=y;
	}
	
	for(int i=1;i<=n;i++)
		dfs(i,ok[i]);
	for(int i=1;i<=n;i++) {
		a[i][i]=-1;
		for(int j=0;j<(int)ver[i].size();j++)
			if(!a[i][ver[i][j]]) mak_tag(ver[i][j],a[i],j+1);
	}
	for(int i=1;i<=n;i++) {
		b[i][i]=-1;
		for(int j=ver[i].size()-1;~j;j--)
			if(!b[i][ver[i][j]]) mak_tag(ver[i][j],b[i],j+1);
	}

	for(int i=1;i<=m;i++) {
		int x=ex[i],y=ey[i];
		puts((ok[y][x])^(a[x][y]!=b[x][y])?"diff":"same");
	}
	return 0;
}

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

int main(){
    int m,n,i,j,k;
    for(int c=1;cin>>m,m;c++){
        cout << "Case " << c << ":\n";
        int mtx[10][10],dd=-1;
        i=0,j=0,n=1;
        for(k=0;k<=2*m-2;k++){
            while(true){
                mtx[i][j]=n;
                n++;
                if(((dd==-1)&&(i*(j-m+1)==0))||((dd==1)&&(j*(i-m+1)==0))) break;
                i+=dd;j-=dd;
            }
            dd*=-1;
            if(i==m-1)j++;
            else if(j==m-1)i++;
            else if(i) i++;
            else j++;
        }
        for(i=0;i<m;i++){
            for(j=0;j<m;j++){
                printf("%3d", mtx[i][j]);
            }
            cout<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 1204
// Problem : D - RGB Triplets
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	string str;
	cin>>str;
	vl vr(N),vg(N),vb(N);
	F0R(x,N)
	{
		if(x!=0)
			vr[x]=vr[x-1],vg[x]=vg[x-1],vb[x]=vb[x-1];
		if(str[x]=='R')
			vr[x]++;
		else if(str[x]=='G')
			vg[x]++;
		else
			vb[x]++;
	}
	ll ans=0;
	FOR(x,1,N-1)
	{
		if(str[x]=='R')
		{
			ans+=vg[x-1]*(vb.back()-vb[x])+vb[x-1]*(vg.back()-vg[x]);
			int off=1;
			while(x-off>=0 && x+off<N)
			{
				if(str[x-off]=='B' && str[x+off]=='G' || str[x-off]=='G' && str[x+off]=='B')
					ans--;
				off++;
			}
		}
		else if(str[x]=='G')
		{
			ans+=vr[x-1]*(vb.back()-vb[x])+vb[x-1]*(vr.back()-vr[x]);
			int off=1;
			while(x-off>=0 && x+off<N)
			{
				if(str[x-off]=='B' && str[x+off]=='R' || str[x-off]=='R' && str[x+off]=='B')
					ans--;
				off++;
			}	
		}
		else
		{
			ans+=vg[x-1]*(vr.back()-vr[x])+vr[x-1]*(vg.back()-vg[x]);
			int off=1;
			while(x-off>=0 && x+off<N)
			{
				if(str[x-off]=='R' && str[x+off]=='G' || str[x-off]=='G' && str[x+off]=='R')
					ans--;
				off++;
			}
		}
		// ans=(ans+MOD)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3752
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1166&lang=jp

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def bfs(maze, w, h):
    # ????????????????§????????????´????????§?¨??????????
    dy = [-1, 1, 0, 0]
    dx = [0, 0, -1, 1]

    # ??????????????°???(S)??¨??´????????°???(G)?????????
    sx = 0                   #  ??????????????°????????§?¨?
    sy = 0
    gx = w - 1                   #  ??´????????°????????§?¨?
    gy = h - 1

    d = [[float('inf')] * w for _ in range(h)] #  ??????????????°?????????????????¢???INF??§?????????
    Q = deque()
    Q.append((sx, sy))
    d[sy][sx] = 0
    while Q:
        cx, cy = Q.popleft()        #  ?????¨??°?????§?¨?
        if cx == gx and cy == gy:
            return d[gy][gx] + 1
        for i in range(4):
            nx = cx + dx[i]
            ny = cy + dy[i]
            # ?§?????????? ??°????????????????????????????????? and ?£?????????£???????????? and ??¢?????¢?´¢?????§?????? ??´???
            if is_passable(maze, w, h, cx, cy, dx[i], dy[i]) and d[ny][nx] == float('inf'):
                Q.append((nx, ny))
                d[ny][nx] = d[cy][cx] + 1
    return 0


def is_passable(maze, w, h, cx, cy, dx, dy):
    if not 0 <= (cx + dx) < w:
        return False
    if not 0 <= (cy + dy) < h:
        return False
    if dy == -1:                #  up
        return True if maze[cy*2-1][cx] == 0 else False
    if dy == 1:                 #  down
        return True if maze[cy*2+1][cx] == 0 else False
    if dx == -1:                #  left
        return True if maze[cy*2][cx-1] == 0 else False
    if dx == 1:                 #  right
        return True if maze[cy*2][cx] == 0 else False


def solve(maze, w, h):
    return bfs(maze, w, h)


def main(args):
    while True:
        w, h = map(int, input().split(' '))
        if w == 0 and h == 0:
            break

        maze = []
        for d in range(h*2-1):
            maze.append([int(x) for x in input().strip().split(' ')])

        res = solve(maze, w, h)
        print(res)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8068
nab=list(map(int, input().split()))
n=nab[0]
a=nab[1]
b=nab[2]
answera=n//(a+b)
remainder=n%(a+b)
if(remainder<=a):
    answer=answera*a+remainder
else:
    answer=answera*a+a
print(answer)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
      printf("a < b\n");
    else if(a>b)
      printf("a > b\n");
    else
      printf("a == b\n");
    return 0;
}



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

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

    int n;
    cin >> n;

    int dp[n+1];

    dp[0] = 0;
    dp[1] = 0;

    int arr[n];

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

    dp[2] = abs(arr[1] - arr[0]);

    for(int i = 3; i<=n; i++){

        dp[i] = min( abs(arr[i-1] - arr[i-2]) + dp[i-1], abs(arr[i-1] - arr[i-3]) + dp[i-2]);
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll n = len(s);
    vector<vector<mint>> dp(n + 1, vector<mint>(4, 0));
    dp[0][0] = 1;
    rep(i, n) {
        rep(ii, 4) {
            if (s[i] == '?') dp[i + 1][ii] = dp[i][ii] * 3;
            else dp[i + 1][ii] = dp[i][ii];
        }
        if ((s[i] == 'A') || (s[i] == '?')) {
            dp[i + 1][1] += dp[i][0];
        }
        if ((s[i] == 'B') || (s[i] == '?')) {
            dp[i + 1][2] += dp[i][1];
        }
        if ((s[i] == 'C') || (s[i] == '?')) {
            dp[i + 1][3] += dp[i][2];
        }
    }
    cout << dp[n][3].x << endl;
    return 0;
}


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

#define INF 900000000
#define LINF 9000000000000000000

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

int H, W, K;
set<int> st;
int main(){
	cin.tie(0);
  ios::sync_with_stdio(false);

	cin >> H >> W >> K;

	for (int i = 0; i <= H; i++) {
		for (int j = 0; j <= W; j++) {
			st.insert(H*j+W*i-i*j*2);
		}
	}

	auto itr = st.find(K);
	if (itr == st.end()) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


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

int gcd(int p, int q) {
	if (p < q) swap(p, q);
	if (p % q == 0) return q;
	else return gcd(p / q, p % q);
}
int keta(long p, int q) {
	if (p / 10 == 0) return q + 1;
	else return keta(p / 10, q + 1);
}
long long kaijo(int p, int q) {
	if (p == 1) return q;
	else return kaijo(p - 1, p * q);
}
long long Combination(int p, int q, int r, long long tmp) {
	if (q == 0) return tmp;
	else {
		tmp = tmp * p / r;
		tmp %= 1000000007;
		return Combination(p - 1, q - 1, r + 1, tmp);
	}
}
long long ruijo(long long p, long long q) {
	long long ans = 1;
	rep(i, q) {
		ans *= p;
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	//テンプレート
	using pll = pair<long long, long long>;

	int x;
	cin >> x;
	if (x == 0) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

inline void fail() {
	printf("-1\n");
	exit(0);
}

int n, m;
vector<int> g[MAXN];
int fa[MAXN], dep[MAXN], siz[MAXN], cu, cv, stk[MAXN], top;

void DFS(int u, int ff) {
	siz[u] = (dep[u] & 1? 1 : -1);
	for (auto v : g[u]) {
		if (v == ff) continue;
		if (v == 1 || fa[v]) {
			cu = u; cv = v;
		} else {
			fa[v] = u;
			dep[v] = dep[u] + 1;
			DFS(v, u);
			siz[u] += siz[v];
		}
	}
}

void init() {
	read(n); read(m);
	for (int i = 1, u, v; i <= m; ++i) {
		read(u); read(v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
}

void solve() {
	LL ans = 0;
	DFS(1, 0);
	if (m == n - 1) {
		if (siz[1]) fail();
	} else if ((dep[cu] - dep[cv]) & 1) { //even circle
		if (siz[1]) fail();
		for (int u = cv; u != cu; u = fa[u]) {
			stk[++top] = siz[u];
		}
		++top;
		sort(stk + 1, stk + top + 1);
		int mid = top / 2;
		for (int i = 1; i <= top; ++i) {
			ans += abs(stk[i] - stk[mid]) - abs(stk[i]);
		}
	} else { //odd circle
		if (siz[1] & 1) fail();
		int d = -siz[1] / 2, u;
		ans += abs(d);
		for (u = cv; u != cu; u = fa[u]) {
			siz[u] += d;
		}
		for (; u; u = fa[u]) {
			siz[u] += d * 2;
		}
	}
	for (int i = 1; i <= n; ++i) {
		ans += abs(siz[i]);
	}
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  for (char c : s) {
    int m = n;
    if (c + n > 'Z') {
      m -= 26;
    }
    cout << (char)(c + m);
  }
  cout << endl;
}

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

int bubbleSort(int A[],int N){
    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag;i++){
        flag = 0;
        for(int j = N-1;j>=i+1;j--){
        if(A[j]<A[j-1]){
            swap(A[j],A[j-1]);
            flag=1;
            sw++;
        }
    }
}
return sw;
}

int main(){
    int A[100],N,sw;
    cin >> N;
    for(int i = 0;i<N;i++) cin >> A[i];
    
    sw = bubbleSort(A,N);
    
    for(int i = 0;i<N;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int argmax = i;
  int l = 2*i;
  int r = 2*i + 1;
  if (l<=H && A[argmax]<A[l]) {
    argmax = l;
  }
  if (r<=H && A[argmax]<A[r]) {
    argmax = r;
  }

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

int extract() {
  int maxv;
  if (H<1) {
    return -INFTY;
  }
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if (key<A[i]) {
    return;
  }
  A[i] = key;
  while (i>1 && A[i/2]<A[i]) {
    swap(A[i], A[i/2]);
    i = i/2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

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



Measured memory_bytes: 6596
//  Created by Vignesh Manoharan

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vi> vvi;

const int INF = 1000000000;
const ll LINF = 1e17;
const double PI =3.141592653589793238;
#pragma unused(INF,PI,LINF)
#define F(i,a,n) for(int i=(a);i<(n);i++)

template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){
    for(int i=0;i<(t).size();i++)s<<t[i]<<((i<(t).size()-1)?" ":"");return s; }
template<typename T> ostream& operator<<(ostream &s,set<T> t){for(T x:t) s<<x<<" ";return s; }
template<typename T> istream& operator>>(istream &s,vector<T> &t){
    for(int _i=0;_i<t.size();_i++) s>>t[_i];return s; }

#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()

const int maxn=100010;
ll a[maxn],tree[4*maxn];
ll merge(ll t1,ll t2){
    return t1+t2;
}
void build(int v,int l,int r){
    // call v=1,l=0,r=n-1
    if(l==r){
        tree[v]=a[l];
    } else {
        int mid=(l+r)/2;
        build(2*v,l,mid);
        build(2*v+1,mid+1,r);
        tree[v]=merge(tree[2*v],tree[2*v+1]);
    }
}
ll query(int v,int l,int r,int ql,int qr){
    // call v=1,l=0,r=n-1 to query from ql to qr(included)
    if(ql>qr)
        return 0; // check this for 'identity' value
    if(l==ql && r==qr)
        return tree[v];
    int mid=(l+r)/2;
    return merge(query(2*v,l,mid,ql,min(qr,mid)),
                 query(2*v+1,mid+1,r,max(ql,mid+1),qr));
}
void update(int v,int l,int r,int idx,int val){
    // call v=1,l=0,r=n-1 to update idx to val
    if(l==r){
        // may want to update a
        tree[v]+=val;
    } else {
        int mid=(l+r)/2;
        if(idx<=mid) update(2*v,l,mid,idx,val);
        else update(2*v+1,mid+1,r,idx,val);
        tree[v]=merge(tree[2*v],tree[2*v+1]);
    }
}

int main(int argc, const char * argv[]) {
#ifdef local_test
    //    input
    //    freopen("input","w",stdout);
    //    cout<<"1 \n 100 10 \n";
     freopen("input","r",stdin);
     freopen("output","w",stdout);
#endif
    int n,m;
    cin>>n>>m;
    F(i,0,n) a[i]=0;
    build(1,0,n-1);
    F(i,0,m){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            a[x-1]+=y;
            update(1,0,n-1,x-1,y);
        } else {
            cout<<query(1,0,n-1,x-1,y-1)<<"\n";
        }
    }
}

Measured memory_bytes: 5884
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	while (1 <= (a && b && c) && (a && b && c) <= 10000)
	{
		if ((a+b) < (a+c) && (a+b) < (b+c))
			cout << a+b ;
		if ( (a+c) < (a+b) && (a+c) < (b+c) )
			cout << a+c ;
		if ((b+c) < (a+b) && (b+c) < (a+c))
			cout << b+c ;
		if ((a + b) && (a + c) == (b + c))
			cout << a + b ;
		break;
	}
	return 0; 
}

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

int main() {
	string S;
	cin >> S;
	int a = 0;
	int b = 0;
	int c = S.length();
	if (S[0] != 'A') {
		cout << "WA" << endl;
	}
	else {
		if (S[1] < 97 || S[1] > 122) {
			cout << "WA" << endl;
		}
		else {
			for (int j = 2; j < (int)S.length() - 1; j++) {
				
					if (S[j] == 'C') {
						a = a + 1;
						c = j;
					}
				
			}
			if (a == 0 || a > 1) {
				cout << "WA" << endl;
			}
			else {
				for (int i = 2; i < c; i++) {
					if ((S[i] < 97 || S[i] > 122)) {
						b = b + 1;
						break;
					}
				}
				for (int k = c + 1; k < S.length(); k++) {
					if ((S[k] < 97 || S[k] > 122)) {
						b = b + 1;
						break;
					}
				}
					if (b >= 1) {
						cout << "WA" << endl;
					}
					else {
						cout << "AC" << endl;
					}
			}
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#define swap(type, x, y)  do{ type t = x; x = y; y = t; }while(0)

void quick(int array[], int left, int right){
  int pl = left,  pr = right;
  int x = array[(left + right) / 2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n, k;  scanf("%d %d", &n, &k);
  int a[200005];
  for(int i=0; i<n; i++)
    scanf("%d", a+i);
  quick(a, 0, n-1);
  
  int count[200005] = {0};
  int num[200005] = {0};
  int len = 0;

  int onecount = 1;
  for(int i=0; i<n-1; i++){
    if(a[i] != a[i+1]){
      count[len++] = onecount;
      onecount = 1;
    }else{
      onecount++;
    }
  }
  count[len++] = onecount;
  quick(count, 0, len-1);
  int ans = 0;
  for(int i=0; i<len-k; i++){
    ans += count[i];
  }

  printf("%d\n", ans);
  return 0;
}





Measured memory_bytes: 1664
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std ;

int main(void){
    int N, res=0;

    cin >> N;
    int B[N-1];

    for(int i=0; i<N-1; i++){
        cin >> B[i];
    }

    for(int i=0; i<N; i++){
       if(i==0) res += B[0];
       else if(i==N-1) res += B[N-2];
       else{
           if(B[i-1] < B[i]) res += B[i-1];
           else res += B[i];
       }
    }
    cout << res << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 && i % 5) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdint>
#include <cmath>

using namespace std;

constexpr int limit = 1'000'000'007;
constexpr int exp_max = 29;

int main() {
    int m, n;
    scanf("%d %d", &m, &n);

    int64_t res = m;
    int64_t m_exp[exp_max];
    m_exp[0] = m;
    int count = 1;
    int i;
    double sup = log(n) / log(2);
    for (i = 1; i <= sup; i++) {
        res *= res;
        res = res % limit;
        m_exp[i] = res;
        count *= 2;
        //printf("%d %lld %d\n", i, res, count); fflush(stdout);
    }
    for (int j = i-2; count < n; j--) {
        if (n - count < pow(2,j)) { continue; }
        res *= m_exp[j];
        res = res % limit;
        count += pow(2,j);
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int N, M;
  ll X;
  cin >> N >> M >> X;
  vector<ll> clist(12);
  vector<vector<ll>> Alist(12, vector<ll>(12));
  for (int i = 0; i < N; i++) {
    ll C;
    cin >> C;
    clist.at(i) = C;
    for (int j = 0; j < M; j++) {
      ll A;
      cin >> A;
      Alist.at(i).at(j) = A;
    }
  }
  
  ll ans=99999999;
  
  for (int tmp = 0; tmp < (1 << 12); tmp++) {
    bitset<12> s(tmp);
    vector<ll> rlist(M);
    ll sum=0;
    for (int i = 0; i<N; i++) {
      if (s.test(i)) {
        for (int j = 0; j<M; j++) {
          rlist.at(j) += Alist.at(i).at(j);
        }
        sum += clist.at(i);
      }
    }
    
    int jud=0;
    for (int j = 0; j < M; j++) {
      if (rlist.at(j)<X) jud++;
    }
    if (jud>0) continue;
    else {
      ans = min(ans, sum);
    }
  }
  
  if (ans==99999999) cout << -1 << endl;
  else cout << ans << endl;
    
      

}

Measured memory_bytes: 3572
import numpy as np
if __name__ == '__main__':
	N = int(input())
	P = np.array(list(map(int, input().split())))
	Tr = np.array([i+1 for i in range(N)])
	ans = Tr - P
	ans = N - np.count_nonzero(ans == 0)
	if ans == 2 or ans == 0:
		print('YES')
	else:
		print('NO')

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

int gcd(int a, int b){
    int r= a%b;
    while(r>0){
        a=b;
        b=r;
        r=a%b;
    }
    return(b);
}

int main() {
    int K;
    cin >> K;
    int sum=0;
    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            for(int c=1; c<=K; c++){
                sum += gcd(a, gcd(b,c));
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
s = int(input())
if s == 1 or s== 2:
    print(4)
else:
    count = 1
    while s != 1:
        if s % 2 == 0:
            s /= 2
        else:
            s = 3*s + 1
        count += 1
    print(count + 1)

Measured memory_bytes: 2940
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,M = inpl()
lines = defaultdict(set)

for _ in range(M):
	a,b,c = inpl()
	a,b = a-1,b-1
	lines[a].add((b,-c))

def BellmanFord(Start,Goal):
	Costs=[INF]*N
	Costs[Start] = 0
	upd8s = [True]*N
	for i in range(N): #N回ループ(高々N-1回で収束する)
		#will_upd8s = [False]*N
		upd8 = False
		for s in range(N):
			#if not upd8s[i]: continue	#前回更新してないので見ない
			for t,c in lines[s]:
				if c + Costs[s] < Costs[t]:
					Costs[t] = Costs[s]+c
					upd8 = True
					#will_upd8s[t] = True #更新した点だけ次に見る

		#upd8s = will_upd8s[:]
		if not upd8:
			return Costs[Goal] #なにも更新しなかったら終わり
	else: #負回路の検出(もうN回)
		pc = Costs[Goal]
		for i in range(N):
			upd8 = True
			for s in range(N):
				for t,c in lines[s]:
					if c + Costs[s] < Costs[t]:
						Costs[t] = Costs[s]+c
						upd8 = True
			if not upd8: break

		if pc != Costs[Goal]:
			return -INF
		else:
			return Costs[Goal]

print(-BellmanFord(0,N-1))


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


int main()
{
	int n;
	cin >> n;
	long long maxp = -1000000000, r, min;
	cin >> r;
	min = r;

	for (int i = 0;i < n - 1;i++) {
		cin >> r;

		if (r - min > maxp) {
			maxp = r - min;
		}

		if (r < min) {
			min = r;
		}
	}

	cout << maxp << endl;
    return 0;
}



Measured memory_bytes: 3096
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List
import Data.Ord

readIntLines :: IO [Int]
readIntLines = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

solve :: [Int] -> [Int] -> [Int]
solve [] _ = []
solve (a:as) list@(s1:s2:ss) = res : solve as list
  where res = if a /= s1 then s1 else s2

main :: IO ()
main = do
  getLine
  as <- readIntLines
  let sorted = sortOn Down as
  mapM_ print $ solve as sorted

Measured memory_bytes: 56316
$debug = false
$flag = false
$count = 0

def func(array, answer)
  $count += 1
  # p array if $debug
  # p answer if $debug

  return if $flag

  if array.empty?
    # arrayが空になった = 操作手順が完成した
    puts "Yay!" if $debug
    puts answer.reverse
    $flag = true
  else
    # arrayが空ではない = 操作を探す
    (array.size-1).step(0, -1) do |k|
      break if $flag
      # 大きい方から見ていって、適合するポイントがあれば再起で放り投げる
      if array[k] == k+1
        next_array = array.dup
        next_array.delete_at(k)
        func(next_array, answer+[k+1])
      end
    end
  end
end

_N = gets.to_i
bs = gets.split.map(&:to_i)

# 先にチェック。n番目にnよりも大きな数字があったら成立せず。
0.step(bs.size - 1, 1) do |n|
  if bs[n] > n + 1
    puts "-1"
    $flag = true
    break
  end
end

# メイン処理。前のチェックでNGで終了フラグが立ってる場合には実行せず。
func(bs, []) unless $flag

# メイン処理を行っても終了フラグが立っていないならダメだったってこと。
puts "-1" unless $flag

puts "count: #{$count}" if $debug


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

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

int main(){
    string S, T;
    cin >> S >> T;
    bool is = true;
    int s = (int)S.size();
    int t = (int)T.size();
    if(t != s + 1) is = false;
    T.erase(t-1);
    if(S != T) is = false;
    if(is) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
import itertools


def main():
    N = int(input())
    d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    for _ in range(N):
        S = input()
        if S[0] in d:
            d[S[0]] += 1
    print(sum(d[a] * d[b] * d[c]
              for a, b, c in itertools.combinations(d.keys(), 3)))


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n,d;cin >> n >> d;
    cout << (n+2*d)/(2*d+1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val a = new Array[Int](M+1)
  val b = new Array[Int](M+1)
  val c = Array.ofDim[Int](M+1, N+1)
  for (i <- 1 to M) {
    val _a, _b = in.next().toInt
    a(i) = _a; b(i) = _b
    for (k <- 1 to _b) {
      c(i)(k) = in.next().toInt
    }
  }


  //
  def toKey(lst: Array[Boolean]): Int = {
    var res = 0
    for (i <- 1 to N) {
      if(lst(i)) {
        res += 1 << (i-1)
      }
    }
    res
  }

  def toArray(key: Int): Array[Boolean] = {
    val res = new Array[Boolean](N+1)
    res(0) = true

    var i = 1
    var k = key
    while (k > 0) {
      if(k%2 == 1)
        res(i) = true
      k /= 2
      i += 1
    }

    res
  }

  //var hash = Map[String, Int]() // (opened, price)
  val imax = Int.MaxValue
  var hash = Array.fill[Int](1<<N)(imax)
  hash(0) = 0
  var set = Set[Int](0)


  for (i <- 1 to M) {
    val nextHash = hash.clone

    for (opened <- set) {
      val price = hash(opened)

      val hoge = toArray(opened)
      for (k <- 1 to b(i)) {
        val ind = c(i)(k)
        if(!hoge(ind))
          hoge(ind) = true
      }
      val key = toKey(hoge)
      if (hash(key) == imax)
        set += key

      val nowPrice = price + a(i)

      if (nowPrice < nextHash(key)) {
        nextHash(key) = nowPrice
      }

    }

    hash = nextHash
  }
  
  
  var ans = -1
  val k = (1<<N) - 1
  if(hash(k) != imax)
    ans = hash(k)

//  println(hash.deep)
  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main() {
  int N,K;
  cin>>N>>K;
  int a[60];
  int l=0;
  for(int i=0;i<N;++i){cin>>a[i];}
  sort(a,a+N,greater<int>());
  for(int i=0;i<K;i++){
      l+=a[i];
  }
  cout<<l<<endl;
}


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

int bubbleSort(int A[], int N){

    int sw = 0;

    for(int i=0; i<N-1; i++){
        for(int j=N-1; j>i; j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                sw++;
            }
        }
    }
    return sw;
}

int main(){

    int A[110],N,sw;

    cin>>N;
    for(int i=0; i<N; i++)cin>>A[i];

    sw = bubbleSort(A,N);

    for(int i=0; i<N-1; i++)cout<<A[i]<<' ';
    cout<<A[N-1]<<endl;
    cout<<sw<<endl;

    return 0;
}



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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if ( a >= 13 ){
    cout << b << endl;
  }else if ( a < 13 && a >= 6 ){
    cout << b / 2 << endl;
  }else{
    cout << 0 << endl;
  }
  
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
  
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> sum(n,0);
  rep(i,2*m){
    int inpt;
    cin >> inpt;
    sum.at(inpt-1)++;
  }
  rep(i,n){
    cout << sum.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 200003, M = N << 2, INF = 0x3f3f3f3f;
int n, S, T, head[N], to[M], nxt[M], w[M], dep[N], cur[N], q[N], f, r, ans[2][N], m;
bool vis[N];
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    for(;ch < '0' || ch > '9';ch = getchar());
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
}
inline void add(int a, int b, int c){
    static int cnt = 1;
    to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt; w[cnt] = c;
    to[++ cnt] = a; nxt[cnt] = head[b]; head[b] = cnt; w[cnt] = 0;
}
inline bool bfs(){
    memset(dep, -1, sizeof dep);
    memcpy(cur, head, sizeof cur);
    dep[S] = f = r = 0; q[r ++] = S;
    while(f < r){
        int u = q[f ++];
        for(Rint i = head[u];i;i = nxt[i])
            if(dep[to[i]] == -1 && w[i]){
                dep[to[i]] = dep[u] + 1; q[r ++] = to[i];
            }
    }
    return ~dep[T];
}
inline int dfs(int x, int lim){
    if(!lim || x == T) return lim;
    int flow = 0, f;
    for(Rint i = cur[x];i;i = nxt[i]){
        cur[x] = i;
        if(dep[to[i]] == dep[x] + 1 && (f = dfs(to[i], min(lim, w[i])))){
            flow += f; lim -= f; w[i] -= f; w[i ^ 1] += f;
            if(!lim) break;
        }
    }
    return flow;
}
inline int dinic(){
    int ans = 0;
    while(bfs()) ans += dfs(S, INF);
    return ans;
}
inline void dfs(int x){
    for(Rint i = head[x];i;i = nxt[i]) if(to[i] != S && !vis[to[i] - n]){
        int u = to[i] - n; vis[u] = true;
        for(Rint j = head[to[i]];j;j = nxt[j]) if(w[j]){
            ++ m; ans[0][u] = x; ans[1][u] = to[j]; dfs(to[j]); break;
        }
    }
}
int main(){
    read(n); S = n << 1; T = S + 1;
    for(Rint i = 1;i <= n;++ i) add(S, i, 1);
    for(Rint i = 1, x, u;i < n;++ i){
        read(x); add(n + i, T, 1);
        while(x --){read(u); add(u, n + i, 1);}
    }
    if(dinic() != n - 1) return puts("-1"), 0;
    for(Rint i = head[S];i;i = nxt[i]) if(w[i]){dfs(to[i]); break;}
    if(m != n - 1) return puts("-1"), 0;
    for(Rint i = 1;i < n;++ i) printf("%d %d\n", ans[0][i], ans[1][i]);
}

Measured memory_bytes: 16384
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
// struct UnionFind {
//     vector<int> par;

//     UnionFind(int n) : par(n, -1) {}
//     void init(int n) {
//         par.assign(n, -1);
//     }
//     int root(int x) {
//         if (par[x] < 0) return x;
//         else return par[x] = root(par[x]);
//     }
//     bool is_same(int x, int y) {
//         return root(x) == root(y);
//     }
//     bool merge(int x, int y) {
//         x = root(x); y = root(y);
//         if (x == y) return false;
//         if (par[x] > par[y]) swap(x, y);
//         par[x] += par[y];
//         par[y] = x;
//         return true;
//     }
//     int size(int x) {
//         return -par[root(x)];
//     }
// };
int main() {
    LL n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind uf(n);
    LL cur = n * (n - 1) / 2;
    vector<LL> res;
    rep(i, m) {
        res.push_back(cur);

        int x = a[m - 1 - i]; int y = b[m - 1 - i];
        if (uf.is_same(x, y)) continue;

        LL sa = uf.size(x); LL sb = uf.size(y);
        cur -= sa * sb;
        uf.merge(x, y);
    }
    reverse(res.begin(), res.end());
    for (auto x : res) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

int main() {
	ll x; cin >> x;
	if (x <= 6) {
		cout << 1 << endl;
		return 0;
	}
	if (x <= 11) {
		cout << 2 << endl;
		return 0;
	}
	ll rem = x - (x / 11)*11;
	ll cnt = (x / 11)*2;
	if (rem == 0) {
		cout << cnt << endl;
		return 0;
	}
	if(1<=rem&&rem<=6){
		cout << cnt + 1 << endl;
		return 0;
	}
	else {
		cout << cnt + 2 << endl;
		return 0;
	}
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

struct Edge{
	int to;
	int cost;
	int time, com;
	Edge(int to, int cost, int time, int com) : to(to), cost(cost), time(time), com(com) {}
};

struct Node{
	int dis;
	bool used;
	Node() : dis(INF), used(false) { }
	Node(int d, bool f) : dis(d), used(f) { }
};


typedef vector<vector<Edge>> graph;
typedef tuple<int,int,int> T;

int dijkstra(graph g, int s, int t, int n, int k, int bit){
	vector<vector<Node>> node(n, vector<Node>(25));
	priority_queue<int, vector<T>, greater<T>> q;

	q.push(T(0, 0, s));
	node[s][0] = Node{0, true};

	while(not q.empty()){
		int dis, t, pos;
		tie(dis, t, pos) = q.top(); q.pop();
		node[pos][t].used = true;

		for(auto e : g[pos]){
			if((bit >> e.com) & 1){
                //cout <<"asdf  " <<  bit << " " << e.com <<endl;
				 e.cost = 0;
			}
            if(t + e.time > k) continue;
            int nt = t + e.time;
			if(node[e.to][nt].used == true) continue;
			if(node[e.to][nt].dis > dis + e.cost){
				node[e.to][nt].dis = dis + e.cost;
				q.emplace(node[e.to][nt].dis, nt, e.to);
			}
		}
	}

	//show("s");
	//for(auto i : node){ for(auto j : i){ cout << j.dis << ' '; } cout << endl; }

    int mini = INF;
    rep(i,k + 1) {
        mini = min(mini, node[t][i].dis);
    }
	return mini;
}

int main(){
	int n, m, h, k;
	while(cin >> n >> m >> h >> k,n) {

		graph g(n);
		rep(i, m) {
			int a, b, c, h, r;
			cin >> a >> b >> c >> h >> r;
			a--;
			b--;
            r--;
			g[a].emplace_back(Edge{b, c, h, r});
			g[b].emplace_back(Edge{a, c, h, r});
		}
		int s, t;
		cin >> s >> t;
		s--;
		t--;

		int p;
		cin >> p;
		vector<int> ticket(p), d(p);
		rep(i, p) {
			int l;
			cin >> l >> d[i];
			rep(j, l) {
				int k;
				cin >> k;
				k--;
				ticket[i] |= 1 << k;
			}
		}

		vector<int> dp(1 << k, INF);
		dp[0] = 0;
		rep(i, 1 << k) {
			if (dp[i] == INF) continue;
			rep(j, p) {
				dp[i bitor ticket[j]] = min(dp[i bitor ticket[j]], dp[i] + d[j]);
			}
		}

		int ans = INF;
		rep(i, 1 << k){
			if(dp[i] == INF) continue;
            //cout << i << " " << dp[i] << endl;
			ans = min(ans, dijkstra(g, s, t, n, h, i) + dp[i]);
		}

		cout << (ans == INF ? -1 : ans)  << endl;
	}
}



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

int main(void){
    int n;
    cin >> n;
    ll sum = 0;
    map<ll, int> cnt;
    rep(i,n){
        ll a;
        cin >> a;
        sum += a;
        cnt[a]++;
    }
    int Q;
    cin >> Q;
    rep(q,Q){
        ll b, c;
        cin >> b >> c;
        sum = sum - b*cnt[b] + c*cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


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

int main() {
  uint32_t N = 0, W = 0;
  std::cin >> N >> W;

  // v_i, w_i pair
  std::vector<std::pair<uint32_t, uint32_t>> products(N + 1);
  products[0] = std::pair<uint32_t, uint32_t>(0, 0);
  for (size_t n = 1; n < N + 1; n++) {
    std::cin >> products[n].first >> products[n].second;
  }

  std::vector<std::vector<uint32_t>> status(W + 1);
  status[0] = std::vector<uint32_t>(N + 1, 0);  // initial states
  for (size_t w = 1; w < W + 1; w++) {
    status[w] = std::vector<uint32_t>(N + 1, 0);
    for (size_t n = 1; n < N + 1; n++) {
      auto p_n = products[n];
      if (w < p_n.second) {               // 重み制約満たさない
        status[w][n] = status[w][n - 1];  // nを選択しない
      } else {
        // nを選択しない中で、重み制約をピッタリ満たすものを参照
        uint32_t update = status[w - p_n.second][n - 1] + p_n.first;
        status[w][n] = std::max(update, status[w][n - 1]);
      }
    }
  }

  std::cout << status[W][N] << std::endl;

  return 0;
}


Measured memory_bytes: 7068
#include<iostream>
#include<string>
using namespace std;
 
int main(){
int n,a[53];
int hantei[53];
char b[53];
 
for(int i=1;i<53;i++){
hantei[i]=0;
}
 
cin>>n;
 
for(int i=1;i<=n;i++){
cin>>b[i]>>a[i];
 
if(b[i]=='S'){
hantei[0+a[i]]=1;
}
 
if(b[i]=='H'){
hantei[13+a[i]]=1;
}
 
if(b[i]=='C'){
hantei[26+a[i]]=1;
}
 
if(b[i]=='D'){
hantei[39+a[i]]=1;
}
 
}
 
for(int i=1;i<53;i++){
if(hantei[i]==0){
 
if(i<=13){
cout<<"S "<<(i-1)%13+1<<endl;
}
 
else if(i<=26){
cout<<"H "<<(i-1)%13+1<<endl;
}
 
else if(i<=39){
cout<<"C "<<(i-1)%13+1<<endl;
}
 
else if(i<=52){
cout<<"D "<<(i-1)%13+1<<endl;
}
 
}
}
 
return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 11;

int n, m;
int x[20][20];
int sx, sy;
int ans;

void dfs(int a, int b, int k){
	if(k >= ans){
		return;
	}

	int dx[] = {-1, 0, 0, 1};
	int dy[] = {0, -1, 1, 0};
	rep(i, 4){
		int p = a;
		int q = b;
		
		int r = p + dx[i];
		int s = q + dy[i];
		if(0 <= r && r < n && 0 <= s && s < m && x[r][s] == 1){
			continue;
		}	

		while(true){
			p += dx[i];
			q += dy[i];
			if(0 <= p && p < n && 0 <= q && q < m){
				if(x[p][q] == 3){
					ans = min(k, ans);
					break;
				}
				else if(x[p][q] == 1){
					x[p][q] = 0;
					dfs(p - dx[i], q - dy[i], k + 1);
					x[p][q] = 1;
					break;
				}
			}
			else{
				break;
			}
		}
	}
}

int main(){
	while(scanf("%d%d", &m, &n), n){
		rep(i, n){
			rep(j, m){
				scanf("%d", &x[i][j]);
				if(x[i][j] == 2){
					sx = i;
					sy = j;
				}
			}
		}
		ans = inf;
		dfs(sx, sy, 1);
		printf("%d\n", ans != inf ? ans : -1);
	}
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll H, W, h, w; cin >> H >> W >> h >> w;
  ll tmp = INF / (h * w) - 1;
  vvll ans(H, vll(W, tmp));
  ll su = H * W * tmp;
  for(int i=h-1;i<H;i += h) {
    for(int j=w-1;j<W;j += w) {
      //cout << "A" << endl;
      ans[i][j] = - (h * w - 1) * tmp - 1;
      //ans[i][j] = -1;
      su -= (h * w - 1) * tmp + 1 + tmp;
    }
  }
  //cout << su << endl;

  if(su <= 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for(int i=0;i<H;++i) {
      printv(ans[i]);
    }
  }
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}

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

  int n; cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec[i];

  vector<int> gcdL(n), gcdR(n);
  gcdL[0] = vec[0];
  gcdR[n-1] = vec[n-1];
  for(int i = 1; i < n; ++i) gcdL[i] = gcd(gcdL[i-1], vec[i]);
  for(int i = n-2; i > 0; --i) gcdR[i] = gcd(gcdR[i+1], vec[i]);

  int ans = 0;
  for(int i = 1; i < n-1; ++i) ans = max(ans, gcd(gcdL[i-1], gcdR[i+1]));
  int m = max(gcdL[n-2], gcdR[1]);
  ans = max(ans, m);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1408