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

namespace Msolutions
{
    class B
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int numx = S.Where(x => x == 'x').Count();
            string r = "YES";
            if (numx >= 8) r = "NO";
            Console.WriteLine(r);

        }
    }
}


Measured memory_bytes: 13268
package main

import "fmt"

func main() {
	var n, m1, m2 int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if a[i] > m1 {
			m1, m2 = a[i], m1
			continue
		}
		if a[i] > m2 {
			m2 = a[i]
		}
	}

	for _, v := range a {
		if v == m1 {
			fmt.Println(m2)
		} else {
			fmt.Println(m1)
		}
	}
}


Measured memory_bytes: 8108
# B Cakes and Donuts

# input
N = int(input())

cake_max = N // 4
donut_max = N // 7

res = 'No'

for cake in range(cake_max+1):
    if cake * 4 == N:
        res = 'Yes'
        break
    for donut in range(donut_max+1):
        if (N - cake*4) % 7 == 0:
            res = 'Yes'
            break

print(res)

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    string S;
    cin >> S;
    string y, m, d;
    int i = 0;
    for (; i < S.length(); i++)
    {
        if (S[i] == '/')
        {
            continue;
        }
        else
        {
            y += S[i];
        }
    }
    if (atoi(y.c_str()) <= 20190430)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;
 
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(n);
    for (int i=0; i<n; i++)
        scanf("%d", &a[i]);
 
    sort(begin(a), end(a));
    long long ret = 0;
    for (int i=0; i<m; i++)
        ret += a[i];
 
    printf("%lld\n", ret);
 
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<map>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
bool isPrime(int u){
	for(int i = 2;i*i<=u;i++){
		if(u %i == 0)return false;
	}

	return true;
}
int main(){
	lli n;cin >> n;
	cout << (n-1ll) * n / 2 << endl;

}



Measured memory_bytes: 256
/* Author: Jason L.(int3xccATgmailDOTcom), Fri Dec 23 12:18:27 CST 2016 */
#include <bits/stdc++.h>
using namespace std;

using ll   = long long;       using ull  = unsigned long long;
using i32  = int32_t;         using ui32 = uint32_t;
using i64  = int64_t;         using ui64 = uint64_t;
using pii  = pair<int, int>;  using pdd  = pair<double, double>;
using vpii = vector<pii>;     using vpdd = vector<pdd>;
//=========================================================================
static int constexpr dbg =
#ifdef INT3XCC_DEBUG
        1;
#else
        0;
