akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            long answer = 0;

            for (int a = 1; a <= K; a++)
            {
                for(int b = 1; b <= K; b++)
                {
                    for(int c = 1; c <= K; c++)
                    {
                        answer += Gcd(Gcd(a, b), c);
                    }
                }
            }

            Console.WriteLine(answer);
        }

        public static int Gcd(int a, int b)
        {
            var x = 0;

            while (true)
            {
                // 割り切れたら
                if (a % b == 0)
                {
                    return b;
                }
                else
                {
                    x = a % b;
                    a = b;
                    b = x;

                }
            }

        }
    }
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


int main(){
	
	
	int n;
	
	cin >> n; 
	
	if(n%2==0){
		cout << n << endl;
	}else{
		cout << n * 2 << endl;
	}
	

    return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            string s;
            cin>>s;
            if(s[1]==s[0] || s[2]==s[1] || s[3]==s[2])
            {
                cout<<"Bad"<<endl;
            }
            else
                cout<<"Good"<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#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(){
    string s;
    cin >> s;
    vector<int> x;
    rep(i,s.size()){
        if(s[i] == 'W'){
            x.push_back(i+1);
        }
    }

    int count=1;
    ll ans = 0;
    for(auto v : x){
        ans += (v-count);
        count++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4352
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, t = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    b = collections.defaultdict(list)
    m_c = 10 ** 9
    for i, v in enumerate(a):
        if i != 0 and m_c < v:
            b[v-m_c] += [m_c]
        m_c = min(m_c, v)
    b = sorted(b.items(), reverse=True)[0]
    print(len(collections.Counter(b[1])))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 76280
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N%2 != 0){
        cout << "No" << "\n";
        return 0;
    }
    for(int i = 0; i < N/2; i++){
        if(S[i] != S[N/2 + i]){
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 256
n, a, b = gets.chomp.split(" ").map(&:to_i)

h = Hash.new(0)
gets.chomp.split(" ").map(&:to_i).each do |v|
    h[v] += 1
end

vv = h.to_a.sort {|a, b| a[0] <=> b[0]}.reverse

cumsum_c = [0]
cumsum_v = [0]
vv.each do |v|
    cumsum_c << cumsum_c[-1] + v[1]
    cumsum_v << cumsum_v[-1] + v[0] * v[1]
end


def combi(n,k)
 #   printf "%d %d\n", n, k

    k=n-k if 2*k > n
    return 1 if k == 0
    return ((n-k+1)..n).reduce(&:*) / ((1..k).reduce(&:*))
end

cumsum_c.each_with_index do |c, i|
    if a == c
        puts cumsum_v[i].to_f / a.to_f
        puts 1
        exit
    elsif a < c
        puts (cumsum_v[i] - vv[i-1][0] * (c-a)) / a.to_f
        if i > 1
            puts combi(vv[i-1][1], c-a)
        else
            sum = 0
            for j in a..[b, vv[i-1][1]].min
                sum += combi(vv[i-1][1], j)
            end
            puts sum
        end
        exit
    end
end

Measured memory_bytes: 3836
R1=range(-2,3)
R2=range(-1,2)
A1=[(x,y) for x in R1 for y in R1 if 3<x**2+y**2<6]
A2=[(x,y) for x in R2 for y in R2]
def fi(): return map(int,raw_input().split(" "))
def f(p,i):
  x,y=p
  A=[A1,A2][i>0]
  return set([(x+dx,y+dy) for dx,dy in A if 0<=x+dx<10 and 0<=y+dy<10])

while 1:
  xf,yf=fi()
  if yf==xf==0: break
  input()
  tmp=fi()
  PA=zip(tmp[0::2],tmp[1::2])
  FA=set([(xf,yf)])
  for ps in PA:
    SA=f(ps,1)
    tmp=set([])
    for pf in FA: tmp=tmp|(SA&f(pf,0))
    FA=tmp
  print ["NA","OK"][len(FA)>0]

Measured memory_bytes: 4288
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld n, m, x, c[12], a[12][12], o = -1;
  cin >> n >> m >> x;
  for (lld i = 0; i < n; i++) {
    cin >> c[i];
    for (lld j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  for (lld i = 0; i < 1 << n; i++) {
    lld s = 0, q[12] = {};
    for (lld j = 0; j < n; j++) {
      if (i & (1 << j)) {
        for (lld k = 0; k < m; k++) {
          q[k] += a[j][k];
        }
        s += c[j];
      }
    }
    for (lld k = 0; k < m; k++) {
      if (q[k] < x) {
        goto cont;
      }
    }
    o = o == -1 ? s : min(o, s);
    cont:;
  }

  cout << o << "\n";
}

Measured memory_bytes: 3624
import sys
N, Y = map(int, input().split(' '))

tmp = 0
tmp_num = 0

for i in range(N + 1):
    for j in range(N + 1 - i):
        tmp_num = N - i - j

        if Y - (10000 * i + 5000 * j + 1000 * tmp_num) == 0:
            print("{} {} {}".format(i, j, tmp_num))
            sys.exit()

print("-1 -1 -1")

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

int a[100+1]={0};

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

    for (int i=1; i<=n; i++)
    {
        int x;
        cin >> x;
        a[x]=1;
    }

    int s=0;
    cin >> s;

    for (int i=1; i<=100; i++)
    {
        if (a[i]==1) s++;
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll a, b;
    int c, d;
    char punto;
    cin >> a >> c >> punto >> d;
    b = c*100 + d;
    ll ans = b*a/100;
    cout << ans << endl;
}


Measured memory_bytes: 3652
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    c=b-a
    ct=0
    for i in range(c):
        ct+=i
    print(ct-a)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  int sum = 0;
  rep(i, n){
    int l, r; cin >> l >> r;
    sum += r - l + 1;
  }

  cout << sum << endl;

  return 0;
}


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

set<int> ch[100005];
bool mark[100005];
set<int> alive;
int n;

void kill(int x)
{
	alive.erase(x);
	for (int u: ch[x]) ch[u].erase(x);
	ch[x].clear();
}

int main()
{
	scanf("%d", &n);
	for (int i = 1;i < n;i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		--a, --b;
		ch[a].insert(b);
		ch[b].insert(a);
	}
	for (int i = 0;i < n;i++) alive.insert(i);
	while (alive.size() > 2)
	{
		vector<int> todo;
		for (auto it = alive.begin();it != alive.end();it++) if (ch[*it].size() == 1)
			todo.push_back(*it);
		vector<int> ext;
		for (int u: todo)
		{
			if (mark[*ch[u].begin()])
			{
				printf("First\n");
				return 0;
			}
			mark[*ch[u].begin()] = true;
			ext.push_back(*ch[u].begin());
		}
		for (int u: todo) kill(u);
		for (int u: ext) kill(u);
	}
	if (alive.size() == 1)
	{
		printf("First\n");
	} else
	{
		if (alive.empty() || ch[*alive.begin()].find(*alive.rbegin()) != ch[*alive.begin()].end()) printf("Second\n");
		else printf("First\n");
	}
	return 0;
}


Measured memory_bytes: 19580
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
 ll n;
 cin >> n;
 vector<ll> a(n);
 rep(i,n) cin >> a[i];
 ll cnt = 0;
 for(int i = 0; i < n - 2; i++){
     for(int j = i + 1; j < n - 1; j++){
         for(int k = j + 1; k < n; k++){
             if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && max({a[i],a[j],a[k]})< a[k] + a[i] + a[j] - max({a[i],a[j],a[k]}))
                cnt++;
         }
     }
 }
 cout << cnt << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  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()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  int i = 0;
  for(i;i < n-1; ++i) {
    if(a[i] == a[i+1]) continue;

    //cout << i+1 << endl;
    if(a[i] < a[i+1]) {
      ++ans;
      while(i+1 < n && a[i] <= a[i+1]) ++i;
    }
    else {
      ++ans;
      while(i+1 < n && a[i] >= a[i+1]) ++i;
    }
  }
  if(i != n) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 24368
import sys

def gcd(a, b):
    b, a = sorted([a, b])
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)

def get_cum_gcd(N, As):
    cum_gcd = [0] * N
    for i, n in enumerate(As):
        if i == 0:
            cum_gcd[i] = n
        else:
            cum_gcd[i] = gcd(cum_gcd[i-1], n)
    return cum_gcd

def get_cav_gcds(N, cum_l, cum_r):
    cav_gcds = [0] * N
    for i in range(N):
        if i == 0:
            cav_gcds[i] = cum_r[i+1]
        elif i == N-1:
            cav_gcds[i] = cum_l[i-1]
        else:
            cav_gcds[i] = gcd(cum_l[i-1], cum_r[i+1])
    return cav_gcds

def main():
    input = sys.stdin.readline
    N = int(input())
    As = list(map(int, input().split()))
    cum_l = get_cum_gcd(N, As)
    cum_r = list(reversed(get_cum_gcd(N, reversed(As))))
    cav_gcds = get_cav_gcds(N, cum_l, cum_r)
    print(max(cav_gcds))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];		//nこの要素を入れる
		int s = 0;			//要素の合計
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
			s += num[i];
		}
		boolean[] map = new boolean[s + 1];		//要素の合計+1のboolean

		slove(0, 0, num, map);		//nこの配列と　booleanを投げる  0 0 は開始地点か？
		int m = scanner.nextInt();
		while (m-- > 0) {
			int a = scanner.nextInt();
			System.out.println(a <= s && map[a] ? "yes" : "no");
		}

	}

	private void slove(int i, int sum, int[] num, boolean[] map) {
		map[sum] = true;		//DP法
		if (i == num.length)
			return;

		slove(i + 1, sum + num[i], num, map);
		slove(i + 1, sum, num, map);
	}
}



