akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int h,w;
	cin>>h>>w;
	if(h%3==0||w%3==0){
		cout<<0<<endl;
		return 0;
	}
	int a,b,c;
	int men=h*w;
	int ans=mod,ans2=mod;
	Rep(i,h){
		int sum;
		a=i*w;
		if((h-i)%2==0||w%2==0){
			b=(men-a)/2;
			c=(men-a)/2;
			sum=abs(a-b);
		}
		else{
			b=min((h-i),w)*(max((h-i),w)/2);
			c=men-a-b;
			sum=max({a,b,c})-min({a,b,c});
		}
		if(sum<ans)ans=sum;
	}
	Rep(i,w){
		int sum2;
		a=i*h;
		if((w-i)%2==0||h%2==0){
			b=(men-a)/2;
			c=(men-a)/2;
			sum2=abs(a-b);
		}
		else{
			b=min((w-i),h)*(max((w-i),h)/2);
			c=men-a-b;
			sum2=max({a,b,c})-min({a,b,c});
		}
		if(sum2<ans2)ans2=sum2;
	}
	cout<<min(ans,ans2)<<endl;
}



Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力
static int siMCnt;												// マス数
static int siLVal;												// 左マス値
static int siRVal;												// 右マス値
static int siDfL;												// 差(小)
static int siDfB;												// 差(大)

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 入力値 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d%d%d%d", &siMCnt, &siLVal, &siRVal, &siDfL, &siDfB);

	// 値範囲
	long long llMaxU = (long long)siLVal + (long long)siDfB * (long long)(siMCnt - 1);
	long long llMaxD = (long long)siLVal + (long long)siDfL * (long long)(siMCnt - 1);
	long long llMinU = (long long)siLVal - (long long)siDfB * (long long)(siMCnt - 1);

	// 範囲チェック
	int liRet = -1;
	long long llNowU = llMaxU;
	long long llNowD = llMaxD;
	while (llNowU >= llMinU) {
		if (llNowD <= (long long)siRVal && (long long)siRVal <= llNowU) {
			liRet = 0;
			break;
		}

		// 次へ
		llNowU -= siDfB + siDfL;
		llNowD -= siDfB + siDfL;
	}

	// 結果 - セット
	if (liRet == 0) {
		sprintf(lc1Out, "YES\n");
	}
	else {
		sprintf(lc1Out, "NO\n");
	}

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{

  class Class1
  {
    static void Main()
    {
      int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();
      char[] dir = Console.ReadLine().ToCharArray();
      Dice dice = new Dice(num);

      foreach (var i in dir)
      {
        switch (i)
        {
          case 'N':
            dice.north();
            break;
          case 'E':
            dice.east();
            break;
          case 'W':
            dice.west();
            break;
          case 'S':
            dice.south();
            break;
        }
      }
      Console.WriteLine(dice.face[0]);
    }
  }

  class Dice
  {
    public int[] face = new int[6];
    public Dice(int[] face)
    {
      this.face = face;
    }

    public void north()
    {
      face = new int[] { face[1], face[5], face[2], face[3], face[0], face[4] };
    }
    public void east()
    {
      face = new int[] { face[3], face[1], face[0], face[5], face[4], face[2] };
    }
    public void west()
    {
      face = new int[] { face[2], face[1], face[5], face[0], face[4], face[3] };
    }
    public void south()
    {
      face = new int[] { face[4], face[0], face[2], face[3], face[5], face[1] };
    }
  }
}





Measured memory_bytes: 9584
th, ta, ah, aa = [int(x) for x in input().split(' ')]

index = 0
while (th > 0 and ah > 0):
    if index % 2 == 0:
        ah -= ta
    else:
        th -= aa

    index += 1

if th <= 0:
    print("No")
else:
    print("Yes")

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

#define fi first
#define se second
typedef long long ll;
const int N = 2e5 +7;

int main()
{
    int a;
    scanf("%d",&a);
    int n = a % 10;
    if(n==2||n==4||n==5||n==7||n==9)
        printf("hon\n");
    if(n==0||n==1||n==6||n==8)
        printf("pon\n");
    if(n==3)
        printf("bon\n");

}


