akhauriyash/Code-Regression huggingface dataset:
using DataStructures
parseline(str=readline()) = parse.(Int, split(str))
function FriendSuggestions()
    N, M, K = parseline()
    direct = [Int[] for n in 1:N]
    friends = IntDisjointSets(N)
    for m in 1:M
        A, B = parseline()
        union!(friends, A, B)
        push!(direct[A], B)
        push!(direct[B], A)
    end
    for k in 1:K
        C, D = parseline()
        push!(direct[C], D)
        push!(direct[D], C)
    end
    for n in 1:N
        _ = find_root!(friends, n)
    end
    ans = zeros(Int, N)
    sz = zeros(Int, N)
    p = friends.parents
    for n in 1:N
        sz[p[n]] += 1
    end
    for n in 1:N
        ans[n] = sz[p[n]] - 1 
        for d in direct[n]
            p[n]!=p[d] && continue
            ans[n] -= 1
        end
        println(ans[n], " ")
    end
end
FriendSuggestions()

Measured memory_bytes: 248012
(defparameter a (read))
(defparameter b (read))
(defparameter h (read))

(defun trape (x y z)
  (declare (type fixnum x y z)
           (optimize (speed 3) (safety 0)))
  (/ (* (+ x y) z) 2))

(compile 'trape)

(princ (trape a b h))

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,s;
    int x,y,z;
    int cnt=0;
    cin>>k>>s;
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
           z=s-x-y;
           if(z>=0 && z<=k)cnt++;
        }
    }
    cout<<cnt<<endl;
return 0;
}

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

cnt = [0] * (n+1)

for i in range(1, n+1):
    for j in range(i+1, n+1):
        cnt[min(j-i, abs(x-i)+abs(y-j)+1)] += 1

for i in range(1, n):
    print(cnt[i])


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "{";
  each (i, v) os << i << ", ";
  os << "}";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    if (n < 1200) {
      cout << "ABC" << endl;
      continue;
    }
    if (n < 2800) {
      cout << "ARC" << endl;
      continue;
    }
    cout << "AGC" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(void){
    int R;
    cin>>R;
    printf("%lf",2*R*M_PI);
    cout<<endl;
}

Measured memory_bytes: 3720
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = (int) IntStream.rangeClosed(1, n).filter(i -> String.valueOf(i).length() % 2 != 0).count();
		//IntStream.rangeClosed(1, n).filter(i -> String.valueOf(i).length() % 2 != 0).forEach(System.out::println);
		System.out.println(ans);
	}

}


