akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  pair<long long,long long>a[n];
  long long x,y;
  long long tempx;
  long long tempy;
  for(long long i=0;i<n;i++){
    cin>>x>>y;
    a[i].first=x;
    a[i].second=y;
  }
  sort(a,a+n);
  long long temp1[n]={0};
  long long temp2[n]={0};
  long long temp3[n]={0};
  long long temp4[n]={0};
  for(long long i=0;i<n;i++){
  temp1[i]=a[i].first+a[i].second;
  temp2[i]=a[i].first-a[i].second;
  temp3[i]=(-1)*a[i].first+a[i].second;
  temp4[i]=(-1)*a[i].first-a[i].second;
  }
  sort(temp1,temp1+n);
  sort(temp2,temp2+n);
  sort(temp3,temp3+n);
  sort(temp4,temp4+n);

  long long ans=0;
  long long temp=temp1[n-1]+temp4[n-1];
  ans=max(ans,temp);
  temp=temp2[n-1]+temp3[n-1];
  ans=max(ans,temp);
  cout<<ans<<endl;
  return 0;
}

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

int sum[1000+1];
int temp[1000+1];
int size;

void update(int score, int weight) {
	for (int i = weight; i <= size; i++) {
		int a = sum[i-weight] + score;
		temp[i] = a > sum[i] ? a : sum[i];
	}
	for (int i = weight; i <= size; i++)
		sum[i] = temp[i];
}

int main() {
	int k = 0, n;
	while (cin >> size, size) {
		k++;
		cin >> n;
		for (int i = 0; i <= size; i++)
			sum[i] = temp[i] = 0;
		
		for (int i = 0; i < n; i++) {
			int a, b; scanf("%d,%d", &a, &b);
			update(a, b);
		}

		int w = size;
		while (w > 0 && sum[w-1] == sum[size]) w--;
		cout << "Case " << k << ":" << endl;
		cout << sum[size] << endl;
		cout << w << endl;
	}
	return 0;
}

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