Measured memory_bytes: 26504
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;

int vis[105];

struct po{
	int x, y;
	int num;
}red[105], blu[105];

bool cmp(po a, po b)
{
	return a.num < b.num;
}


int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> red[i].x >> red[i].y;
		red[i].num = 0;
	}
	for(int i = 1; i <= n; i++)
	{
		cin >> blu[i].x >> blu[i].y;
		blu[i].num = 0;
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(red[i].x < blu[j].x && red[i].y < blu[j].y)
			{
				red[i].num++;
				blu[j].num++;
			}
		}
	}
	sort(red + 1, red + 1 + n, cmp);
	sort(blu + 1, blu + 1 + n, cmp);
	int sum = 0;
	for(int i = 1; i <= n; i++)	
	{
		for(int j = 1; j <= n; j++)
		{
			if(red[i].x < blu[j].x && red[i].y < blu[j].y && vis[j] == 0)
			{
				sum++;
				vis[j] = 1;
				break;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int M,N,i;
    cin>>N>>M;
    int sum=0,full=0,okane;
    for(i=0;i<M;i++){
        int A,B;
        cin>>A>>B;
        okane=max(N-A,0);
        if(okane>full)full=okane;
        sum+=okane;
    }
    cout<<sum-full<<endl;
    return 0;
}



Measured memory_bytes: 3092
x,n=map(int,input().split())
Q=list(map(int,input().split()))

if n==0:
  print(x);exit()
  
if not x in Q:
  print(x) ; exit()

A=[]
for i in range(1,250):
  A.append(-i)
  A.append(i)
  
for i in A:
  if not x+i in Q:
    print(x+i)
    exit()


Measured memory_bytes: 9040
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int m,id[40];
pair<int,int> p[40];

int main(){
	while(cin>>m&&m){
		rep(i,m){
			cin>>p[i].second;
			int f=1,n,b=0,b2=0,sc=0,sec=0,prv,thi=0;
			while(f<11){
				cin>>n;
				sc+=n;
				if(b2>0){sc+=n*2;b2--;b--;if(!b){b=b2;b2=0;}}
				else if(b>0){sc+=n;b--;}
				//cout<<f<<"-"<<sec+1<<" "<<n<<" "<<sc<<endl;
				if(f==10){
					if(sec==2)break;
					sec+=1;
					if(n==10||sec>1&&prv+n==10)thi=1;
					//cout<<sec<<thi<<endl;
					if(sec==2&&!thi)break;
				}
				else{
					if(!sec){
						if(n==10){f++;if(b>0)b2=2;else b=2;}
						else sec=1;
					}
					else{
						sec=0;f++;
						if(prv+n==10)b=1;
					}
				}
				prv=n;
			}
			p[i].first=-sc;
		}
		sort(p,p+m);
		rep(i,m)cout<<p[i].second<<" "<<-p[i].first<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define v vector<long long>
#define f first
#define s second
#define pb push_back

using namespace std;
typedef long long ll;
int main() {
    ll n,m,x,mx,my,y;
    cin>>n>>m>>x>>y;
    unordered_set<int> s;x++;
    while(x<=y)
        s.insert(x++);
    cin>>mx;
    for(int i=1;i<n;i++)
    {
        cin>>x;
        mx=max(mx,x);
    }
    cin>>my;
    for(int i=1;i<m;i++)
    {
        cin>>y;
        my=min(my,y);
    }
    mx++;
    while(mx<=my)
    {
        if(s.find(mx)!=s.end())
        {
            cout<<"No War";
            return 0;
        }mx++;
    }
    cout<<"War";
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define N 100010
vii M(N,vi());
ll n, m;
vi color(N, -1);
//二部グラフかどうかを判断
bool bipartite() {
	stack<int> st;
	color[0] = 0;
	st.push(0);
	int i, j;
	while (!st.empty()) {
		i = st.top();
		st.pop();
		for (j = 0; j < M[i].size(); j++) {
			if (color[M[i][j]] == color[i]) {
				//cout << "NO" << endl;
				return false;
			}
			else {
				if (color[M[i][j]] == -1) {
					color[M[i][j]] = 1 - color[i];
					st.push(M[i][j]);
				}
			}
		}
	}
	//cout << "YES" << endl;
	return true;
}

int main(){
	int i, j;
	scanf("%lld%lld", &n, &m);
	int a, b;

	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		a--; b--;
		M[a].push_back(b);
		M[b].push_back(a);
	}
	bool flag = bipartite();
	if (flag) {
		ll w = 0, b = 0;
		for (i = 0; i < n; i++) {
			if (color[i] == 0) {
				w++;
			}
			else {
				b++;
			}
		}
		cout << w*b - m << endl;
		return 0;
	}
	else {
		cout << (n*n - n) / 2 - m << endl;
		return 0;
	}
}

Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct node
{
	int x,y;
}a[200001];
int x[200001],y[200001];
int main()
{
	int n;
	scanf("%d",&n);
	int tot=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].x,&a[i].y);
		x[++tot]=a[i].x+a[i].y;
		y[tot]=a[i].x-a[i].y;
	}
	sort(x+1,x+tot+1);
	sort(y+1,y+tot+1);
	int x1=x[1]-x[n],x2=x[n]-x[1],y1=y[1]-y[n],y2=y[n]-y[1];
	printf("%d",max(x1,max(x2,max(y1,y2))));
	return 0;
} 

Measured memory_bytes: 6952
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;

ll f(ll n, ll x) {
   if (n < 0)
       return 0;
    
    return n/x + 1;
}

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

    ll a, b, x;
    cin >> a >> b >> x;
    
    cout << f(b, x) - f(a-1, x) << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a[10];
for(int i=0;i<10;i++){	cin >> a[i];
}sort(a,a+10);
cout<<a[9]<<endl;
cout<<a[8]<<endl;	
cout<<a[7]<<endl;
return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
    // Your code here!
    int x;
    double y;
    double z;
    
    cin >> x ;
    
    z = double(x);
    
    if(x % 2 == 0){
        y = 0.5;   
    }else{
        y = ((x / 2) + 1) / z;
    }
    

    printf("%f\n",y);
}