Measured memory_bytes: 31060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h)cin>>s[i];
  int dx[8]={0,1,0,-1,1,1,-1,-1};
  int dy[8]={1,0,-1,0,1,-1,1,-1};
  rep(i,h)rep(j,w)if(s[i][j]=='.'){
    int cnt=0,k;
    rep(k,8)if(0<=i+dx[k] && i+dx[k]<h && 0<=j+dy[k] && j+dy[k]<w){
      if(s[i+dx[k]][j+dy[k]]=='#')cnt++;
    }
    s[i][j]='0'+cnt;
  }
  rep(i,h)cout<<s[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
mt19937_64 gen (random_device{}());
ll rint(ll a, ll b) { // generate rand int in [a, b]
    return a + gen() % (b - a + 1);
}

const int N = 2e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin >> n;
    vector<int> a(n+1);
    vector<int> f(13);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    if(f[0] > 1 || f[12] > 1) {
        cout << "0\n";
        return 0;
    }
    for(int i = 1; i < 12; i++) {
        if(f[i] > 2) {
            cout << "0\n";
            return 0;
        }
    }
    int ans = a[1];
    sort(a.begin() + 1, a.end());
    int rm = 0, lm = 24;
    for(int i = 1; i <= n; i++) {
        if(i & 1) {
            ans = min(ans, a[i] - rm);
            // cout << "rm: " << a[i] << " " << rm << endl;
            rm = a[i];
        } else {
            int pos = 24-a[i];
            ans = min(ans, lm - pos);
            // cout << "lm: " << pos << " " << lm << endl;
            lm = pos;
        }
        // cout << "A: " << ans << endl;
    }
    // cout << lm << " " << rm << endl;
    ans = min(ans, lm - rm);
    cout << ans << "\n";
    return 0;
    
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define iterator IT
inline int in(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
int a,b,c,d;
int main(){FAST;xRand;
cin>>a>>b>>c>>d;
cout<<a*b-b*c-a*d+c*d<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/





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

int main()
{
	ios::sync_with_stdio(false);
	int N;
	cin>>N;
	int jx=0,jy=0,jt=0,x,y,t;
	for(int i=0;i<N;++i)
	{
		cin>>t>>x>>y;
		int d=abs(y-jy)+abs(x-jx);
		int T=t-jt;

		if(T>=d&&(T-d)%2==0)	;
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
		jx=x;
		jt=t;
		jy=y;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
using namespace std;

#define INF 1<<21
#define MAX 100005
#define MOD 10e9+7

int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=100000;i++){
        if(i*i>n){
            cout<<ans<<endl;
            return 0;
        }
        ans=i*i;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 2e5 + 5;

 
int arr[31][31];

int32_t  main() {

	IOS;



	for (int i = 1; i <= INT_MAX; i++) {


		int tmp;
		cin >> tmp;

		if (tmp == 0) {
			cout << i << endl;
			break;
		}

	}

}

Measured memory_bytes: 3140
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const int  N     =  4e5+5;
const int  mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const int  LEVEL =  log2(N)+1;

ll n;
vll points, points1;

void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		ll x, y; cin >> x >> y;
		points.pb(x+y);
		points1.pb(x-y);
	}
	sort(all(points));
	sort(all(points1));
	deb1(max(abs(points[n-1] - points[0]), abs(points1[n-1] - points1[0])))
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 6728
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;

namespace {

}
int main()
{
	string S;

	cin >> S;

	set<char> strSet(S.cbegin(), S.cend());
	const set<char> str1 = { 'N', 'E', 'W', 'S' };
	const set<char> str2 = { 'N', 'S' };
	const set<char> str3 = { 'E', 'W' };

	if (strSet == str1 || strSet == str2 || strSet == str3){
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

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

using namespace std;

int main(){
    string s;
    cin>>s;

    int res=0;
    for(int i=0;i<s.size();i++){
        int j=i;
        int cnt=0;
        while(1){
            if(s[j]=='A'||s[j]=='T'||s[j]=='G'||s[j]=='C'){
                j++;
                cnt++;
            }else
                break;
        }
        res = max(res,cnt);
    }
    cout<<res;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    int n; cin >> n;
    ll a[n+1],b[n];
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans=0;
    ll res=0;
    rep(i,n){
        if(res+b[i]<=a[i]){
            ans+=res+b[i];
            res=0;
        }else if(res>=a[i]){
            ans+=a[i];
            res=b[i];
        }else{
            ans+=a[i];
            res=(res+b[i]-a[i]);
        }
    }
    ans+=min(res,a[n]);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
long long n, K, res;
int main() {
	int i, j;
	scanf("%lld%lld", &n, &K);
	if (K == 0) {
		printf("%lld\n", n*n);
		return 0;
	}
	for (i = K + 1; i <= n; i++) {
		for (j = 1; j <= n; ) {
			if (j + i <= n) {
				res += i - K;
				j += i;
				continue;
			}
			if (j%i < K)j += K - (j%i);
			if (j > n)break;
			if(n%i)res += n - j + 1;
			else res += n - j;
			break;
		}
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 128
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int x = fs.nextInt();
        int y = fs.nextInt();

        boolean isThere = false;
        for (int i = 0; i <= x; ++i) {
            int cranes = i;
            int turtles = x - i;
            if (cranes * 2 + turtles * 4 == y) {
                isThere = true;
                break;
            }
        }

        System.out.println(isThere? "Yes": "No");
   }
}


Measured memory_bytes: 32792
'use strict';
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  let inputs = input.split("\n");
  let tmp1 = inputs[0].split(" ");
  let l = inputs[1].split(" ");
  //文字列から10進数に変換するときはparseIntを使います
  let n = parseInt(tmp1[0], 10);
  let x = parseInt(tmp1[1], 10);

  let d = [];
  d.push(0);

  l.map(elm => parseInt(elm, 10))
    .forEach((elm, i) => {
    d[i + 1] = d[i] + elm;
  });

  if (d.findIndex(isLargeNumber) === -1) {
    console.log(d.length);
  } else {
    console.log(d.findIndex(isLargeNumber));
  }

  function isLargeNumber(element) {
    return element > x;
  }

  //出力
  // console.log('%d %s', b, c);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const int MAXN = 60;
const int MOD = 1000 * 1000 * 1000 + 7;
int dp[MAXN + 1][3][3];

void add(int &x, int y) {
    x += y;
    if (x >= MOD)
        x -= MOD;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    s1 = "#" + s1;
    s2 = "#" + s2;
    if (s1[1] == s2[1])
        dp[1][0][0] = dp[1][1][1] = dp[1][2][2] = 1;
    else {
        for(int i = 0; i <= 2; i++)
            for(int j = 0; j <= 2; j++)
                if (i != j)
                    dp[1][i][j] = 1;
    }
    for(int i = 2; i <= n; i++) {
        for(int a = 0; a <= 2; a++) {
            for(int b = 0; b <= 2; b++) {
                for(int c = 0; c <= 2; c++) {
                    for(int d = 0; d <= 2; d++) {
                        if (s1[i - 1] == s1[i] && a != c)
                            continue;
                        if (s2[i - 1] == s2[i] && b != d)
                            continue;
                        if (s1[i - 1] != s1[i] && a == c)
                            continue;
                        if (s2[i - 1] != s2[i] && b == d)
                            continue;
                        if (s1[i] != s2[i] && c == d)
                            continue;
                        if (s1[i] == s2[i] && c != d)
                            continue;
                        add(dp[i][c][d], dp[i - 1][a][b]);
                    }
                }
            }
        }
    }
    int res = 0;
    for(int i = 0; i <= 2; i++)
        for(int j = 0; j <= 2; j++)
            add(res, dp[n][i][j]);
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll N; 
    cin >> N;

    ll zeinuki = ceil(N/1.08);
    ll zeikomi = zeinuki * 1.08;
    
    if(zeikomi==N){
      p(zeinuki);
    }else{
      p(":(");
    }
    return 0;
}

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


int main(){
  double N;
  cin >> N;
  for(double h=1;h<=3500;++h){
    for(double n=2;n<=3500;++n){
      long long a=N*h*n;
      long long b=4*h*n-N*n-N*h;
      if(b>0 && a%b==0){
        auto w=a/b;
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
words = [input() for _ in range(n)]
words_count = collections.Counter(words)
first_word = words[0]
word_end = first_word[0]
not_siritori = 0

for i in words_count.values():
  if i > 1:
    not_siritori += 1

for word in words:
  if word_end != word[0]:
    not_siritori += 1
  word_end = word[-1]

if not_siritori != 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3316
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(N)]
    # 座標圧縮
    xs = []
    ys = []
    xy = sorted(xy, key=lambda x: x[0])
    for i in range(N):
        xs.append(xy[i][0])
        xy[i][0] = i+1
    xy = sorted(xy, key=lambda x: x[1])
    for i in range(N):
        ys.append(xy[i][1])
        xy[i][1] = i+1
    # 2次元累積和
    sum_ = np.zeros((N+1, N+1), dtype=int)
    for i in range(N):
        x, y = xy[i]
        sum_[y][x] = 1
    for i in range(1, N+1):
        sum_[i] += sum_[i-1]
    for i in range(1, N+1):
        sum_[:,i] += sum_[:,i-1]
    # 全探索
    ans = int(1e20)
    for l in range(1, N+1):
        no_three = True
        for r in range(N, l, -1):
            no_two = True
            for d in range(1, N+1):
                no_one = True
                for u in range(d+1, N+1):
                    tmp = sum_[u][r] - sum_[d-1][r] - sum_[u][l-1] + sum_[d-1][l-1]
                    if tmp >= K:
                        tmp = (xs[r-1] - xs[l-1]) * (ys[u-1] - ys[d-1])
                        ans = min(ans, tmp)
                        no_one = False
                        break
                if no_one:
                    break
                else:
                    no_two = False
            if no_two:
                break
            else:
                no_three = False
        if no_three:
            break
                

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14508
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VL l(n), r(n), d(n);
    REP(i,n){
        l[i] = in();
        r[i] = in();
        d[i] = r[i] - l[i];
    }
    multiset<ll> ri, le;
    ri.insert(l[0]);
    le.insert(l[0]);
    ll sr = 0, sl = 0, mi = 0;
    REP(i,n-1){
        sr += d[i];
        sl -= d[i + 1];
        ll r0 = *ri.begin() + sr;
        ll l0 = *le.rbegin() + sl;
        ll x = l[i + 1];
        if (x > r0){
            mi += x - r0;
            ri.insert(x - sr);
            ri.insert(x - sr);
            ri.erase(ri.find(r0 - sr));
            le.insert(r0 - sl);
        }else if (x < l0){
            mi += l0 - x;
            le.insert(x - sl);
            le.insert(x - sl);
            le.erase(le.find(l0 - sl));
            ri.insert(l0 - sr);
        }else{
            ri.insert(x - sr);
            le.insert(x - sl);
        }
        // cout << "right" << endl;
        // for (ll x : ri) cout << x + sr << " ";
        // cout << endl;
        // cout << "left" << endl;
        // for (ll x : le) cout << x + sl << " ";
        // cout << endl;
    }
    cout << mi << endl;

    return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n, Y, M, D;
  cin >> n;
  vector<int> ans;
  vector<int> mon = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0};
  for(int i = 0; i < n; i++){
    int A = 0;
    cin >> Y >> M >> D;
    for(int j = 999; j >= Y; j--){
      for(int k = 9; k >= 0; k--){
        if(j == Y && k <= M-1) continue;
        if((j)%3 == 0){
          A += 20;
        }
        else{
          A += 19+mon[k];
        }
      }
    }
    Y%3!=0?A += 19-D+mon[M-1]+1:A += 20-D+1;
    ans.push_back(A);
  }
  for(int i = 0; i < n; i++) cout << ans[i] << endl;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 1e5 + 2;
const ll MOD = 1e9 + 7;

int main()
{
    string str;
    cin >> str;
    //cout << str << endl;

    // dp[i][j] ...i桁目まで決めた時に13で割った余りがjの数のパターン
    //              をMODで割ったもの(i = 0, 1, .... , str.size()-1 )
    int N = str.size();
    ll dp[N][13];
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 13; ++j) dp[i][j] = 0;
    }

    ll digit = 1;
    // i = 0のとき、遷移の最初の状態を求める。
    if(str[N-1] != '?') {
        ll num = (ll)(str[N-1] - '0');
        dp[0][(num*digit)%13] = 1;
    }
    else {
        for(ll j = 0; j <= 9; ++j) 
            dp[0][(j*digit)%13] = 1;
    }

    for(int i = 1; i < N; ++i) {
        digit *= 10;
        digit %= 13;
        int i2 = N - i - 1;
        if(str[i2] != '?') {
            ll num = (ll)(str[i2] - '0');
            for(ll j = 0; j <= 12; ++j) {
                ll neo = (j + num*digit)%13;
                dp[i][neo] +=  dp[i-1][j];
                dp[i][neo] %= MOD;
            }
        }
        else {
            for(ll j = 0; j <= 9; ++j) {
                for(ll k = 0; k <= 12; ++k) {
                    ll neo = (k + j*digit)%13;
                    dp[i][neo] += dp[i-1][k];
                    dp[i][neo] %= MOD;
                }
            }
        }
    }

    cout << dp[N-1][5] << endl;
    return 0;
}

Measured memory_bytes: 10624
def dfs(i,s,sum):
  if i == 3:
    if sum == 7:
      print(s+"=7")
      exit()

  else:
    dfs(i+1, s + "+" + S[i+1], sum + int(S[i+1]))
    dfs(i+1, s + "-" + S[i+1], sum - int(S[i+1]))

S = str(input())
dfs(0,S[0],int(S[0]))

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


int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int _max=0;
    for(int i=0; i<n; i++){
        if(x >= a[i]){
            _max++;
            x -= a[i];
        }
    }
    if(_max == n && x >0){
        _max--;
    }

    cout << _max << endl;
}

Measured memory_bytes: 256
// She is Pretty pretty!
// DAG上dp
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e6+100;
int n , m , x , y ,dp[N], deg[N];
vector<int > G[N];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m ; i++){
        cin >> x >> y;
        deg[y]++;G[x].pb(y);
    }
    queue<int > q ;
    for(int i = 1; i <= n; i++){
        if(!deg[i])q.push(i);
    }
    while(!q.empty()){
        int now = q.front();
        q.pop();
        // cout << "now === " << now << endl;
        for(int it = 0; it < G[now].size(); it++){
            dp[G[now][it]] = max(dp[now]+1, dp[G[now][it]]);
            deg[G[now][it]]--;
            if(!deg[G[now][it]])q.push(G[now][it]);
            // cout << "it ==" <<  it << endl;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(dp[i], ans);
    }cout << ans << endl;
    return 0;
}

Measured memory_bytes: 29952
use std::io::Read;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s);
    let mut splits = s.trim().split_whitespace();

    let a = splits.next().unwrap().parse::<usize>().unwrap();
    let s = splits.next().unwrap().parse::<String>().unwrap();

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}

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

int main() {
  string S;
  cin >> S;
  bool check = true;
  for(int i = 0; i < S.size(); i++) {
    if(i % 2 == 0 && S.at(i) == 'L') {
      check = false;
      break;
    }
    else if(i % 2 == 1 && S.at(i) == 'R') {
      check = false;
      break;
    }
  }
  if(check) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 100;

int main()
{

	for (int z = 0; z < 100; z++) {

		int n, x;

		cin >> n >> x;
		if (n == 0 && x == 0)break;

		int count = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}

		cout << count << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)

	count := 0
	for {
		count++
		if s == 1 || s == 2 || s == 4 {
			fmt.Println(count + 3)
			break
		}
		if s%2 == 0 {
			s /= 2
		} else {
			s = 3*s + 1
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;

void solve(int T){
	int n,x,t;
	scanf("%d %d %d",&n,&x,&t);
	printf("%d",t*((n+x-1)/x)); 
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
////////////////////////////////////////////////*kedar1514*////////////////////////////////////////////////(Template Start)*****
#define endl "\n"
#define ll long long
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,n) for(i=1;i<=n;i++)
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define all(x)  (x.begin(),x.end())
#define sortAll(x) sort(all(x))   
#define clearAll(arr) memset(arr,0,sizeof(arr))
#define deb(sum) cout<<"deb = "<<sum<<endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
typedef pair<int, int>              pii;
typedef pair<long long, long long>  pll;
typedef vector<int>                 vi;
typedef vector<long long>           vl;
typedef vector<pii>                 vpii;
typedef vector<pll>                  vpll;
#define kedar ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll powerMod(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
	if (n & 1)
	  res = (res * x) % mod;
	x = (x * x) % mod;
	n >>= 1;
  }
  return res;
}

ll power(ll x, ll n) {
  ll res = 1;
  while (n) {
	if (n & 1)
	  res = (res * x);
	x = (x * x);
	n >>= 1;
  }
  return res;
}

int gcd(int A, int B) {
    if(B==0)
        return A;
    else
        return gcd(B, A % B);
}
////////////////////////////////////////////////*kedar1514*////////////////////////////////////////////////(Template ends)*****
// <<
//  <<,
//  , cout<<<<endl;
ll ww[105];
ll vv[105];
ll dp[105][100005];

ll totalCost(ll n,ll w)
{
  if(n==0||w==0)
  {
    return 0;
  }
  if(dp[n-1][w]!=-1)
  {
    return dp[n-1][w];
  }
  if(ww[n-1]<=w)
  {
    ll tt = vv[n-1]+totalCost(n-1,w-ww[n-1]);
    ll ttt = totalCost(n-1,w); 
    return dp[n-1][w] = max(tt,ttt);
  }
  else if(ww[n-1]>w)
  {
    return dp[n-1][w] = totalCost(n-1,w);
  }
}

void solve()
{
  ll n;
  ll w;
  cin>>n>>w;
  for (ll i = 0; i < n; i++)
  {
    cin>>ww[i]>>vv[i];
  }
  memset(dp,-1,sizeof(dp));
  cout<<totalCost(n,w);
}

int main(){
    kedar;
// <<
//  <<,
//  ,

    ll t=1;
    //cin>>t;
    while(t--)
    {       
        solve();
    }
    return 0;
}// <<
//  <<,
//  ,


Measured memory_bytes: 82304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int sum = (n * n) - x;
            out.println(sum);
        }

    }
}



Measured memory_bytes: 21716
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		String S = sc.next();

		sc.close();

		int h = 0; // 初期の幸福度
		for (int i = 0; i < N; i++) {
			if (S.charAt(i) == 'L') {
				if (i == 0) {
					continue;
				}

				if (S.charAt(i - 1) == 'L') {
					h++;
				}

			} else { // 'R'
				if (i == N - 1) {
					continue;
				}

				if (S.charAt(i + 1) == 'R') {
					h++;
				}
			}
		}

		int num = 0;
		for (int i = 1; i < N; i++) {
			if (S.charAt(i - 1) != S.charAt(i)) {
				num++;
			}
		}

		int ans = h + Math.min(num / 2, K) * 2 + Math.min(num % 2, Math.max(K - num / 2, 0));

		out.println(ans);

	}

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