int64_t mod = 1000000007;

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

	vector<vector<int64_t>> c(2005);
	c.at(0) = {1};
	c.at(1) = {1, 1};
	for (int i = 2; i <= 2004; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0) {
				c.at(i).push_back(1);
			} else if (j != i) {
				int64_t temp = c.at(i - 1).at(j - 1) + c.at(i - 1).at(j);
				temp %= mod;
				c.at(i).push_back(temp);
			} else {
				c.at(i).push_back(1);
			}
		}
	}

	for (int i = 1; i <= k; i++) {
		int64_t ans;
		if (i > n - k + 1) {
			ans = 0;
		} else {
			ans = c.at(n - k + 1).at(i) * c.at(k - 1).at(i - 1);
			ans %= mod;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 20480
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
using namespace std;


int main()
{
	int n, d, c = 0;
	int x[10][10];
	int s[10][10] = {}, r;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 0; i < n-1; i++) {
		for (int k = i; k < n; k++) {
			for (int j = 0; j < d; j++) {
				s[i][k-i] += (x[k][j] - x[i][j]) * (x[k][j] - x[i][j]);
			}
		}
	}
	for (int i = 0; i < n - 1; i++) {
		for (int k = i+1; k < n; k++) {
			r = (int)sqrt(s[i][k - i]);
			if (s[i][k-i] == r * r&&s[i][k-i]!=0)
				c += 1;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

alphe = ['A','B','C','D','E','F','G','H',
         'I','J','K','L','M','N','O','P',
         'Q','R','S','T','U','V','W','X','Y','Z'
         ]
beta = ['A','B','C','D','E','F','G','H',
         'I','J','K','L','M','N','O','P',
         'Q','R','S','T','U','V','W','X','Y','Z',
         'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
         'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
         'Q', 'R', 'S', 'T', 'U','V','W','X', 'Y', 'Z'
         ]

for i in range(len(S)):
    S[i]=beta[alphe.index(S[i])+N]

print(''.join(S))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll k, n;
	cin >> k >> n;
	
	vector<ll> a(n);
	bool zero = false;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	vector<ll> diff(n);
	ll ans = 0;
	for(int i = 0; i < n - 1; ++i) {
		diff[i] = a[i + 1] - a[i];
		ans += a[i + 1] - a[i];
	}
		
	diff[n - 1] = (k + a[0]) - a[n - 1];
	ans += diff[n - 1];
	
	sort(diff.begin(), diff.end(), greater<ll>());
	
	ans -= diff[0];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  int x, y;
  cin >> x >> y;
  for(int i = 0; i <= x; i++) {
    int j = x - i;
    if(y == 2 * i + 4 * j) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long 
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}

ll f(ll b,ll n){
	ll s=0;
	while(n)s+=n%b,n/=b;
	return s;
}
int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>s;
    for(i=2;i<=1e6;++i){
    	if(f(i,n)==s){
    		cout<<i<<"\n";die();
    	}
    }
   	k=n-s;
   	if(k==0){
   		cout<<n+1<<"\n";die();
   	}
   	vii v;
   	for(i=1;i*i<=k;++i){
   		if(k%i==0){
   			v.pb(i);if(k/i!=i)v.pb(k/i);
   		}
   	}
   	ll mn=inf;
   	for(auto x:v){
   		ll b=k/x+1;
   		if(b==1)continue;
   		if(x<b&&s-x<b&&s-x>=0)mn=min(mn,b);
   	}
   	if(mn==inf)mn=-1;
   	cout<<mn<<"\n";



}



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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	while (n--)
	{
		int s, f;
		cin >> s >> f;
		for (int i = s; i < f; i++)
			if (a <= i && i < b)
			{
				cout << 1 << endl;
				return 0;
			}
	}
	cout << 0 << endl;

	return 0;
}



Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << (a != c) << endl;



	return 0;
}

Measured memory_bytes: 256
import Data.List.Split
import Data.Maybe
import Control.Applicative

type Student = (Int, Double, Double)

toStudent :: [String] -> Student
toStudent [] = (0, 0, 0)
toStudent (x:y:z:_) =
  let num = read x :: Int
      weight = read y :: Double
      height = read z :: Double
  in
      (num, weight, height)
toStudent [_] = (0, 0, 0)
toStudent [_, _] = (0, 0, 0)


toStudent' :: [[String]] -> [Student]
toStudent' [] = []
toStudent' xs = map toStudent xs

bmi :: Student -> Maybe Int
bmi (0, 0, 0) = Nothing
bmi (i, w, h) =
  let h2 = h * h
      b = w / h2
  in
      if b >= 25.0
        then Just i
        else Nothing

solver :: [Student] -> [Maybe Int]
solver [] = []
solver xs = map bmi xs


main :: IO()
main = do
  contents <- map (splitOn ",") . lines <$> getContents
  let sList = toStudent' contents
      ans = catMaybes $ solver sList
  mapM_ print ans

Measured memory_bytes: 4124
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n; double x[100000], y[100000];
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        scanf("%lf", &x[i]);
        scanf("%lf", &y[i]);
    }
    
    pair<double, double> p1[100000], p2[100000];
    
    for(int i = 0; i < n; i++)
    {
        p1[i] = make_pair(x[i], y[i]);
    }
    
    for(int i = 0; i < n; i++)
    {
        p2[i] = make_pair(y[i], x[i]);
    }
    
    sort(p1, p1 + n);
    sort(p2, p2 + n);
    
    double sqr_ans = 100000000.0;
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(200, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p1[i + j].first - p1[i].first) * (p1[i + j].first - p1[i].first) + (p1[i + j].second - p1[i].second) * (p1[i + j].second - p1[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(200, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p2[i + 1].first - p2[i].first) * (p2[i + 1].first - p2[i].first) + (p2[i + 1].second - p2[i].second) * (p2[i + 1].second - p2[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    printf("%.15f\n", sqrt(sqr_ans));
    
    return 0;
}

Measured memory_bytes: 7328
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d",&X,&Y,&Z);
  int T;
  T=X;
  X=Y;
  Y=T;
  T=Z;
  Z=X;
  X=T;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 1704
#include<stdio.h>
#define N 100

int main(){
  int i, j, minj, temp, flag = 0, s, t = 0;
  int A[N];

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

  for(i = 0; i < s; i++){
    minj = i;
    for(j = i; j < s; j++){
      if(A[j] < A[minj]){
	minj = j;
	flag = 1;
      }
    }
    temp = A[i];
    A[i] = A[minj];
    A[minj] = temp;
    if(flag == 1){
      t++;
      flag = 0;
    }
  }

  for(i = 0; i < s; i++){
    printf("%d",A[i]);
    if(i != s - 1) printf(" ");
  }
  printf("\n%d\n",t);

  return 0;
}

Measured memory_bytes: 604
N = gets.to_i
count = Array.new(N+1, 0)
#puts count

(1..100).each { |x|
  (1..100).each { |y|
    (1..100).each { |z|
      sum = x*x + y*y + z*z + x*y + y*z + z*x
      break if sum > N
      count[sum] += 1
    }
  }
}

puts count[1,N]


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

int main(){
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
import collections

def is753(s):
    c = collections.Counter(s)
    if c["3"] > 0 and c["5"] > 0 and c["7"] > 0 :
        if c["3"] + c["5"] + c["7"] == len(str(int(s))):
            return True
    return False

def f(s):
    if int(s) > n:
        return 0
    ans=0
    if is753(s):
        ans+=1

    return ans + f(s+"3")+ f(s+"5")+ f(s+"7")

print(f("0"))

Measured memory_bytes: 50024
#include<stdio.h>

int main(){
	int N,sum=0;
	int p,max=0;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d\n",&p);
		sum+=p;
		//printf("%d\n",sum);
		max = max>p ? max:p ;
	}
	printf("%d\n",sum-max/2);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int r,c;
    int a[100][100];
    int x[100]={0};
    int y[100]={0};
    int i,j,z;
    
    scanf("%d %d",&r,&c);
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
        }
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            z+=a[i][j];
        }
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            x[i]+=a[i][j];
        }
    }
    for(j=0;j<c;j++){
        for(i=0;i<r;i++){
            y[j]+=a[i][j];
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d ",a[i][j]);
        }printf("%d\n",x[i]);
    }
    for(j=0;j<c;j++){
        printf("%d ",y[j]);
    }printf("%d\n",z);
    
    return 0;
}

