akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define M 1000000000
int CO[100010];
int MIN(int a,int b){return a<b?a:b;}
int R=1,C=1,H[2000010],N[2000010];
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int mifl(int v,int e,int f,int s,int t,int *a,int *b,int *c,int *d){
  int ta[110],to[2010],co[2010],nt[2010],ca[2010],u[110];
  int i,j,k,min,mi,ans=0,id[100010],fe[110],fv[110];
  int h[110]={0};
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ca[i  ]=c[i];
    ca[i+e]=0;
    co[ta[a[i]]=i  ]= d[i];
    co[ta[b[i]]=i+e]=-d[i];
  }
  while(f>0){
    for(i=0;i<v;i++)CO[i]=M;
    for(i=0;i<v;i++)u[i]=0;
    R=C=1;
    fv[s]=fe[s]=-1;
    CO[mi=s]=0;
    while(u[mi]-1){
      u[mi]=1;
      for(i=ta[mi];i+1;i=nt[i]){
	if(ca[i]&&  CO[to[i]]>CO[mi]+co[i]+h[mi]-h[to[i]]){
	  hin(CO[id[R]=to[i]]=CO[mi]+co[fe[to[i]]=i]+h[fv[to[i]]=mi]-h[to[i]]);
	}
      }
      while(u[mi]&&C-1)mi=id[hout()];
    }
    if(CO[t]==M)return -1;
    for(i=0;i<v;i++)h[i]+=CO[i];
    min=f;
    for(i=t;i-s;i=fv[i])min=MIN(min,ca[fe[i]]);
    f-=min;
    ans+=h[t]*min;
    for(i=t;i-s;i=fv[i]){
      ca[fe[i]]-=min;
      ca[(fe[i]+e)%(2*e)]+=min;
    }
  }
  return ans;
}
int main(){
  int v,e,m,i,a[100010],b[100010],c[100010],d[100010];
  scanf("%d %d %d",&v,&e,&m);
  for(i=0;i<e;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
  printf("%d\n",mifl(v,e,m,0,v-1,a,b,c,d));
  return 0;
}

Measured memory_bytes: 2728
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  char n[5];
  bool c[3]={0,0,0};
  cin>>n;
  for(int i=0;i<3;i++){
    switch(n[i]){
      case 'a':
        c[0]=1;
        break;
      case 'b':
        c[1]=1;
        break;
      case 'c':
        c[2]=1;
        break;
    }
  }
  if(c[0]&&c[1]&&c[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main(){
    int n; cin>>n;
    int a=n/100;
    int b=n%100;
    if(1<=a && a<=12){
        if(1<=b && b<=12) cout<<"AMBIGUOUS"<<endl;
        else cout<<"MMYY"<<endl;
    }
    else{
        if(1<=b && b<=12) cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}


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

int main() {

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

    long long n, k;
    cin >> n >> k;
    vector <long long> arr(n);
    for(int i=0;i<n;i++)
        cin >> arr[i];

    long long cost = LONG_LONG_MAX;
    for(int i=0;i<=n-k;i++){
        if(arr[i] < 0 && arr[i+k-1] <= 0){
            cost = min(cost, abs(arr[i]));
        }
        else if( arr[i]>=0 && arr[i+k-1] > 0){
            cost = min(cost, arr[i+k-1]);
        }
        else{
            cost= min(cost, min(abs(arr[i])*2+arr[i+k-1], abs(arr[i])+arr[i+k-1]*2));
        }
    }
    cout << cost << '\n';
    return 0;
}


Measured memory_bytes: 1024
def gcd(x, y):
    if x > y:
        tmp = x
        x = y
        y = tmp
    if x == 0:
        return y
    else:
        return gcd(y%x, x)

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

Llist = [0]
Rlist = [0]

for i in range(N):
    Llist.append(gcd(Llist[i], A[i])) 
    # Rlist.insert(0, gcd(Rlist[0], A[N-1-i]))
    Rlist.append(gcd(Rlist[i], A[N-1-i]))
Rlist = Rlist[::-1]
ans = 0
for i in range(N):
    t = gcd(Llist[i], Rlist[i+1])
    if ans < t:
        ans = t

print(ans)


Measured memory_bytes: 14436
#include <cstdio>

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

using namespace std;

int main(){
	int sx,sy,tx,ty; scanf("%d%d%d%d",&sx,&sy,&tx,&ty);

	rep(i,ty-sy) putchar('U');
	rep(i,tx-sx) putchar('R');
	rep(i,ty-sy) putchar('D');
	rep(i,tx-sx) putchar('L');

	putchar('L');
	rep(i,ty-sy+1) putchar('U');
	rep(i,tx-sx+1) putchar('R');
	putchar('D');
	putchar('R');
	rep(i,ty-sy+1) putchar('D');
	rep(i,tx-sx+1) putchar('L');
	putchar('U');

	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    int q;cin >> q;
    int rev = 0;
    string l, r;
    REP(i, q) {
        int t;
        cin >> t;
        if (t == 1)
        {
            rev = !rev;
        }
        if (t == 2)
        {
            int f;
            string c;
            cin >> f >> c;
            if((rev^(f-1))!=0){
                r += c;
            }else{
                l += c;
            }
        }
    }
    
    if(rev){
        reverse(ALL(r));
        reverse(ALL(s));
        cout << r << s << l << "\n";
    }else{
        reverse(ALL(l));
        cout << l << s << r << "\n";
    }

    return 0;
}

Measured memory_bytes: 1088
#include<bits/stdc++.h>
int num[10000000];

int main(){
    int n;
    scanf("%d",&n);
    int max=INT_MIN;
    for(int i=1;i<=n;i++){
        int temp;
        scanf("%d",&temp);
        num[temp]++;
        max=std::max(max,temp);
    }
    int t;
    scanf("%d",&t);

    unsigned long long count=0;
    for(int i=1;i<=max;i++){
        count+=i*num[i];
    }
    for(int i=1;i<=t;i++){
        int b,c;
        scanf("%d %d",&b,&c);
        if(num[b]){
            count += (c-b)*num[b];
            num[c]+=num[b];
            num[b]=0;
        }
        printf("%llu\n",count);
    }
}


Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[110][110000];
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;}
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  string s;
  cin >> s;
  int tmp = 0, ans = 0;
  rep(i,s.size()){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      tmp++;
    }else{
      chmax(ans,tmp);
      tmp=0;
    }
  }
  chmax(ans,tmp);
  cout << ans << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  
  vector<pair<int, int>> p(N);
  
  bool ans = false;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> p.at(i).first >>p.at(i).second;
    if(p.at(i).first == p.at(i).second){
      count++;
      if(count == 3)
        ans = true;
    }else{
    	count = 0;
    }
  }
  if(ans == true){
  cout << "Yes" << endl;   // Aliceの成績
  }else{
  cout << "No" << endl;   // Aliceの成績
  }

  
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX_N = 101;
const ll MAX_W = 1e5 + 10;
ll dp[MAX_N][MAX_W];

void init() {
	for (ll i = 0; i < MAX_N; i++) {
		for (ll j = 0; j < MAX_W; j++) {
			dp[i][j] = 0;
		}
	}
}

int main() {
	init();
	ll N, X;
	cin >> N >> X;
	vll W, V;
	ll i, j;
	for (i = 0; i < N; i++) {
		ll w, v;
		cin >> w >> v;
		W.push_back(w);
		V.push_back(v);
	}

	for (j = 0; j <= X; j++) {
		if (j < W[0]) {
			dp[1][j] = 0;
		}
		else {
			dp[1][j] = V[0];
		}
	}
	for (i = 2; i <= N; i++) {
		for (j = 0; j <= X; j++) {
			if (j - W[i - 1] < 0) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - W[i - 1]] + V[i - 1]);
			}
		}
	}
	cout << dp[N][X] << endl;

	return 0;
}