Measured memory_bytes: 26400
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll X;

void dfs(vl &cnt, vl coin, ll kind, ll &pat){
  if(kind == 3){
    if(500*cnt[0] + 100*cnt[1] + 50*cnt[2] == X) pat++;
    return;
  }

  rep(i, coin[kind] + 1){
    cnt.push_back(i);
    dfs(cnt, coin, kind + 1, pat);
    cnt.pop_back();
  }
}

int main(){
  vl coin(3);
  cin >> coin[0] >> coin[1] >> coin[2] >> X;

  vl cnt;
  ll pat = 0;
  dfs(cnt, coin, 0, pat);

  cout << pat << endl;
  
  return 0;
}


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

#define int long long
#define pb emplace_back
#define f(i,n) for(int i=0 ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
int fun(int a, int b, int k)
{
	int ans = b/k - (a-1)/k;
	return ans;
}
int32_t main(){
	fast;
	int a,b,c,d;    cin >> a >> b >> c >> d;
	
	int tot = b - a + 1;
	int temp  = __gcd(c,d);
	int l = (c*d)/temp;
	int ans = fun(a,b,c) + fun(a,b,d) - fun(a,b,l);
	int qq= tot - ans;
	cout << qq;
}







Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int time = (h2 - h1) * 60;
	time += (m2 - m1) - k;
	if(time < 0)
		time = 0;
	cout << time << endl;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    string s;
    cin >> s;

    // 処理
    int  cnt = 0;
    bool ans = true;
    if (s[0] != 'A') {
        ans = false;
    }

    for (int i = 1; i < s.size(); i++) {
        if (isupper(s[i])) {
            if (i == 1 || i == s.size() - 1 || s[i] != 'C') {
                ans = false;
            } else if (s[i] == 'C') {
                cnt++;
            }
        }
    }

    // 出力
    cout << (cnt == 1 && ans == true ? "AC" : "WA") << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