Measured memory_bytes: 256
#include <iostream>

typedef std::pair<int,int> TV; // Time and Value

void add(TV* A, int s, int t, int index, int l, int r, int time, int val)
{
	if (t<l || r<=s) return; // no intersection
	else if (s<=l && r<=t+1) { // [l,r) is contained in [s,t] 
		A[index].first = time;
		A[index].second += val;
		return;
	}
	else { // at least one end exceeds the range
		int mid = (l+r)/2;
		add(A, s, t, 2*index+1, l, mid, time, val);
		add(A, s, t, 2*index+2, mid, r, time, val);
	}
}

int get(TV* A, int k, int index, int l, int r)
{
	if (l+1==r) return A[index].second;
	
	int mid = (l+r)/2;

	if (k<mid) return A[index].second + get(A, k, 2*index+1, l, mid);
	else return A[index].second + get(A, k, 2*index+2, mid, r);
}

int main ()
{
	int n, q;
	std::cin >> n >> q;
	
	int a_size = 1;
	for(; a_size<n; a_size<<=1);
	TV* A = new TV[2*a_size-1];
	for (int i=0; i<2*a_size-1; i++) {
		A[i].first = -1;
		A[i].second = 0;
	}
	
	
	for (int i=0; i<q; i++) {
		int op, s, t, x, k;
		std::cin >> op;
		if (op==0) {
			std::cin >> s >> t >> x;
			add(A, s-1, t-1, 0, 0, n, i, x);
		} else {
			std::cin >> k;
			std::cout << get(A, k-1, 0, 0, n) << std::endl;
		}
	}
	
	delete[] A;
	
	return 0;
}