#endif
#define Dprintf(fmt, ...)  do { if (dbg) printf(fmt, ##__VA_ARGS__); } while(0)
//=========================================================================
int const NMX = 100009;
ll constexpr M = 1e9 + 7LL;
int c[NMX];
int main(int argc, char *argv[])
{
    if (!dbg) { std::ios::sync_with_stdio(false);}

    ll n; cin>>n;
    ll ans = 1;
    for (int i = 1; i <= n; ++i) {
        int ai; cin>>ai;
        ++c[ai];
        if (ai == 0) {
            if (n % 2 != 1 || c[ai] > 1) goto fail;
        } else {
            if (c[ai] > 2) goto fail;
            else if (c[ai] == 2) {
                ans <<= 1;
                if (ans > M) ans -= M;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
    fail:
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
bool Lower(char c){
  if('a' <= c && c <= 'z')return false;
  else return true;
}
int solve(){
  string s;
  cin >> s;
  int n = s.size();
  bool ans = true;
  if(s[0] != 'A')ans = false;
  int count = 0;
  REP(i,2,n - 1)if(s[i] == 'C')count++;
  if(count != 1)ans = false;
  REP(i,1,n)if(Lower(s[i]) && s[i] != 'C')ans = false;
  cout << (ans ? "AC" : "WA") << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

struct item{
    int wt,val;
};

int solve(vector<item> ar , int n, int W){
    int maxVal=1000*n;
    int dp[n+1][maxVal+1];
    
    for(int i=0;i<=maxVal;i++){
        dp[1][i]=inf;
    }
    dp[1][0]=0;
    dp[1][ar[1].val]=ar[1].wt;
    
    for(int i=2;i<=n;i++){
        for(int j=0;j<=maxVal;j++){
            dp[i][j]=dp[i-1][j];
            if(ar[i].val>j)
                continue;
            dp[i][j]=min(dp[i][j],ar[i].wt+dp[i-1][j-ar[i].val]);
        }
    }
    
    int ans = 0;
    for(int i=0;i<=maxVal;i++){
        if(dp[n][i]<=W)
            ans = i;
    }
    
    return ans;
}

int main() {
	// your code goes here
	int n ,W;
	cin>>n>>W;
	vector<item> ar(n+1);
	
	for(int i=1;i<=n;i++){
	    cin>>ar[i].wt>>ar[i].val;
	}
	
	cout<<solve(ar,n,W);
	return 0;
}


Measured memory_bytes: 42688
import sys
sys.setrecursionlimit(10**6)
n = int(input())
edge = [[] for i in range(n)]
colors = [0] * n
for i in range(n-1):
    u, v, w = [int(item) for item in input().split()] 
    u -= 1
    v -= 1
    edge[u].append([v, w%2])
    edge[v].append([u, w%2])

def dfs(frm, n, d):
    for tv, tw in edge[n]:
        if tv == frm:
            continue
        else:
            td = (d + tw) % 2
            if td == 1:
                colors[tv] = 1 
            else:
                colors[tv] = 0 
            dfs(n, tv, td)
    return True

colors[0] = 0
dfs(0, 0, 0)
for item in colors:
    print(item)

Measured memory_bytes: 82224
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  LL n, m;
  cin >> n >> m;
  LL lower = 0, upper = max(n, m), mid; // Number of S
  while(lower < upper) {
    mid = (lower + upper + 1) / 2;
    LL need = max(0ll, mid - n);
    if(2*need + mid*2 <= m) {
      lower = mid;
    } else {
      upper = mid - 1;
    }
  }
  cout << lower << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[301] = {};
  int count[4] = {};
  int i;
  int min = 300;

  gets(s);
  for (i = 0;i < strlen(s); i++){
    if( s[i] == 'K')
      count[0]++;
    if( s[i] == 'U')
      count[1]++;
    if( s[i] == 'P')
      count[2]++;
    if( s[i] == 'C')
      count[3]++;
  }

  for(i = 0; i < 4; i++)
    if(min > count[i])
    min = count[i];

  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i != n;
}
int main(){
  int i,n,A[10000+1],q,key,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int num;
string s;
int k;
void dfs(string ss)
{
    for(char i='a';i<='z';i++)
    {
        string sss=ss+i;
        if(num==k)
        {
            return;
        }
        if(s.find(sss)==string::npos)
        {

        }
        else
        {
            num++;
            if(num==k)
            {
                cout<<sss<<endl;
                return;
            }
            dfs(sss);
        }
    }
}
int main()
{
    cin>>s;
    cin>>k;
    string ss="";
    dfs(ss);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

int N;
long Ans=0;
int Bs;
cin>>N;
vector<int> A(N);
vector<int> D(100001,0);
for(int i=0;i<N;i++){
cin>>A.at(i);
D.at(A.at(i))++;
Ans=Ans+A.at(i);
}
int Q;
cin>>Q;
vector<int> B(Q);
vector<int> C(Q);
vector<long> S(Q);
for(int i=0;i<Q;i++){
cin>>B.at(i);
cin>>C.at(i);
}
for(int i=0;i<Q;i++){
    Bs=D.at(B.at(i));
    Ans=Ans+Bs*(C.at(i)-B.at(i));
    cout<<Ans<<endl;
	D.at(C.at(i))=D.at(B.at(i))+D.at(C.at(i));
    D.at(B.at(i))=0;
}




}

Measured memory_bytes: 5556
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
class AOJ0023 {
    static final double EPS = 1e-9;
    public void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n-- > 0) {
            double[] x = new double[2];
            double[] y = new double[2];
            double[] r = new double[2];
            for(int i = 0; i < 2; i++) {
                x[i] = sc.nextDouble();
                y[i] = sc.nextDouble();
                r[i] = sc.nextDouble();
            }
            double d = hypot(x[1] - x[0], y[1] - y[0]);
            if(r[0] + r[1] < d)
                System.out.println(0);
            else if(r[0] > r[1] + d)
                System.out.println(2);
            else if(r[1] > r[0] + d)
                System.out.println(-2);
            else
                System.out.println(1);
        }
    }
 
    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }
}
 
public class Main {
    public static void main(String...args) {
        new AOJ0023().run();
    }
}

Measured memory_bytes: 12000
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const S=input[1].split(' ').map(e=>{
    return e-0;
  });
  var max=0;
  var previous=0;
  var temp=0;
  for(var i=0;i<N;i++){
    if(previous>=S[i]){
      temp++;
    }else{
      max=Math.max(max,temp);
      temp=0;
    }
    previous=S[i];
  }
  max=Math.max(max,temp);
  
  console.log(max);
 
}




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

Measured memory_bytes: 39796
n = int(input())
a = list(map(int, input().split()))

b = [0 for i in range(n)]

cnt = 0
for i in range(n):
    if i - a[i] >= 0:
        cnt += b[i - a[i]]
    if i + a[i] < n:
        b[i + a[i]] += 1
print(cnt)

Measured memory_bytes: 32364
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>

using namespace std;

const double PI = 3.14159265358979;

struct Node {
	int key;
	Node* left, * right;
};

void preorder(Node* const root) {

	if (root) {
		printf(" %d", root->key);
		preorder(root->left);
		preorder(root->right);
	}
}

void inorder(Node* const root) {

	if (root) {
		inorder(root->left);
		printf(" %d", root->key);
		inorder(root->right);
	}
}


void insert_key(Node *root, int key) {

	Node* comer = new Node;
	comer->key = key;
	comer->left = 0;
	comer->right = 0;

	Node* temp = root;
	Node* par = 0;
	while (temp) {
		par = temp;
		if (key < temp->key)
			temp = temp->left;
		else
			temp = temp->right;
	}
	if (key < par->key) par->left = comer;
	else par->right = comer;

}

bool find_key(Node* const root, int key) {
	
	Node* temp = root;
	while (temp) {
		if (temp->key == key) return true;

		if (key < temp->key)
			temp = temp->left;
		else if (key > temp->key)
			temp = temp->right;
		else
			return true;
	}
	return false;
}

void display_tree(Node* const root) {

	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

int main() {

	int n;  cin >> n;
	Node* root = 0;

	string cmd;
	int key;
	for (int i = 0; i < n; i++)	{
		cin >> cmd;
		if (cmd[0] == 'i') {
			cin >> key;
			if (!root) {
				root = new Node;
				root->key = key;
				root->left = root->right = 0;
			} else
				insert_key(root, key);
		} 
		else if (cmd[0] == 'p') {
			display_tree(root);
		}
		else if (cmd[0] == 'f') {
			cin >> key;
			bool res = find_key(root, key);
			if (res) cout << "yes\n";
			else cout << "no\n";
		}
	}

	return 0;
}



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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
LL k;
int main(){
	IO();
	cin>>k;
	int lim = (int)4e6;
	int rem = 0;
	LL ans = -1;
	for(int i=0;i<lim;i++){
		rem = (10 * rem + 7) % k;
		if(rem == 0){
			ans = i+1;
			break;
		}
	}
	cout<<ans;
	return 0;
}

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

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

    rep(i, s.size()) {
        if(char(s[i] + n) > 'Z') {
            cout << char(s[i] + n - 26);
        } else {
            cout << char(s[i] + n);
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }
    else{
        cout<<min(a+(b-a-1)/2,n-b+1+(b-a-1)/2)<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int N=0;
        double ans=0;
        string A="No";
        for(int i=0;i<S.Length;i++)
        {
          ans+=double.Parse(S[i].ToString())*Math.Pow(10,(double)(S.Length-i-1));
          N+=int.Parse(S[i].ToString());
        }
        if(ans%N==0)A="Yes";
        Console.WriteLine(A);
        
    }


}



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);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
  
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;
        
    }
}

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

