akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin >> n >> m;
vector<pair<int,string>> a(m);
for(int i = 0; i < m; i++){
    int b;
    string c;
    cin >> b >> c;
    a[i] = make_pair(b,c);
}
vector<int> wa(n),ac(n);
for(int i = 0; i < m; i++){
    if(ac[a[i].first - 1] == 0 && a[i].second == "WA")
    wa[a[i].first - 1]++;
    if(ac[a[i].first - 1] == 0 && a[i].second == "AC")
    ac[a[i].first - 1]++;
}
int sumac = 0,sumwa = 0;
for(int i = 0; i < n; i++){
    if(ac[i] == 0){
        wa[i] = 0;
    }
    sumac += ac[i];
    sumwa += wa[i];
}
cout << sumac << " " << sumwa << endl;
}

Measured memory_bytes: 7296
#include<stdio.h>
int main()
{
int A,B,C,sum;
scanf("%d %d %d",&A,&B,&C);

if(B+C<=A)
{
    printf("0");
}

else if(B+C>A)
{
    printf("%d",sum=B+C-A);

}
return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if(x >= r && y >= r && x+r <= w && y+r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int main()
{
  int N;

  cin >> N;

  if (N % 2 == 0)
  {
    cout << N / 2 << endl;
  }
  else
  {
    cout << (N / 2) + 1 << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
x, y, h = [0]*N, [0]*N, [0]*N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] > 0:
                H = h[i] + abs(x[i]-cx)+abs(y[i]-cy)
        
        for i in range(N):
            if h[i] != max(0, H-abs(x[i]-cx)-abs(y[i]-cy)):
                break
        else:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 3064
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<pair<int,int>> points;
    for (int i = 0; i < 2; ++i) {
        int x, y;
        cin >> x >> y;
        points.emplace_back(x, y);
    }

    auto next = [&](pair<int,int>& A, pair<int,int>& B) -> pair<int,int> {
        int dx = B.first - A.first;
        int dy = B.second - A.second;

        int x = A.first + dy;
        int y = A.second - dx;
        return {x, y};
    };

    for (int i = 0; i < 2; ++i) {
        points.emplace_back(next(points.back(), points[points.size() - 2]));    
    }

    auto A = points[2];
    auto B = points[3];

    cout << A.first << ' ' << A.second << ' ' << B.first << ' ' << B.second << '\n';




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int ans = a+b;
  if (ans >= 10) cout << "error" << endl;
  else cout << ans << endl;
}
  
  

Measured memory_bytes: 256
main :: IO ()
main = do
  n <- readLn
  k <- readLn
  print $ solve n k 1

solve :: Int -> Int -> Int -> Int
solve 0 _ acc = acc
solve n k acc =
  let db = acc*2
      ad = acc+k
      in if db > ad
            then
              solve (n-1) k ad  
             else
              solve (n-1) k db


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    rep(i,H)cin>>S.at(i);
    vector<vector<int>> obyoko(H,vector<int>(1,-1)),obtate(W,vector<int>(1,-1));
    rep(i,H){
        rep(j,W){
            if(S.at(i).at(j)=='#'){
                obyoko.at(i).pb(j);
                obtate.at(j).pb(i);
            }
        }
    }
    rep(i,H){obyoko.at(i).pb(W);}
    rep(i,W){obtate.at(i).pb(H);}
    int ans=1;
    rep(i,H){
        rep(j,W){
            if(S.at(i).at(j)=='#')continue;
            auto y=lower_bound(obyoko.at(i).begin(),obyoko.at(i).end(),j);
            int before,after;
            after=*y;
            y--;
            before=*y;
            int now=after-before-1;
            auto t=lower_bound(obtate.at(j).begin(),obtate.at(j).end(),i);
            after=*t;
            t--;
            before=*t;
            now+=after-before-2;
            chmax(ans,now);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 38400
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int w;
  cin >> s >> w;
  string ans;
  REP(i, 0, s.length()) {
    if (i % w == 0) {
      ans += s[i];
    }
  }
  cout << ans << endl;
}


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

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

int main(){
	
	int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
		
	int k = partition(A,0, n-1);
	
	for(int i=0;i<k;i++)
		cout<<A[i]<<" ";
	cout<<"["<<A[k]<<"]"<<" ";
	for(int i=k+1;i<n-1;i++)
		cout<<A[i]<<" ";
	cout<<A[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 3464
/* In the name of Allah */

#include <bits/stdc++.h>
using namespace std;

// const int INF = 20000000;

#define ll long long
#define _SetBit(A, k) (A[(k / 32)] |= (1 << (k % 32)))
#define _ClearBit(A, k) (A[(k / 32)] &= ~(1 << (k % 32)))
#define _CheckBit(A, k) (A[(k / 32)] & (1 << (k % 32)))
#define SetBit(x, k) (x |= (1 << k))
#define ClearBit(x, k) (x &= ~(1 << k))
#define CheckBit(x, k) (x & (1 << k))

int main()
{
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<pair<int, int>> apple;
  for (int i = 0; i < a; i++)
  {
    int p;
    cin >> p;
    apple.push_back({p, 0});
  }
  for (int i = 0; i < b; i++)
  {
    int p;
    cin >> p;
    apple.push_back({p, 1});
  }
  for (int i = 0; i < c; i++)
  {
    int p;
    cin >> p;
    apple.push_back({p, 2});
  }

  sort(apple.rbegin(), apple.rend());

  int red = 0, green = 0, cnt = 0;
  ll sum = 0;
  int i = 0;
  while (cnt < x + y)
  {
    if (apple[i].second == 0 && red < x)
    {
      sum += apple[i].first;
      cnt++;
      red++;
    }
    else if (apple[i].second == 1 && green < y)
    {
      sum += apple[i].first;
      cnt++;
      green++;
    }
    else if (apple[i].second == 2)
    {
      sum += apple[i].first;
      cnt++;
    }

    i++;
  }

  cout << sum << "\n";

  return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int cnt=1;
  vi cnts;
  rep(i,n-1){
    if(s[i]==s[i+1]) cnt++;
    else{
      cnts.push_back(cnt);
      cnt=1;
    }
  }
  cnts.push_back(cnt);
  int m=cnts.size();
  int l=0,r=m-1;
  int sl=0,sr=0;
  while (l<=r){
    if(sl<sr){
      sl+=cnts[l];
      l++;
    }else{
      sr+=cnts[r];
      r--;
    }
  }
  int ans=max(sl,sr);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,n,count;
  char ring[21],se[21];
  scanf("%s",se);
  scanf("%d",&n);
  for(i=0,count=0;i<n;i++){
    scanf("%s",ring);
    for(j=0;j<10;j++) ring[j+10]=ring[j];
    ring[j+10]='\0';
    if(strstr(ring,se)) count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 0
#include "stdio.h"

#define ALP_SIZE 26

int main()
{
	int A[ALP_SIZE];
	int i;
	char ch;

	for (i = 0; i < ALP_SIZE; i++) A[i] = 0;

	while ((ch = getchar()) != EOF)
	{
		if (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A) A[(ch & 0x1F) - 1]++;
	}

	for (i = 0; i < ALP_SIZE; i++) printf("%c : %d\n",0x61 + i, A[i]); 

	return 0;
}

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

int main(){
	int n, x, t;
  	cin >> n >> x >> t;
  	
  	int c = (n+x-1) / x;
  	cout << c * t << endl;
}

Measured memory_bytes: 3632
import math

n,h = map(int,input().split())
A = []
B = []
for i in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
x = max(A)
B = sorted(B, reverse=True)

B_lst = []
for i in range(n):
    if B[i] > x:
        B_lst.append(B[i])
        
cnt = 0
damage = 0
ans = None
for i in range(len(B_lst)):
    damage += B_lst[i]
    cnt += 1
    if damage >= h:
        ans = cnt
        break
ans = cnt
if damage < h:
    ans = cnt + math.ceil((h - damage)/x)
print(ans)

Measured memory_bytes: 12156
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

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

    int r = N / 2;
    int l = r - 1;
    if(d[r] == d[l]){
        cout << 0 << endl;
    }
    else{
        cout << d[r] - d[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>

int main()
{
  int m, n;
  std::cin >> n >> m;
  std::cout << (n *  (n-1) + m * (m-1)) / 2;
  return 0;
}


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

int main() {
    int n, m;
    cin>>n>>m;

    vector<int> even, odd;

    for (int i=0; i<m; i++) {
        int x;
        cin>>x;

        if (x%2)        odd.push_back(x);
        else            even.push_back(x);
    }

    if (odd.size() > 2) {
        cout<<"Impossible"<<endl;
    }
    else if (odd.size() == 0) {
        vector<int> ans = even;
        for (int x: ans)   cout<<x<<" ";
        cout<<endl;

        ans[0]--;
        ans.push_back(1);

        cout<<ans.size()<<endl;
        for (int x: ans)   cout<<x<<" ";
        cout<<endl;
    }
    else if (odd.size() == 1) {
        vector<int> ans = even;
        ans.push_back(odd[0]);

        for (int x: ans)   cout<<x<<" ";
        cout<<endl;

        if (ans.size() == 1)    ans.push_back(0);
        ans[0]--;
        ans.back()++;

        if (ans[0] == 0) ans.erase(ans.begin());

        cout<<ans.size()<<endl;
        for (int x: ans)   cout<<x<<" ";
        cout<<endl;
    }
    else {
        vector<int> ans = even;
        ans.insert(ans.begin(), odd[0]);
        ans.push_back(odd[1]);

        for (int x: ans)   cout<<x<<" ";
        cout<<endl;

        ans[0]++;
        ans.back()--;
        if (ans.back() == 0)    ans.pop_back();
        cout<<ans.size()<<endl;
        for (int x: ans)   cout<<x<<" ";
        cout<<endl;

    }
}






Measured memory_bytes: 3588
n,k=map(int,input().split())
r,s,p=map(int,input().split())
T=input()

def R(i):
    if T[i-1]==("s"):
        return r
    else:
        return 0
def S(i):
    if T[i-1]==("p"):
        return s
    else:
        return 0

def P(i):
    if T[i-1]==("r"):
        return p
    else:
        return 0

dp=[[0]*3 for _ in range(n+1)]
dp[0][0],dp[0][1],dp[0][2]=0,0,0
for i in range(1,k+1):
    dp[i][0]=max(dp[i-1][0],dp[i-1][1],dp[i-1][2])+R(i)
    dp[i][1]=max(dp[i-1][0],dp[i-1][1],dp[i-1][2])+S(i)
    dp[i][2]=max(dp[i-1][0],dp[i-1][1],dp[i-1][2])+P(i)
    

for i in range(0,n-k):
    if T[i]!="r":
        dp[i+k+1][2]=max(dp[i+k])+P(i+k+1)
    else:
        if dp[i+1][2]==0:
            dp[i+k+1][2]=max(dp[i+k])+P(i+k+1)
    if T[i]!="s":
        dp[i+k+1][0]=max(dp[i+k])+R(i+k+1)
    else:
        if dp[i+1][0]==0:
            dp[i+k+1][0]=max(dp[i+k])+R(i+k+1)

    if T[i]!="p":
        dp[i+k+1][1]=max(dp[i+k])+S(i+k+1)
    else:
        if dp[i+1][1]==0:
            dp[i+k+1][1]=max(dp[i+k])+S(i+k+1)

    
print(max(dp[n]))


Measured memory_bytes: 22476
n,k = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
ab =zip(a,b)
ab =sorted(ab)
a,b = zip(*ab)
counter = k
for i in range(n):
    counter -=b[i]
    if counter <= 0:
        print(a[i])
        break

Measured memory_bytes: 26868
//Sameer's Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = 0;
    if (n % x == 0)
    {
        ans = (n / x) * t;
    }
    else {
        ans = ((n / x) + 1) * t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
def main(hitpoint,hissatsu_num,hissatsu_attack):
    for damage in hissatsu_attack:
        hitpoint -= int(damage)
    if hitpoint <= 0:
        return "Yes"
    else:
        return "No"
 
if __name__ == "__main__":
    inp1 = input().split()
    hitpoint = int(inp1[0])
    hissatsu_num = int(inp1[1])
    inp2 = input().split()
    inp2.sort(reverse=True)
    print(main( hitpoint , hissatsu_num , inp2))

Measured memory_bytes: 10712
#include <stdio.h>
#include <stdlib.h>

int Parent(int a){
  return a/2;
}

int Left (int a){
  return a*2;
}
int Right (int a){
  return a*2 + 1;
}

int main (){
  int n,i;
  int *A;

  scanf("%d",&n);

  A = malloc(sizeof(int) * (n+1));

  for(i=1;i<=n;++i){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=n;++i){
    printf("node %d: key = %d,",i,A[i]);

    if(Parent(i) != 0)printf(" parent key = %d,",A[Parent(i)]);

    if(Left(i) <= n) printf(" left key = %d,",A[Left(i)]);

    if(Right(i) <= n) printf(" right key = %d,",A[Right(i)]);

    printf(" \n");
  }

  return 0;
}



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

int main(){
	int N, M; cin >> N >> M;
	vector<int> L(M), R(M), table(N+1, 0);

	for(int i = 0; i < M; ++i) cin >> L[i] >> R[i];

	for(int i = 0; i < M; ++i){
		table[(L[i]-1)]++;
		table[(R[i])]--;
	}

	for(int i = 1; i < table.size(); ++i){
		table[i] += table[i-1];
	}

	int cnt = 0;
	for(int i = 0; i < table.size(); ++i){
		if(table[i] == M) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  for(int i = 0;i < N;i++)cin >> A[i];
  double ans = 0;

  for(int i = 0;i < N;i++)ans += 1/A[i];

  printf("%.14lf\n",1/ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define pb push_back
#define F first
#define S second
using namespace std;

int main()
{
	ll n,i,j,k;
	cin >> n;
	vl v(n+1,0);
    for(i=0;i<n;i++)
      cin >> v[i];
  ll mn=10000000000;
    for(i=1;i<=100;i++)
    {ll s=0;
     for(j=0;j<n;j++)
     {
       s+=(v[j]-i)*(v[j]-i);
     }
	mn=min(mn,s);
    }
  cout << mn;
	return 0;
}

Measured memory_bytes: 3600
package main

import (
	"fmt"
	"sort"
)

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

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

	sort.Ints(a)
	fmt.Println(a[n/2] - a[n/2-1])
}


Measured memory_bytes: 5504
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	
		public static void main(String[] args) {
			int a=scan.nextInt()*100+scan.nextInt()*10+scan.nextInt();
			System.out.println(a%4==0?"YES":"NO");
		}
}


Measured memory_bytes: 21844
e = [[int(i) for i in input().split()] for i in range(2)]

r = 0
l = 0

for a in e[1]:
    if e[0][2] > a:
        l += 1
    elif e[0][2] < a:
        r += 1

if l <= r:
    print(l)
else:
    print(r)


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

int main () {
  int N;
  cin >> N;
  bool ans = false;
  for (int i = 0; i <= N/4; i++){
    for (int j = 0; j <= N/7; j++){
     if (i*4 + j*7 == N) {
      ans = true;
      break;
     }
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
PROGRAM sumOfLargeNumbers
      IMPLICIT NONE
      integer(16) :: n,k
      integer(16),allocatable :: up(:)
      integer(16) :: i, ma,mi, ans
      integer(16),parameter :: modulus = 10**9+7
      
      read*,n,k
      
      allocate( up(n+1) )
      do i = 1,n+1
        up(i) = i-1
      end do
      
      
      ans = 0
      
      !first case
      i = k
      ma = sum( up((n+1)-i+1:(n+1)) )
      mi = sum( up(1:i) )
      ans = mod( ans+(ma-mi+1), modulus )
      
      do i = k+1,n+1
        !Max, min
        ma = ma + up( (n+1)-i+1 )
        mi = mi + up( i )
        
        ans = mod(ans+(ma-mi+1),modulus)
      end do
      
      print*,ans
      
      
      END PROGRAM

Measured memory_bytes: 5928
#include<iostream>
#include<string>
#include<list>
#include <stdio.h>

using namespace std;
list<int> lst;

int main()
{
	int dataset; scanf("%d", &dataset);
	for (int i = 0; i < dataset; i++)
	{
		char order[20];
		scanf("%s", order);
		if (order[0] == 'i') {
			int a; scanf("%d", &a);
			lst.push_front(a);
		}
		else if (order[6] == 'F') {
			lst.pop_front();
		}
		else if (order[6] == 'L') {
			lst.pop_back();
		}
		else {
			int order; cin >> order;
			auto itr = lst.begin();
			int size = lst.size();
			for (int i = 0; i < size; i++)
			{
				if (*itr == order) {
					lst.erase(itr);
					break;
				}
				itr++;
			}
		}
	}
	for (
		auto itr = lst.begin(); itr != lst.end(); itr++)
	{
		if (itr != lst.begin()) {
			printf(" ");
		}
		printf("%d", *itr);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 34436
n = int(input())

xyh = [list(map(int, input().split())) for i in range(n)]
if xyh[0][2]:
    x,y,h = xyh[0]
if xyh[1][2]:
    x,y,h = xyh[1]
if xyh[-1][2]:
    x,y,h = xyh[-1]
for i in range(101):
    for j in range(101):
        k = h + abs(i - x) + abs(j - y)
        if all(h == max(k - abs(i - x) - abs(j - y), 0) for x, y, h in xyh):
            print(i, j, k)

Measured memory_bytes: 9120
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	cin >> N;
	ll A[200006] = { 0 };
	vector<int> S;
	rep(i, 0, N) {
		int a;
		cin >> a;
		A[a] ++;
		S.push_back(a);
	}
	ll Sum = 0;
	rep(i, 0, N+1) {
		if (A[i] < 2)
			continue;
		Sum += A[i] * (A[i] - 1) / 2;
	}

	rep(i, 0, N) {
		int x = S[i];
		if (A[x] > 2) {
			cout << Sum - (A[x] - 1);
		}
		else if(A[x]==2){
			cout << Sum - 1;

		}
		else {
			cout << Sum;
		}
		cout << endl;
	}


	return 0;
	
}

Measured memory_bytes: 5108
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]

t=list(range(N+1))
x=list(range(N+1))
y=list(range(N+1))

for i in range(N):
    t[i+1] = l[i][0]
    x[i+1] = l[i][1]
    y[i+1] = l[i][2]

ans = list()

for i in range(N):
    dt = t[i+1] - t[i]
    dp = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dt-dp >= 0 and (dt-dp) % 2 == 0:
        ans.append("y")
    else:
        ans.append("n")
        
if "n" in ans:
    print("No")
else:
    print("Yes")
    
        
    

Measured memory_bytes: 98140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int x;
  cin >> x;
  string ans = "ARC";
  if (x < 1200)
    ans = "ABC";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,a[10101],b[10101],g;
bool p[10101];
vector<int> v,ans;

int gcd(int x, int y){
	return ((y)?(gcd(y,x%y)):(x));
}

bool check(int x){
	int i;
	for(i=0; i<=n; ++i){
		b[i] = a[i];
	}
	for(i=n; i>=x; --i){
		b[i-x+1] += b[i];
		b[i] = 0;
	}
	for(i=0; i<=n; ++i){
		if(b[i]%x){
			return false;
		}
	}
	return true;
}

int main(void){
	int i,j,m;
	fill(p,p+10101,true);
	p[0] = false; p[1] = false;
	cin >> n;
	for(i=0; i<=n; ++i){
		cin >> a[n-i];
		g = gcd(abs(g),abs(a[n-i]));
	}
	for(i=2; i<10101; ++i){
		if(!p[i]){
			continue;
		}
		for(j=i; j<10101; j+=i){
			p[j] = false;
		}
		if(g%i && i<=n){
			v.push_back(i);
		}
	}
	sort(v.begin(),v.end());
	m = v.l_ength();
	for(i=0; i<m; ++i){
		if(check(v[i])){
			ans.push_back(v[i]);
		}
	}
	for(i=2; i*i<=g; ++i){
		if(g%i){
			continue;
		}
		while(!(g%i)){
			g /= i;
		}
		ans.push_back(i);
	}
	if(g>1){
		ans.push_back(g);
	}
	sort(ans.begin(),ans.end());
	m = ans.l_ength();
	for(i=0; i<m; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 384
def getlist():
    return list(map(int, input().split()))

n,m = getlist()

cities = [0 for i in range(n)]
for i in range(m):
    a,b = getlist()
    cities[a-1] += 1
    cities[b-1] += 1

print("\n".join(list(map(str, cities))))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, c; cin >> n >> c;
  V<> v(n), w(n); for (int i = 0; i < n; i++) cin >> v[i] >> w[i];
  V<> dp(c + 1);
  for (int i = 0; i < n; i++) {
    for (int j = c; j >= w[i]; j--) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
  }
  cout << dp[c] << '\n';
}


Measured memory_bytes: 3224
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
  


int main() {
	int S, D, M;
	while (cin >> S >> D >> M) {
		map<pair<int, int>, int>nums;
		vector<vector<pair<int, int>>>sws(S);
		for (int i = 0; i < S; ++i) {
			int k; cin >> k;
			vector<pair<int, int>>sw(k);
			for (int j = 0; j < k; ++j) {
				int w, p; cin >> w >> p;
				sw[j] = make_pair(w, p);
			}
			sws[i] = sw;
		}
		map<int, int>mp;
		for (int i = 0; i < D; ++i) {
			int f; cin >> f;
			mp[f]++;
		}
		for (int i = 0; i < S; ++i) {
			for (int j = 0; j < sws[i].size(); ++j) {
				nums[sws[i][j]] += mp[i];
			}
		}

		vector<vector<int>>memo(nums.size() + 1, vector<int>(M + 1,-1e8));
		memo[0][0] = 0;
		int aa = 0;
		for (auto num:nums) {
			for (int nweight = 0; nweight<= M; ++nweight) {
				for (int i = 0; i <= num.second; ++i) {
					const int nextweight = nweight + num.first.second*i;
					const int nextvalue = memo[aa][nweight] + num.first.first*i;
					if (nextweight <= M) {
						memo[aa + 1][nextweight] = max(memo[aa + 1][nextweight], nextvalue);
					}
					else {
						break;
					}
				}
			}
			
			aa++;
		}

		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i <= M; ++i) {
			if (ans < memo[nums.size()][i]) {
				ans = memo[nums.size()][i];
				ans2 = i;
			}
		}
		cout << ans<<" "<<ans2 << endl;
	}
	return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod){};
    mint operator-() const
    {
        return mint(-x);
    }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (1 & t)
            a *= *this;
        return a;
    }

    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};


int main(){
    int x, y;
    cin >> x >> y;
    if((x+y) % 3 != 0){
        cout << "0" << endl;
        return 0;
    }
    int move = (x + y) / 3;
    int xc = x - move;
    if(xc<0){
        cout << "0" << endl;
        return 0;
    }

    combination c(move);

    cout << c(move, xc).x << endl;

    return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

int main(int argc, const char * argv[]) {
  int x;
  int y;
  scanf("%d", &x);
  scanf("%d", &y);
  cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
import re

S = input()
if S[0] == 'A':
    test = S[2:-1]
    if test.count('C') == 1:
        if len(re.findall('[A-Z]',S)) == 2:
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3188
N,Q=map(int,input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf=UnionFind(N)
for _ in range(Q):
    t,u,v=map(int,input().split())
    if t:print(1*uf.same(u,v))
    else:uf.union(u,v)

Measured memory_bytes: 11584
import sys

def input():
    return sys.stdin.readline()[:-1]

n = int(input())
a_li = list(map(int, input().split()))
a_li.sort(reverse=True)
dd = int((n+1)/2)
if n%2==0:
    print(2*sum(a_li[:dd])-a_li[0])
else:
    print(2*sum(a_li[:dd])-a_li[0]-a_li[dd-1])


Measured memory_bytes: 94152
#include <iostream>
using namespace std;
int main(void)
{
  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  while (1)
  {
    if (a > b)
    {
      int tmp = a;
      a = b;
      b = tmp;
    }
    else if (b > c)
    {
      int tmp = c;
      c = b;
      b = tmp;
    }

    if (a <= b && b <= c)
    {
      break;
    }
  }

  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
	int a[5][4][11]={0},n,b,f,r,v,j,i,k;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);
		a[b][f][r]+=v;
	}
	for(i=1; i<5; i++)
	{
		for(j=1; j<4; j++)
		{
			for(k=1; k<11; k++)
			printf(" %d", a[i][j][k]);
			printf("\n");
		}
		if(i<4)
		printf("####################\n");
	}
	
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;

bool vis[31];
long tmpscore = 0;
long cost[4][31];
long d[31][31];
long c[501][501];
long ans = 1e10;
long N, C;
void dfs(long i, long x){
    vis[x] = true;
    tmpscore += cost[i][x];
    if(i == 3){
        ans = min(ans, tmpscore);
        vis[x] = false;
        tmpscore -= cost[i][x];
        return;
    }
    erep(k, 1, C){
        if(vis[k] == false){
            dfs(i+1, k);
        }
    }
    vis[x] = false;
    tmpscore -= cost[i][x];
}

int main() {
cin >> N >> C;
erep(i, 1, C){
    erep(j, 1, C){
        cin >> d[i][j];
    }
}
erep(i, 1, N){
    erep(j, 1, N){
        cin >> c[i][j];
    }
}
erep(k, 1, C){
    erep(i, 1, N){
        erep(j, 1, N){
            if((i+j)%3 == 2){
                cost[1][k] += d[c[i][j]][k];
            }
            if((i+j)%3 == 0){
                cost[2][k] += d[c[i][j]][k];
            }
            if((i+j)%3 == 1){
                cost[3][k] += d[c[i][j]][k];
            }
        }
    }
}
// erep (i , 1, C ) erep (j , 1, C ) if ( i != j ) erep (k , 1, C ) if ( i != k && j != k ){
//     ans = min(ans, cost[1][i]+cost[2][j]+cost[3][k]);
// }
erep(i, 1, C) dfs(1, i);
show(ans);
  return 0;
 
}



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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    long long ans = 1;

    for (int i = 0; i < N; i++) {
        if (A.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < N; i++) {
        if (A.at(i) < LLONG_MAX / ans && ans * A.at(i) <= 1000000000000000000) {
            ans *= A.at(i);
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

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

box = [0]*n
ans = 0
for i in range(n):
    box[i] = a[i] - (i+1)
box.sort()

idx = n//2

b = box[idx]

for i in range(n):
    ans += abs(a[i]-(i+1+b))
print(ans)

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

typedef struct {
  int l,u,a,p;
} T;

int main(){
  int n;
  T team[1000], tmp;
  int U[1001];

  while( cin>>n && n ){
    for( int i=0;i<n;i++ )
      cin >> team[i].l >> team[i].u >> team[i].a >> team[i].p ;

    bool f;
    do{
      f=false;
      for( int i=1;i<n;i++ ){
	if( team[i-1].a < team[i].a ||
	    ( team[i-1].a==team[i].a && (team[i-1].p>team[i].p || (team[i-1].p==team[i].p && team[i-1].l>team[i].l)))){
	  tmp = team[i-1];
	  team[i-1] = team[i];
	  team[i] = tmp;
	  f=true;
	}	 
      }
    }while( f );

    memset( U,0,sizeof(U) );
    int Nteam=0;
    for( int i=0;i<n && Nteam<26;i++ ){
      if(  (Nteam<10 && U[ team[i].u ]<3 ) ||
	   (Nteam<20 && U[ team[i].u ]<2 ) ||
	   (Nteam<26 && U[ team[i].u ]<1 ) )
	{
	  U[ team[i].u ]++;
	  Nteam++;
	  cout << team[i].l << endl;
	}
    }

    /*
    for( int i=0;i<n;i++ )
      cout << team[i].l << " "<< team[i].u << " "
	   << team[i].a << " "<< team[i].p << endl;
    */
  }

  return 0;
}

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

int main(){
    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;
    vector<int> ans(N);
    rep(i, N){
        rep2(j, i + 1, N){
            ans.at(min(min(abs(j - i), abs(X - i) + 1 + abs(Y - j)), abs(Y - i) + 1 + abs(X - j)))++;
        }
    }
    rep2(i, 1, N){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int f[100010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
   	int n=read(),m=read();
   	for(int i=1;i<=m;i++)f[i]=i;
   	for(int i=1;i<=m;i++)
   	{
   		for(int j=2*i;j<=m;j+=i)f[j]=dec(f[j]-f[i]);
   	}
   	int ans=0;
   	for(int i=1;i<=m;i++)ans=ad(ans+1LL*f[i]*power(m/i,n)%mod);
   	pr2(ans);
    return 0;
}

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

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

    string a, b;
    cin >> a >> b;
    int na, nb;
    cin >> na >> nb;
    string u;
    cin >> u;
    if(u == a) na--;
    else nb--;
    cout << na << " " << nb << endl;


}

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

int main(){
  double W,H;
  double x,y;
  cin >> W >> H >> x >> y;
  if (x==W/2 && y==H/2){
    cout << W*H/2 << " " << 1 << endl;
  }
  else
    cout << W*H/2 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<long long>ans;
void make(int k)
{
    ans.push_back(0);
    for(int i=0;ans.size()<=k;++i){
        for(int j=0;j<=9;++j){
            if(i==0){
                if(j!=0)ans.push_back(j);
            }
            else{
                if(j-ans[i]%10>1)break;
                if(ans[i]%10-j<=1)ans.push_back(ans[i]*10+j);
            }
        }
    }
}
int main(int argc,char ** argv)
{
    int k;
    cin>>k;
    make(k);
    cout<<ans[k]<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    iota(a.begin(), a.end(), 1);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        vector<int> b(k);
        for(int j = 0; j < k; j++){
            cin >> b[j];
        }
        for(int j = 0; j < a.size();){
            if(find(b.begin(), b.end(), a[j]) == b.end())
                a.erase(a.begin()+j);
            else j++;
        }
    }

    cout << a.size() << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n;cin>>n;
    vi a(n+1);
    int cnt=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        if(a[i]%2==1&&i%2==1)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout <<fixed<< setprecision(15);
	int n;
	cin >> n;
	int num[100003];
	int hatena[100003] = { 0 };
	for (int i = 0; i < n; i++) {
		num[i] = INT_MAX;
	}
	int t[100003];
	int a[100003];
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	num[0] = t[0];
	hatena[0] = 1;
	for (int i = 1; i < n; i++) {
		if (t[i] == t[i - 1])num[i] = min(num[i], t[i]);
		else { num[i] = t[i]; hatena[i] = 1; }
	}
	if (num[n - 1] < a[n - 1] || (hatena[n - 1] == 1 && num[n - 1] != a[n - 1])) {
		cout << 0; return 0;
	}
	num[n - 1] = a[n - 1];
	hatena[n - 1] = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] == a[i + 1]) {
			if (hatena[i] == 1 && num[i]>a[i]) {
				cout << 0; return 0;
			}
			else {
				num[i] = min(num[i], a[i]);
			}
		}
		else { 
			if ((hatena[i] == 1 && num[i] != a[i]) || num[i] < a[i]) {
				cout << 0; return 0;
			}
			num[i] = a[i]; hatena[i] = 1; }
	}
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		if (hatena[i] == 0) {
			ans *= num[i];
			ans %= mod;
		}
	}
	cout << ans;
}

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

using namespace std;

int main(){
    long k, n;
    cin >> k >> n;
    vector <long> d(n);
    for (int i = 0; i < n; i++){
        cin >> d[i];
    }
    long ans = INT64_MAX;
    for (int i = 1; i < n-1; i++){
        ans = min(ans, k-max((d[i+1]-d[i]), d[i]-d[i-1]));
    }
    ans = min(ans, min(k-(d[1]-d[0]), -d[0]+d[n-1]));
    ans = min(ans, min(k-d[n-1]+d[n-2], d[n-1]-d[0]));
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
int n;
char a[200200];
int cnt[200200][2]; // count of . and #
int main()
{
	// #. is a bad pattern
	// only possible patterns is ... followed by ###
	scanf("%d%s", &n, &a[1]);
	for (int i = 1; i <= n; i++)
	{
		cnt[i][0] = cnt[i - 1][0] + (a[i] == '.');
		cnt[i][1] = cnt[i - 1][1] + (a[i] == '#');
	}
	int ans = n;
	for (int i = 0; i <= n; i++) // number of .
	{
		int v = cnt[i][1] + (cnt[n][0] - cnt[i][0]);
		if (ans > v) ans = v;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        string s;
        cin>>s;
        if( s[1]=='B' )
            cout<<"ARC";
        else
            cout<<"ABC"<<endl;
    }
    return 0;
}












Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
int main() {
    int N;
    cin >> N;
    vector<i64> B(N - 1);
    for(auto &x : B) cin >> x;
    i64 ans = 0;
    for(int i = 0; i < N; i++) {
        if(i && i < N - 1) {
            ans += min(B[i], B[i - 1]);
        } else if(i == N - 1) {
            ans += B[i - 1];
        } else {
            ans += B[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int m,n,row,col;
    for(;;){
    scanf("%d %d",&m,&n);
    if(m == 0 && n == 0)
        break;
     for(row=1;row<=n;row++)
      {printf("#");}
      printf("\n");
    for(row=1;row<=m-2;row++){
      printf("#");
      for(col=1;col<=n-2;col++){
        printf(".");
       }
    printf("#\n");
    }
      for(row=1;row<=n;row++)
      printf("#");
      printf("\n\n");

    }
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string s,t="keyence";
	cin>>s;
	// ote(s);///
	rp(i,0,7){

		string r="";

		rp(j,0,s.size()){
			if(j<i || s.size()-(7-i)-1<j) r += s[j];
		}
		// ote(r);//

		if(r==t){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = []
nS = 0
for i in range(H):
    A.append(list(input()))
for a in A: nS += a.count('#')

def dfs(i,j):
    if (i,j) == (H-1,W-1): return True
    if i >= H or j >= W or A[i][j] == '.': return
    return dfs(i+1,j) or dfs(i,j+1)

if dfs(0,0) and nS == (H+W-1): print('Possible')
else: print('Impossible')

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

int main() {

  int k = 0;
  int array[5];
  for (int i = 0; i < 5; i++) {
    cin >> array[i];
  }
  cin >> k;
  
  bool flag = false;

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      if (array[j] - array[i] > k) {
        flag = true;
        break;
      }
    }
    if (flag) {
      break;
    }
  }
  
  if (flag) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }

}


Measured memory_bytes: 256