akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(123456789)
#define LINF (long long int)(123456789012345678)
#define MAX_V 1000


int main(void){
	int N, W;	cin >> N >> W;
	vector<int> w(N), v(N);
	rep(i,N){
		cin >> w[i] >> v[i];
	}

	vector< vector<ll> > dp;
	rep(i, N+1){
		dp.push_back(vector<ll>());
		rep(j,W+1){
			dp[i].push_back(0);
		}
	}

	rep(i,N){
		reps(sum_w, W){
			if(sum_w < w[i]){
				dp[i+1][sum_w] = dp[i][sum_w];
			}else{
				dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]]+v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}


Measured memory_bytes: 80240
n = int(input())
a_list = list(map(int, input().split()))

swap_count = 0
for i in range(0, n):
    for j in reversed(range(i + 1, n)):
        if a_list[j - 1] > a_list[j]:
            temp = a_list[j]
            a_list[j] = a_list[j - 1]
            a_list[j - 1] = temp
            swap_count = swap_count + 1

print(' '.join(map(str, a_list)))
print(swap_count)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  string s;
  cin>>N>>s;
  ll cnt(1LL);
  for (int i(0);i<2*N;i++){
    if (i%2==0) {
      if (s[i]=='W') s[i]='B';
      else if (s[i]=='B') s[i]='W';
    }
  }
  ll cw(0LL);
  for (int i(0);i<N*2;i++){
    if (s[i]=='W'){
      cw+=1;
    } else {
      cnt*=cw;
      cw--;
      cnt%=mod;
    }
  }
  if (cw!=0) {
    cout << 0 << endl;
    return 0;
  }
  //cout << cnt << endl;
  ll p(1);
  for (int i(1);i<=N;i++){
    p*=i;
    p%=mod;
  }
  cout << (cnt*p)%mod << endl;
  return 0;
}



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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  int i;
  bool x  = false;
  for(i=A;i<=B;i++){
    if(i%K==0){
      x = 1;
      break;
    }
  }
  if(x == true){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
    char s[5];
    scanf("%s",s);

    int n[2];
    n[0] = (s[0] - '0') * 10 + (s[1] - '0');
    n[1] = (s[2] - '0') * 10 + (s[3] - '0');

    int f[2] = {0};
    
    if (1 <= n[0] && n[0] <= 12)
    {
        f[0] = 1;
    }
    if (1 <= n[1] && n[1] <= 12)
    {
        f[1] = 1;
    }

    if (f[0] == 1 && f[1] == 0)
    {
        printf("MMYY");
    }
    else if(f[0] == 1 && f[1] == 1)
    {
        printf("AMBIGUOUS");
    }
    else if (f[0] == 0 && f[1] == 1)
    {
        printf("YYMM");
    }
    else
    {
        printf("NA");
    }
    
    
}

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

int main() {
    long long int n;
    cin>>n;
    int ans=1;
    for (int k = 2; k <= floor(sqrt(n)); k++){
        long long int tmp=n;
        while (1)
        {
            if(tmp%k==0)tmp/=k;
            else break;
        }
        if(tmp<n&&tmp%k==1) ans++;
    }
    int old_k=2;;
    long long int tmp=n-1;
    int count=0;
    int num_of_factors=1;
    for (int k = 2; k <= floor(sqrt(n-1));){
        if(tmp==1)break;
        if(tmp%k==0&&old_k==k){
            tmp/=k;
            count++;
        }
        else if(tmp%k==0){
            num_of_factors*=count+1;
            tmp/=k;
            count=1;
            old_k=k;
        }else{
            k++;
            num_of_factors*=count+1;
            count=0;
        }
    }
    num_of_factors*=count+1;
    if(tmp>1)num_of_factors*=2;
    ans+=num_of_factors-1;
    cout << ans<<endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int overlap = 0;
		Set<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			if(set.contains(tmp)) {
				overlap++;
			}
			set.add(tmp);
		}
		int ans = 0;
		if(overlap % 2 == 0) {
			ans = n - overlap;
		} else {
			ans = n - overlap - 1;
		}
		System.out.println(ans);
	}

}


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

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(solve(s[0],s[1],s[2]));
    }
    static int solve(int x, int y, int z) {
        x -= z;
        return x/(y+z);
    }
}

Measured memory_bytes: 13268
N , A , B , C = map(int , input().split())
l = []
Takesakusen = []

for n in range(N):
	l.append(int(input()))

m = 4
K = 4**N-1

a = 0
b = 0
c = 0
jointmagic = 0
magic = 2**20

def dec(m , k):
	k_m = []
	for count in range(N-1):
		k_m.append(k%m)
		k = k // m
	k_m.append(k)
	return(k_m)

for k in range(K):
	Takesakusen.append(dec(m , k))