Measured memory_bytes: 636
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u64> = procon_read();
	let n = v[0];
	let s:Vec<char> = n.to_string().chars().collect();
	let mut fx:u64 = 0;
	for i in s {
		fx += ((i as u8) - ('0' as u8)) as u64;
	}
	if n%fx == 0 {
		println!("Yes");
	}else{
		println!("No");
	}
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  Solver(LL n) : n(n){};

  void solve() {
    map<string, LL> S;
    for (int i = 0; i < n; ++i) {
      string tmp;
      cin >> tmp;
      sort(tmp.begin(), tmp.end());
      S[tmp]++;
    }
    LL ans = 0;
    for (auto p : S) {
      ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 11264
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int h[3][22];

bool check(int t,int n){
  if(n >= 10) return true;
  if(h[t][n] >= 3) h[t][n] -= 3;
  if(h[t][n] <= h[t][n+1] && h[t][n] <= h[t][n+2]){
    h[t][n+1] -= h[t][n];
    h[t][n+2] -= h[t][n];
    h[t][n] -= h[t][n];
  }
  if(h[t][n]) return false;
  return check(t,n+1);
}

int main(void){
  int n;
  cin >> n;
  for(int k = 0; k < n; k++){
    memset(h,0,sizeof(h));
    int a[11];
    for(int i = 0; i < 9; i++){
      cin >> a[i];
    }
    for(int i = 0; i < 9; i++){
      char c;
      cin >> c;
      switch(c){
      case 'R': h[0][a[i]]++; break;
      case 'G': h[1][a[i]]++; break;
      case 'B': h[2][a[i]]++; break;
      }
    }
    if(check(0,1) && check(1,1) && check(2,1)) cout << 1 << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		
		//String s=sc.next();
		int n=sc.nextInt();
		int h[]=new int[n];
		int ans=0;
		for (int i = 0; i < n; i++) {
			h[i]=sc.nextInt();
			
			if(i!=0) {
				ans+=h[i]-h[i-1]>0?h[i]-h[i-1]:0;
			}else {
				ans+=h[i];
			}
			
		}
		
		
		System.out.println(ans);
		
		
	}	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


Measured memory_bytes: 21204
#include <stdio.h>

int main(void){
  int n, a, b, h[100000], i, max=0, right, left, mid;
  long long re;
  scanf("%d%d%d", &n, &a, &b);
  for(i=0; i<n; ++i){
    scanf("%d", &h[i]);
    if(h[i] > max) max = h[i];
  }
  right = max / b + 1;
  left = max / a;
  while(right - left > 1){
    mid = (right + left)/2;
    re = 0;
    for(i=0; i<n; ++i){
      if(h[i] > mid*b){
	re += (h[i]-mid*b)%(a-b) ? (h[i]-mid*b)/(a-b)+1:(h[i]-mid*b)/(a-b);
	if(re > mid) break;
      }  
    }
    if(re>mid) left=mid;
    else right=mid;
  }
  printf("%d\n", right);
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

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

Measured memory_bytes: 256
import java.util.Scanner;
    public class Main{
  public static void main(String[] args){
          Scanner scan = new Scanner(System.in);
          int W = scan.nextInt();
          int H = scan.nextInt();
          int x = scan.nextInt();
          int y = scan.nextInt();
          int r = scan.nextInt();
          if(r<=x&&x<=(W-r)&&r<=y&&y<=(H-r)){
            System.out.println("Yes");
          }else{
            System.out.println("No");
          }
          scan.close();
}
}



Measured memory_bytes: 26416
#!/usr/bin/env python3

N, K = map(int, input().split())

P = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        P.append(a)

ans = 0
s_P = list(set(P))
for i in range(1, N+1):
    if i not in s_P: ans+=1
print(ans)



Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < n;i++)
typedef long long int ll;

using namespace std;

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    ll cntmi = 0;
    ll m = 100000000;
    ll sum = 0;
    ll ans = 0;
    rep(i,N){
        cin >> A[i];
        if(A[i] < 0) cntmi++;
        m = min(m,abs(A[i]));
        sum += abs(A[i]);
    }
    if(cntmi % 2 == 0) ans = sum;
    else ans = sum - 2 * m;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=305,mo=1e9+7;
int f[2][N][N];
vector<pii> v[N];
void upd(int &x,int y){
	x+=y;if(x>=mo) x-=mo;
}
int main(){
	int n=read(),m=read();
	For(i,1,m){
		int l=read(),r=read(),x=read();
		v[r].pb(mp(l,x));
	}
	f[0][0][0]=1;
	For(i,0,n){
		int op=i%2;
		for(auto x:v[i]){
			For(j,0,i) For(k,0,j) if(f[op][j][k]){
				int sum=(i>=x.fi)+(j>=x.fi)+(k>=x.fi);
				if(sum!=x.se) f[op][j][k]=0;
			}
		}
		memset(f[!op],0,sizeof(f[!op]));
		For(j,0,i) For(k,0,j) if(f[op][j][k]){
			upd(f[!op][j][k],f[op][j][k]);
			upd(f[!op][i][j],f[op][j][k]);
			upd(f[!op][i][k],f[op][j][k]);
		}
	}
	int ans=0;
	For(i,0,n-1) For(j,0,i){
		upd(ans,f[n&1][i][j]);
	}
	cout<<ans;
}

Measured memory_bytes: 4360
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b, x;
   cin >> a >> b >> x;
   int total = a + b;
   if(a + b >= x && a <= x){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d %d", $N, $A, $B, $C);

$list = [];
for( $i=0; $i<$N; $i++ )
{ $list[] += trim(fgets(STDIN)); }

$INF = 10**9;
echo dfs(0,0,0,0);

function dfs( $cur, $a, $b, $c )
{
  global $N,$A,$B,$C,$list,$INF;
  
  if( $cur == $N )
  {
    if( min( $a, $b, $c ) > 0 )
    { return abs( $A-$a )+abs( $B-$b )+abs( $C-$c )-30; }
    else
    { return $INF; }
  }
  
  $pattern[] = dfs( $cur+1, $a, $b, $c );
  $pattern[] = dfs( $cur+1, $a+$list[$cur], $b, $c ) + 10;
  $pattern[] = dfs( $cur+1, $a, $b+$list[$cur], $c ) + 10;
  $pattern[] = dfs( $cur+1, $a, $b, $c+$list[$cur] ) + 10;

  return min($pattern);
}


Measured memory_bytes: 4604
#include<stdio.h>
int main(void){
	int i, N, d[101] = { 0 }, in, ans = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &in);
		d[in - 1] = 1;
	}
	for (i = 0; i < 100; i++) {
		if (d[i] == 1) ans++;
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(val) cerr << "Value " << #val << " : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ld epsilon = 10e-9;
const ll nax = 0;
ll s, c;
	
int main(void){
	IOS
	cin >> s >> c;
	ll ans;
	if(c>2*s){
		s+=c/2;
		ans=s/2;
	}
	else{
		ans=min(c/2, s);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

bool match(string pat, string s) {
	for (int i = 0; i < pat.size(); i++) {
		if (pat[i] == '*' || pat[i] == s[i]) continue;
		return false;
	}
	return true;
}

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) break;
		map<string, int> win_pat;
		for (int i = 0; i < n; i++) {
			string s; int p;
			cin >> s >> p;
			win_pat[s] = p;
		}

		int prize = 0;
		for (int i = 0; i < m; i++) {
			string s; cin >> s;
			for (map<string, int>::iterator mi = win_pat.begin();
					mi != win_pat.end(); mi++) {
				if (match(mi->first, s)) {
					prize += mi->second;
				}
			}
		}

		cout << prize << endl;
	}
	return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;



int main() {
	

	int k,n,temp,ans;
	cin >> k>>n;

	vector<int> v_A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v_A[i];
	}

	temp = v_A[0] + (k - v_A[n - 1]);
	for (int i = 1; i < n; i++)
	{
		int tempp = v_A[i] - v_A[i - 1];
		if (tempp > temp)
		{
			temp = tempp;
		}

	}

	ans = k - temp;

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 1024
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    n, k = wi()
    d = []
    a = []
    b = []
    cnt = 0
    for i in range(k):
        d = int(input())
        a.append(wi())
    for i in range(k):
        for j in a[i]:
            if j in b:
                continue
            else:
                b.append(j)
                cnt += 1
    print(n-cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68072
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string S, T;
vector<string> words;

string solve(){
    size_t ss = S.size();
    size_t st = T.size();
    
    if(ss<st) return "UNRESTORABLE";
    
    for(int i=0; i<ss-st+1; i++){
        for(int j=i; j<i+st; j++){
            if(S[j]!='?' && S[j]!=T[j-i]) break;
            if(j==i+st-1){
                string s = S.substr(0, i) + T + S.substr(i+st,ss-i-st);
                replace(s.begin(), s.end(), '?', 'a');
                words.push_back(s);
            }
        }
    }
    
    if(!words.size()) return "UNRESTORABLE";
    sort(words.begin(), words.end());
    return words[0];
}

int main() {
    cin >> S >> T;
    
    string ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict
readline = stdin.readline

#readline = open('GRL_5_B-in10.txt').readline

def main():
    n = int(readline())
    g = defaultdict(list)
    for _ in range(n - 1):
        s, t, d = map(int, readline().split())
        g[s].append([d, t])
        g[t].append([d, s])

    dp = defaultdict(dict)
    for i in postorder(g, n):
        for di, ti in g[i]:
            dp[i][ti] = di
            candidate = [v for k, v in dp[ti].items() if k != i]
            if candidate:
                dp[i][ti] += max(candidate)
    height = [None] * n
    for i in preorder(g, n):
        import operator
        candidate = list(dp[i].items())
        candidate.sort(key=operator.itemgetter(1))
        height[i] = candidate[-1][1] if candidate else 0
        for d, t in g[i]:
            dp[t][i] = d
            if 1 < len(candidate):
                k = -1 if candidate[-1][0] != t else -2
                dp[t][i] += candidate[k][1]
    print('\n'.join(map(str, height)))


def postorder(g, n):
    visited = set()
    for i in range(n):
        if i in visited:
            continue
        parent_stack = []
        dfs_stack = [(i, None)]
        while dfs_stack:
            u, prev = dfs_stack.pop()
            visited |= {u}
            dfs_stack.extend((t, u) for d, t in g[u] if t != prev)
            while parent_stack and parent_stack[-1] != prev:
                yield parent_stack.pop()
            parent_stack.append(u)
        while parent_stack:
            yield parent_stack.pop()


def preorder(g, n):
    visited = set()
    for i in range(n):
        if i in visited:
            continue
        dfs_stack = [(i, None)]
        while dfs_stack:
            u, prev = dfs_stack.pop()
            visited |= {u}
            yield(u)
            dfs_stack.extend((t, u) for d, t in g[u] if t != prev)

main()

Measured memory_bytes: 17896
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)

Measured memory_bytes: 9112
// AFTER CONTEST

//
// A* search (TLE on killer_01.txt and killer_02.txt)
//

#include <bits/stdc++.h>

using namespace std;

int main() {
  // Input
  int h, w, k;
  int x1, y1, x2, y2;
  cin >> h >> w >> k;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--; y1--; x2--; y2--;  // Zero-based index

  vector<bool> field(h * w, 0);
  auto __ = [&](int i, int j) { return i * w + j; };
  char c;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> c;
      field[__(i, j)] = c == '.';
    }
  }
  #ifdef DEBUG
    for (auto x : field) {
      printf("%s", x ? "." : "@");
    }
    puts("");
  #endif

  // Admissible heuristics
  auto heuristics = [&](int x, int y) {
    return (abs(x2 - x) + (k - 1)) / k + (abs(y2 - y) + (k - 1)) / k;
  };
  // Consistent heuristics (with floating point)
  // auto heuristics = [&](int x, int y) {
  //   return (abs(x2 - x) + abs(y2 - y)) / (double)k;
  // };

  // Define A* star search queue
  // [ min-heap ]
  // using pq_v_t = tuple<int, int, int>;
  // using pq_c_t = vector<pq_v_t>;
  // priority_queue<pq_v_t, pq_c_t, std::greater<pq_v_t>> pq; // "greater" for min-heap

  // [ Balanced tree for "decrease-key" ]
  set<tuple<int, int, int>> pq;

  // Initialize
  vector<int> distance(h * w, -1);
  distance[__(x1, y1)] = 0;
  // pq.push({heuristics(x1, y1), x1, y1}); // MIN HEAP
  pq.insert({heuristics(x1, y1), x1, y1}); // BALANCED TREE

  // Iterate search
  int result = -1;
  while (!pq.empty()) {
    // auto [score, x, y] = pq.top(); // MIN HEAP
    // pq.pop();                      // MIN HEAP
    auto top = pq.begin();     // BALANCED TREE
    auto [score, x, y] = *top; // BALANCED TREE
    pq.erase(top);             // BALANCED TREE

    #if DEBUG >= 2
      printf("(%d, %d) [%d]\n", x, y, score);
    #endif

    if (x == x2 && y == y2) {
      result = score;
      break;
    }
    auto d = distance[__(x, y)] + 1;
    constexpr tuple<int, int> dirs[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    for (auto [dir_x, dir_y] : dirs) {
      for (int i = 1; i <= k; i++) {
        int xx = x + dir_x * i;
        int yy = y + dir_y * i;
        // Check boundaries
        if (xx < 0 || xx >= h || yy < 0 || yy >= w) {
          break;
        }
        // Check obstacles
        if (!field[__(xx, yy)]) {
          break;
        }
        int d_old = distance[__(xx, yy)];
        if (d_old != -1 && d_old < d) {
          // Cull all the rest if old path is shorter
          break;
        }
        if (d_old != -1 && d_old == d) {
          continue;
        }
        distance[__(xx, yy)] = d;
        #ifdef DEBUG
          printf("(%d, %d) => (%d, %d) [%d]\n", x, y, xx, yy, d);
        #endif

        int heu = heuristics(xx, yy);
        // pq.push({d + heu, xx, yy}); // MIN HEAP
        pq.erase({d_old + heu, xx, yy}); // BALANCED TREE
        pq.insert({d + heu, xx, yy});    // BALANCED TREE
      }
    }
  }

  // Output
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 43160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define v_inputrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    map<char, int> mps, mpt;
    string s,t;
    cin >> s >> t;
    vi S(s.length()), T(t.length());

    //map作成 >　値だけを取り出した配列作成
    for(int i = 0 ; i < s.length() ; i++){
        mps[s[i]]++;
    }
    for(int i = 0 ; i < t.length() ; i++){
        mpt[t[i]]++;
    }

    for(auto itr = mps.begin() ; itr != mps.end() ; itr++){
        S.push_back(itr->second);
    }
    for(auto itr = mpt.begin() ; itr != mpt.end() ; itr++){
        T.push_back(itr->second);
    }
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
  
    bool flag = true;
    if(S.size() != T.size()){flag = false;}
    else{
        for(int i = 0 ; i < S.size() ; i++){
            if(S[i] != T[i]){
                flag = false;
            }
        }
    }
    if(flag){cout << "Yes";}else{cout << "No";}


}

Measured memory_bytes: 3080
class Process(object):
    def __init__(self, name, s):
        self.name = name
        self.s = s

    def exec(self, q):
        if self.s <= q:
            time = self.s
            self.s = 0
            return time
        else:
            time = q
            self.s = self.s - q
            return time

def execute(processes, q):
    time = 0
    completed = []
    while processes:
        p = processes.pop()
        time += p.exec(q)
        if p.s == 0:
            completed.append((p, time))
        else:
            processes.insert(0, p)
    return completed

def run():
    n, q = list(map(int, input().split()))
    processes = []
    for _ in range(n):
        name, time = input().split()
        processes.append(Process(name, int(time)))
    processes.reverse()
    completed = execute(processes, q)
    for c in completed:
        print(c[0].name, c[1])

if __name__ == '__main__':
    run()




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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

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


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string w;
    cin >> w;

    map<char, int> mp;

    rep(i, w.size()){
        mp[w[i]]++;
    }

    for(char c = 'a'; c <= 'z'; c++){
        if(mp[c]%2){
            No();
            return 0;
        }
    }
    Yes();
    return 0;
}


Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            if i == 0 or i == H-1:
                print('#' * W)
            else:
                print('#' + '.' * (W-2) + '#')
    print()


Measured memory_bytes: 5612
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num, gen, tim;
	scanf("%d%d%d", &num, &gen, &tim);
	vector<int>v;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int st = -1, cnt = 0;
	for (int i = 0; i < num; i++)
	{
		if (st == -1)
		{
			st = v[i];
			cnt = 1;
		}
		else
		{
			if (v[i] > st + tim)
			{
				ans++;
				st = v[i];
				cnt = 1;
			}
			else cnt++;
		}
		if (cnt == gen)
		{
			ans++;
			st = -1;
			cnt = 0;
		}
	}
	if (cnt > 0)ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 892
N = int(input())
array = input().split(' ')
harray = []
for z in array:
    z = int(z)
    harray.append(z)
counter = 0
while harray != [0]*N:
    if 0 not in harray:
        a = min(harray)
        for i in range(len(harray)):
            harray[i] -= a
        counter += a
    else:
        zeroarray = [j for j, x in enumerate(harray) if x == 0]
        if len(zeroarray) == 1:
            if zeroarray[0] == 0:
                a = min(harray[1:])
                if len(harray) == 2:
                    harray[1] -= a
                else:
                    for y in range(1,N):
                        harray[y] -= a
                counter += a
            elif zeroarray[0] == N-1:
                a = min(harray[:N-1])
                for y in range(N-1):
                    harray[y] -= a
                counter += a
            else:
                a = min(harray[:zeroarray[0]])
                for y in range(zeroarray[0]):
                    harray[y] -= a
                counter += a
                a = min(harray[zeroarray[0]+1:])
                if zeroarray[0]+1 != N:
                    for y in range(zeroarray[0]+1,N):
                            harray[y] -= a
                else:
                    harray[N-1] -= a
                counter += a
        else:
            if zeroarray[0] != 0:
                    a = min(harray[:zeroarray[0]])
                    for y in range(zeroarray[0]):
                        harray[y] -= a
                    counter += a
            if zeroarray[-1] != N-1:
                    a = min(harray[zeroarray[-1]+1:])
                    if zeroarray[-1]+1 != N:
                        for y in range(zeroarray[-1]+1,N):
                            harray[y] -= a
                    else:
                        harray[N-1] -= a
                    counter += a
            for k in range(len(zeroarray)-1):
                
                if zeroarray[k+1] - zeroarray[k] == 1:
                    continue
                else:
                    a = min(harray[zeroarray[k]+1:zeroarray[k+1]])
                    for y in range(zeroarray[k]+1,zeroarray[k+1]):
                        harray[y] -= a
                    counter += a
                

print(counter)

Measured memory_bytes: 3192
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;




int main(){
    int n;
    LL h;
    cin>>n>>h;
    LL a=-1;
    VEC b(n);

    for(int i=0;i<n;++i){
        LL c;
        cin>>c>>b[i];
        a=max(a,c);
    }

    for(int i=0;i<b.size();++i){
        if(a>b[i]) {
            n--;
        }
    }

    sort(b.begin(),b.end(),greater<LL>());

    LL ans=0;
    
    int i=0;
    while(i<n&&h>0){
        ans++;
        h-=b[i];
        i++;
    }


    if(h>0)ans+=(h+a-1)/a;

    cout<<ans<<endl;


}



Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());

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


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
     int N,count = 0 ;
     cin >> N ;
     for(int i=0;i<N;i++){
          int t ;
          cin >> t ;
          if(t%2!=0){
               count++ ;
          }
     }
     if(count%2==0){
          cout << "YES"<< endl ;
     }else{
          cout << "NO" << endl ;
     }
     
    
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc074/tasks/abc074_b
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  int sum = 0;
  rep(i, N) {
    int x;
    cin >> x;

    sum += min(x, K - x) * 2;
  }

  cout << sum;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = a + b;
        boolean answer = false;
        if (a % 3 == 0) {
            answer = true;
        } else if (b % 3 == 0) {
            answer = true;
        } else if (c % 3 == 0) {
            answer = true;
        }
        System.out.println(answer ? "Possible" : "Impossible");
    }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(){
  int p[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  
  cout<<p[k-1]<<endl;
}

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

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

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

class ATaskSchedulingProblem {
public:
	void solve(std::istream& in, std::ostream& out) {
		int arr[3];
		f(i, 3) in >> arr[i];
		sort(arr, arr + 3);
		int res = arr[2]-arr[0];
		out << res;
	}
};


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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll bit[200010];
ll n;

vector<P> vec;

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		ll a;
		cin >> a;
		vec.push_back(P(a, i));
	}

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

	for (int i = 0; i < vec.size(); i++)
	{
		cout << vec[i].second;
		if (i == vec.size() - 1)
		{
			cout << endl;
		}
		else
		{
			cout << ' ';
		}
	}

	int www;
	cin >> www;
}


