akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int desc(const void *a, const void *b){
    return *(int *)b - *(int *)a;
}
int min(int a, int b){
    if(a>b){
        return b;
    }
    return a;
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    return b;
}
int main(){
    int N;
    int A[100000];
    int i;
    int m;
    m=10000;
    int n;
    n=-10000;
    int M[100000];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        if(A[i]<0){
            M[i]=-1;
        }else{
            M[i]=1;
        }
        m=min(m,A[i]);
        n=max(n,A[i]);
    }
    int ans;
    ans=0;
    for(i=0;i<N;i++){
        ans=ans+A[i]*M[i];
    }
    if(m>0){
        ans=ans-2*m;
    }
    if(n<0){
        ans=ans+2*n;
    }
    printf("%d\n",ans);
    qsort(A,N,sizeof(*A),desc);
    int j;
    if(m<0){
        for(i=N-1;i>=0;i--){
            if(A[i-1]>=0||i==0){
                j=i;
                goto next;
            }
            printf("%d %d\n",A[0],A[i]);
            A[0]=A[0]-A[i];
        }
        next:
        for(i=0;i<j-1;i++){
            printf("%d %d\n",A[j],A[i]);
            A[j]=A[j]-A[i];
        }
        if(j>0){
            printf("%d %d\n",A[j-1],A[j]);
        }
    }
    if(m>=0){
        for(i=0;i<N-2;i++){
            printf("%d %d\n",A[N-1],A[i]);
            A[N-1]=A[N-1]-A[i];
        }
        printf("%d %d\n",A[N-2],A[N-1]);
    }
}

Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main()
{
  int n;
  ll ans = 1, s = 1000000000000000000;
  cin >> n;
  vector<ll> a(n);
  rep(i, n)
  {
    cin >> ans;
    a[i] = ans;
    if (ans == 0)
    {
      cout << 0;
      return 0;
    }
  }
  ans = 1;
  rep(i, n)
  {
    if (a[i] > s / ans)
    {
      cout << -1;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
const int mod=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}
bool cmp(int a, int b){
	return a>b;
}
int32_t main(){
	
	FIO();
	
		int n,m;cin>>n>>m;
		vi a(n);int tot=0;
		for(int i=0; i<n; i++){
			cin>>a[i];tot+=a[i];
		}
		sort(a.begin(), a.end(), cmp);
		if(a[m-1]<(tot+4*m-1)/(4*m))
			cout<<"No";
		else
			cout<<"Yes";
	
	return 0;
	
		
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin>>a>>b;
  if (a+b>=10) {
    cout<<"error"<<endl;
  }
  else{
    cout<<a+b<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		for (int i = 0; i < K; i++) {
			int dk = sc.nextInt();
			int list[] = new int[dk];
			for (int c = 0; c < dk; c++) {
				list[c] = sc.nextInt();
			}
			for (int num : list) {
				ans[num - 1] = 9;
			}
		}

		for (int num : ans) {
			if (num == 9) {
				ans2++;
			}
		}

		System.out.println(N - ans2);
	}
}


Measured memory_bytes: 46192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int divCount(int n){
    int cnt = 0;
    while(n % 2 == 0){
        cnt ++;
        n = n / 2;
    }
    return cnt;
}

int main(){

    int n;
    cin >> n;

    int ans = 0;
    int cntMax = 0;
    for(int i = 1; i <= n; i++){
        if(cntMax <= divCount(i) ){
            ans = i;
            cntMax = divCount(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

w_s = s[::-1]

w_s = w_s.replace('b', '1')
w_s = w_s.replace('d', '2')
w_s = w_s.replace('p', '3')
w_s = w_s.replace('q', '4')

w_s = w_s.replace('1', 'd')
w_s = w_s.replace('2', 'b')
w_s = w_s.replace('3', 'q')
w_s = w_s.replace('4', 'p')

if s == w_s:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
h, w=map(int, input().split())
table=[[0]*(w+2) for i in range(h+2)]
flag=0

for i in range(1, h+1):
    s=input()
    for j in range(1, w+1):
        table[i][j]=s[j-1]


for i in range(1, h+1):
    for j in range(1, w+1):
        if table[i][j]=="#":
            if table[i][j-1]!="#" and table[i-1][j]!="#" and table[i][j+1]!="#" and table[i+1][j]!="#":
                flag=1

if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

string S;
int dp[100000+10];
int main(void) {
    cin>>S;

    for(int i = 0;i < S.size();i++) {
        dp[i] = 0;
    }
    int N = S.size();
    
    //RL
    int l_num = 0; //Lの個数
    int r_num = 1;
    int r_pos = 0; //rの位置
    for(int i = 1;i <= N-1;i++) {
        if(S[i] == 'R') {
            r_num++;
            r_pos = i;
        } else {
            if(S[i-1] == 'L') {
                if((r_pos - i) % 2 == 0)
                    dp[r_pos]++;
                else
                    dp[r_pos+1]++;
                
            } else {
            dp[i] += r_num / 2 + 1;
            dp[i-1] += r_num - (r_num / 2);
            r_num = 0;
            }
           
        }
    }

    for(int i = 0;i < N;i++) {
        cout<<dp[i]<<" ";
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import itertools

N = int(input())
D = [int(x) for x in input().split()]

counter = [1] + [0] * 12
for x in D:
    counter[x] += 1

bl = counter[0] > 1 or counter[12] > 1 or any(x >= 3 for x in counter)
if bl:
    print(0)
    exit()

itrs = [[[0]]]
for x in range(1,12):
    if counter[x] == 0:
        itr = [[]]
    elif counter[x] == 1:
        itr = [[x],[-x]]
    else:
        itr = [[x,-x]]
    itrs.append(itr)
itrs.append([[]] if counter[12] == 0 else [[12]])

def F(arr):
    f = lambda x,y: min((x-y)%24, (y-x)%24)
    return min(f(x,y) for x,y in itertools.combinations(arr,2))

answer = 0
for p in itertools.product(*itrs):
    arr = []
    for x in p:
        arr += x
    answer = max(answer, F(arr))

print(answer)

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    if (n >= 65 && n<=90) printf("%d\n", 1);
    else if (n >= 97 && n<=122) printf("%d\n", 2);
    else printf("%d\n", 0);
}



Measured memory_bytes: 2760
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>b){
    for(int i=0;i<a;i++){
      printf("%d",b);
    }
    return 0;
  }
  else
    for(int i=0;i<b;i++)
      printf("%d",a);
}

Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	set<string> s;
	s.insert("a");
	cout << "?a" << endl;
	fflush(stdout);
	string str; cin >> str;
	char last='a';
	while(1){
		if(str[0]!=last){
			cout << "!OUT" << endl;
			return 0;
		}
		if(s.find(str)!=s.end()){
			cout << "!OUT" << endl;
			return 0;
		}
		s.insert(str);
		string next="";
		next+=str[str.size()-1];
		next+=str;
		next+='a';
		while(s.find(next)!=s.end())next+='a';
		cout << "?" << next << endl;
		fflush(stdout);
		cin >> str;
	}
}


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

using namespace std;

int main() {
  int ans = 0;
  int n;
  cin >> n;

  std::vector<int> l(n);

  for(int i = 0; i < n; i++) {
    cin >> l[i];
  }
  std::sort(l.begin(), l.end(), std::greater<int>());

  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      for(int k = j + 1; k < n; k++) {
	if( l[i] < l[j] + l[k] && l[j] < l[i] + l[k] && l[k] < l[i] + l[j]) {
	  ans += 1;
	} else {
	  break;
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int a,b;
  int c=0,d=0;
  
  cin >> a >> b;

  if ( a <= 8  && b <= 8 ) cout << "Yay!" << endl;
  else   cout << ":(" << endl;
  
		     

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define N 1000001
using namespace std;

int main() {
	vector<bool>sosuu(N, true);
	sosuu[0] = sosuu[1] = false;
	for (int b = 2; b < N; b++) {
		if (sosuu[b]) {
			for (int c = b * 2; c < N; c += b)sosuu[c] = false;
		}
	}
	int d, e, f;
	while (cin >> d >> e >> f, d | e | f) {
		int s = 0;
		for (;; d += e) {
			if (sosuu[d])s++;
			if (s == f) { cout << d << endl; break; }
		}
	}
}

Measured memory_bytes: 3128
import java.util.HashSet;
import java.util.Scanner;

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

        long money = 1000L;
        long stock = 0;

        int N = scanner.nextInt();
        int[] A = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }

        for (int i = 0; i < N; i++) {
            if (i + 1 < N && A[i] < A[i + 1]) {
                // 次上がるときは購入する
                long num = money / A[i];
                stock += num;
                money -= num * A[i];
            } else {
                // 次上がらないor最後のときは売却する
                money += stock * A[i];
                stock = 0;
            }
        }

        System.out.println(money);
    }
}


Measured memory_bytes: 35896
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ele int
using namespace std;
#define maxn 100010
ele n;
char s[maxn];
int main(){
	scanf("%s",s); n=strlen(s);
	ele ans=n;
	for (int i=0; i<n-1; ++i)
		if (s[i]!=s[i+1]) ans=min(ans,max(i+1,n-1-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
const long long mod = 1000000007;
const long long inf = 1145141919810;
typedef pair<int, int> P;
typedef pair<P, P> PP;
struct edge {int to, cost;};

signed main() {
	string s; cin >> s; int a; cin >> a;
	for (int i = 0; i < s.size(); i += a)cout << s[i];
	cout << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstring>
using namespace std;
bool prim[1000005];
int main(){
	int n;
	int i,j,k;
	int a,b,c;
	memset(prim,true,sizeof(prim));
	prim[0]=false,prim[1]=false;
	for(i=2;i<1000005;i++){
		if(!prim[i])continue;
		for(j=i*2;j<1000005;j+=i)prim[j]=false;
	}
	while(cin>>a>>b>>n){
		if(!a)break;
		for(i=a;;i+=b){
			if(prim[i])n--;
			if(!n)break;
		}
		cout<<i<<endl;
	}
}



Measured memory_bytes: 4028
#include <stdio.h>
main(){
  while(1){
  int a,n[100],i,j,tmp,m,c=0;
    scanf("%d",&a);
    if(a==0) break;
    for(i=0;i<a;i++){
      scanf("%d",&n[i]);
    }

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

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


int main(){
    int n,ans=0;
    cin >> n ;
   vector<int> a(n);
   for(int i=0;i<n;i++){
       cin >> a.at(i);
   }
   sort(a.rbegin(),a.rend());
   a.at(0)/=2;
   for(int i=0;i<n;i++){
       ans+=a.at(i);
   }
   cout << ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
     
int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int sum=0;
    int a1,a2,a3;
    if(k>=a){
        sum=sum+(a*1);
        k=k-a;
        //printf(" %d %d\n",k,sum);
    }
    else if(k<a && k>0){
        sum=sum+(k*(1));
        k=0;
        //printf("%d %d\n",k,sum);
    }
    if(k>=b){
        sum=sum+(b*0);
        k=k-b;
        //printf("%d %d\n",k,sum);
    }
    else if(k<b && k>0){
        sum=sum+(k*(0));
        k=0;
        //printf("%d %d\n",k,sum);
    }
    if(k>=c){
        sum=sum+(c*(-1));
        k=k-c;
        //printf("%d %d\n",k,sum);
    }
    else if(k<c && k>0){
        sum=sum+(k*(-1));
        //printf("%d %d\n",k,sum);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
vector<vector<ll> > dp;
vector<vector<vector<ll> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	string S;
	cin>>S;
	int N=S.size();
	dp=vector<vector<ll> >(N+1, vector<ll>(4,0));
	//dp[0][0]=1;
	for(int i=N;i>=0;i--){
		for(int j=3;j>=0;j--){
			if(i==N) dp[i][j]=(j==3 ? 1:0);
			else{
				dp[i][j]=dp[i+1][j]*(S[i]=='?'? 3LL:1LL);
				if(j<3 && (S[i]=='?' || S[i]=="ABC"[j])) 
					dp[i][j]+=dp[i+1][j+1];
			
			dp[i][j]%=mod;
			}
		}
	}
	
	cout<<dp[0][0]<<endl;
	return 0;
}


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

int main() {
   int n,k;
   cin>>n;
   cin>>k;
   int h[n];
   for(int i = 0;i<n;i++)
{
    cin>>h[i];
}

int dp[n] = {0};

dp[1] = abs(h[0]-h[1]);
for(int i = 2;i<n;i++)
{   int ans = INT_MAX;
    for(int j = 1;j<=k && j<=i;j++)
  { ans = min(ans,dp[i-j] + abs(h[i]-h[i-j]) );
     // dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2]+ abs(h[i]-h[i-2]));
  }
  dp[i] = ans;
}
cout<<dp[n-1];

}


Measured memory_bytes: 1024
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 3e3+2;
int dp[N][N];
int a[N];
int n;
int solve(int l,int r)
{
    if(l>r || l>n || r<1)
        return 0;
    if(dp[l][r]!=-1)
        return dp[l][r];
    int ans1 = a[l]-solve(l+1,r);
    int ans2 = a[r]-solve(l,r-1);
    dp[l][r] = max(ans1,ans2);
    return dp[l][r];
}
signed main()
{
    fast;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,n);
}

Measured memory_bytes: 70784
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

#define PI 3.14159265359

int main(){
    //input
    int a,b,x;
    cin >> a >> b >> x;

    //calc
    double ans;
    if(2*x<=a*a*b){
        ans = 180.0/PI*atan((double)a * (double)b * (double)b / 2.0 / (double)x);
    }else{
        ans = 180.0/PI*atan(2.0 * ((double)a * (double)a * (double)b - (double)x) / (double)a / (double)a / (double)a);
    }

    //answer
    cout << fixed << setprecision(10) << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;cin >> s >> t;
    int ans=0;
    REP(i,s.size()){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

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

void findCounts(int *arr, int n)
{
    //Hashmap
    int hash[n] = {0};

    // Traverse all array elements
    int i = 0;
    while (i < n-1)
    {
        //update the frequency of array[i]
        hash[arr[i] - 1]++;

        //increase the index
        i++;
    }

    //printf("\nBelow are counts of all elements\n");
    for (int i = 0; i < n; i++)
        printf("%d\n",hash[i]);
}

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0; i < n-1; i++)
        cin>>arr[i];
    findCounts(arr, n);
    return 0;
}

Measured memory_bytes: 5324
import java.util.*

var d = IntArray(0)
var f = IntArray(0)
var count = 0
var map =java.util.HashMap<Int, Array<Int>>()
fun main(args: Array<String>) {


    var sc = Scanner(System.`in`)

    val n = sc.nextInt()

     d = IntArray(n + 1)
     f = IntArray(n + 1)


    for(i in 0 until n){
        val id = sc.nextInt()
        val k = sc.nextInt()

        map[id] = (0 until k).map { sc.nextInt() }.toIntArray().toTypedArray()
    }

    for(i in 1..n){
        ds(i)
    }

    for(i in 1..n){
        println("$i ${d[i]} ${f[i]}")
    }

}

private fun ds(id: Int){
    val neighbors = map[id]!!
    if(d[id] > 0){
        return
    }
    d[id] = ++count
    for(i in neighbors){
        ds(i)
    }
    f[id] = ++count
}





Measured memory_bytes: 31292
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define ll long long 
#define MAX (int)(pow(10,7) + 10)
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9) + 7;
double eps = 1e-6;
ifstream in;
ofstream out;


void deal(){
	ll n;
	cin>>n;
	cout<<(n+1)/2;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

Measured memory_bytes: 384
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn=1e5+10;
vector<int> V[maxn];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	int value,day;
	while(n--)
	{
		scanf("%d%d",&day,&value);
		if(day>m) {continue;}
		V[m-day+1].push_back(value);
	}
	priority_queue<int> Q;
	int money=0;
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<V[i].size();j++)
		{
			Q.push(V[i][j]);
		}
		while(!Q.empty())
		{
			money+=Q.top();
			Q.pop();
			break;
		}
	}
	printf("%d\n",money);
	return 0;
}

Measured memory_bytes: 5632
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    println!("{}", max_acgt_len(s.as_str()))
}

fn max_acgt_len(s: &str) -> i32 {
    fn inner(rest: &mut std::str::Chars, current: i32, max: i32) -> i32 {
        let head = match rest.next() {
            Some(head) => head,
            None => return max,
        };

        match "ACGT".find(head) {
            Some(_) => {
                let next = current + 1;
                inner(rest, next, if max > next { max } else { next })
            },
            None => inner(rest, 0, max),
        }
    }

    inner(&mut s.chars(), 0, 0)
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int win = 0;
    int lose = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == 'g') {
        if(i % 2 == 1) win++;
      } else {
        if(i % 2 == 0) lose++;
      }
    }
    System.out.println(win - lose);
  }
}

Measured memory_bytes: 24904
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
 #define debug(x) cerr<<#x<<":"<<x<<endl
 const int maxn=(int)1e6+5;
 typedef long long ll;
 const ll MOD=(ll)1e9+7;
inline ll qpow(ll a, ll b) {return b? ((b&1)? a*qpow(a*a%MOD,b>>1)%MOD: qpow(a*a%MOD,b>>1))%MOD: 1;}
inline ll gcd(ll a, ll b) {return b? gcd(b, a%b): a;}
ll c(ll a,ll b){
    ll ret=1;
    rep(i,1,b){
        ret*=a-i+1;ret%=MOD;
        ret*=qpow(i,MOD-2);ret%=MOD;

    }
    return ret;
}
    
 int main(){
     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     ll n,a,b;
     cin>>n>>a>>b;
     debug(c(n,a));debug(c(n,b));
     cout<<((qpow(2,n)-c(n,a)-c(n,b)-1)%MOD+MOD)%MOD;
 }

 /*
 4 1 3
   */

Measured memory_bytes: 256
import sys
n = int(input())
nun_list = list(map(int, input().split()))
result = 0
if nun_list.__contains__(0):
    print(0)
    sys.exit()

for i in range(n):
    if i == 0:
        result = nun_list[i]
    else:
        result = result * nun_list[i]
    if result > 10**18:
        print('-1')
        sys.exit()
print(result)

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

int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;

const ll mod = 1e9 + 7;
const int N = 2e5 + 10;
ll fac[N], inv[N], finv[N];
int n, m, k;
ll ans = 0;

ll brute(int n, int m, int k) {
  ll mult = fac[n * m - 2] * finv[k - 2] % mod * finv[n * m - k] % mod;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < n; k++) {
        for (int l = 0; l < m; l++) {
          if (i * m + j >= k * m + l) {
            ans += (abs(i - k) + abs(j - l)) * mult;
            ans %= mod;
          }
        }
      }
    }
  }
  return ans;
}