int N, K, a[100006];

int abs(int a){
	return a >= 0? a : -a;
}

int main(){
	scanf("%d %d", &N, &K);
	int pos = -1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if (a[i] >= 0 && pos < 0) {
			pos = i;
		}
	}
	int ans = 1000000000;
	int c, d;
	if (pos < 0) {
		c = 0;
		d = N - K + 1;
	} else {
		c = max(0, pos - K);
		d = min(N - K + 1, pos + 1);
	}
	for (int i = c; i < d; i++) {
		if (a[i] >= 0) {
			ans = min(ans, a[i + K - 1]);
		} else if (a[i + K - 1] < 0){
			ans = min(ans, abs(a[i]));
		} else {
			ans = min(ans, min(2*abs(a[i]) + a[i + K - 1], abs(a[i]) + 2*a[i + K -1]));
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
/*note:- in first sight it seems that it will be solved with greddy techniqe
(but that is wrong as it will give wrong ans).*/
/*4 3 270
100 10 10 10
90 90 90
using greedy approach we will be able to read only three books in the above test
case(and it will consume entire 270 minutes) but actually we can read 4 books (in just 130 minutes)
*/
/*
this approch uses calculation of prefix sum of both the arrays
refer editorial(and YT_vid) for more details
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>a(n);
    vector<ll>b(m);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll j=0;j<m;j++)
        cin>>b[j];
    vector<ll>sumA(n+1,0);
    vector<ll>sumB(m+1,0);
    for(ll i=0;i<n;i++)
    sumA[i+1]=sumA[i]+a[i];
    for(ll j=0;j<m;j++)
    sumB[j+1]=sumB[j]+b[j];
    ll total=0;
    for(ll i=0;i<=n;i++)
    {
        ll other=k-sumA[i];
        if(other<0)
            continue;
        ll l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
        if(l>m||sumB[l]>other)
            l--;
        total=max(total,i+l);
    }
    cout<<total;
    return 0;
}


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

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	for (int i = 1; i < B; i++) {
		int AA = A*i;
		if (AA % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

string str;
int p;
int getdig(){
    return str[p++] - '0';
}
int num(){
    int n = 0;
    while(isdigit(str[p])){
        n*=10;
        n+=getdig();
    }
    return n;
}

int g(){
    vector<int> down;
    p++;
    while(str[p] == '['){
        p++;
        down.push_back(num());
        p++;
    }
    p++;
    int ans = 0;
    sort(all(down));
    rep(i,down.size()/2+1) ans += down[i]/2+1;
    return ans;
}
 
int f(){
    if(str[p]=='[' && str[p+1]=='[' && str[p+2]=='['){
        p++;
        // p+=2;
        vector<int> up;
        while(str[p]=='['){
            up.push_back(f());
        }
        p++;
        // p+=2;
        int n = 0;
        sort(all(up));
        rep(i,up.size()/2+1) n+=up[i];
        return n;
    } else return g();
}
int main(){
    int n;
    cin >> n;
    while(n--){
        p = 0;
        cin >> str;
        cout << f() << endl;
    }
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> H(A), W(B);
  int mh = 0, mw = 0, cnt = 0;
  vector<pair<int, int>> V;
  for (int h, w; cin >> h >> w;) {
    mh = max(mh, ++H.at(--h)), mw = max(mw, ++W.at(--w)), V.push_back({h, w});
  }
  for (auto [h, w] : V) if (H.at(h) == mh && W.at(w) == mw) cnt++;
  cout << mh + mw - (cnt == count(H.begin(), H.end(), mh) * count(W.begin(), W.end(), mw)) << "\n";
}

Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

long long n,a[N],l,r,ans=-1;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];
	}
	l=0,r=LLONG_MAX/2;
	while (l<=r){
		long long mid=(l+r)/2,now=mid;
		for (int i=1;i<=n;i++){
			now=now/a[i]*a[i];
		}
		if (now>=2){
			if (now==2){
				ans=(l+r)/2;
			}
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if (ans==-1){
		cout << "-1\n";
		return 0;
	}
	cout << ans << " ";
	l=0,r=LLONG_MAX/2;
	while (l<=r){
		long long mid=(l+r)/2,now=mid;
		for (int i=1;i<=n;i++){
			now=now/a[i]*a[i];
		}
		if (now<=2){
			if (now==2){
				ans=(l+r)/2;
			}
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1024
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i
        - max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i
        for i in range(1, int(math.log2(K)) + 1 + 1))) / N)
    return


main()


Measured memory_bytes: 3060
n = int(input())
all_a = []
a1 = 0
a2 = 0
for i in range(n):
    a = int(input())
    all_a.append(a)
    if a > a1:
        a2 = a1
        a1 = a
    elif a > a2:
        a2 = a
for i in range(n):
    if a1 == a2:
        print(a1)
    elif all_a[i] == a1:
        print(a2)
    else:
        print(a1)


Measured memory_bytes: 68952
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
       
        String[] str = scan.nextLine().split(" ");
        double a = Double.parseDouble(str[0]);
        double b = Double.parseDouble(str[1]);
        double c = Double.parseDouble(str[2]);

        double r = c * Math.PI / 180;
        double S = a * b * Math.sin(r) / 2;
        double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r));
        double h = S * 2 /a;

        System.out.println(String.format("%.7f",S));
        System.out.println(String.format("%.7f",L));
        System.out.println(String.format("%.7f",h));

    }
}

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

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;

    vector<int> ans(n);
    rep(ov,n) {

        vector<int> dist(n, -1);
        queue<int> que;

        dist[ov] = 0;
        que.push(ov);

        auto f = [&](int v, int d) {
            if (dist[v] != -1) return;
            dist[v] = d + 1;
            que.push(v);
        };
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            if (v-1 >= 0) f(v-1, dist[v]);
            if (v+1 < n) f(v+1, dist[v]);
            if (v == x) f(y, dist[v]);
            if (v == y) f(x, dist[v]);
        }

        rep(i,n) {
            ans[dist[i]]++;
        }
    }

    rep(i,n) ans[i] /= 2;

    for (int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
int M,N;
string S[130];
 
int dp[(1<<11)][(1<<11)];
 
 
bool check(int st,int fr){
  int mem[130]={};
  int n = __builtin_popcount(st);
  for(int i=0;i<M;i++){
    if( st & (1<<i) ) {
      for(int j=0;j<N;j++){
    if( S[j][i] == '0' && !(fr & (1<<i)) ){
      mem[j]++;
    } else if( S[j][i] == '1' && (fr & (1<<i) ) ) {
      mem[j]++;
    }
      }
    }
  }
  int cnt=0;
  for(int j=0;j<N;j++){
    if( mem[j] == n ) cnt++;
  }
  if( cnt == 1 ) return true;
  return false;
}
 
int solve(int st,int fr){
  if( dp[st][fr] != -1 ) return dp[st][fr];
  if( st>0 && check(st,fr) ) return dp[st][fr] = 0;
  if( st == (1<<M) - 1 ) return dp[st][fr] = 0;
  int ret = 100000;
  for(int i=0;i<M;i++){
    if( (st&(1<<i)) ) continue;
    ret = min( ret,
           max( solve(st|(1<<i),fr|(1<<i))+1,
            solve(st|(1<<i),fr)+1 ) );
  }
  return dp[st][fr] = ret;
}
 
int main() {
  while( cin >> M >> N && ( M||N ) ){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++) cin >> S[i];
    if( N == 1) cout << 0 << endl;
    else cout << solve( 0, 0 ) << endl;
  }
}

Measured memory_bytes: 17612
#include <bits/stdc++.h>
using namespace std;
#define LL long long

int main () {
	int n; cin >> n;
	bool flg = false;
	while (n) {
		if (n % 10 == 7) {
			flg = true;
			break;
		}
		n /= 10;
	}
	cout << (flg ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

int main(void){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    int ans = 0;
    for(int i=0;i<k;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//
// main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

struct Mod {
	static uint64_t PRIME;
	struct LocalPrime {
		uint64_t backup;
		LocalPrime(uint64_t prime) { backup = exchange(Mod::PRIME, prime); }
		~LocalPrime() { Mod::PRIME = backup; }
	};
	uint64_t value = 0;
	Mod()
	: value(0) {}
	Mod(ll v) {
		if (v >= 0) {
			value = v % PRIME;
		} else {
			value = PRIME - (-v) % PRIME;
		}
	}
	Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
	Mod& operator+=(const Mod& rhs) {
		value += rhs.value;
		if (value >= PRIME) {
			value -= PRIME;
		}
		return *this;
	}
	Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
	Mod& operator-=(const Mod& rhs) {
		if (value < rhs.value) {
			value += PRIME;
		}
		value -= rhs.value;
		return *this;
	}
	Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
	Mod& operator*=(const Mod& rhs) {
		value = (value * rhs.value) % PRIME;
		return *this;
	}
	Mod inv() const { return power(*this, PRIME - 2); }
	Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
	Mod& operator/=(const Mod& rhs) {
		*this *= rhs.inv();
		return *this;
	}
	static Mod power(Mod rhs, ll exp) {
		Mod ans = 1;
		while (exp > 0) {
			if (exp % 2) {
				ans *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return ans;
	}
};
uint64_t Mod::PRIME = 1000000007;

int main() {
	ll N, X;
	cin >> N >> X;
	vector<ll> S(N);
	rep(i,0,N) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	auto dp = make_vec_nd((Mod)0, N+1, X+1);
	rep(x,0,X+1) {
		dp[0][x] = x;
	}
	rep(e,1,N+1) {
		rep(x,0,X+1) {
			dp[e][x] = dp[e-1][x%S[e-1]];
			dp[e][x] += dp[e-1][x] * (e-1);
		}
	}
	cout << dp[N][X].value << endl;
}


Measured memory_bytes: 158592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll n,k;
		cin >> n>>k;
		ll arr[n];
		ll i;
		F(i,0,n)
		{
			cin >> arr[i];
		}
		ll dp[n];
		ll x = k;
		for(i=0;i<n;i++)
		{
			dp[i] = MOD;
		}
	//	cout << dp[n-2] << dp[n-3] << endl;
		dp[n-2] = abs(arr[n-2]-arr[n-1]);
		for(i=2;i<=k;i++)
		{
			dp[n-1-i] = abs(arr[n-1-i]-arr[n-1]);
			  
		}
		ll count = 0;
		RF(i,n-2,0)
		{
			count++;
			ll j;
			for(j=1;j<=k;j++)
			{
				if(j>count)
				{
					break;
				}
				dp[i] = min(dp[i+j]+abs(arr[i]-arr[i+j]),dp[i]);
			}
	//		cout << dp[i] << endl;
			
		}
		cout << dp[0] ;
		
	}
	return 0;

}



Measured memory_bytes: 1792
line = input()
N, M, X = [int(v) for v in line.split(" ")]

Ci, Aij = [], []
for i in range(N):
    line = input().split(" ")
    line = [int(v) for v in line]

    Ci.append(line[0])
    Aij.append(line[1:])

ans = []
def dfs(candidate):
    if len(candidate) == N:
        X_ = [0 for _ in range(M)]
        cost = 0
        for i in range(N):
            if candidate[i] == 0:
                continue
            cost += Ci[i]
            for j in range(M):
                X_[j] += Aij[i][j]
        if min(X_) >= X:
            ans.append(cost)
    else:
        for bit in range(2):
            candidate.append(bit)
            dfs(candidate)
            candidate.pop()

dfs([])
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))

Measured memory_bytes: 9340
#include <iostream>

int N, K, X, Y;

void solve() {
    std::cin >> N >> K >> X >> Y;
    if (N < K)
        std::cout << N * X << std::endl;
    else
        std::cout << (X * K) + (Y * (N-K)) << std::endl;
}

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

Measured memory_bytes: 256
fn main() {
    let v = read_vec::<usize>();
    let a = v[0];
    let b = v[1];
    let (first, times) = if a <= b { (a, b) } else { (b, a) };

    for _ in 0..times {
        print!("{}", first);
    }
    println!("");
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

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

#define pb push_back
#define mp make_pair
#define mod 1000000007

vector<int> g[1<<20];
vector<int> v(1<<20, INT_MIN);
vector<int> llimit(1<<20, -1000000);
vector<int> ulimit(1<<20, 1000000);

bool dfs(int c, int p, int oe) {

    if(v[c] != INT_MIN) {
        if(v[c]%2 != oe) {
            return 0;
        }
    }

    for(int u:g[c]) {
        if(u != p) {
            if(not dfs(u, c, oe^1)) return 0;
            llimit[c] = max(llimit[u]-1, llimit[c]);
            ulimit[c] = min(ulimit[u]+1, ulimit[c]);
        }
    }

    if(v[c] != INT_MIN) {
        llimit[c] = max(v[c], llimit[c]);
        ulimit[c] = min(v[c], ulimit[c]);
    }

    if(llimit[c] > ulimit[c]) return 0;
    return 1;
}

bool dfs2(int c, int p, int lv, int uv) {
    llimit[c] = max(lv, llimit[c]);
    ulimit[c] = min(uv, ulimit[c]);

    if(llimit[c] > ulimit[c]) return 0;
    v[c] = llimit[c];

    for(int u:g[c]) {
        if(u != p) {
            if(not dfs2(u, c, llimit[c]-1, llimit[c]+1)) return 0;
        }
    }

    return 1;
}

int main() {
    int n,x,y,k;
    cin>>n;
    for(int i=1;i<n;i++) {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }

    cin>>k;
    while(k--) {
        cin>>x>>y;
        v[x] = y;
    }

    if((not dfs(x, -1, y%2)) or (not dfs2(x, -1, y, y))) {
        cout<<"No";return 0;
    }

    cout<<"Yes"<<endl;
    for(int i=1;i<=n;i++) cout<<v[i]<<endl;


    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353; // うくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうくうく

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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 F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  N %= 10;
  if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9)cout << "hon\n";
  else if(N == 0 || N == 1 || N == 6 || N == 8) cout << "pon\n";
  else cout << "bon\n";
}


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

using namespace std;

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

void solve(){
    int n,y;
    cin>>n>>y;
    for (int i=0;i<=n;i++){
        for (int j=0;j<=n;j++){
            if ((10000*i+5000*j+(n-i-j)*1000)==y&&(n-i-j)>=0){
                cout<<i<<' '<<j<<' '<<n-i-j;
                return;
            }
        }
    }cout<<"-1 -1 -1";
}

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

    solve();

    return 0;
}


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

int main() {
  int n;
  int dif, difx, dify, d;

  cin >> n;

  int t[n+1][3] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> t[i][j];
    }
  }

  string str;

  for (int i = 0; i < n; i++) {
      dif = abs(t[i+1][0] - t[i][0]);
      difx = abs(t[i+1][1] - t[i][1]);
      dify = abs(t[i+1][2] - t[i][2]);
      d = dif - (difx + dify);
      if (d % 2 != 0 || d < 0) {
        str = "No";
        break;
      }
      str = "Yes";
  }

  cout << str << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=2005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B,C,D;cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        A-=D;
        if(A<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
}





Measured memory_bytes: 3656
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n;
    cin >> n;

    cout << updiv(n,2) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
int main(){
	ll n;
	float m; cin>>n>>m;
	ll a[n],cnt=0;
	float sum=0;
	for(ll i=0;i<n;i++) {
		cin>>a[i];
		sum+=a[i];
		}
		//cout<<sum<<" ";
	float p=1/(4*m);
	float q=sum*p;
	//cout<<p<<" "<<q<<" ";
	for(ll i=0;i<n;i++) {
		if(a[i]>=q) cnt++;
		}
		//cout<<cnt;
	if(cnt>=m) cout<<"Yes\n";
	else cout<<"No\n";
	}
	
		

		

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n);
	for (int i=0; i<m; i++) {
		int x, y;
		cin >> x >> y;
		adj[--x].push_back(--y);
		adj[y].push_back(x);
	}
	queue<int> bfs;
	vector<int> ans(n, -1);
	bfs.push(0);
	while (!bfs.empty()) {
		int cur = bfs.front(); bfs.pop();
		for (int x : adj[cur]) {
			if (ans[x] < 0) {
				ans[x] = cur;
				bfs.push(x);
			}
		}
	}
	for (int i=1; i<n; i++) {
		if (ans[i] < 0) {
			cout << "No"; return 0;
		}
	}
	cout << "Yes\n";
	for (int i=1; i<n; i++) {
		cout << ans[i]+1 << '\n';
	}
}

Measured memory_bytes: 9996
n,x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

if a.sum==x
    puts a.length
    return
end

a=a.sort
count=0
(n-1).times do |i|
    x-=a[i]
    if x>=0
        count+=1
    else
        break
    end
end
puts count


Measured memory_bytes: 14356
<?php
$bunsetus = trim(fgets(STDIN));
$bunsetu = explode(" ", $bunsetus);
$seven_count=0;
$five_count=0;
 
for($i = 0 ; $i < count($bunsetu); $i++){
    if($bunsetu[$i]==7){
        $seven_count+=1;
    }
}
 
for($j = 0 ; $j < count($bunsetu); $j++){
    if($bunsetu[$j]==5){
        $five_count+=1;
    }
}
 
if($five_count==2 && $seven_count ==1){
   echo "YES";
}else{
   echo "NO";
}
 
?>

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long sum = 0;
		for (int i = 1; i <= N; i++) {
			if (!(i % 3 == 0) && !(i % 5 == 0)) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 35876
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> v(h);
  rep(i,h) cin>>v[i];
  ll ans=0;
  rep(tmp,(1<<(h+w))){
    bitset<12> s(tmp);
    set<int> a,b;
    a.insert(-1); b.insert(-1);
    rep(i,h){
      if(s.test(i)) a.insert(i);
    }
    rep(i,w){
      if(s.test(h+i)) b.insert(i);
    }
    int cnt=0;
    rep(i,h)rep(j,w){
      if(a.count(i)&&b.count(j)){
        if(v[i][j]=='#') cnt++;
      }
    }
    if(cnt==k) ans++;
    //out(cnt);
  }
  out(ans);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    
     for(int i = 0;i < n; ++i) cin >> d[i];
    sort(d.begin(), d.end());
   
    cout << d[n / 2] - d[n / 2-1];
    return 0;
}


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

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

    int half = (N + 1) / 2;

    int ans = 100;
    for (int i=1; i<=half; ++i) {
        int A = i;
        int B = N - A;
        int sumAB = 0;
        while (A > 0) {
            sumAB += A % 10;
            A /= 10;
        }
        while (B > 0) {
            sumAB += B % 10;
            B /= 10;
        }
        if (sumAB < ans) ans = sumAB;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    
    int d = a / b;
    int r = a % b;
    double f = (double) a / b;
    printf("%d %d %.10f\n",d,r,f);
    //cout << d << " " << r << " " << f << endl;

}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<int> prime;
bool is_prime[1000010];
int min_factor[1000010];
int sieve(int n) {
  fill(is_prime + 2, is_prime + 1000010, true);
  min_factor[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
        if (min_factor[j] == 0) min_factor[j] = i;
      }
    }
  }
  return prime.size();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  sieve(1000000);
  int cum[1000010];
  for (int i = 1; i <= 1000000; i++) {
    cum[i] = is_prime[i] + cum[i - 1];
  }
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int p, m;
      cin >> p >> m;
      ans += cum[min(1000000, p + m)] - cum[max(1, p - m) - 1] - 1;
    }
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
    int N, M;
    int Foodlist[40];
    int A[100][100];
    int K[100];
    cin >> N >> M;

    for(int i = 0; i < N; ++i){
      cin >> K[i];
      for(int j = 0; j < K[i]; ++j) cin >> A[i][j];
    }
    for(int i = 0; i < M; ++i) Foodlist[i] = 0;
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < K[i]; ++j){
        Foodlist[A[i][j] - 1] += 1;
      }
    }
    int count = 0;
    for(int i = 0; i < M; ++i){
      if(Foodlist[i] == N) count += 1;
    }
	cout << count << endl;

}

Measured memory_bytes: 256