Measured memory_bytes: 79104
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
ans1=a[0]
num=99999999999999
for i in range(1,n):
    if ans1%2==0:
        u=abs(a[i]-ans1//2)
        if num>u:
            num=u
            ans2=a[i]
    else:
        u,v=abs(a[i]-ans1//2),abs(a[i]-(ans1//2+1))
        if num>min([u,v]):
            num=min([u,v])
            ans2=a[i]
print(ans1,ans2)


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

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v)
    is >> x;
  return is;
}

ostream &operator<<(ostream &os, const pair<char, int> &unit) {
  return os << unit.first << "^" << unit.second;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 200010;

int n;
vector<int> g[N];
int prt[N], mx[N], ans[N];
bool vis[N];

void dfs(int u) {
  vis[u] = true;
  for (int v : g[u])
    if (!vis[v]) {
      prt[v] = u;
      mx[v] = max(mx[u], u);
      dfs(v);
    }
}

int f(int u, int x) {
  static unordered_map<ll, int> memo;
  auto it = memo.find(u * (ll)n + x);
  if (it == memo.end()) {
    int ret = 1;
    for (int v : g[u])
      if (prt[v] == u && v < x)
        ret += f(v, x);
    it = memo.insert(make_pair(u * (ll)n + x, ret)).first;
  }
  return it->second;
}

void dfs2(int u) {
  if (u != 1) {
    if (u > mx[prt[u]])
      ans[u] = ans[prt[u]] + f(u, mx[u]);
    else
      ans[u] = ans[prt[u]] + f(u, mx[u]) - f(u, mx[prt[u]]);
  }
  for (int v : g[u])
    if (prt[v] == u)
      dfs2(v);
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n;
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1);
  dfs2(1);
  cout << vi(ans + 2, ans + n + 1);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
      -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 42824
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]


