akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)

int main(void) {
	int num = 0;
	cin >> num;
	rep(0, num) {
		int cookie_amount = 0, cookie_first = 0, sum = 0;
		vector<int> cookie;
		cin >> cookie_amount >> cookie_first;
		cookie.push_back(cookie_first);
		int cookie_new = 127, cookie_bin = cookie_first, cookie_input = cookie_first;
		if (cookie_amount == 1) {
			cout << cookie_first << endl;
			continue;
		}
		 for (int j = 0;  j < cookie_amount - 1; j++) {
			int last = cookie.size() - 1;
			/*if (cookie_input > cookie_bin)*/ cookie_input = cookie_bin;
			//sort(cookie.begin(),cookie.end(),greater<int>());
			//cookie_input = cookie[last];
			//cookie_bin = ~cookie_input & 127;
			cookie_bin = 127 - cookie_input;
			//cookie_new = (cookie_input ^ cookie_bin) & 127;
			//cookie[last] = cookie_bin;
			cookie.push_back(cookie_new);

		}
		 sum = cookie_new* (cookie_amount - 1) + cookie_bin;
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
		"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const INF = 0x7FFFFFFF

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		having := map[string]Entry{}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			name := buf[0]
			price, _ := strconv.Atoi(buf[1])
			having[name] = Entry{price, []string{}}
		}
		scanner.Scan()
		m, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < m; i++ {
			scanner.Scan()
			buf_ := strings.Split(scanner.Text(), " ")
			name_, price_ := buf_[0], INF
			if _, ok := having[name_]; ok {
				price_ = having[name_].price
			}
			having[name_] = Entry{price_, buf_[2:]}
		}
		scanner.Scan()
		fmt.Println(calculation(scanner.Text(), having))
	}
}

type Entry struct {
	price int
	elements []string
}