ll fix(ll x) {
  x %= mod;
  x += mod;
  x %= mod;
  return x;
}
int main() {

  fac[0] = fac[1] = 1;
  inv[1] = 1;
  finv[0] = finv[1] = 1;
  for(int i=2; i < N; i++){
    fac[i] = (i * fac[i-1]) % mod;
    inv[i] = (mod - (mod/i) * inv[(mod%i)] % mod) % mod;
    finv[i] = (inv[i] * finv[i-1]) % mod;
  }


  cin >> n >> m >> k;
  
  ll mult = fac[n * m - 2] * finv[k - 2] % mod * finv[n * m - k] % mod;

  vector<vector<ll>> nw(n, vector<ll>(m, 0ll));
  vector<vector<ll>> ne(n, vector<ll>(m, 0ll));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      nw[i][j] += i + j;
      if (i > 0) nw[i][j] += nw[i - 1][j];
      if (j > 0) nw[i][j] += nw[i][j - 1];
      if (i > 0 && j > 0) nw[i][j] -= nw[i - 1][j - 1];
      ans += mult * fix((i + 1) * (j + 1) * 1ll * (i + j) - nw[i][j]) % mod;
      ans %= mod;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      ne[i][j] += i + (m - 1 - j);
      if (i > 0) ne[i][j] += ne[i - 1][j];
      if (j < m - 1) ne[i][j] += ne[i][j + 1];
      if (i > 0 && j < m - 1) ne[i][j] -= ne[i - 1][j + 1];
      
      if (i > 0 && j + 1 < m) {
        ans += mult * (fix(i * (m - 1 - j) * 1ll * (i + (m - 1 - j)) - ne[i - 1][j + 1])) % mod;
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int in=getInt();
		System.out.println(in/10==9||in%10==9?"Yes":"No");
	}
}