def binarysearch(start, end):
    left = start
    right = end
    mid = 0

    while left < right:
        mid = (left + right)//2
        # print(mid)
        if simulate(mid, w, k):
            right = mid
            # print("ok")
        else:
            mid += 1
            left = mid
    return mid


def simulate(prb, wei, dai):
    cnt = 1
    tmp = 0
    for j in wei:
        tmp += j
        if tmp > prb:
            tmp = j
            cnt += 1
            if cnt > dai:
                return False
    return True

print(binarysearch(max(w), sum(w)))

Measured memory_bytes: 11632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private static Dictionary<string,int> dic = new Dictionary<string, int>();

        static void Solve()
        {
            string s = Console.ReadLine();
            int ans = int.MaxValue;
            for(int i=0;i<s.Length-2;++i)
            {
                int num = int.Parse( s.Substring(i, 3));
                int d = Math.Abs(num - 753);
                ans = Math.Min(ans, d);
            }
            Console.WriteLine(ans);
        }
#region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
#endregion
    }
}

Measured memory_bytes: 11104
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  std::vector<int> a(3);
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  sort(all(a));
  printf("%d\n",a[0]+a[1]);
  return 0;
}


Measured memory_bytes: 256
#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;

//10000は100で2回割り切れてしまうので、D==1のときはいれない
int main(){
  ll D,N;
  cin >> D >> N;

  ll res = 1;
  REP(i,D)
  {
    res *= 100;
  }
  if(N == 100)N++;

  cout << res * N << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n,k,s; cin >>n >>k >>s;
  int a;
  if(s==1000000000) a=555555555;
  else a=s+1;
  rep(i,k){
    printf("%d ",s);
  }
  rep(i,n-k){
    printf("%d ",a);
  }
}