f = [int(input().replace(" ",""),2) for j in range(n)]
p = [[int(i) for i in input().split()] for i in range(n)]

out = float('-inf')


for i in range(1,1024):
    b = 0
    for j in range(n):
        b += p[j][bin(f[j] & i).count('1')]
    out = max(b, out)
print(out)



Measured memory_bytes: 3060
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

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

    ll t = n / 11;
    t *= 2;
    ll rem = n % 11;
    if(rem > 5)
        t += 2;
    else
        t++;
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;

int n, m, cc[100002], nr, k, sz[100002], viz[100002];
vector<int> v[100002], bad[100002];

void dfs(int nod)
{
    cc[nod] = nr;
    ++sz[nr];
    viz[nod] = 1;
    for(int i = 0; i < v[nod].size(); ++i)
    {
        int vecin = v[nod][i];
        if(!viz[vecin])
            dfs(vecin);
    }
}
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k;
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i = 1; i <= k; ++i)
    {
        int a, b;
        cin >> a >> b;
        bad[a].pb(b);
        bad[b].pb(a);
    }
    for(int i = 1; i <= n; ++i)
        if(!cc[i])
        {
            ++nr;
            dfs(i);
        }
    for(int i = 1; i <= n; ++i)
    {
        int ans = sz[cc[i]] - v[i].size() - 1;
        for(int j = 0; j < bad[i].size(); ++j)
        {
            int vecin = bad[i][j];
            if(cc[vecin] == cc[i])
                --ans;
        }
        cout << ans << " ";
    }
    return 0;
}