// メモ再帰的
func calculation(target string, having map[string]Entry) int {
	ans := INF
	if len(having[target].elements) > 0 {
		ans = 0
		for _, item := range having[target].elements {
			ans += calculation(item, having)
		}
	}
	return min(ans, having[target].price)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<(int)n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
const int maxn = 3005;
using ll = long long;
ll s[maxn],dp[maxn][maxn],arr[maxn];
#define int ll



int32_t main(){
  	IOS;
    int n;
    cin>>n;
    rep(i,n)
        cin>>arr[i];
    s[0]=arr[0];
    
    rep1(i,n)
        s[i]=arr[i]+s[i-1];
    
    rep(i,n)
        dp[i][i]=arr[i];
    
    for(int i=1;i<n;i++){
        for(int j=i-1;j>=0;j--){
            dp[j][i]=max(
                s[i]-s[j]-dp[j+1][i]+arr[j],
                s[i-1]-s[j-1]-dp[j][i-1]+arr[i]
            );
        }
    }
    cout<<dp[0][n-1]-s[n-1]+dp[0][n-1]<<endl;


    return 0;
}

Measured memory_bytes: 70016
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//snippet
#define N 200009

int main() {
	LL n, a[N], b[N] = { 0 }, sum = 0;
	scanf("%lld", &n);
	rep(i, n) {
		scanf("%lld", a + i);
		b[a[i]]++;
	}
	Rep(i, 1, n + 1)sum += (b[i] - 1) * (b[i]) / 2;
	rep(i, n)printf("%lld\n", sum - b[a[i]] + 1);

	return 0;
}

Measured memory_bytes: 5792
#include<stdio.h>
int main()
{
	int k=0, s=0,y=0;
	scanf("%d", &y);
	while (y != 0){
		k = 1000 - y;
		s += k / 500;
		k= k % 500;
		s += k / 100;
		k = k % 100;
		s += k / 50;
		k = k % 50;
		s += k / 10;
		k = k % 10;
		s += k / 5;
		k = k % 5;
		s += k;
		printf("%d\n", s);
		s = 0;
		scanf("%d", &y);
	}
	return 0;
}

Measured memory_bytes: 600
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

bool check(int n){
    llong cnt=0;
    while(n>0){
        n = n / 10;
        cnt++;
    }
    if(cnt%2!=0){
        return true;
    }
    return false;
}

int main(){
    llong N;
    llong ans=0;
    cin >> N;
    for(int i=1; i<=N; i++){
        if(check(i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3164
import sys
from collections import deque

readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def bfs(G, s, t=None):
    """
    G[v] = [x1, x2,...]
    """
    dist = [-1] * len(G)
    dist[s] = 0
    par = [-1] * len(G)
    q = deque([s])
    while q:
        v = q.popleft()
        for x in G[v]:
            if dist[x] < 0 or dist[x] > dist[v] + 1:
                par[x] = v + 1
                dist[x] = dist[v] + 1
                q.append(x)
    return par


def solve():
    n, m = nm()
    G = [list() for _ in range(n)]
    for _ in range(m):
        u, v = nm()
        u -= 1; v -= 1
        G[u].append(v)
        G[v].append(u)
    par = bfs(G, 0)
    print('Yes')
    print(*par[1:], sep='\n')
    return

solve()

# T = ni()
# for _ in range(T):
#     solve()


Measured memory_bytes: 39252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int fx[]={0,1,0,-1};
int fy[]={-1,0,1,0};
int main()
{
    ll t,i,j,n,m,k,r,r1,ans,ck,cnt=0,sum=0,c=0;
    cin>>n>>m>>ck;
    ll a[n][m],b[m];
    for(i=0;i<m;i++){
        cin>>b[i];
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(i=0;i<n;i++){
            sum=0;
        for(j=0;j<m;j++){
            sum=sum+(a[i][j]*b[j]);
        }
    sum=sum+ck;
    if(sum>0)cnt++;
    }
   cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int a,b,c;
	cin>>a>>b>>c;

	cout<<(a+b+c>=22?"bust":"win")<<endl;


	return 0;
}



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

int main(){
    string s;
    int ans=700;
    cin>>s;
    for(int i=0;i<3;i++)
        if(s[i]=='o') ans += 100;
    cout<<ans<<endl;
    return 0;
}

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

int h, w;
int ans = 0;
int map[50][50];


bool safe(int x, int y){
    return (x >= 0 && y >= 0 && x < w && y < h);
}

int main(){
    cin >> w >> h;
    char c;
    for (int i = 0; i < w; i++){
	for (int j = 0; j < h; j++){
	    cin >> c;
	    map[i][j] = c - '0';
	}
    }
    

    for (int i = 0; i < w; i++){
	for (int j = 0; j < h; j++){
	    if (safe(i, j-1) && safe(i-1, j)){
		map[i][j] += min(map[i][j-1], map[i-1][j]);
	    } else if (safe(i, j-1)){
		map[i][j] += map[i][j-1];
	    } else if (safe(i-1, j)){
		map[i][j] += map[i-1][j];
	    }
	}
    }

    cout << map[w-1][h-1] << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
const int HMAX=1000,WMAX=1000,INF=INT_MAX;
const int m[4][2]={{-1,0},{0,-1},{0,1},{1,0}}; 

char A[HMAX][WMAX+1];
int S[HMAX][WMAX];
deque<PII> Q;
int h,w,maxn;

void init()
{
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)S[i][j]=INF;
}

int bfs(int sx,int sy)
{
	init();
	int now=1;
	S[sx][sy]=0;
	Q.push_back(make_pair(sx,sy));
	while(!Q.empty())
	{
		bool restart=false;
		int x=Q.front().first,y=Q.front().second;Q.pop_front();
		//printf("x=%d, y=%d, s=%d\n",x,y,S[x][y]);
		for(int i=0;i<4;i++)
		{
			int nx=x+m[i][0],ny=y+m[i][1],ns=S[x][y]+1;
			//printf("push: nx=%d ny=%d ns=%d\n",nx,ny,ns);
			if(nx<0||nx>=h)continue;
			if(ny<0||ny>=w)continue;
			if(A[nx][ny]=='X'||S[nx][ny]<=ns)continue;
			//printf("PASS\n");
			if(A[nx][ny]==(now+'0'))
			{
				//printf("end: nx=%d, ny=%d, ns=%d\n",nx,ny,ns);
				if(now>=maxn)return ns;
				++now;
				Q.clear();
				init();
				restart=true;
			}
			S[nx][ny]=ns;
			Q.push_back(make_pair(nx,ny));
			if(restart)break;
		}
	}
	//printf("NO MORE\n"); 
}

int main()
{
	int sx,sy;
	scanf("%d%d%d",&h,&w,&maxn);
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			scanf(" %c",&A[i][j]);
			if(A[i][j]=='S')sx=i,sy=j;
		}
	}
	printf("%d\n",bfs(sx,sy));
	return 0;
}

Measured memory_bytes: 6092
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 cin>>s;
 int i;
 stack<char> st;
 int len=0;
 for(i=0;i<s.length();i++)
 {
 	if(s[i]=='B')
 	{
 		if(len!=0)
 		{
 			st.pop();
 			len--;
		}
	}
	else
	{
		st.push(s[i]);
		len++;
	}
 }
 //cout<<st.size()<<endl;
 string ans="";
 for(i=0;i<st.size();i++)
 {
 ans=st.top()+ans;
 //cout<<ans<<"P"<<endl;
 st.pop();
 i=-1;
}
cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n ; 
	cin >> n ; 
	if ( n % 2 == 0 ){
		cout << fixed << setprecision(12) << 0.5 << endl;}
	else{
		double ans = (n / 2 + 1) / (double) n ; 
		cout << fixed << setprecision(12) << ans << endl;
	}
	return 0 ; }

Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val A = input.nextInt()
    val B = input.nextInt()
    val C = input.nextInt()
    
    if ((A == B && B != C)
      ||(A == C && B != C)
      ||(B == C && A != C)) {
      println ("Yes") 
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 36372
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
vector<pair<ll,ll>> d;
void divisors(ll n)
{
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            d.push_back({i,n/i});
        }
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll n;
      cin>>n;
      divisors(n);
      ll c=0;
      ll ans=INT64_MAX;
      for(auto i:d)
      {
          c=i.first + i.second - 2;
          ans=min(ans,c);
      }
      cout<<ans;
  }
  return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().strip().split())
k=min(k,n-1)
MOD=10**9+7

# a*a**(p-2) mod p (Fermat's little theorem)
def modInv(x,m=10**9+7):
    return pow(x,m-2,m)

class combMod:
    def __init__(self,maxN,mod=10**9+7):
        self.maxN=maxN
        self.mod=mod
        self.fac=[None]*(maxN+1) # fac[0]=1, fac[1]=1, fac[2]=2 ... fac[maxN]
        self.ifac=[None]*(maxN+1)
        # self.ifac[0]=1
        
    def calc_fact(self): # make the table
        self.fac[0]=1
        for i in range(1,self.maxN+1):
            self.fac[i] = self.fac[i-1]*i % self.mod
        self.ifac[-1] = modInv(self.fac[-1])
        for i in range(self.maxN,0,-1):
            self.ifac[i-1] = self.ifac[i]*i % self.mod
    def modnCr(self,n, r,mod=None):
        if mod is None:
            mod=self.mod
        denom = self.fac[n]
        numer = self.ifac[r] * self.ifac[n-r] % mod
        return  denom * numer % mod

combMod=combMod(2*n+1)
combMod.calc_fact()
ans=0
for ki in range(k+1):
    ans += combMod.modnCr(n, ki)*combMod.modnCr(n-ki-1+ki, ki)%MOD
print(ans%MOD)

Measured memory_bytes: 34676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  sort(ALL(v));
  int cur = x;
  int cnt = 0;
  for(;;) {
    if (cnt >= n) {
      if (cur > 0) cnt--;
      break;
    } else if (cur < v[cnt]) {
      break;
    } else {
      cur -= v[cnt];
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

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

using namespace std;
typedef long long LL;
const int mod = 1e9+7;
const int maxn = 4e3+23;
LL C[maxn][maxn],n,k;
void init(){
    C[0][0] = 1;
    for(int i = 1;i < maxn; ++i){
        C[i][0] = 1;
        for(int j = 1;j <= i; ++j){
            C[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;
        }
    }
}
LL solve(int x){
    LL red = n-k;
    if(red < x-1) return 0;
    LL res = C[k-1][x-1];
    LL m = red - (x-1);
    if(m == 0) return res;
    LL s = x+1;
    return C[s+m-1][s-1]*res%mod; 
    
}
int main(){
    init();
    cin >> n >> k;
    for(int i = 1;i <= k; ++i){
        cout << solve(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 124928
import java.time.Instant;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int[] x = new int[11];
		x[0] = sc.nextInt();

		for(int i=1; i<11; i++){
			x[i] = r* x[i-1] - D;
			System.out.println(x[i]);
		}

	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

const int MOD = 1e9+7;
const int MAXR = 3010000;

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    com_init();
    int K; cin >> K;
    string S; cin >> S;
    int s = S.size();

    mint ans = 0;
    REP(x,K+1){
        ans += com(s-1+x, s-1) * modpow(25,x) * modpow(26,K-x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 75748
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}
int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, m;
	cin >> n >> m;
	vi dp(n);
	vi in_degree(n);
	vvi g(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		in_degree[b]++;
	}
	vector<bool> visited(n, false);
	function<void(int)> dfs = [&](int u)
	{
		visited[u] = true;
		for (auto v : g[u])
		{
			max_self(dp[v], dp[u] + 1);
			in_degree[v]--;
			if (in_degree[v] == 0)
				dfs(v);
		}
	};
	for (int i = 0; i < n; i++)
		if (!visited[i] && in_degree[i] == 0)
			dfs(i);
	cout << *max_element(all(dp));
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0, count;
    bool flag1, flag2;
    for(int i=1;i<S.size()-1;i++){
        string substr1 = S.substr(i);  // S[i]~
        string substr2 = S.substr(0, i);   // S[0]からi文字
        count = 0;
        for(int i=0;i<26;i++){
            char tmp = 'a' + i;
            flag1 = false;
            flag2 = false;
            for(int i=0;i<substr1.size();i++){
                if(substr1.at(i) == tmp)
                    flag1 = true;
            }
            for(int i=0;i<substr2.size();i++){
                if(substr2.at(i) == tmp)
                    flag2 = true;
            }
            if(flag1 && flag2)
                count++;
        }
        if(count > ans)
            ans = count;        
    }

    cout << ans << endl;

}


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

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n+5];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n+5];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k && j<=i; j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 1024
N,M,D = [int(i) for i in input().split(" ")]
space=[]
for i in range(N):
    S=input()
    row=[]
    for s in S:
        if s==".":
            row.append(0)
        else:
            row.append(1)
    space.append(row)

retval=0
for i in range(N):
    for j in range(M):
        if space[i][j]==1:
            continue
        try:
            for k in range(D):
                if space[i+k][j]==1:
                    break
            else:
                retval+=1
        except IndexError:
            pass
        try:
            for k in range(D):
                if space[i][j+k]==1:
                    break
            else:
                retval+=1
        except IndexError:
            pass

print(retval)



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

int main() {
	int n;
	cin >> n;
	int ans = n / 25;
	n -= n / 25 * 25;
	ans += n / 10;
	n -= n / 10 * 10;
	ans += n / 5;
	n -= n / 5 * 5;
	ans += n;
	cout << ans << endl;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
char txt[101];
bool chk(int S, int E){
	for(int i=0;S+i<=E-1-i;i++){
		if(txt[S+i]!=txt[E-1-i]) return false;
	}
	return true;
}
int main(){
	scanf("%s",txt);
	int N = strlen(txt);
	printf("%s",(chk(0,N)&&chk(0,N/2)&&chk(N/2+1,N))?"Yes":"No");
}

Measured memory_bytes: 128
from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

dist_f = [None]*n
dist_s = [None]*n

que = deque([(0,0)])
while que:
    node, cost = que.popleft()
    if dist_f[node] != None:
        continue
    dist_f[node] = cost
    for to in g[node]:
        que.append((to, cost+1))

que = deque([(n-1, 0)])
while que:
    node, cost = que.popleft()
    if dist_s[node] != None:
        continue
    dist_s[node] = cost
    for to in g[node]:
        que.append((to, cost+1))
        
cnt = 0
for i in range(n):
    if dist_f[i] <= dist_s[i]:
        cnt += 1
print('Fennec' if cnt>n-cnt else 'Snuke')

Measured memory_bytes: 75424
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 10000000; 


int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}

int main() {
		int n,m;
		cin >> n>>m;
		int C[20];
		for (int i = 0;i < m;i++) {
			cin >> C[i];
		}
		cout<<getNumberOfCoin(C,n,m)<<endl;


}

Measured memory_bytes: 1352
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    ll S, W;
    cin >> S >> W;
    if (W >= S)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    return;
}

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


Measured memory_bytes: 3584
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K, S = map(int, input().split())
    MAX = 10 ** 9

    ans = []
    if S == MAX:
        ans += [S] * K
        ans += [1] * (N - K)
    else:
        ans += [S] * K
        ans += [MAX] * (N - K)

    print(*ans, sep=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 6780
n,a,b = map(int,input().split())
ans = 0
count = 0
for i in range(1,n+1):
    ch = i
    while True:
        ans += i%10
        if i == 0:
            if ans >= a and ans <= b:
                count += ch
            ans = 0
            break
        i //= 10
print(count)

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

int main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a>=3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))

if k == 0:
    print(max(a))
    sys.exit()

def check(t):
    if t == 0:
        return False
    ans = 0
    for ai in a:
        if ai > t:
            ans += ai // t
    return ans <= k

l = 0
r = 10 ** 9 + 1

while r - l > 1:
    mid = (r + l) // 2
    if check(mid):
        r = mid
    else:
        l = mid

if check(l):
    print(l)
else:
    print(r)



Measured memory_bytes: 31220
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int K;
    cin >> K;
    const int N = 50;
    int base = K / N;
    int simulation = K % N;
    vector<int> ans(N, N - 1 + base);
    while (simulation != 0) {
        --simulation;
        ans[simulation] += N;
        for (int i = 0; i < N; i++) {
            if (i == simulation) continue;
            ans[i]--;
        }
    }
    cout << N << endl;
    for (int i = 0; i < N; i++) cout << ans[i] << (i == N - 1 ? '\n' : ' ');
}

Measured memory_bytes: 256
A = list(map(int, input()))
signs = [None] * 3
for b in range(1 << 3):
    sum = A[0]
    for i in range(3):
        if (b & (1 << i)) != 0:
            signs[i] = '+'
            sum += A[i + 1]
        else:
            signs[i] = '-'
            sum -= A[i + 1]
    if sum == 7:
        break
result = [None] * (4 + 3 + 2)
result[:4*2:2] = map(str, A)
result[1:1+3*2:2] = signs
result[-2:] = "=7"
print("".join(result))

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

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

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	LL ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'A' and s[i] != 'C' and s[i] != 'G' and s[i] != 'T') {
			continue;
		}
		LL tmp = 0;
		for (int j = i; j < s.size(); j++) {
			if (s[j] != 'A' and s[j] != 'C' and s[j] != 'G' and s[j] != 'T') {
				break;
			}
			tmp++;
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, S[10000], q, T[500];
  cin >> n;
  for (int i = 0; i < n; i++) { cin >> S[i]; }
  cin >> q;
  for (int i = 0; i < q; i++) { cin >> T[i]; }

  int ans = 0;
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (S[j] == T[i]) {
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
	/* time: O(1), space: O(1) */
	int tenki(const string& S, const string& T) {
		int ans = 0;
		for (int i = 0; i < 3; ++i) {
			if (S[i] == T[i])
				++ans;
		}
		return ans;
	}
};

int main() {
	int a;
	string S, T;
	cin >> S >> T;

	Solution sol;
	int ans = sol.tenki(S, T);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

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

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;
    ans += string(tx - sx, 'R');
    ans += string(ty - sy, 'U');
    ans += string(tx - sx, 'L');
    ans += string(ty - sy, 'D');
    ans += 'D';
    ans += string(tx - sx + 1, 'R');
    ans += string(ty - sy + 1, 'U');
    ans += 'L';
    ans += 'U';
    ans += string(tx - sx + 1, 'L');
    ans += string(ty - sy + 1, 'D');
    ans += 'R';

    cout << ans << "\n";

    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, k;
	cin >> n >> k;
	vector<int> d(n);
	rep(i, k) {
		int m;
		cin >> m;
		rep(j, m) {
			int a = 0;
			cin >> a;
			d[a - 1] = 1;
		}
	}
	int ans = 0;
	rep(i, n)if (d[i] == 0)++ans;
	cout << ans << endl;
	return 0;

}






Measured memory_bytes: 3584
#include <stdio.h>

void way(int n, int k) {
  int ans = k;
  for (n = n; n > 1; n--) {
    ans = ans * (k - 1);
  }
  printf("%d\n", ans);
}

int main(void) {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  way(n, k);
  return 0;
}

Measured memory_bytes: 128
#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(){
    ll r,c,k;
    cin >> r >> c >> k;
    vector <vector <ll>> m(r,vector <ll>(c,0)),dp1(r,vector <ll>(c,0)),dp2(r,vector <ll>(c,0)),dp3(r,vector <ll>(c,0)) ;
    ll rr,cc,vv;
    rep(i,k){
        cin >> rr >> cc >> vv;
        m[rr-1][cc-1]=vv;
    }
    vector <ll> va3(4,0),va2(3,0),va1(2,0),vb3(4,0),vb2(3,0),vb1(2,0);
    ll yo1=0;
    ll yo2=0;
    ll yo3=0;

    rep(i,r){
        va1=vb1;
        va2=vb2;
        va3=vb3;
        
        yo1=0;
        yo2=0;
        yo3=0;
        
        if(i!=0){
            yo1=dp3[i-1][0];
            yo2=dp3[i-1][0];
            yo3=dp3[i-1][0];
            
        }
        rep(j,c){
            va3[3]=m[i][j];
            va2[2]=m[i][j];
            va1[1]=m[i][j];
            
            sort(va1.rbegin(),va1.rend());
            sort(va2.rbegin(),va2.rend());
            sort(va3.rbegin(),va3.rend());
            
            if(i==0){
                dp1[i][j]=va1[0]+yo1;
                dp2[i][j]=va2[0]+va2[1]+yo2;
                dp3[i][j]=va3[0]+va3[1]+va3[2]+yo3;
                
            }
            else{
                dp1[i][j]=va1[0]+yo1;
                dp2[i][j]=va2[0]+va2[1]+yo2;
                dp3[i][j]=va3[0]+va3[1]+va3[2]+yo3;


                if(j!=0){
                if((dp2[i][j-1]+m[i][j])>=dp3[i][j]){
                    dp3[i][j]=dp2[i][j-1]+m[i][j];
                    va3[0]=va2[0];
                    va3[1]=va2[1];
                    va3[2]=va2[2];
                    va3[3]=0;
                    yo3=yo2;
                }
                if((dp1[i][j-1]+m[i][j])>=dp2[i][j]){
                    dp2[i][j]=dp1[i][j-1]+m[i][j];
                    va2[0]=va1[0];
                    va2[1]=va1[1];
                    va2[2]=0;
                    yo2=yo1;
                }

                }


                if((dp3[i-1][j]+m[i][j])>=dp3[i][j]){
                    dp3[i][j]=dp3[i-1][j]+m[i][j];
                    va3[0]=m[i][j];
                    va3[1]=0;
                    va3[2]=0;
                    va3[3]=0;
                    
                    yo3=dp3[i-1][j];
                }


                if((dp3[i-1][j]+m[i][j])>=dp2[i][j]){
                    dp2[i][j]=dp3[i-1][j]+m[i][j];
                    va2[0]=m[i][j];
                    va2[1]=0;
                    va2[2]=0;
                    
                    yo2=dp3[i-1][j];
                }
                if((dp3[i-1][j]+m[i][j])>=dp1[i][j]){
                    dp1[i][j]=dp3[i-1][j]+m[i][j];
                    va1[0]=m[i][j];
                    va1[1]=0;
                    
                    yo1=dp3[i-1][j];
                }
                


            }

            //cout << dp3[i][j] << " ";
            //cout << dp1[i][j] << " " << dp2[i][j] << " " << dp3[i][j] << endl;
        }
        //cout << endl;
    }

    cout << dp3[r-1][c-1] << endl;
    

    return 0;
}

Measured memory_bytes: 284772
n = int(input())
x = input()
count_1 = x.count('1')
value = [0, 0]
x_int = int(x, 2)
value[0] = x_int % (count_1 - 1) if count_1 > 1 else 0
value[1] = x_int % (count_1 + 1)
for i in range(n):
    if x[i] == '0':
        tmp = (pow(2, n - i - 1, count_1 + 1) + value[1]) % (count_1 + 1)
    else:
        if count_1 == 1:
            print(0)
            continue
        tmp = (-pow(2, n - i - 1, count_1 - 1) + value[0]) % (count_1 - 1)
    ans = 1
    while tmp > 0:
        tmp = tmp % (bin(tmp).count('1'))
        ans += 1
    print(ans)

Measured memory_bytes: 81876
def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                l = [L[i], L[j], L[k]]
                l.sort()
                if l[0] + l[1] > l[2]:
                    if l[0] != l[1] and l[1] != l[2]:
                        # print(l, i, j, k)
                        ans += 1
    print(ans)
if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin >> n ;
  int a[n], b[n];
  int i = 0;
  a[n] = 0;
  b[n] = 0;
  while (i < n){
    cin >> a[i] ;
    b[i] = a[i];
    i = i + 1;
  }

  i = 0;  
  sort(b, b + n);
  while (i < n){

    if (a[i] * 2 <= b[(n/2)-1] + b[(n/2)])  {
      cout << b[(n/2)] << endl; }
    else {cout << b[(n/2) -1] << endl;}
    i = i + 1;

    }


}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            WriteLine(180 * (n - 2));
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 17596
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  long long X, res;
  rd(X);
  res = X / 11 * 2;
  if(X%11){
    res++;
  }
  if(X%11 > 6){
    res++;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// {
//   ll X, res;
//   rd(X);
//   res = X / 11 * 2;
//   if(X%11) res++;
//   if(X%11 > 6) res++;
//   wt(res);
// }


Measured memory_bytes: 256
def f_intervals_on_tree():
    N = int(input())
    Edges = [[int(i) for i in input().split()] for j in range(N - 1)]

    # L を 1 から N まで変化させたときの頂点数の総和
    ans = sum(L * (N - L + 1) for L in range(1, N + 1))
    for u, v in Edges:
        u, v = min(u, v), max(u, v)  # u < v を仮定した計算を行いたい
        ans -= u * (N - v + 1)
    return ans

print(f_intervals_on_tree())

Measured memory_bytes: 42224
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,a,b;
	cin>>n>>a>>b;
	int c=abs(a-b)-1;
	int l1=a-1;
	int l2=n-b;
	if(c%2==1){
		puts("Alice");
		return 0;
	}
	if(c%2==0){
		puts("Borys");
		return 0;
	}
	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;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

int n;
vector <ll> l;

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

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		ll x; cin >> x;
		l.push_back(x);
	}

	int ans = 0;
	for (int i = 0; i < l.size(); i++) for (int j = i + 1; j < l.size(); j++) for (int k = j + 1; k < l.size(); k++)
	{
		if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;

		vector <int> v;
		v.push_back(l[i]);
		v.push_back(l[j]);
		v.push_back(l[k]);

		sort(v.begin(), v.end());

		if (v[2] < v[0] + v[1]) ans++;
	}

	cout << ans;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
    return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < 0 && b < 0){
        if ((abs(a-b)+1) % 2 == 0){
            printf("Positive\n");
        }else{
            printf("Negative\n");
        }
    }else if (a <= 0 && 0 <= b ){
        printf("Zero\n");
    }else if (0 < a && 0 < b){
        printf("Positive\n");
    }

    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,n,b=0;
    cin >> n;
    int a[n];
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=1;i<n-1;i++){
        if(a[i]<a[i-1]&&a[i]>a[i+1]||a[i]<a[i+1]&&a[i]>a[i-1]){
            b++;
        }
    }
    cout << b;
}

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