Measured memory_bytes: 4940
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
#define mod1 (ll)998242353
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

    ll a,b,v,w;
    cin>>a>>v;
    cin>>b>>w;
    double t;
    cin>>t;
    if(w>=v){
        cout<<"NO"<<endl;
    }
    else{
        double t1=((double)abs(a-b)/(double)(v-w));
        if(t1<=t){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    


    return 0;
}



Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct kk{
int id;
int ac;
int wa;
vector<int> p;//核問題に対するペナルティ
vector<bool>acs;
int psum;
};
//
kk ans[105];
int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&(T+P+R)!=0){//Tチーム、P問,R個のログ
	for(int i=0;i<105;i++){
	ans[i].p.resize(180);
	ans[i].acs.resize(190);
	for(int j=0;j<103;j++)ans[i].p[j]=0,ans[i].acs[j]=0;
	ans[i].id=i;
	}

	for(int i=0;i<R;i++){
	int a,b,c;//id,問題id,経過時間
	string d;//メッセージ
	cin>>a>>b>>c>>d;
	if(d=="WRONG"){
	ans[a].p[b]++;
	}
	else if(d=="CORRECT"){
	ans[a].ac++;
	ans[a].acs[b]=true;
	ans[a].p[b]=ans[a].p[b]*1200+c;
	}
	}
	for(int i=1;i<=T;i++){
		int sum=0;
		for(int j=0;j<=P;j++)if(ans[i].acs[j])sum+=ans[i].p[j];
		ans[i].psum=sum;
	}

	//for(int i=1;i<=T;i++)cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	for(int i=1;i<=T;i++){
		for(int j=i+1;j<=T;j++){
			if(ans[i].ac<ans[j].ac)swap(ans[i],ans[j]);//右のほうが強ければswap
			else if(ans[i].ac==ans[j].ac){

				if(ans[i].psum>ans[j].psum)swap(ans[i],ans[j]);
				if(ans[i].psum==ans[j].psum&&ans[i].id>ans[j].id)swap(ans[i],ans[j]);
			}
		}
	}
	for(int i=1;i<=T;i++){
	cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	}
		for(int i=0;i<=104;i++){ans[i].p.clear();ans[i].acs.clear();ans[i].psum=0;ans[i].ac=0;ans[i].wa=0;ans[i].id=0;}
	}
		return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b; cin >> a>> b;
    int flag =1;
    if((a<1)||(9<a)) flag = 0;
    if((b<1)||(9<b)) flag = 0;
    if (flag) cout << a*b <<"\n";
    else cout << -1 << "\n";
}