Measured memory_bytes: 21844
from collections import deque

H, W = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(H)]
visited = []
odd = False
o_cnt = 0
for i in range(H):
  for j in range(W):
    if grid[i][j]%2 == 1:
      o_cnt += 1

cnt = 0
h = w = 0
if o_cnt%2 == 1:
  o_cnt -= 1
for i in range(H):
  for j in range(W)[::-1 if i%2 == 1 else 1]:
    if cnt == o_cnt:
      break
    if odd:
      if grid[i][j]%2 == 1:
        cnt += 1
        odd = False
      visited.append((h+1, w+1, i+1, j+1))
      h, w = i, j
    elif grid[i][j]%2 == 1:
      cnt += 1
      odd = True
      h, w = i, j
print(len(visited))
for v in visited:
  print(' '.join(map(str, v)))




Measured memory_bytes: 26544
S = input()

a = list(set(S))
b,c = 0,0

for i in range(4):
    if S[i] == a[0]:
        b += 1
    elif S[i] == a[1]:
        c += 1

if b == 2 and c == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2028
def main():
    MX = 10 ** 2
    
    N = int(input())

    ctr = [0] * (N + 1)
    for x in range(1, MX + 1):
        for y in range(1, MX + 1):
            for z in range(1, MX + 1):
                t = x * x + y * y + z * z + x * y + y * z + z * x
                if t <= N:
                    ctr[t] += 1

    print(*ctr[1:], sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
from math import ceil, floor

def tax(yen, percent):
  start = yen * 100 / percent
  end = (yen + 1) * 100 / percent
  return set(range(ceil(start), ceil(end)))

A, B = map(int, input().split(" "))
a = tax(A, 8)
b = tax(B, 10)
r = a & b
if len(r):
  print(sorted(list(r))[0])
else:
  print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define Max(a,b) (a>b?a:b)
const int N = 300050;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
struct heap{
  int c[N],tot; ll s;
  void push(int w){
    c[++tot]=w; push_heap(c+1,c+tot+1);
    s+=w; return;
  }
  void pop(){
    pop_heap(c+1,c+tot+1); --tot;
    s-=c[tot+1]; return;
  }
}S;
ll mn[N],mx[N];
int a[N];
int main(){
  int n=gi(),m=n*3;
  for (int i=1; i<=m; ++i)
    a[i]=gi();
  for (int i=1; i<=n; ++i)
    S.push(-a[i]);
  mx[n]=-S.s;
  for (int i=n+1; i<=m; ++i)
    S.push(-a[i]),S.pop(),mx[i]=-S.s;
  while(S.tot) S.pop();
  for (int i=m; i>m-n; --i)
    S.push(a[i]);
  mn[m-n+1]=S.s;
  for (int i=m-n; i; --i)
    S.push(a[i]),S.pop(),mn[i]=S.s;
  ll ans=-1e16;
  for (int i=n; i<=m-n; ++i)
    ans=Max(ans,mx[i]-mn[i+1]);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 5888
using System;

public class Hello
{
    public static void Main()
    {
        var x = long.Parse(Console.ReadLine().Trim());
        getAns(x);
    }
    static void getAns(long x)
    {
        var t = 100L;
        var count = 1;
        while (true)
        {
            t += t / 100;
            if (t >= x) { Console.WriteLine(count); return; }
            count++;
        }
    }
}


Measured memory_bytes: 17480
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, ans = 0;
    cin >> N;

    int A[N], B[N], C[N-1];
    REP(i, N){
        cin >> A[i];
    }
    REP(i, N){
        cin >> B[i];
    }
    REP(i, N-1){
        cin >> C[i];
    }
    
    REP(i, N){
        ans += B[A[i]-1];
        if(A[i-1]+1 == A[i]) ans+=C[A[i-1]-1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3532
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;

int n,m,x,y;
int l[100005];
vector<int> adj[100005];
class GLongestPath {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> m;
		f(i,0,n)
			l[i]=-1;
		f(i,0,m)
		{
			in >> x >> y;
			x--;y--;
			adj[x].push_back(y);
		}
		int ans=0;
		f(i,0,n)
			ans=max(ans,maxl(i));
		out << ans << "\n";
	}
	int maxl(int x)
	{
		if(l[x]==-1)
		{
			l[x]=0;
			for(auto v : adj[x])
				l[x]=max(l[x],1+maxl(v));
		}
		return l[x];
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	GLongestPath solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7680
N = int(input())    #勇者の数
monster_list = list(map(int,input().split()))       #モンスターの数
cap_list = list(map(int,input().split()))       #倒せる数

count = 0

for i in range(N):
    winnum = monster_list[i] - cap_list[i]
    if winnum >= 0:      #モンスターの数のほうが多い場合
        count += cap_list[i]

    elif monster_list[i+1] + winnum < 0:       #i+1でもモンスターの数が少ない場合
        count += monster_list[i] + monster_list[i+1]
        monster_list[i+1] = 0
    
    elif monster_list[i+1] + winnum >= 0:
        count += monster_list[i] - winnum
        monster_list[i+1]  = monster_list[i+1] + winnum

print(count)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using indexed_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mem(a, s) memset(a, s, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; --i)
typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};
void solve();
void pre();
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    // cin >> t;
    rep(i, 1, t) { solve(); }
    return 0;
}
const int mod = 1e9 + 7;
void pre() {}
void solve() {
    int ans = 0;
    int n;
    cin >> n;
    rep(i, 1, n - 1) { ans += (n - 1) / i; }
    cout << ans;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) ((x).begin(), (x).end())

signed main() {
#ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
#endif
    string s;
    cin >> s;
    map<char, int> cnt;
    for (auto c : s)
        cnt[c]++;
    ll res = 1 + sz(s) * 1ll * (sz(s) - 1) / 2;
    for (auto p : cnt) {
        ll x = p.second;
        res -= x * (x - 1) / 2;
    }
    cout << res << '\n';
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n+1);
	vector<int> b(n+1);
	rep(i,n) cin >> a.at(i+1);
	rep(i,n) cin >> b.at(i+1);
	int ans=0;
	rep(i,n){
		a.at(i+1)+=a.at(i);
		b.at(i+1)+=b.at(i);
	}
	rep(i,n){
		ans=max(ans,a.at(i+1)+b.at(n)-b.at(i));
	}
	cout << ans << endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

int main(){
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < int(e.size()); i++) {
    cout << o[i] << e[i];
  }

  if(o.size() > e.size()) {
   cout << o[int(o.size()-1)] << endl;
  }else{
    cout << endl;
  }



}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e6+7;

int t,n,m,k=0,fl=0;
int a[N]={0};

int main(){
    scanf("%d%d",&n,&k);
    k--;
    rep(i,1,n){
        scanf("%d",&a[i]);
    }
    int ans=INF;
    rep(i,1,n-k){
        if(a[i]<0&&a[i+k]<0) ans=min(ans,-a[i]);
        else if(a[i]>0&&a[i+k]>0) ans=min(ans,a[i+k]);
        else ans=min(ans,a[i+k]-a[i]+min(a[i+k],-a[i]));
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
N = int(input())
relevant = {"M":0,
            "A":0,
            "R":0,
            "C":0,
            "H":0}

for i in range(N):
    name = input()
    try:
        relevant[name[0]] += 1
    except:
        pass

chars = [key for key in relevant.keys() if relevant[key] != 0]
ans = 0
for i in range(len(chars)):
    for j in range(i+1,len(chars)):
        for k in range(j+1,len(chars)):
            ans += relevant[chars[i]] * relevant[chars[j]] * relevant[chars[k]]
print(ans)


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

int main(){
	string s, t;
	cin >> s >> t;
	if (s.size() == t.size()) {
		for (int i = 0;i < s.size();i++) {
			bool b = true;
			for (int j = 0;j < s.size();j++) {
				if (s[j] != t[(i + j) % s.size()]) {
					b = false;
				}
			}
			if (b) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

int main() {
  int N;
  vector<vector<int>> bingo(3,vector<int>(3));
  vector<vector<bool>> bingo2(3,vector<bool>(3));
  
  for(int i = 0; i < 3; i++){ 
    for(int j = 0; j < 3;j++){
      cin >> bingo.at(i).at(j);
    }
  }
  cin >> N;
  vector<int> num(N);
  for(int i = 0; i < N; i++) cin >> num.at(i);
  
  bool answer = false;
  for(int i = 0; i < 3; i++){ 
    for(int j = 0; j < 3;j++){
      for(int k = 0; k < N;k++){ 
        if(bingo.at(i).at(j) == num.at(k)) bingo2.at(i).at(j) = true;
      }
    }
  }
  for(int i = 0; i < 3; i++){ 
    if(bingo2.at(i).at(0)&&bingo2.at(i).at(1)&&bingo2.at(i).at(2)) answer = true;
  }
  for(int i = 0; i < 3; i++){ 
    if(bingo2.at(0).at(i)&&bingo2.at(1).at(i)&&bingo2.at(2).at(i)) answer = true;
  }
  if(bingo2.at(0).at(0)&&bingo2.at(1).at(1)&&bingo2.at(2).at(2)) answer = true;
  if(bingo2.at(2).at(0)&&bingo2.at(1).at(1)&&bingo2.at(0).at(2)) answer = true;
  
  if(answer) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    int[] taste = new int[n];
    
    int sum = 0;
    int min = 0;
    for(int i = 0; i < n; i++){
      taste[i] = l + (i+1) - 1;
      sum += taste[i];
    }
    
    int data = 0;
    int t = 300;
    int near = 0;
    for(int i = 0; i < n; i++){
      data = taste[i];
      int target = Math.abs(data - min);
      if(t > target){
        t = target;
        near = data;
      }
    }
   
    System.out.println(sum - near);
    
  }
}

Measured memory_bytes: 35812
n=int(input())
ls=[]
ans=[]
for i in range(n-1):
  ls.append(list(map(int,input().split())))

def calculate(i):
  time=ls[i][1]+ls[i][0]
  for j in range(i+1,len(ls)):
    if time<ls[j][1]:
      time=ls[j][1]+ls[j][0]
    elif time %ls[j][2]==0:
      time+=ls[j][0]
    else:
      time+=ls[j][0]+ls[j][2]-time%ls[j][2]
  return time

for i in range(len(ls)):
  ans.append(calculate(i))
ans.append(0)
for i in ans:
  print(i)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    ll ans=0;
    cin>>n;
    ll a[200010];
    map<ll,ll> mp;
    vll v;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(auto i:mp){
        if(i.sc>i.fi) ans+=(i.sc-i.fi);
        else if(i.fi>i.sc) ans+=i.sc;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int theta; cin >> theta;

	int hour = theta / 30;
	int minute = (theta % 30) * 2;

	cout << hour << ' ' << minute << endl;

	return 0;
}

Measured memory_bytes: 3184
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
    //cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
int a[1050];
void solve(){
    int n,k;
    cin>>n>>k;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    for (int i = 0; i < k; ++i) {
//        cout<<a[i]<<endl;
        sum+=a[i];
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 3640
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var a = new int[N];
		for (var i = 0; i < N; i++) a[i] = F() - 1;
		var used = new bool[N];
		var p = 0;
		var n = 0;
		while (p != 1)
		{
			if (used[p]) break;
			used[p] = true;
			p = a[p];
			n++;
		}
		WriteLine(p == 1 ? n : -1);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 15200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int a,b,c;cin >> a >> b >> c;
  YESNO(c-b==b-a); 
  return 0;
}


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

 
int main(void)
{
    int64_t n,k,i;

    cin >> n >> k;

    vector<int64_t> a(n);

    for(i=0;i<n;i++)cin >> a.at(i);

    for(i=k;i<n;i++){
        if(a.at(i)>a.at(i-k)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using vi = std::vector<int>;
template<class X, class Y> X& remax(X& x, Y y) { return x = (y > x) ? y : x; }
const int NMAX = 100100;
int nV, nE;
vi next[NMAX];
int cnt[NMAX];
int dfs(int x) {
    if (cnt[x] != -1) { return cnt[x]; }
    for (int y : next[x]) {
        remax(cnt[x], dfs(y) + 1);
    }
    remax(cnt[x], 0);
    return cnt[x];
}
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    while(std::cin >> nV >> nE) {
        std::fill(cnt,cnt+NMAX,-1);
        std::fill(next,next+NMAX,vi{});
        for (int i = 0; i < nE; i++) {
            int x, y; std::cin >> x >> y;
            next[x].push_back(y);
        }
        int answ = 0;
        for (int i = 1; i <= nV; i++) {
            if (cnt[i] == -1) {
                remax(answ,dfs(i));
            }
        }
        std::cout << answ << std::endl;
    }
    return 0;
}

Measured memory_bytes: 7552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int h, w, a, b;
  while (cin >> h) {
    cin >> w >> a >> b;
    cout << h * w - (h / a) * a * (w / b) * b << endl;
  }
  return 0;	
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = 0;
    int n = s.size();

    int i = 0;
    while(true){
        if(i>=n){
            break;
        }if(i<n-2){
            if(s[i]!=s[i+1]){
                ans++;
                i++;
            }else{
                ans += 2;
                i += 3;
            }
        }else if(i==n-2){
            if(s[i]!=s[i+1]){
                ans += 2;
                i += 2;
            }else{
                ans++;
                i += 2;
            }
        }else if(i==n-1){
            ans++;
            i++;
        }
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin >>s;
  cin >>t;
  int l =s.size();
  rep(i,l){
    rep(j,l){
      if(s[j] != t[(i+j)%l]) break;
      if(j==l-1){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
    

}


Measured memory_bytes: 256