Measured memory_bytes: 2544
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool C=false, F=false;
  for(char c:s){
    if(c=='C') C=true;
    if(C && c=='F') F=true;
  }
  if(C&&F) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
using static System.Math;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
 
 
    void solve()
    {
        int N = cin.nextint;
        var Z = cin.nextlong;
        var W = cin.nextlong;
 
        var A = cin.scanlong;
        if (N == 1)
        {
            WriteLine(Abs(W - A[0]));
            return;
        }
 
        var MAX = new long[N];
        var MIN = new long[N];
        MAX[N - 1] = Abs(A[N - 1] - A[N - 2]);
        MIN[N - 1] = Abs(A[N - 1] - A[N - 2]);
 
 
        for (int j = N - 2; j > 0; j--)
        {
            MAX[j] = Abs(A[j - 1] - A[N - 1]);
            MIN[j] = Abs(A[j - 1] - A[N - 1]);
            for (int i = j + 1; i < N; i++)
            {
                MAX[j] = Max(MAX[j], MIN[i]);
                MIN[j] = Min(MIN[j], MAX[i]);
            }
        }
        long ans = Abs(W - A[N - 1]);
        int id = N;
        for (int i = 1; i < N; i++)
        {
            if (ans < MIN[i])
            {
                id = i;
                ans = MIN[i];
            }
        }
        WriteLine(ans);
 
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13304