#print(Takesakusen)

for T in Takesakusen:
	if 1 in T and 2 in T and 3 in T:
		for s in range(N):
			if T[s] == 1:
				a += l[s]
				jointmagic += 10
			if T[s] == 2:
				b += l[s]
				jointmagic += 10
			if T[s] == 3:
				c += l[s]
				jointmagic += 10
		if magic > abs(a - A) + abs(b - B) + abs(c - C) + jointmagic - 30 :
			magic = abs(a - A) + abs(b - B) + abs(c - C) + jointmagic - 30
#		print("T =" + str(T) )
#		print("a = " + str(a))
#		print("b = " + str(b))
#		print("c = " + str(c)	)
#		print(abs(a - A) + abs(b - B) + abs(c - C) + jointmagic - 30)
#		print("magic =" + str(magic))


	a = 0
	b = 0
	c = 0
	jointmagic = 0

print(magic)




Measured memory_bytes: 14836
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

h,w = map(int,input().split())
dp = [[0]*(w+1) for i in range(h+1)]
a = list(input() for _ in range(h))
dp[0][0] = 1
#配るDP
for i in range(h):
    for j in range(w):
        if i+1 < h and a[i+1][j] ==".":
            dp[i+1][j] =(dp[i+1][j] + dp[i][j])%mod
        if j+1 < w and a[i][j+1] ==".":
            dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod
print(dp[h-1][w-1])


Measured memory_bytes: 53360
package main

import "fmt"

func main() {
	var N, a int
	fmt.Scan(&N)

	colors := [8]bool{}
	numOver := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if a >= 3200 {
			numOver++
		} else {
			colors[a/400] = true
		}
	}

	numUnder := 0
	for _, color := range colors {
		if color {
			numUnder++
		}
	}

	min, max := numUnder, numUnder+numOver
	if numUnder == 0 {
		min = 1
	}
	fmt.Println(min, max)
}


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

struct Node {
    int left;
    int right;
    int parent;
};
Node tree[25];

int searchRoot(int n, Node a[]) {
    int i;
    for (i = 0; i < n; i++) {
        if (a[i].parent == i) break;
    }
    return i;
}
void Preparse(int u) {
    if (u == -1) return;
    cout << " " << u;
    Preparse(tree[u].left);
    Preparse(tree[u].right);
}
void Inparse(int u) {
    if (u == -1) return;
    Inparse(tree[u].left);
    cout << " " << u;
    Inparse(tree[u].right);
}
void Postparse(int u) {
    if (u == -1) return;
    Postparse(tree[u].left);
    Postparse(tree[u].right);
    cout << " " << u;
}
int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        tree[i].parent = i;
        tree[i].left = -1;
        tree[i].right = -1;
    }
    int id, left, right;
    for (int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        tree[id].left = left;
        tree[id].right = right;
        tree[left].parent = id;
        tree[right].parent = id;
    }
    int tmp = searchRoot(n, tree);
    cout << "Preorder" << endl;
    Preparse(tmp);
    cout << endl;
    cout << "Inorder" << endl;
    Inparse(tmp);
    cout << endl;
    cout << "Postorder" << endl;
    Postparse(tmp);
    cout << endl;

    return 0;
}



Measured memory_bytes: 3088
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;


void main()
{
    readln();
    auto aList = readln().split.to!(int[]).sort();
    readln();
    int[] qList = readln().split.to!(int[]);

    foreach(q; qList)
    {
        bool func(Range)(int m, Range list)
        {
            if(m == 0)
            {
                return true;
            }
            if(m < 0)
            {
                return false;
            }
            if(list.length == 0)
            {
                return false;
            }
            return func(m, list[1..$]) || func(m-list[0], list[1..$]);
        }
        writeln(func(q, aList)?"yes":"no");
    }
}


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