Measured memory_bytes: 256
function main()
    A = parse(Int, readline())
    B = parse(Int, readline())
    C = parse(Int, readline())
    X = parse(Int, readline())

    res = 0
    for a = 0:A
        for b = 0:B
            for c = 0:C
                total = 500 * a + 100 * b + 50 * c
                if total == X
                    res += 1
                end
            end
        end
    end

    println(res)
end

main()

Measured memory_bytes: 110088
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int main(){
  int n,k;cin>>n>>k;
  puts(k*2-1<=n?"YES":"NO");
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N, D;
    cin >> N >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,k,b,a[999999];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=n-k+1;i--)
    {
    	b+=a[i];
    }
    cout<<b;
	return 0;
}


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

using namespace std;

bool isPerfectSquare(long long n)
{
    long long squareRootN=(long long)round((sqrt(n)));

    if(squareRootN*squareRootN == n)
    {
        return true;
    }
    else
    {
        return false;
    }

}

int main()
{
    long long i,n, maxi = -1;

    cin >> n;

    for( i = n; i >= 1; i-- )
    {
        if( isPerfectSquare( i ) ){
            cout << i << endl;
            return 0;
        }
    }

    //deb( maxi );
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

int main() {
	string s;
	int ans = 0;
	cin >> s;
	press(s);
	ans = s.size() - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int N; cin >> N;
    vi A(N); rep(i,N) cin >> A[i];
    ll ans = 0;
    if(A[0] != 0) {
        cout << -1;
        return 0;
    }

    ll tmp = 0;
    rep(i,N){
        if(i == N-1) {
            ans += A[i];
            break;
        }
        if(A[i+1] <= tmp){
            ans += tmp;
        }else if(A[i+1] != tmp+1) {
            cout << -1;
            return 0;
        }
        tmp = A[i+1];
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;cin>>n;vector<int> a(n);
    for(int i=0;i<n;i++)
    {
    	scanf("%d",&a[i]);
	}
	sort(a.begin(),a.end());
	double ans=a[0];
	for(int i=1;i<n;i++)
	{
		ans+=a[i];ans/=2.0;
	}
	printf("%.7lf\n",ans);
}

Measured memory_bytes: 256
N = int(input())
tmp, ans = 0, 0
for i in range(1, N + 1):
	if i % 2 != 0:
		for j in range(1, i + 1):
			if i % j == 0:
				tmp += 1
		if tmp == 8:
			ans += 1
		tmp = 0
print(ans)


Measured memory_bytes: 2940
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

 public static void main(String[] args) {
	createMap(0, null, new boolean[10], 0);
	Scanner in = new Scanner(System.in);
	boolean endflag = false;
	while (!endflag && in.hasNext()) {
	 int n = in.nextInt();
	 int s = in.nextInt();
	 if (n != 0 || s != 0) {
		Integer ans = valMap
		  .get(Integer.valueOf(n))
		  .get(Integer.valueOf(s));
		if (ans == null) {
		 ans = Integer.valueOf(0);
		}
		System.out.println(
		  ans);
	 } else {
		endflag = true;
	 }
	}
 }

 static Map<Integer, Map<Integer, Integer>> valMap = new HashMap<Integer, Map<Integer, Integer>>();
 static {
	for (int i = 1; i <= 10; i++) {
	 valMap.put(Integer.valueOf(i),
		 new HashMap<Integer, Integer>());
	}
 }

 private static void
	 createMap(Integer n, Map<Integer, Integer> map,
	   boolean[] used, Integer s) {
	if (map != null) {
	 int val = 1;
	 if (map.containsKey(s)) {
		val += map.get(s);
	 }
	 map.put(s, val);
	}
	for (int i = 0; i < 10; i++) {
	 if (!used[i]) {
		used[i] = true;
		createMap(n + 1, valMap.get(n + 1), used,
		  s + i * (n + 1));
		used[i] = false;
	 }
	}
 }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a+b == 15) cout << '+' << endl;
  else if(a*b == 15) cout << '*' << endl;
  else cout << 'x' << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin >> n ;
	if('A' <= n && n <= 'Z')		cout << 1 << endl;
	else if('a' <= n && n <= 'z')	cout << 2 << endl;
	else							cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cstdlib>
#include <iostream>

int main() {
    int N, X, Y; std::cin >> N >> X >> Y;
    int i, j, shortest, n_paths[N-1];

    for (i = 0; i < N-1; i++) {
        n_paths[i] = 0;
    }

    for (i = 1; i <= N; i++) {
        for (j = i+1; j <= N; j++) {
            shortest = std::min(std::abs(i - X) + std::abs(j - Y) + 1, j - i);
            n_paths[shortest-1]++;
        }
    }

    for (i = 0; i < N-1; i++) {
        std::cout << n_paths[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//arc068_c
//サイコロの6と5を繰り返せば良い
//x / 11 と x / 6
int main(){
  ll X,res;
  cin >> X;

  res = (X / 11) * 2;

  X %= 11;

  if(X != 0)
  {
    if(X > 6)res+=2;
    else res++;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), fgets()
#include <string.h>         // strstr()
#include <ctype.h>          // islower()

static const int NUL = '\0';

int
main(int argc, char** argv)
{
	char line[81];
	char output[81];
	const char* key[3] = {"the", "this", "that"};

	while (fgets(line, sizeof(line), stdin) != NULL)
	{
		int i, j;

		for (i = 1; i <= 26; ++i)
		{
			for (j = 0;; ++j)
			{
				if (islower(line[j]))
					output[j] = (line[j] + i - 'a') % 26 + 'a';
				else
					output[j] = line[j];

				if (output[j] == NUL)
					break;
			}

			for (j = 0; j < 3; ++j)
			{
				if (strstr(output, key[j]) != NULL)
					break;
			}

			if (j < 3)
			{
				printf("%s", output);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 528
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 2005;
vector<int> a;
int n,k;

int count(int x){
	int cnt = 0;
	rep(i,n){
		if(a[i] * a[i] <= x)	cnt--;

		if(a[i] == 0 && x >= 0)	cnt += n;
		else if(a[i] < 0){
			cnt += n - (lower_bound(a.begin(), a.end(), (long double)x / a[i]) - a.begin());
		}
		else if(a[i] > 0){
			int pos = upper_bound(a.begin(), a.end(), (long double)x / a[i]) - a.begin();
			cnt += pos;
		}

		// if(a[i] * a[i] < x)	cnt--;

		// if(a[i] <= 0){ // negative or zero
		// 	int l = -1,r = n;
		// 	while(r-l > 1){
		// 		int mid = (l+r) / 2;
		// 		if(a[i] * a[mid] < x)	r = mid;
		// 		else	l = mid;
		// 	}
		// 	cnt += n-r;
		// }
		// else{			// positive
		// 	int l = -1,r = n;
		// 	while(r-l > 1){
		// 		int mid = (l+r) / 2;
		// 		if(a[i] * a[mid] < x)	l = mid;
		// 		else	r = mid;
		// 	}
		// 	cnt += r;
		// }

		// cout << cnt << ' ';
	}
	// cout << endl << x << ' ' << cnt << endl;

	return cnt / 2;
}
// O(n * log(n) * log(C)), C = 1e18 

signed main(){
	IOS
	cin >> n >> k;
	a.resize(n);
	rep(i,n)	cin >> a[i];
	sort(a.begin(), a.end());
	int l = -1e18+7, r = 1e18+7;
	while(r-l > 1){
		int mid = (l+r) / 2;
		if(count(mid) < k)	l = mid;
		else		r = mid;
	}
	cout << r << endl;
}


Measured memory_bytes: 1792
#[cfg(test)]
#[macro_use]
extern crate contest;

use std::fmt::Debug;
use std::io::{self, Bytes, Read, Stdin, StdinLock};
use std::str::{self, FromStr};

fn main() {
    let stdin = io::stdin();
    let mut sc = StdinScanner::new(&stdin);
    println!("{}", solve(sc.next(), sc.next()));
}


fn solve(n: u64, m: u64) -> u64 {
    if !(n == m + 1 || n + 1 == m || n == m) {
        return 0;
    }

    const M: u64 = 1000000007;
    let mut result = 1;
    for i in 2..n + 1 {
        result = (result * i) % M;
    }
    for i in 2..m + 1 {
        result = (result * i) % M;
    }
    if n == m {
        result = (2 * result) % M;
    }
    result
}


#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        assert_eq_in_time!(1000, "", "");
    }
}


struct StdinScanner<'a> {
    buf: Vec<u8>,
    bytes: Bytes<StdinLock<'a>>,
}


#[allow(dead_code)]
impl<'a> StdinScanner<'a> {
    fn new(stdin: &'a Stdin) -> Self {
        StdinScanner {
            buf: Vec::with_capacity(256),
            bytes: stdin.lock().bytes(),
        }
    }

    fn next<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut c = self.bytes.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = self.bytes.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = self.bytes.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
        where <A as FromStr>::Err: Debug,
              <B as FromStr>::Err: Debug
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
        where <A as FromStr>::Err: Debug,
              <B as FromStr>::Err: Debug,
              <C as FromStr>::Err: Debug
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
        where <T as FromStr>::Err: Debug
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


trait PrintYn {
    fn print_yn(self, yes: &str, no: &str);
}

impl PrintYn for bool {
    fn print_yn(self, yes: &str, no: &str) {
        println!("{}", if self { yes } else { no });
    }
}


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

int main(){
  int length, width;
  while(1){
    cin >> length >> width;
    if(length == 0 || width == 0){
      break;
    }
    for(int i = 0; i < length; i++){
      for(int j = 0; j < width; j++){
        if (((i != 0 && j != 0) && (i != length - 1)) && (j != width - 1)){
          cout << ".";
        }else{
        cout << "#";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3012
# ARC069D - Menagerie (ABC055D)
def check(a: int, b: int) -> list:
    ret, cur, prev = [], a, b
    for i in S:
        ret += [cur]
        if cur ^ (i == "o"):  # oSo or oWx
            prev, cur = cur, prev ^ 1  # both neighbors are different
        else:  # oSx or oWo
            prev, cur = cur, prev  # both are the same
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else []


def main():
    global S
    N = int(input())
    S = input().rstrip()
    for a in range(2):
        for b in range(2):
            x = check(a, b)
            if x:
                ans = "".join("S" if i else "W" for i in x)
                print(ans)
                return
    print(-1)


if __name__ == "__main__":
    main()

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

using namespace std;

const int maxn=2e5+5;

int n,u,v,dis1[maxn],dis2[maxn],ans,cnt;
int head[maxn],ver[maxn],nxt[maxn];

inline void add(int x,int y){
	nxt[++cnt]=head[x];
	head[x]=cnt;
	ver[cnt]=y;
}

inline void dfs1(int x,int fa){
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y==fa) continue;
		dis1[y]=dis1[x]+1;
		dfs1(y,x);
	}
}

inline void dfs2(int x,int fa){
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y==fa) continue;
		dis2[y]=dis2[x]+1;
		dfs2(y,x);
	}
}
int main(){
	cin>>n>>u>>v;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		add(x,y);add(y,x);
	}
	dfs1(u,0);
	dfs2(v,0);
	for(int i=1;i<=n;i++){
		if(dis1[i]<dis2[i]) ans=max(ans,dis2[i]-1);
	}
	cout<<ans<<endl;
	return 0;
}







Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?')break;
        if(op=='+')cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else if(op=='/')cout<<a/b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a,b;
int ans;
inline bool judge(int x){
	int k=x,len=0,p[10];
	while(k){
		p[++len]=k%10;
		k/=10;
	}
	for(int i=1;i<=len/2+1;i++){
		if(p[i]!=p[len-i+1])return 0;
	}
	return 1;
}
int main(){
	cin>>a>>b;
	for(register int i=a;i<=b;i++){
		if(judge(i))ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256