Measured memory_bytes: 12664
#include<stdio.h>

int main()
{
	int dis[128][128];
	int i,j,n,x[128];
	
	scanf("%d",&n);
	for (i=1;i<=n;i++)	
		scanf("%d",&x[i]);
		
	for (i=1;i<=100;i++)
		for (j=1;j<=100;j++)
			dis[i][j]=(i-j)*(i-j);
		
	int min=2000000000;	
	int total;
	for (i=1;i<=100;i++)
	{
		total=0;
		for (j=1;j<=n;j++)
			total+=dis[i][x[j]];
		if (total<min) min=total;		
	}
	printf("%d",min);
	return 0;
}



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

d = [0]*(n-1)
for i in range(1, n+1):
    for j in range(i+1,n+1):
        c = min(j-i, abs(i-x)+1+abs(j-y))
        d[c-1] = d[c-1] + 1

for i in d:
    print(i)

Measured memory_bytes: 3572
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=2000;
const long long MOD=(long long)1e9+7;

int n,m;
long long tot,cnt;
int num[N+7];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			tot+=num[i]>num[j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cnt+=num[i]>num[j];
	long long ans=tot*m%MOD+(m-1ll)*m/2%MOD*cnt%MOD;
	printf("%lld\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(){

  int n,i,j,flag=1,t,c=0;

  int* A;

  scanf("%d",&n);
  A = (int*)malloc(n);
   for(i=0;i<n;i++){
     scanf("%d",&A[i]);
  }

   while(flag){

    flag=0;
    
    for(j=n-1;j>0;j--){
      
      if(A[j]<A[j-1]){
	t=A[j-1];
	A[j-1]=A[j];
	A[j]=t;
	c++;
	flag=1;
	
	}
      }
}
   printf("%d",A[0]);
   for(i=1;i<n;i++){
   printf(" %d",A[i]);
  }
  printf("\n%d\n",c);
  return 0;
}




Measured memory_bytes: 2140
#include <iostream>
#include <algorithm> 
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;

using ll = long long;

int main() {
	int n;
	cin >> n;
	int ans = (int) 1e9;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x < ans) {
			ans = x;
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dist_x = tx - sx
dist_y = ty - sy

print('R' * dist_x, end='')
print('U' * dist_y, end='')

print('L' * dist_x, end='')
print('D' * dist_y, end='')

print('D', end='')
print('R' * (dist_x + 1), end='')
print('U' * (dist_y + 1), end='')
print('L', end='')

print('U', end='')
print('L' * (dist_x + 1), end='')
print('D' * (dist_y + 1), end='')
print('R', end='')


Measured memory_bytes: 3064
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = list(str(readline().rstrip().decode('utf-8')))
    for i in range(1, len(s)):
        if s[i] != s[i-1]:
            print("Yes")
            exit()
    print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
   
  
   
int main(){
   
    int n; 
    int r[1000],w[1000];
    int sum_r=0,sum_w=0,idx=0;
    while(scanf("%d",&n),n){
         
        sum_r=sum_w=idx=0;
        for(int i=0;i<n;i++){
            scanf("%d %d",&r[i],&w[i]);
            sum_r+=r[i];
            sum_w+=w[i];
            if(r[idx]<r[i]) idx=i;
        }
  
        int r0=r[idx],r=sum_r-r0;
        w[idx]=0;
 
        if(r0 <= r){
            cout<<sum_r+sum_w<<endl;
        }else{
  
            int res=2*r0;
            //vector<vector<bool> > dp(1001,vector<bool>(1000,false));
  
			bool dp[1001][1000]={};
            dp[0][0]=true;
            for(int i=0;i<n;i++){
                for(int j=0;j<1000;j++){
                    if(dp[i][j]){
                        dp[i+1][j]=true; 
                        if(j+w[i]<1000)
                            dp[i+1][j+w[i]]=true; 
                    }
                }
            }
  
            int opt=r0-r;
            while(!dp[n][opt]) opt--;
  
            res+=sum_w-opt;
            printf("%d\n",res);
  
  
  
        }
          
          
    }
}

Measured memory_bytes: 2228