int main(){
    int A,B,M;
    cin >> A >> B >> M;
    
    int a_min(1000000),b_min(1000000),a[A],b[B];
    for(int i=0;i<A;i++){
        cin >> a[i];
        a_min = min(a[i],a_min);
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
        b_min = min(b[i],b_min);
    }
    
    int ans = a_min + b_min;
    
    for(int i=0;i<M;i++){
        int x,y,c;
        cin >> x >> y >> c;
        
        ans = min(ans,a[x-1]+b[y-1]-c);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4412
n = int(input())
h = list(map(int,input().split()))
h[0] -= 1
for i in range(n-1):
    if h[i+1] > h[i]:
        h[i+1] -= 1
    if h[i] > h[i+1]:
        print('No')
        exit()
print('Yes')


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

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

  long long x = 1, y = 1;
  for(int i = 0; i < N; i++) {
    int T, A;
    cin >> T >> A;
    long long g = max((y + A - 1) / A, (x + T - 1) / T);
    x = g * T;
    y = g * A;
  }
  cout << x + y << endl;
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,m,s,c;
  set<int> a;

  bool ans = true;
  cin >> n >> m;
  vector<int> num(n,-1);
  rep(i,m){
    cin >> s >> c;
    if(num.at(s-1)!=-1 && num.at(s-1)!=c) ans = false;
    else{ 
      num.at(s-1)=c;
    }
  }
  if(num.at(0)==0 && n!=1) ans=false;
  if(ans){
    rep(i,n){ 
      if(num.at(i)!=-1)cout << num.at(i);
      else if(i==0 && n!=1) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  else cout << -1 <<endl;
}


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

int main() {
	int N;
    cin >> N;
	vector<int> kagamimochi(N);
    for(int i = 0; i < N; i++){
    	cin >> kagamimochi.at(i);
    }
    int Max , Count;
    Count = 0;
    for(int i = 0; i < N; i++){
    	Max = kagamimochi.at(i);
        for(int j = 0; j < N; j++){
        	if(Max < kagamimochi.at(j)){
            	Max = kagamimochi.at(j);
            }
        }
        if(Max == 0){
        	break;
        }
        for(int k = 0; k < N; k++){
        	if(kagamimochi.at(k) == Max){
            	kagamimochi.at(k) = 0;
            }
        }
        Count++;
    }
  	cout << Count << endl;
}

Measured memory_bytes: 3584
'''
Author : Shubhanshu Jain;
'''

import math
import random;
from collections import defaultdict 
mod =1000000007
r1 = lambda : int(input());
rm = lambda : map(int,input().split());
rms = lambda : map(str,input().split());
rls = lambda : list(rm())

def solve():
    a,l = rm();
    if(a*4>=l and a*2<=l and l%2==0):
        print("Yes");
    else:
        print("No")
        
        





def def_value(): 
	return "nan"
	
solve();



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x, y, red[100000] = {1}, balls[100000] = {};
    cin >> n >> m;
    for (int k = 0; k < n; ++k) balls[k] = 1;
    for (int k = 0; k < m; ++k) {
        cin >> x >> y;
        --x;
        --y;
        if (red[x]) {
            if (balls[x] == 1) red[x] = 0;
            red[y] = 1;
        }
        balls[x] -= 1;
        balls[y] += 1;
    }
    int ans = 0;
    for (int k = 0; k < n; ++k) {
        if (red[k]) ++ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

ll d;

int main() {
    cin >> d;
    cin >> n;
    if (n != 100)
        cout << (int)(pow(100, d) * n) << endl; 
    else
        cout << (int)pow(100, d) * 101 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int t[1001]={0},p[1000]={0};
int main(){
int i,j,a,b,n,l,g,c;
cin>>n>>a>>b>>c;
for(i=1;i<=n;i++)cin>>t[i];
for(i=1;i<=n;i++){
	for(j=i+1;j<=n;j++){
		if(t[i]<t[j]){
			l=t[j];
			t[j]=t[i];
			t[i]=l;
		}
	}
}
p[0]=c/a;
g=c;
for(i=1;i<=n;i++){
	g=g+t[i];
	p[i]=max(p[i-1],g/(a+b*i));
}
cout<<p[n]<<endl;
return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	if(a[1]>=0){
		int tmp=a[1];
		for(int i=2;i<=n-1;i++){
			tmp-=a[i];
		}
		cout<<a[n]-tmp<<endl;
		tmp=a[1];
		for(int i=2;i<=n-1;i++){
			cout<<tmp<<' '<<a[i]<<endl;
			tmp-=a[i];
		}
		cout<<a[n]<<' '<<tmp<<endl;
		return 0;
	}
	else if(a[n]<=0){
		int tmp=a[n];
		for(int i=2;i<=n-1;i++){
			tmp-=a[i];
		}
		cout<<tmp-a[1]<<endl;
		tmp=a[n];
		for(int i=2;i<=n-1;i++){
			cout<<tmp<<' '<<a[i]<<endl;
			tmp-=a[i];
		}
		cout<<tmp<<' '<<a[1]<<endl;
		return 0;
	}
	else{
		vector<int> pos,neg;
		for(int i=1;i<=n;i++){
			if(a[i]>=0)
				pos.push_back(a[i]);
			else
				neg.push_back(a[i]);
		}
		int tmp1=pos[0];
		int tmp2=neg[0];
		for(int i=1;i<neg.size();i++)
			tmp1-=neg[i];
		for(int i=1;i<pos.size();i++)
			tmp2-=pos[i];
		cout<<tmp1-tmp2<<endl;
		tmp1=pos[0];
		tmp2=neg[0];
		for(int i=1;i<neg.size();i++){
			cout<<tmp1<<' '<<neg[i]<<endl;
			tmp1-=neg[i];
		}
		for(int i=1;i<pos.size();i++){
			cout<<tmp2<<' '<<pos[i]<<endl;
			tmp2-=pos[i];
		}
		cout<<tmp1<<' '<<tmp2<<endl;
		return 0;
	}
}


Measured memory_bytes: 2808
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
 
int main () {
	int a=0;
	string W,T;
	cin >> W ;
	transform(W.begin(),W.end(),W.begin(), ::toupper);

	while(1){
		cin >> T;
		if(T=="END_OF_TEXT")break;
		transform(T.begin(),T.end(),T.begin(), ::toupper);

		if(T==W){
			a++;
		}
	}
	cout << a << endl;

	return 0;
}

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

using namespace std;

using ll = long long;

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

ll n, x;
vector<ll> a, mi;

ll calc(int pos)
{
  ll res = 0;
  rep(i, n) mi[i] = min(mi[i], a[(i+pos)%n]);
  rep(i, n) res+= mi[i];
  return res + pos * x;
}

int main()
{
  cin >> n >> x;
  rep(i, n) {
    ll t;
    cin >> t;
    a.push_back(t);
    mi.push_back(t);
  }
  ll res = LLONG_MAX;
  rep(i, n) {
    res = min(res, calc(i));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;



void solve(void){

  char a;
  std::cin >> a;

  if('A'<=a && a <= 'Z') std::cout << "A" << std::endl;
  else       std::cout << "a" << std::endl;
  
}

int main(void){

  solve();
  
  return 0;
}


Measured memory_bytes: 3588
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val line = Seq.fill(4)(sc.nextDouble)
    val (w, h, x, y) = (line(0), line(1), line(2), line(3))
    val maxArea = w * h / 2
    val isMulti = if (x == w / 2 && y == h / 2) 1 else 0
    println(s"$maxArea $isMulti")
  }
}

Measured memory_bytes: 27328
# -*- coding: utf-8 -*-
# E

from collections import Counter

N = int(input())
a = list(map(int, input().split()))

num = list(range(1, N+1))

l1 = [] * N
l2 = [] * N

for i in range(N):
    l1.append(a[i] - num[i])
    l2.append(-a[i] - num[i])

k = list(set(l1) & set(l2))
c1 = Counter(l1)
c2 = Counter(l2)

ans = 0
for k in k:
    ans += c1[k] * c2[k]

print(ans)

Measured memory_bytes: 209532
import java.io.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	static FastScanner sc = new FastScanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i=0; i<n; i++) {array[i] = sc.nextInt();}
		
		int m = sc.nextInt();
		int[] element = new int[m];
		for (int i=0; i<m; i++) {element[i] = sc.nextInt();}
		
		int num = 0, L, R, M;
		for (int i=0; i<m; i++) {
			L = 0;
			R = n;
			while (L < R) {
				M = (L+R)/2;
				if (array[M] == element[i]) {num++; break;}
				else if (array[M] > element[i]) {R = M;}
				else if (array[M] < element[i]) {L = M+1;}
			}
		}
		
		out.println(num);
	}
}



class FastScanner implements Closeable {
	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	public FastScanner(InputStream in) {this.in = in;}
	private boolean hasNextByte() {
		if (ptr < buflen) {return true;}
		else{
			ptr = 0;
			try {buflen = in.read(buffer);}
			catch (IOException e) {e.printStackTrace();}
			if (buflen <= 0) {return false;}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {throw new NumberFormatException();}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){return minus ? -n : n;}
			else{throw new NumberFormatException();}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
	public void close() {
		try {in.close();}
		catch (IOException e) {}
	}
}


Measured memory_bytes: 27404
//b
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

int n;
bool vacant[128][64] = {0};

int solve(){
	
	bool dp[128][128][64] = {0};
	
	for(ll i=0; i<n; ++i){
	
		dp[i][i][0] = true;
	}
	
	for(int d = 1; d <= 30; ++d){
		
		bool sum[128] = {false};
		
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
			
				dp[i][j][d] |= dp[i][j][d-1];
				
				if(vacant[i][d]){
					sum[j] |= dp[i][j][d-1];
				}
				
			}
		}
		
		for(int i=0; i<n; ++i){
			for(int j=0; j<n; ++j){
				if(vacant[i][d]){
					dp[i][j][d] |= sum[j];
				}
			}
		}
		
		for(int i=0; i<n; ++i){
			
			int cnt = 0;
			
			for(int j=0; j<n; ++j){	
				cnt += dp[i][j][d];
			}
			
			if(cnt == n)
				return d;
		}
		
	}
	
	return -1;
}

int main(){
	
	while(cin>>n, n){
			
		memset(vacant, false, sizeof(vacant));
			
		for(int i = 0; i < n; ++i){
			
			int d;
			cin >> d;
			
			for(int j = 0; j < d; ++j){
				int a;
				cin >> a;
				vacant[i][a] = true;
			}
		}
			
		cout << solve() << endl;
	}
	
	return 0;	
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF 1000000010

#define MAX_N 1000

int n,m;
vector<int> xs,ys,xss,yss;
int ks[5555][5555];
int res=0;

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	xs.pb(-INF); ys.pb(-INF);
	rep(i,n){
		int x,y;
		cin>>x>>y;
		xs.pb(x); ys.pb(y);
		xss.pb(x); yss.pb(y);
	}
	xs.pb(INF); ys.pb(INF);
	sort(all(xs)); sort(all(ys));
	uni(xs); uni(ys);
	rep(i,n){
		int ix=lower_bound(all(xs),xss[i])-xs.begin(),iy=lower_bound(all(ys),yss[i])-ys.begin();
		ks[ix][iy]++;
	}
	rep(i,5005)rep(j,5005){
		ks[i][j+1]+=ks[i][j];
	}
	rep(i,5005)rep(j,5005){
		ks[i+1][j]+=ks[i][j];
	}
	rep(i,m){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		int ix1=lower_bound(all(xs),x1)-xs.begin()-1,iy1=lower_bound(all(ys),y1)-ys.begin()-1;
		int ix2=upper_bound(all(xs),x2)-xs.begin()-1,iy2=upper_bound(all(ys),y2)-ys.begin()-1;
		//dbg(ix1); dbg(iy1);dbg(ix2); dbg(iy2);
		cout<<ks[ix2][iy2]-ks[ix1][iy2]-ks[ix2][iy1]+ks[ix1][iy1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 111924
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, a = 1;
  cin >> n;
  map<int, int> m;
  rep(i, n){
    if(i == 0) continue;
    else if(i == 1 || i == 2) m[i+1] = 1;
    else{
      int a = i+1;
      for(int j = 2; j <= pow(i+1, 0.5); ++j){
        int b = 0;
        while(a % j == 0){
          a /= j;
          ++b;
        }
        if(b != 0) m[j] += b;
        if(a == 1) break;
      }
      if(a != 1) m[a] += 1;
    }
  }
  for(auto p: m){
    int d = p.se;
    a *= d+1;
    a %= mod1;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define int long long

int max(int a, int b){
	return a >= b ? a : b;
}

signed main(){
	int aI, aO, aT, aJ, aL, aS, aZ, ans;
	scanf("%lld%lld%lld%lld%lld%lld%lld", &aI, &aO, &aT, &aJ, &aL, &aS, &aZ);
	ans = aO + (aI / 2) * 2 + (aJ / 2) * 2 + (aL / 2) * 2;
	if(aI > 0 && aJ > 0 && aL > 0){
		ans = max(ans, aO + 3 + ((aI - 1) / 2) * 2 + ((aJ - 1) / 2) * 2 + ((aL - 1) / 2) * 2);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const ll N= 1e7+10;
ll n;
ll a[N],ans=0;
int main(){
  cin>>n;
  for(ll i=1;i<=n;i++){
    for(ll j=1;i*j<=n;j++)
      a[i*j]++;
      ans+=i*a[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double

#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define MX LLONG_MAX
#define MN LLONG_MIN

const ll mod=1e9+7;
const ll N=1e5+5;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x = (b/c)+(b/d)-(b/lcm(c,d));
    ll y = ((a-1)/c)+((a-1)/d)-((a-1)/lcm(c,d));
    cout<<(b-a+1)-(x-y);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

main(){
  int c1, c2, c3;
  while(cin >> c1 >> c2 >> c3){
    int sum=0;
    for(int i=1;i<=10;i++){
      if(i==c1) continue;
      if(i==c2) continue;
      if(i==c3) continue;
      if(c1+c2+i<=20) sum++;
    }
    if(sum>=4) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
s = input()
ok = False
al = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in al:
    if i not in s:
        print(i)
        ok = True
        break
if not ok:
    print('None')

Measured memory_bytes: 3188
local n, m = io.read("*n", "*n")
local a = {}
for i = 1, m do
  table.insert(a, io.read("*n"))
end
if(m <= n) then print(0) else
  table.sort(a)
  local ret = a[#a] - a[1]
  local diff = {}
  for i = 2, m do
    diff[i - 1] = a[i] - a[i - 1]
  end
  table.sort(diff, function(x, y) return x > y end)
  for i = 1, n - 1 do
    ret = ret - diff[i]
  end
  print(ret)
end


Measured memory_bytes: 4472
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, s, n, m) for(ll i = s; i < (ll)(n); i+=m)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N;
    cin >> N;
    vector<string> s(N);
    rep(i, 0, N, 1) {
        cin >> s[i];
        sort(all(s[i]));
    }
    map<string, ll> m;
    rep(i, 0, N, 1) {
        m[s[i]]++;
    }
    ll cnt = 0;
    for (pair<string , ll> p : m) {
        cnt += (p.second-1)*p.second / 2;
    }
    print(cnt);
    
    return 0;
}

Measured memory_bytes: 18176
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

X,Y = I()
print(X+Y//2)

Measured memory_bytes: 5052
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include "cmath"
using namespace std;

int main(int argc, const char * argv[]) {
    long long  a;
    cin>>a;
    long long  b,c,d,e;
    b=a/1000;
    c=(a%1000)/100;
    d=(a%100)/10;
    e=(a%10);
    
    for (int i=0; i<2; i++) {
        for (int j=0; j<2; j++) {
            for (int k=0; k<2; k++) {
                long long tmp=b;
                if (i==0) {
                    tmp+=c;
                }else tmp-=c;
                if (j==0) {
                    tmp+=d;
                }else tmp-=d;
                if (k==0) {
                    tmp+=e;
                }else tmp-=e;
                if (tmp==7) {
                    cout<<b;
                    if (i==0) {
                        cout<<'+';
                    }else cout<<'-';
                    cout<<c;
                    if (j==0) {
                        cout<<'+';
                    }else cout<<'-';
                    cout<<d;
                    if (k==0) {
                        cout<<'+';
                    }else cout<<'-';
                    cout<<e<<"=7"<<endl;;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0] == s[1]||s[1] == s[2]||s[2] == s[3])
	{
		cout<<"Bad\n";
	}
	else
	{
		cout<<"Good\n";
	}
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int H,W,h,w;
  cin>>H>>W>>h>>w;
  if(H%h==0 && W%w==0)
    cout<<"No"<<endl;
  else{
  cout<<"Yes"<<endl;
    vector<vector<int>>A(H,vector<int>(W));
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
        if(i%h==h-1 && j%w==w-1)
          A[i][j]=-4000*(h*w-1)-1;
    else
      A[i][j]=4000;
   for(int i=0;i<H;i++){
    for(int j=0;j<W-1;j++)
      cout<<A[i][j]<<" ";
    cout<<A[i][W-1]<<endl;
   }
  }
  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; i++){
        double score = i;
        double coin = 1.0/n;
        while (score < k){
            score *= 2;
            coin /= 2;
        };
        ans += coin;
    }; 
    cout << fixed << setprecision(15) << ans << endl;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int X,A;

  cin>>X>>A;

  if(X<A){
    cout<<0<<endl;
  }else{
    cout<<10<<endl;
  }
  
  return 0;

}


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

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

#define MOD 1000000007

int main(void) {
    ll N;
    ll pt = 0, px = 0, py = 0;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll t, x, y;
        ll temp;
        cin >> t >> x >> y;
        temp = (t - pt) - (abs(x - px) + abs(y - py));
        if(temp < 0 || temp % 2) {
            cout << "No" << endl;
            return 0;
        }
        pt = t;
        px = x;
        py = y;
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(void) {
    i64 h, w, ans = true;
    cin >> h >> w;
    i64 e[16][2];
    for (i64 i = 0; i < h; i++) {
        e[i][0] = e[i][1] = -1;
        string a;
        cin >> a;
        for (i64 j = 0; j < w; j++) {
            if (e[i][1] != -1 && a[j] == '#') ans = false;
            if (e[i][0] == -1 && a[j] == '#') e[i][0] = j;
            if (e[i][0] != -1 && e[i][1] == -1
                && a[j] == '.') e[i][1] = j - 1;
        }
        if (e[i][1] == -1) e[i][1] = w - 1;
        //cout << e[i][0] << ' ' << e[i][1] << endl;
    }
    for (i64 i = 1; i < h; i++) {
        if (e[i][0] != e[i - 1][1]) ans = false;
    }
    cout << (ans ? "Possible" : "Impossible") << endl;
}

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

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (auto &e : a[i]) cin >> e;
    }

    int cost = INT_MAX;
    for (int i = 1; i < (1 << n); ++i) {
        int csum = 0;
        vector<int> asum(m, 0);

        for (int j = 0; j < n; ++j) {
            if (!(i & (1 << j))) continue;
            csum += c[j];
            for (int k = 0; k < m; ++k) {
                asum[k] += a[j][k];
            }
        }

        bool bad = false;
        for (auto e : asum) {
            if (e < x) {
                bad = true;
                break;
            }
        }
        if (bad) continue;

        cost = min(cost, csum);
    }

    if (cost == INT_MAX) {
        cout << -1 << endl;
    }
    else {
        cout << cost << endl;
    }
}



Measured memory_bytes: 3600
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def dfs(balls,B=-2,C=-1,cp=0):
	if cp==len(balls): 	return True
	ball = balls[cp]
	if C<ball:
		is_find = dfs(balls,B,ball,cp+1)
		if is_find: return True
	if B<ball:
		is_find = dfs(balls,ball,C,cp+1)
		if is_find: return True
	return False

def not_dfs(balls):
	B, C = -2, -1
	for ball in balls:
		if C<ball:
			C = ball
			continue
		if B<ball:
			B = ball
			continue
		return False
	return True

def main():
	N = int(input().strip())
	for _ in range(N):
		balls = list(map(int,input().split(' ')))
#		is_find = dfs(balls)
		is_find = not_dfs(balls)
		if is_find:		print('YES')
		else:			print('NO')

if __name__=='__main__':
	main()

"""
2
3 1 4 2 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
"""

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

int main() {
    int count = 0;
    int n; 
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    
    for(int i = 0; i < n; i++) {
        for(int j = n-1; j >= i+1; j--) {
            if(arr[j] < arr[j-1]) {
                int temp = arr[j];
                arr[j] = arr[j-1]; 
                arr[j-1] = temp; 
                count = count + 1; 
            }
        }
    }
    
    for(int i = 0; i < n; i++) {
        cout << arr[i];
        if(i == n-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    
    cout << count << endl;
    
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }

        long acnt = 0;
        long bcnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= b[i]) {
                bcnt += a[i] - b[i];
            } else {
                if ((b[i] - a[i]) % 2 == 0) {
                    acnt += (b[i] - a[i]) / 2;
                } else {
                    acnt += (b[i] - a[i] + 1) / 2;
                    bcnt++;
                }
            }
        }
        if (acnt < bcnt) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

}


Measured memory_bytes: 56512
from collections import deque

n, m = map(int, input().split())

graph = [[] for _ in range(n + 1)]

for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

#  print(graph)

mark = [-1]*(n+1)
mark[0] = 0
mark[1] = 0

d = deque()
d.append(1)

while d:
    v = d.popleft()
    for i in graph[v]:
        if mark[i] != -1:
            continue
        mark[i] = v
        d.append(i)
if mark.count(-1) > 0:
    print("No")
else:
    print("Yes")
    ans = mark[2:]
    print(*ans, sep="\n")

Measured memory_bytes: 36404
'''
Created on 2020/08/23

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  H=list(map(int,pin().split()))
  H.reverse()
  for i in range(N-1):
    if H[i]>=H[i+1]:
      pass
    elif H[i]==H[i+1]-1:
      H[i+1]-=1
    else:
      print("No")
      break
  else:
    print("Yes")
  return 

main()

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

void solve( ) {
	int  n , m , x , y , z , h , w , a , b , c , d , r , l;
	string s , t , line;
	cin >> n >> m;
	cin >> s;
	int ans = 0;
	vector<int> v( s.size( ) , 0 );
	rep( i , s.size( )  ) {
		v[ i ]=ans;
		auto ss = s.substr( i , 2 );
		if ( ss == "AC" )ans++;
	}
	rep( i , m ) {
		cin >> l >> r;
		l--; r--;
		cout << v[ r ] - v[ l ] << endl;
	}
}


signed main( ) {
	solve( );
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 2e5+5;
ll a[maxn];

int main(){
	ll n, k; cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	ll sum = 0;
	for(int i = 1; i <= n-k; i++) sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 1792
#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>

using namespace std;
#define next __next
#define prev __prev
#define right __right
#define left __left
#define index __index

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<int, int> ipair;
#define szof(x) ((int)(x).size())
#define ff first
#define ss second
#define puba push_back
#define bend(x) (x).begin(), (x).end()

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
mt19937 tw(960172);

bool is_prime(ll x) { for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return x > 1; }
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }
ll sqr(int a) { return (ll) a * a; } template<class T> T sqr(T const& a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }


void solve() {
    ll x;
    cin >> x;
    ll ans = x / 11 * 2;
    x %= 11;
    if (x == 0)
        ans += 0;
    else if (x <= 6)
        ans += 1;
    else
        ans += 2;
    cout << ans << '\n';
}

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    cout << setprecision(15) << fixed;
#ifdef LOCAL
    cerr << setprecision(6) << fixed;
#endif
    int tcnt = 1;
    for (int test = 1; test <= tcnt; ++test)
        solve();
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int n, k, p[100010], q[100010], fp[100010], fq[100010], A[100010], a[100010], b[100010], c[100010], ans[100010], tmp[100010];

inline void ksm (int p) {
	if (!p) return;
	ksm (p >> 1);
	for (int i = 1; i <= n; ++i) tmp[i] = a[a[i]];
	for (int i = 1; i <= n; ++i) a[i] = tmp[i];
	if (p & 1) {
		for (int i = 1; i <= n; ++i) tmp[i] = A[a[i]];
		for (int i = 1; i <= n; ++i) a[i] = tmp[i];
	}
}

int main () {
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) scanf ("%d", &p[i]), fp[p[i]] = i;
	for (int i = 1; i <= n; ++i) scanf ("%d", &q[i]), fq[q[i]] = i;
	
	for (int i = 1; i <= n; ++i) A[i] = q[fp[fq[p[i]]]];
	for (int i = 1; i <= n; ++i) a[i] = i;
	
	ksm ((k - 1) / 6);
	
	if (k % 6 == 1) for (int i = 1; i <= n; ++i) c[i] = p[i];
	if (k % 6 == 2) for (int i = 1; i <= n; ++i) c[i] = q[i];
	if (k % 6 == 3) for (int i = 1; i <= n; ++i) c[i] = q[fp[i]];
	if (k % 6 == 4) {
		for (int i = 1; i <= n; ++i) c[i] = fp[i];
		for (int i = 1; i <= n; ++i) tmp[i] = a[q[i]];
		for (int i = 1; i <= n; ++i) a[i] = tmp[i];
	}
	if (k % 6 == 5) {
		for (int i = 1; i <= n; ++i) c[i] = fq[i];
		for (int i = 1; i <= n; ++i) tmp[i] = a[q[fp[i]]];
		for (int i = 1; i <= n; ++i) a[i] = tmp[i];
	}
	if (k % 6 == 0) {
		for (int i = 1; i <= n; ++i) c[i] = fq[p[i]];
		for (int i = 1; i <= n; ++i) tmp[i] = a[q[fp[i]]];
		for (int i = 1; i <= n; ++i) a[i] = tmp[i];
	}
	
	for (int i = 1; i <= n; ++i) b[a[i]] = i;
	
	for (int i = 1; i <= n; ++i) ans[i] = a[c[b[i]]];
	
	for (int i = 1; i <= n; ++i) printf ("%d%c", ans[i], " \n"[i == n]);
	
	return 0;
}

Measured memory_bytes: 4736
from sys import stdin
input = stdin.readline

s = int(input())
mod = 1000000007
cnt = 0

a = [[1] for _ in range(2001)]
a[0].append(0)

for x in range(1, 2001):
    for y in range(1, x):
        a[x].append(a[x - 1][y - 1] + a[x - 1][y])
    a[x].append(1)

for x in range(1, 2001):
    s -= 3

    if s < 0:
        break

    cnt += a[s + x - 1][s]
    cnt %= mod

print(cnt)

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

def main():
    n, m = map(int, input().split())
    li_answers = [[] for i in range(n + 1)]
    for i in range(m):
        p, s = input().split()
        li_answers[int(p)].append(s)
    acs = 0
    pens = 0
    for i in range(n + 1):
        for j, s in enumerate(li_answers[i]):
            if s == "AC":
                acs += 1
                pens += j
                break
    print(acs, pens)

main()


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

int main(){
  int N,count=0;
  string S;
  cin>>N>>S;
  for(int i=0; i<N-2; i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C'){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int digits(int n) {
	int i = 1;
	while(n /= 10) {
		i++;
	}
	return i;
}

bool check(string s, const int n, vector<pair<int, int>>& sc) {
	if(s.size() != n) {
		return false;
	}
	EACH(e, sc) {
		if(s[e.first - 1] != (e.second + '0')) {
			return false;
		}
	}
	return true;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> sc(m);
	REP(i, m) { cin >> sc[i].first >> sc[i].second; }
	sort(ALL(sc));
	REP(i, m - 1) {
		if(sc[i].first == sc[i + 1].first && sc[i].second != sc[i + 1].second) {
			cout << "-1" << endl;
			return 0;
		}
	}
	REP(i, 1000) {
		if(check(to_string(i), n, sc)) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false
int n;
int L[100];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    L[0] = 2;
    L[1] = 1;
    rep2(i, 2, n + 1) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[n] << endl;
}

Measured memory_bytes: 256
S = input()
lists = [ 'dream', 'dreamer', 'erase', 'eraser']
while len(S) > 0:
  if S[-7:] in lists:
    S = S[:-7]
  elif S[-6:] in lists:
    S = S[:-6]
  elif S[-5:] in lists:
    S = S[:-5]
  else:
    print('NO')
    exit()

print('YES')


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,x,y,ans=0;

int main()
{
	cin>>n;
	repn(i,n) ans+=(LL)(1+i)*(LL)i/2;
	rep(i,n-1)
	{
		scanf("%lld%lld",&x,&y);
		if(x>y) swap(x,y);
		ans-=x*(n-y+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3748