/// confirm df==0 ///


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,m);
    vector<vector<int>> graph(n);
    vector<int> checked(n,-1);
    int a,b;
    rep(i,m){
        in(a,b);
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    queue<int> next;
    int ans=0,x,d=0;
    for(int i=0;i<n;i++){
        if(checked[i]==-1){
            d=1;
            checked[i]=d;
            ans=max(ans,checked[i]);
            next.push(i);
            while(!next.empty()){
                x=next.front();
                next.pop();
                for(int j=0;j<graph[x].size();j++){
                    if(checked[graph[x][j]]==-1){
                        d++;
                        next.push(graph[x][j]);
                        checked[graph[x][j]]=d;
                        ans=max(ans,d);
                    }
                }
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 15640
#include <bits/stdc++.h>
using namespace std;
int64_t f(int64_t H) {
  if (H == 1) {
    return 1;
  } else {
    return f(H / 2) * 2 + 1;
  }
}
int main() {
  int64_t H;
  cin >> H;
  cout << f(H) << endl;
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
choco = [0] * n

for i in range(n):
    count = d
    while count > 0:
        count -= a[i]
        choco[i] += 1

ans = sum(choco) + x
print(ans)

Measured memory_bytes: 3064
from collections import Counter
from scipy.misc import comb
c=Counter()
n,m=map(int,input().split())
t=2
#Fanction of Factoring
while(t**2 <= m):
    if m%t:
        t+=1
        continue
    while m%t==0:
        c[t]+=1
        m//=t
if m>1:c[m]+=1
a=1

for i in c:
    a=a*comb(n+c[i]-1,n-1,exact=1)%(10**9+7)
print(a)


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define mod 1000000007

void solve(){
    int n;cin>>n;
    set<int> x;
    int a;
    for (int i=0;i<n;i++){
        cin>>a;
        x.insert(a);
    }cout<<x.size();
}

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

    solve();

    return 0;
}



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

#define FOR(i, a, n) for (int i = a; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
using lli = long long int;

int N;
int A[200001];

int main()
{
  cin >> N;
  REP(i, N) cin >> A[i];

  sort(A, A+N);
  reverse(A, A+N);

  lli ans = 0;
  priority_queue<lli> Q;
  Q.push(A[0]);
  FOR(i, 1, N) {
    ans += Q.top();
    Q.pop();
    Q.push(A[i]);
    Q.push(A[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6136
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main() {
	int S;
	cin >> S;
	int y = S % 100;
	int x = (S - y)/100;
	if (1<=x&&x<=12) {
		if (1 <= y && y <= 12)cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}
	else {
		if (1 <= y && y <= 12)cout << "YYMM"<<endl;
		else cout << "NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int w, h, n;
	int x[100], y[100], a[100];
	int nw = 0, nh = 0;
	
	cin >> w >> h >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			if (nw < x[i]) nw = x[i];
		}
		else if (a[i] == 2) {
			if (w > x[i]) w = x[i];
		}
		else if (a[i] == 3) {
			if (nh < y[i]) nh = y[i];
		}
		else if (a[i] == 4) {
			if (h > y[i]) h = y[i];
		}
	}
	
	cout << (w <= nw || h <= nh ? 0 : (w - nw) * (h - nh)) << endl;
	
	return (0);
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

ll fun(const Vl& B, ll b) {
    ll res = 0;
    for (const auto& bi : B) {
        res += abs(bi - b);
    }
    return res;
}

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

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

    ll t0, t1, t2, t3;
    t0 = -1e9, t3 = 1e9;
    while (t3 - t0 > 2) {
        t1 = (t0 * 2 + t3) / 3;
        t2 = (t0 + t3 * 2) / 3;

        ll f1 = fun(B, t1);
        ll f2 = fun(B, t2);

        if (f1 <= f2) {
            t3 = t2;
        }
        else {
            t0 = t1;
        }
    }

    cout << min(fun(B, t0), min(fun(B, t0 + 1), fun(B, t0 + 2))) << endl;

    return 0;
}

Measured memory_bytes: 1792
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl
#define REP(i,n) for(int (i) = 0; i < (n); ++(i))
#define Yes cout << "Yes" NL
#define No cout << "No" NL

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int INTMAX = numeric_limits<int>::max();
constexpr int INTMIN = numeric_limits<int>::min();
constexpr ll LLMAX = numeric_limits<long long>::max();
constexpr ll LLMIN = numeric_limits<long long>::min();
constexpr int MOD = 1000000007;


int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

using namespace std;


signed main() {

	int x, y;
	cin >> x >> y;

	cout << x + y / 2 NL;

	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=300003,INF=1<<30;
int prime[MAX];//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(300000);
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        int cnt=0;
        
        for(int i=N+1;i<=2*N;i++){
            if(is_prime[i]) cnt++;
        }
        
        cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3512
X = gets.to_i
sq = []
prev = 0
0.upto(100000) do |i|
  d = i*i*i*i*i
  sq << d
  break if d - prev > 1000000000
  prev = d
end

sq2 = sq.dup
sq.each do |a|
    sq2.shift
    sq2.each do |b|
        if a - b == X
            puts "#{sq.index(a)} #{sq.index(b)}"
            exit
        elsif (-a) - b == X
            puts "-#{sq.index(a)} #{sq.index(b)}"
            exit
        elsif a + b == X
            puts "#{sq.index(a)} -#{sq.index(b)}"
            exit
        elsif (-a) + b == X
            puts "-#{sq.index(a)} -#{sq.index(b)}"
            exit
        end
    end
end



Measured memory_bytes: 14384
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b;
    REP(i,m){
        int t;
        cin >> t;
        b.pb(t);
    }
    int ans = 0;
    REP(i,n){
        int sum=0;
        REP(j,m){
            int t;
            cin >> t;
            sum+=t*b[j];
        }
        sum+=c;
        if(sum>0)ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K, X; cin >> K >> X;
    rep2(i, -(K - 1), K){
        cout << X + i << " ";
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main() {

	int x; cin >> x;
	int ans = 0;
	for (int i = 1; i <= x / 10; i++) {
		if (100 * i <= x && x <= 105 * i) {
			ans = 1;
			break;
		}
	}
	cout << ans << endl;
    return 0;
}

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

int main() {
	int n, r = 0;
	cin >> n;
	int x [n];
	for(int i = 0; i < n; i++) cin >> x[i];
	priority_queue <int> A; A.push(0);
	for(int i = 0; i < n; i++){
		if(A.top() <= x[i]) r++;
		A.push(x[i]);
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

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


// a と b の最大公約数を返す
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}



// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


int main(){
    ll n;  cin >> n;
    ll res = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        res += i;
    }

    cout << res << endl;

    return 0;
}


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

main() {
    string S; cin >> S;
    map<char,int>m;
    rep(i,3)m[S[i]]++;
    cout << 700+m['o']*100 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int a,b;
    cin>>a>>b;
    if((a+b)%2) cout<<"IMPOSSIBLE";
    else cout<<(a+b)/2;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	Scanner stdin = new Scanner(System.in);

	while ( true ) {
	    final int n = stdin.nextInt();
	    final int sum = stdin.nextInt();

	    if ( n == 0 && sum == 0 ) {
		break;
	    }
	    
	    System.out.println( dfs( 0, n, 0, sum, -1 ) );	    
	}
	
    }

    static int dfs( final int depth, final int maxDepth, final int sum, final int maxSum, final int maxNum ) {
	if ( depth == maxDepth ) {
	    return ( sum == maxSum ? 1 : 0 );
	} 

	int ans = 0;
	final int lim = Math.min( maxSum - sum, 9 );
	for ( int i = maxNum + 1; i <= lim; i++ ) {
	    ans += dfs( depth + 1, maxDepth, sum + i, maxSum, i );
	}
	return ans;	
    }
    
}

Measured memory_bytes: 18060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll A, B, C;
	
	cin >> A >> B >> C;

	/*
	ll count = 0;
	for (ll i = A; i <= B; i++)
	{
		if (i % C == 0)
		{
			count++;
		}
	}
	*/

	ll start = 0, end = 0;

	if (A % C == 0)
	{
		start = A / C;
	}
	else 
	{
		start = A / C + 1;
	}

	if (B % C == 0)
	{
		end = B / C;
	}
	else 
	{
		end = B / C ;
	}

	cout << end - start + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;

	k--;

	s[k] = tolower(s[k]);
	cout << s << endl;

	return 0;
}


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

int main() {
    ll x;
    cin >> x;

    ll ans = x / 11 * 2;
    ll a = x % 11;
    if (a == 0) {
        cout << ans << endl;
        return 0;
    } else if (a <= 6)
        ans++;
    else
        ans += 2;

    cout << ans << endl;
    return 0;
}


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

import numpy as np

def main():
    n,m,c = map(int, input().split())
    b_li = np.array(list(map(int, input().split())))

    ans = 0

    for i in range(n):
        a_li = np.array(list(map(int, input().split())))

        if np.dot(a_li, b_li)+c > 0:
            ans += 1

    print(ans)




if __name__ == '__main__':
    main()


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


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [0 for _ in range(k + 1)]

    # See:
    # https://atcoder.jp/contests/dp/submissions/3956066
    for i in range(k):
        if dp[i]:
            continue

        for ai in a:
            if i + ai > k:
                break

            dp[i + ai] = 1

    if dp[-1] == 1:
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3864
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

typedef long long ll;

const int N = 1e5 + 5;

int A[N];

int main()
{
    fast;

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

    int n;
    cin>>n;

    for(int i=1;i<10;i++){
        if(n%i==0){
            if(n/i<10) {
                cout<<"Yes";
                return 0;
            }
        }
    }

    cout<<"No";
   

    return 0;
}


Measured memory_bytes: 256
H, W, K = gets.chomp.split.map(&:to_i)

mas = []

H.times do 
  mas << gets.chomp
end

ans = 0
(2**H).times do |h_bit|
  (2**W).times do |w_bit|
    h_bit_bool = h_bit.to_s(2).chars.map(&:to_i).reverse
    h_bit_bool += [0] * (H - h_bit_bool.size)
    w_bit_bool = w_bit.to_s(2).chars.map(&:to_i).reverse
    w_bit_bool += [0] * (W - w_bit_bool.size)
    ct = 0
    H.times do |h|
      W.times do |w|
        ct += 1 if h_bit_bool[h] == 1 && w_bit_bool[w] == 1 && mas[h][w] == "#"
      end
    end
    ans += 1 if ct == K
  end
end 

puts ans


Measured memory_bytes: 14276
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    int n;
    double x;
    string u;
    double ans = 0;
    cin >> n;
    rep(i,n){
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else{
            ans += 380000*x;
        }
    }
    printf("%.10f",ans);
}

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

def bellmanford(G, s):
    n = len(G)
    inf = -float('inf')
    dist = [inf] * n
    dist[s] = 0
    for i in range(2*n):
        for v in range(n):
            for w, c in G[v]:
                if dist[w] < dist[v] + c:
                    dist[w] = dist[v] + c
                    if i >= n - 1 and w == n-1:
                        return -1
    return dist

def main():
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append((b, c))
    dist = bellmanford(graph, 0)
    if dist == -1:
        print("inf")
    else:
        print(dist[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v,int N,bool visited[nmax]){

  bool all_visited = true;

  for(int i=0;i<N;i++){
    if(visited[i] == false)
    all_visited = false;
  }

  if(all_visited){
    return 1;
  }

  int ret = 0;

  for(int i=0;i<N;i++){
    if(graph[v][i] == false)continue;
    if(visited[i])continue;

    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i] = false;
  }

  return ret;

}

int main(void){
  int N,M;
  cin >> N >> M;

  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
  }

  bool visited[nmax];
  for(int i=0;i<N;i++){
    visited[i] = false;
  }

  visited[0] = true;
  cout << dfs(0,N,visited) << endl;

  return 0;

}


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

#define M 100
#define TRUE 10
#define WHITE 1
#define BLACK 2
#define GRAY 3
stack<int> T;
int n,t = 1,D[M + 1],F[M + 1],color[M + 1],N[M + 1][M + 1],Ni[M + 1];

int next(int v){
  for(int i = Ni[v];i <= n;i++){
    Ni[v] = i + 1;
    if(N[v][i] == TRUE) return i;
  }
  return -1;
}
  
void dsearch(int v){
  int top;
  
  T.push(v);
  color[v] = GRAY;
  D[v] = t++;

  while(!T.empty()){
    v = T.top();
    top = next(v);
    if(top != -1){
      if(color[top] == WHITE){
	color[top] = GRAY;
	D[top] = t++;
	T.push(top);
      }
    }
    else{
      T.pop();
      color[v] = BLACK;
      F[v] = t++;
    }
  }
}
  
int main (){
  int r,c,v;

  cin >> n;
  for(int i = 1;i <= n;i++){
    color[i] = WHITE;
    Ni[i] = 0;
  }
 
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      N[i][j] = 0;
    }
  }
  
  for(int i = 1;i <= n;i++){
    cin >> r >> c;
    for(int j = 1;j <= c;j++){
      cin >> v;
      N[r][v] = TRUE;
    }
  }
  for(int i = 1;i <= n;i++){
    if(color[i] == WHITE) dsearch(i);
  }
  for(int i = 1;i <= n;i++){
    cout << i << " "<< D[i] << " "<< F[i] << endl;
  }

  return 0;
}

  



Measured memory_bytes: 3124
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,t,r){"use strict";e.exports=function(e){for(var t=Number(e[0]),r=e[1].split(" ").map(function(e){return Number(e)}),n=0,o=r[0],u=1,i=0;i<t;i++){for(;f(o,u)&&u<t;)o^=r[u],u++;n+=u-i,o^=r[i]}function f(e,t){return(e^r[t])==(e|r[t])}console.log(n)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 22256
import java.util.*;

// public class A{
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = x - x % 11L;
        long ans = y / 11L * 2L;
        ans += (x % 11L == 0L)? 0L : (x % 11L <= 6)? 1L : 2L;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#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>
using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<long long> arr(n);
    vector<long long> ans(n, 0);
    for (long long i=0; i<n; i++) {
        cin >> arr[i];
        ans[0] += arr[i];
        arr[i] *= 2;
    }
    for (long long i=0; i<n/2; i++) {
        ans[0] -= arr[(i*2+1)%n];
    }
    for (long long i=0; i<n; i++) {
        if (i) ans[i] = arr[i-1] - ans[i-1];
        cout << ans[i] << ' ';
    }
}

Measured memory_bytes: 2816
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

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

int main()
{
  int ans = 1;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  rep(i,n){
    if(a[i] == a[i+1]){
      ans = 0;
    }
  }
  if(ans){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	c[0] = 0;
	for(int i = 1; i < n; i++) {
		cin >> c[i];
	}
	ll total = b[a[0]];
	for(int i = 1; i < n; i++) {
		total += b[a[i]];
		if(a[i - 1] + 1 == a[i]) {
			total += c[a[i]];
		}
	}
	cout << total;	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3608
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,a,b = readline() |> split |> parseMap
	if a*b<n||a+b>n+1
		println(-1)
	else
		if b == 1
			for i in 1:n-1
				print(i, " ")
			end
			println(n)
		else
		x = floor(Int,(a*b-n)/(b-1))
		k = ceil(Int,(n-x)/b)
		for i in 1:x
			print(i," ")
		end
		nx = x
		for i in 1:k-1
			for j in b:-1:1
				print(nx+j," ")
			end
			nx += b
		end
		for i in n:-1:nx+2
			print(i," ")
		end
		println(nx+1)
		end
	end
end

main()

Measured memory_bytes: 151016
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		String str = scan.nextLine();
		String strA="";
		String strB="";


		for (int i = 2;i < str.length() + 1;i++) {
			String temp =str.substring(0, str.length() - i);
			if (temp.length() % 2 != 0) {
				continue;
			}

			strA = temp.substring(0, temp.length() / 2);
			strB = temp.substring(temp.length() / 2, temp.length());

			if (strA.equals(strB)) {
				break;
			}
		}

		System.out.println(strA.length() * 2);

	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  string S;
  cin >> A >> B >> C;
  rep(i,0,C){
    if(i%2==0){
      if(A%2==1)A--;
      B+=A/2;
      A-=A/2;
    }
    else{
      if(B%2==1)B--;
      A+=B/2;
      B-=B/2;
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	map<char,int> mp;
	ll n; cin >> n;
	rep(i,n){
		char c; cin >> c;
		mp[c]++;
	}
	if(mp.size()==3) puts("Three");
	else puts("Four");
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

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;
  }
}


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

int main() {
  int n, cnt = 0, genius = 0;
  bool gray = true, brown = true, green = true, lightblue = true, blue = true,
       yellow = true, orange = true, red = true;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp >= 3200) {
      genius++;
    } else if (tmp >= 2800 && tmp < 3200 && red) {
      cnt++;
      red = false;
    } else if (tmp >= 2400 && tmp < 2800 && orange) {
      cnt++;
      orange = false;
    } else if (tmp >= 2000 && tmp < 2400 && yellow) {
      cnt++;
      yellow = false;
    } else if (tmp >= 1600 && tmp < 2000 && blue) {
      cnt++;
      blue = false;
    } else if (tmp >= 1200 && tmp < 1600 && lightblue) {
      cnt++;
      lightblue = false;
    } else if (tmp >= 800 && tmp < 1200 && green) {
      cnt++;
      green = false;
    } else if (tmp >= 400 && tmp < 800 && brown) {
      cnt++;
      brown = false;
    } else if (tmp < 400 && gray) {
      cnt++;
      gray = false;
    }
  }

  if (cnt == 0) {
    cout << 1 << " " << genius;
    return 0;
  }

  cout << cnt << " " << cnt + genius;

  return 0;
}

Measured memory_bytes: 256