Measured memory_bytes: 3724
#include<iostream>
using namespace std;
int main(){
	int a,b,x;
	cin>>a>>b>>x;
	int d=x-a;
	if (a>x)
	cout<<"NO"<<endl;
	else if (a==x)
	cout<<"YES"<<endl;
	else {
		if (d>b)
		cout<<"NO"<<endl;
		else 
		cout<<"YES"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
ll mod =1000000007;
ll fact[100005];
vector<ll> v[100005];
ll k=7;
void factorial()
{
    fact[0]=1;
    for(int i=1;i<100005;i++){
        fact[i]=(fact[i-1]*i)% mod;
    }
}
ll power(ll a,ll b)
{
    ll res=1LL;
    while(b>0){
        if(b&1LL) res=(res*a)%mod;
        b>>=1;
        a=(a*a)% mod;
        
    }
    return res%mod;
}
ll inv(ll a)
{
    return power(a,mod-2)%mod;
}
ll npr(ll n, ll r)
{
    if(n<(r)) return 0;
    ll ans=fact[n-r];
    ans=inv(ans);
    return (fact[n]*ans)%mod;
    
}
ll vis[100005];
ll fin=1LL;
void dfs(ll a){
    if(vis[a]==1) return ;
    vis[a]=1;
    for(int i=0;i<v[a].size();i++){
        if(vis[v[a][i]]==0){
            fin*= npr(k-2,v[v[a][i]].size()-1);
            fin%=mod;
            dfs(v[a][i]);
            vis[v[a][i]]=1;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    factorial();
    cin>>n>>k;
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        v[a].push_back(b); v[b].push_back(a);
    }
    ll ans=1LL;
    ans*=k;
    ans*=npr(k-1,v[1].size());
    ans%=mod;
    dfs(1);
    ans*=fin;
    ans%=mod;
    cout<<ans%mod<<endl;
    
    
}


Measured memory_bytes: 10752
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static int count(String s, String t) {
      if (t.length() > s.length()) return Integer.MAX_VALUE;
      int res = 0;
      for (int i = 0; i < t.length(); i++) {
         if (s.charAt(i) != t.charAt(i)) res++;
      }
      return res;
   }

   static void solve(InputReader in, PrintWriter out) {
      String s = in.nextToken(), t = in.nextToken();

      int ans = Integer.MAX_VALUE;
      for (int i = 0; i < s.length(); i++) {
         ans = Math.min(ans, count(s.substring(i, Math.min(s.length(), i + t.length())), t));
      }
      out.println(ans);
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

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

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

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

}


Measured memory_bytes: 34008
#include<stdio.h>

void print(int A[], int N){
    for(int i = 0; i < N-1; i++){
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
}

void insertionSort(int A[], int N){
    for(int i = 0; i < N; i++){
        int v, j;
        v = A[i];
        j = i-1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        print(A, N);
    }
}

 

int main(void){
    int n, a[200];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    insertionSort(a, n);

    return 0;   
}


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

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}


int main(){
    long long N,M,X;
    cin>>N>>M>>X;
    long long A[N][M];
    long long C[N];
    long long minans=10000000;
    long long ans;
    for(int i=0;i<N;i++){
        cin>>C[i];
        for(int j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    
    
    bool exist = false;
    for (int bit = 0; bit < (1 << N); ++bit) {
        // どれを選ぶか
        vector<int> S = IntegerToVector(bit, N);

        // 部分集合に対応する総和
        vector <int> sum(M,0) ;
        for(int j=0;j<M;j++){
            for (int i : S) sum[j]+=A[i][j];
        }
        int flag=1;
        for(int k=0;k<M;k++){
            if(sum[k]<X) flag=0;
        }
        if(flag==1){
            ans=0;
            for (int i : S) ans+=C[i];
            minans=min(minans,ans);
        }
    }
    if(minans==10000000){
        cout<<-1<<endl;
        return 0;
    }
    cout<<minans<<endl;
    

    return 0;

    
}


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

using namespace std;

int main() {
  
  char s[5];
  scanf("%s", s);
  for(int i = 1; i < 4; i++) {
    if(s[i] == s[i-1]) {
      printf("Bad");
      return 0;
    }
  }
  printf("Good");
  
  return 0; 
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long ll;
ll arr[100010], s[100010];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i <= n; ++i)
		scanf("%lld", arr + i);
	s[n] = arr[n];
	for (int i = n - 1; i >= 0; --i)
		s[i] = s[i + 1] + arr[i];
	ll ans = 0, cur = 1;
if (n == 0) {
puts(arr[0] == 1 ? "1" : "-1");
return 0;
}
	if (arr[0] || !arr[n]) {
		puts("-1");
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		if (cur > s[i + 1])
			cur = s[i + 1];
		if (cur * 2 < arr[i + 1]) {
			puts("-1");
			return 0;
		}
		ans += cur + arr[i];
		cur = cur * 2 - arr[i + 1];	
	}
	printf("%lld", ans + arr[n]);
	return 0;
}

Measured memory_bytes: 3276
import copy
N, M, X = map(int, input().split())
C = []
A = []
for n in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

buy = []
queue = [buy]
counter = 0
min_cost = 10000000
while counter < len(queue):
    item = queue[counter]
    counter += 1
    if len(item) != N:
        for dicision in [True, False]:
            tmp = copy.copy(item)
            tmp.append(dicision)
            queue.append(tmp)
    else:
        cost = 0
        B = [0] * M
        for index, book in enumerate(item):
            if book:
                cost += C[index]
                for m in range(M):
                    B[m] += A[index][m]
        clear = True
        for b in B:
            if b < X:
                clear = False
        if clear and cost < min_cost:
            min_cost = cost

print(-1 if min_cost == 10000000 else min_cost)

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red"  << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

int N;
int A, B, C;
vi l;
int ans;

void dfs(int n, vi& use) {
    if (n >= N) {
        int a = 0, b = 0, c = 0;
        int cat = 0;
        REP(i,N) {
            switch (use[i]) {
            case 1:
                if (a > 0) cat++;
                a += l[i];
                break;
            case 2:
                if (b > 0) cat++;
                b += l[i];
                break;
            case 3:
                if (c > 0) cat++;
                c += l[i];
                break;
            default:
                break;
            }
        }
        if (a > 0 && b > 0 && c > 0) {
            ans = min(ans, cat * 10 + abs(a - A) + abs(b - B) + abs(c - C));
        }
        return;
    }

    REP(i,4) { // 0:Not Used, 1:A, 2:B, 3:C
        use[n] = i;
        dfs(n + 1, use);
    }
}

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

    cin >> N;
    cin >> A >> B >> C;
    l = vi(N); REP(i, N) cin >> l[i];
    
    ans = INF;
    vi use(N, 0);
    dfs(0, use);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//まだ解けていない



//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool p[55000];

void prime() {
  fill(p, p+55000, true);
  p[0] = false;
  p[1] = false;

  for(int i = 2; i < 55000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 55000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n, min, max;
  prime();
  
  while(cin >> n) {
    max = 2;
    for(int i = 3; i < n; i++) {
      if(p[i] && max < i) max = i;
    }
    for(int i = n+1; i < 55000; i++) {
      if(p[i]) {
	min = i;
	break;
      }
    }
    cout << max << ' ' << min << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define N 231080
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define pii pair<ll,ll>
#define mp make_pair
#define fr first
#define sd second
#define mcpy(x,y) memcpy(x,y,sizeof(x))
#define mset(x,y) memset(x,y,sizeof(x))
using namespace std;
int n,cnt[N];
ll mn[N];
vector<pii> a[N];
vector<int> g[N];
bool cmp1(const pii &x,const pii &y){ return x.fr<y.fr; }
bool cmp2(const pii &x,const pii &y){ return x.sd<y.sd; }
struct ed{ int v,w; }ch[N][2];
void merge(vector<pii> &c,vector<pii> &aa,vector<pii> &bb,ll val){
	//if(aa.size()<bb.size()) aa.swap(bb);
	sort(aa.begin(),aa.end(),cmp2);
	sort(bb.begin(),bb.end(),cmp1);
	int _a=(int)aa.size(),_b=(int)bb.size();
	int p=_a-1;
	mn[0]=aa[0].fr;
	For(i,1,_a-1) mn[i]=min(mn[i-1],aa[i].fr);
	For(i,0,_b-1){
		while(p>=0 && aa[p].sd+bb[i].fr>val) p--;
		if(p>=0) c.push_back(mp(mn[p],bb[i].sd));
	}p=_a-1;
	sort(aa.begin(),aa.end(),cmp1);
	sort(bb.begin(),bb.end(),cmp2);
	mn[0]=aa[0].sd;
	For(i,1,_a-1) mn[i]=min(mn[i-1],aa[i].sd);
	For(i,0,_b-1){
		while(p>=0 && aa[p].fr+bb[i].sd>val) p--;
		if(p>=0) c.push_back(mp(bb[i].fr,mn[p]));
	}
}
void dfs(int x,ll val){
	if(!a[x].empty()) a[x].clear();
	if(!cnt[x]){ a[x].push_back(mp(0,0));return; }
	for(auto to:g[x]) dfs(to,val);
	vector<pii> &ls=a[ch[x][0].v];
	vector<pii> &rs=a[ch[x][1].v];
	For(i,0,(int)ls.size()-1)ls[i].fr+=ch[x][0].w,ls[i].sd+=ch[x][0].w;
	For(i,0,(int)rs.size()-1) rs[i].fr+=ch[x][1].w,rs[i].sd+=ch[x][1].w;
	if(ls.size()<rs.size()) swap(ls,rs);
	merge(a[x],ls,rs,val);
	a[ch[x][0].v].clear();
	a[ch[x][1].v].clear();
}
bool check(ll x){
	dfs(1,x);
	if(a[1].size()==0) return 0;
	return 1;
}
int main(){
	int x,v;ll ans;
	ll l=0,r=0;
	scanf("%d",&n);
	For(i,2,n) scanf("%d%d",&x,&v),ch[x][cnt[x]++]=(ed){i,v},g[x].push_back(i),r+=v;
	ans=r;
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 41076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    string s;
    cin >> s;

    int N = sz(s);


    rep(i,N-1){
        if(s[i] == s[i+1]){
            cout << i+1 << ' ' << i+2 << endl;
            return 0;
        }
        if(i < N-2 && s[i] == s[i+2]){
            cout << i+1 << ' ' << i+3 << endl;
            return 0;
        }
        // if(i < N-3 && s[i] == s[i+3]){
        //     cout << i+1 << ' ' << i+4 << endl;
        //     return 0;
        // }
    }

    cout << -1 << ' ' << -1 << endl;


}

Measured memory_bytes: 512
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑



int digits(int n) {
	int ans = 0;
	while (n) {
		++ans;
		n /= 10;
	}
	return ans;
}

int main() {


	ll n, k[100005];
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	--k[0];
	for (int i = 1; i < n; ++i) {
		if (k[i] > k[i - 1]) { --k[i]; }
	}

	for (int i = 1; i < n; ++i) {
		if (k[i] < k[i - 1]) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

ll a[112345];
ll b[112345];

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<ll, int>> v;
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    v.emplace_back(m - a[i], b[i]);
  }
  sort(begin(v), end(v));
  priority_queue<int> pq;
  ll ans = 0;
  for(int i = m; i >= 0; i--) {
    while(v.size() and v.back().first == i) {
      pq.push(v.back().second);
      v.pop_back();
    }
    if(pq.size()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4336
N, M = map(int, input().split())

shop_list = [0] * N

for n in range(N):
    shop_list[n] = list(map(int, input().split()))

sorted_list = sorted(shop_list, key=lambda x: x[0])

need_count = M
cost = 0
for item in sorted_list:
    if need_count >= item[1]:
        cost += item[1] * item[0]
        need_count -= item[1]
        if need_count < 0:
            break
    elif need_count < item[1]:
        cost += need_count * item[0]
        need_count -= item[1]
        if need_count < 0:
            break
print(cost)
        

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

map<int, int> m;
int a[200009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
	}
	sort(a, a + n);
	int t = (1 << 30);
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		while (t / 2 > a[i]) t /= 2;
		if (m[a[i]] <= 0)
			continue;
		m[a[i]]--;
		for (int j = t; j >= a[i]; j /= 2) {
			if (m[j - a[i]] > 0) {
				m[j - a[i]]--; ans++;
				break;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  rep(i,s.size()){
    if(s[i]=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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


int main(){
	/*
		what's important so far? happiness and decision made for it
		why do i need to track decisions or happiness via different paths?
		so that later on i can choose a sequence of decisions that gives overall better happiness
		how far back do i need to store decisions and corresponding happiness?
		if i ensure that every decision-happiness cell takes care of i!=j where j=i+1
		that is consecutive days don't have same activity then I only need 2 arrays
		i can switch decisions using the info of prev day and current day and it won't violate any rule
		because values of prev day are already consistent with the non-consecutive restriction
	*/
	int n;
	cin>>n;
	vector<int> prev(3,0);
	vector<int> curr(3,INT_MIN);
	vector<int> values(3,0);
	while(n--){
		// fill in values of happiness given by activities today
		for(auto& v: values) cin>>v;
		// pick one today and can't pick one from prev -> 3*2 possibilities 
		for(int i=0;i<3;++i){
			for(int j=0;j<3;++j){
				if(i!=j){
					curr[j] = max(curr[j] , values[j] + prev[i] );
				}
			}
		}
		prev = curr;
	}
	cout<<max({curr[0],curr[1],curr[2]});
}

Measured memory_bytes: 256
#3
s = str(input())
t = str(input())
memo = {}
ifadd = False
ifsamedest = False
destlist = set()
for i in range(len(s)):
    sor = s[i]
    des = t[i]
    if sor not in memo:
        memo[sor] = des
        if des in destlist:
            ifsamedest = True
        destlist.add(des)
    else:
        if memo[sor]!=des:
            ifadd = True

#同じ文字から複数の行き先はアウト
#異なる文字から同じ行き先もアウト
#交換関係になっていなければアウト


ans = "Yes"
visited = set()
if ifadd == True:
    ans = "No"
if ifsamedest == True:
    ans = "No"
else:
    for sta in memo:
        if sta not in visited:
            visited.add(sta)
            gol = memo[sta]
            fsta = sta
            while(gol!=sta):
                if gol not in memo:
                    gol = sta
                else:
                    sta,gol = gol,memo[gol]
                    visited.add(sta)
                    if gol == fsta:
                        gol = sta
                        
print(ans)

        

Measured memory_bytes: 41932
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a+b+c)%2) puts("No");
    else {
        int g = (a+b+c)/2;
        if(a==g||b==g||c==g) puts("Yes");
        else puts("No");
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

const ll MAX = 2000010;
const ll MOD = 1e9 + 7;

ll fac[MAX], finv[MAX], inv[MAX];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.length();

    com_init();
    ll res = 0;
    for (int i = n - 1; i < n + k; ++i) {
        int right = n + k - 1 - i;
        ll tmp = modpow(26, right, MOD) * modpow(25, k - right, MOD);
        tmp %= MOD;
        res += com(n + k - 1 - right, n - 1) * tmp;
        res %= MOD;
    }

    res += MOD;
    res %= MOD;
    cout << res << endl;
}

Measured memory_bytes: 51136
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        ab: [(i64, i64); n]
    }

    let mut aa = ab.iter().map(|&(a, _)| a).collect_vec();
    aa.sort();
    let mut bb = ab.iter().map(|&(_, b)| b).collect_vec();
    bb.sort();

    let ans = if n % 2 == 0 {
        bb[n/2] + bb[n/2 - 1] - (aa[n/2] + aa[n/2 - 1]) + 1
    } else {
        bb[n/2] - aa[n/2] + 1
    };
    println!("{}", ans);
}


Measured memory_bytes: 12816
#include<bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;
ll a1 , b  , ans = 1 , n , m , cnt , c;
string s;
int main(){
    cin >> n >> m;
    while( ans <= n )
        ans += 2 * m + 1 , cnt ++;
    cout << cnt;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int H = 20;
const int W = 2000;
const ll MOD = 1e9 + 7;

char s[W];
int ch[H][W], p[H], dp[H][W];

inline int get(int x1, int y1, int x2, int y2) {
    return dp[x2][y2] - dp[x2][y1] - dp[x1][y2] + dp[x1][y1];
}

int main() {
    int h, w, k;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++) {
        cin>>s;
        for(int j=1;j<=w;j++) {
            ch[i][j] = (s[j-1] == '0') ? 0 : 1;
        }
    }



    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + ch[i][j];
        }
    }

    int ed = (1<<(h-1)), ans = 100000000000;
    for(int hCut = 0; hCut < ed; hCut ++) {
        int cnt = 1, d = 0, ret = 0, lastW = 0, temp = hCut, flag = 1;
        p[d++] = 0;
        while(temp) {
            if(temp & 1)p[d++] = cnt;
            cnt ++;
            temp = temp >> 1;
        }
        p[d++] = h;

        //for(int i=0;i<d;i++)cout<<p[i]<<" ";
        //cout<<endl;

        for(int j=1;j<=w;j++) {
            for(int i=1;i<d;i++) {
                //cout<<j<<" "<<i<<" "<<get(p[i-1], lastW, p[i], j)<<endl;
                if(get(p[i-1], lastW, p[i], j) > k) {
                    lastW = j - 1;
                    ret ++;
                }
                if(get(p[i-1], j-1, p[i], j) > k) {
                    flag = 0;
                }
            }
        }
        //cout<<ret<<endl;
        //cout<<"-------------------"<<endl;
        if(flag)
            ans = min(ans, ret + max(0, d - 2));
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    int digit = 0;
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    boolean no = true;
	    while(n != 0){
	        digit = n % 10;
	        if(digit == 7){
	            System.out.println("Yes");
	            no = false;
	            break;
	        }
	        n= Math.floorDiv(n, 10);
	        
	    }
	    if(no == true)
	    System.out.println("No");
	}
}


Measured memory_bytes: 35712
#include <stdio.h>
int main(void){
  char s[100],t[100];
  scanf("%s",s);
  scanf("%s",t);
  int i;
  for(i=0;i<strlen(s);i++)
    if(s[i]!=t[i]) break;
  if(i==strlen(s))
    printf("Yes");
  else
    printf("No");
  return 0;
}

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

int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int arr[m];
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<m;i++)
    {
        sum+=arr[i];
    }
    if(sum>n)
    {
        cout<<-1<<endl;
        return 0;
    }
    else if(sum<=n)
    {
        cout<<n-sum<<endl;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <list>
using namespace std;
 
#define REP(i, n) for (long long i = 0; i < (n); ++i)
#define rep(i, a, b) for (long long i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;


int main(void) {

    int N;
    cin >> N;
    int s[N];
    for(int i = 0; i < N; i++) {
        cin >> s[i];
    }
    sort(s, s+N);

    int sum = 0;
    for(int i = 0; i < N; i++) {
        sum += s[i];
    }

    if(sum % 10  != 0){
        cout << sum << endl;
    }else {
        for(int i = 0; i < N; i++) {
            if((sum - s[i]) % 10 != 0) {
                cout << sum - s[i] << endl;
                return 0;
            }
        }
        cout << "0"<< endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll X;
  cin >> X;
  const ll m = 6+5;
  ll st = X / m * m;
  ll ans = X / m * 2;
  DEBUG1(X-st);
  if (X - st > 6) {
    ans += 2;
  } else if (X - st >= 1){
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}



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

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            long H = cin.nextLong();
            long N = cin.nextLong();

            long sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += cin.nextLong();
                if(H <= sum)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 18528
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&c <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;








int main() {

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N];
    rep(i,N) cin >> x[i];
    int y[M];
    rep(i,M) cin >> y[i];

    bool war = true;
    for (int z = -100; z <= 100; ++z) {
        bool flag = true;
        if (Y < z || z <= X) flag = false;
        rep(i,N) if (z <= x[i]) flag = false;
        rep(i,M) if (y[i] < z) flag = false;
        if (flag) war = false; 
    }

    if (war) cout << "War" << endl;
    else cout << "No War" << endl;

    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 256
import java.util.Scanner;

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

		if (N % 2 == 0) {
			System.out.println(N / 2);
		} else {
			System.out.println(N / 2 + 1);
		}

	}
}

Measured memory_bytes: 21588
#include <stdio.h>

int max(int i, int j);
int min(int i, int j);

int main(){
    int a, b, c, x, y, ans = 0;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

    if(a + b <= 2 * c){
        ans = x * a + y * b;
    }else if(a + b > 2 * c && max(a, b) < 2 * c){
        ans = 2 * c * min(x, y) + (max(x, y) - min(x, y)) * ((x > y) ? a : b);
    }else{
        ans = 2 * c * min(x, y) + (max(x, y) - min(x, y)) * min(((x > y) ? a : b), 2 * c);
    }
    printf("%d\n", ans);
    return 0;
}

int max(int i, int j){
    return ((i > j) ? i : j);
}

int min(int i, int j){
    return ((i < j) ? i : j);
}

Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////
int main(){
	int N;
  	cin >> N;
	int data[N];
  
  	ll r=0,g=0,b=0;
  
  	REP(i,N){
      	char a;
      	cin >> a;
    	if(a == 'R'){data[i] = 2; r++;}
      	if(a == 'G'){data[i] = 3; g++;}
      	if(a == 'B'){data[i] = 7; b++;}
    }
  	ll kari = r * g * b;
  	FOR(i,0,N){
      	FOR(j,1,min(i+1,N-i)){
      	if(data[i-j]+data[i]+data[i+j]==12)kari--;
    	//cout << data[j] << data[j+i]<<data[j+i+i] <<  kari<< endl;
        }
    }
  cout << kari << endl;
}


Measured memory_bytes: 3644