int par[12];

void nex(){
	par[0]++;
	int k=0;
	while(par[k]>=2){par[k]-=2; par[k+1]++; k++;}
}

int pow(int x){
	if(x==1)return 2;
	return 2*pow(x-1);
}

int main(){
while(1){
	int r,c,a[12][10002],ret=0;
	scanf("%d%d",&r,&c);
	if(r==0&&c==0)break;
	for(int i=0;i<r;i++)for(int j=0;j<c;j++)scanf("%d",&a[i][j]);
	int pr=pow(r);
	for(int i=0;i<12;i++)par[i]=0;
	for(int i=0;i<pr;i++){
		nex();
		int ans=0;
		for(int j=0;j<c;j++){
			int sum=0;
			for(int k=0;k<r;k++){
				if((a[k][j]+par[k])%2==0)sum++;
			}
			ans+=max(sum,r-sum);
		}
		if(ret<ans)ret=ans;
	}
	printf("%d\n",ret);
}
}

Measured memory_bytes: 1568
#include<stdio.h>
#include<string.h>
int main()
{
int a,n;
int f[13][4];
int i,j;
char b;
for(i=0;i<13;i++) for(j=0;j<4;j++) f[i][j]=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf(" %c %d",&b,&a);
if(b=='S') f[a-1][0]=1;
if(b=='H') f[a-1][1]=1;
if(b=='C') f[a-1][2]=1;
if(b=='D') f[a-1][3]=1;
}
for(i=0;i<4;i++) 
{
for(j=0;j<13;j++) 
{
if(f[j][i]==0) 
{
if(i==0) printf("S %d\n",j+1); 
else if(i==1) printf("H %d\n",j+1); 
else if(i==2) printf("C %d\n",j+1); 
else if(i==3) printf("D %d\n",j+1);
}
}
}
return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
	
	ll N, W;
	cin>>N>>W;
	ll dp[N+1][W+1];
	ll w[N+1], v[N+1];

	for (int i = 0;i <= N;++i) {
		for (int j = 0;j <= W;++j) {
			dp[i][j] = 0;
		}
	}
	
	for (int i = 1;i <= N;++i) {
		cin>>w[i]>>v[i];
	}
	
	for (int i = 1;i <= N;++i)  {
		for (int j = 1;j <= W;++j) {
			if (w[i] > j) {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
			else {
				dp[i][j] = max(max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]), dp[i][j-1]);
			}
		}
	}
	
	cout<<dp[N][W];
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, o = 0;
  long long a;
  cin >> n;
  while(n--){
    cin >> a;
    if(a%2 != 0) ++o;
  }
  cout << (o%2 == 0 ? "YES" : "NO") << endl;
}

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

int main(){
    string s;
    cin>>s;
    if(s.length()==2){
        cout<<s<<endl;
    }else{
        cout<<s[2]<<s[1]<<s[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

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

#define CEIL(a, b) ((a) + (b)-1) / (b)

ll N;

int main()
{
    cin >> N;

    ll ans = CEIL(N, 2);

    OUT(ans);
}


Measured memory_bytes: 256