akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> kazu(n);
	int f=0;
	int g=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		if(a==1){
			g=1;
		}
		if(kazu.at(a-1)!=0&&kazu.at(a-1)!=b){
			f=-1;
		}else{
			kazu.at(a-1) = b;
		}
	}
	if(g==0&&n!=1){
		kazu.at(0)=1;
	}
	if(f!=0||(n>1&&kazu.at(0)==0)){
		cout << -1 << endl;
	}else{
		for(int i=0;i<n;i++){
			cout << kazu.at(i);
		}
		cout << endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
int a[100000+500];

int main()
{
    int n,i;
	scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        int ans=0,maxx=0;
       	for(int i=1;i<n;i++){
       		if(a[i]>=a[i+1]){
       			ans++;	
       			maxx=max(ans,maxx);
			}else{
				ans=0;
			}
		}
		cout<<maxx<<endl; 
    return 0;
}

Measured memory_bytes: 640
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  while True:
    x = c[i]
    if x == 0:
      break
    r = r * pow(p, x, M) % M
    p = x; n -= p; i += 1
print((r, 0)[n > 1])


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll x=0;
  rep(i,n){
    if(i%2==0) x+=a[i];
    else x-=a[i];
  }
  cout<<x<<endl;
  rep(i,n-1){
    x=2*a[i]-x;
    cout<<x<<endl;
  }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const double eps = 1e-2;

int main() {
    ll x, k, d; cin >> x >> k >> d;
    double k_ = (double)(k-(double)x/d)/2;
    k_ = ll(k_+eps);
    ll ans = inf_l;
    for (ll i = k_ - 1; i <= k_ + 1; i++) {
        ll y = i;
        if (y < 0) y = 0;
        if (y > k) y = k;
        ans = min(ans,abs(x+y*d-(k-y)*d));
    }
    cout << ans << endl;
}

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

int main() {
  int N;cin>>N;
  vector<pair<int,int>> tasks;
  for(int i=0;i<N;i++){
    int a,b;cin>>a>>b;
    tasks.emplace_back(b,a);
  }
  sort(tasks.begin(),tasks.end());
  int flow=0;
  bool can=true;
  for(auto v :tasks){
    flow += v.second;
    if(flow>v.first){
      can =false;
      break;
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 5344
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())

import heapq
q = []
a = map(int, readline().split())
for i in a:
    heapq.heappush(q, (-i, 1))
for i in range(m):
    b, c = map(int, readline().split())
    heapq.heappush(q, (-c, b))

ans = 0
for i in range(n):
    p = heapq.heappop(q)
    ans += abs(p[0])
    if p[1] > 1:
        heapq.heappush(q, (p[0], p[1] - 1))

print(ans)

Measured memory_bytes: 27912
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>

#define f first
#define s second
#define MAX_N 155
#define INF 1000000000

using namespace std;

typedef long long ll;

typedef pair<int,int> P;

int main(void){

  int n,m,k,a,b;

  while(cin >> n >> m,n|m){
    vector<P>v[MAX_N];
    
    for(int i=1;i<=n;i++){
      cin >> k;
      for(int j=0;j<k;j++){
	cin >> a >> b;
	v[i].push_back(make_pair(a,b));
      }
    }

    int dp[MAX_N][11][80];

    for(int i=0;i<MAX_N;i++)
      for(int j=0;j<11;j++)
	for(int k=0;k<80;k++)
	  dp[i][j][k]=INF;

    for(int i=0;i<11;i++)
      for(int j=0;j<80;j++)
	dp[0][i][j]=dp[1][i][j]=0;

    for(int i=2;i<=n;i++){
      for(int j=0;j<v[i].size();j++){
	for(int l=m;l>=0;l--){
	  for(int k=0;k<v[i-1].size();k++){
	    dp[i][j][l]=min(dp[i][j][l],dp[i-1][k][l]+(v[i][j].s+v[i-1][k].s)*abs(v[i][j].f-v[i-1][k].f));
	  }
	  if(l<m){
	    if(i==2)dp[i][j][l]=0;
	    for(int p=0;p<v[i-2].size();p++)
	      dp[i][j][l]=min(dp[i][j][l],dp[i-2][p][l+1]+(v[i][j].s+v[i-2][p].s)*abs(v[i][j].f-v[i-2][p].f));
	  }
	}
      }
    }
    
    int ans=INF;
    /*
    for(int i=0;i<v[n].size();i++){
      for(int j=0;j<=m;j++){
      ans=min(ans,dp[n][i][j]);
      if(j>0)ans=min(ans,dp[n-1][i][j]);
      }
    }
    */
    for(int i=0;i<v[n].size();i++)ans=min(ans,dp[n][i][0]);
    if(m>=1)for(int i=0;i<v[n-1].size();i++)ans=min(ans,dp[n-1][i][1]);

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

bool acgt(char x) {
  if(x == 'A' or x == 'C' or x == 'G' or x == 'T')
    return true;
  else
    return false;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  
  int a = 0;
  int b = 0;
  
  rep(i, 0, s.size()) {
    if(acgt(s.at(i))) {
      a++;
      b = max(a, b);
    }
    else {
      b = max(a, b);
      a = 0;
    }
  }
 
  cout << b << "\n";

}


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

int main() {
  
  int n;
  cin >> n;
  
  double a,sum = 0, ans;
  
  for ( int i = 0; i < n; i++){
    cin >> a;
    sum += 1 / a;
  }
  
  ans = 1 / sum;
  
  cout << fixed << setprecision(10) << ans << endl;
 
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
f = 0
for i in range(1,N):
  if H[-(i+1)] <= H[-i]:
    continue
  else:
    if H[-(i+1)]-H[-i] == 1:
      H[-(i+1)] -= 1
    else:
      f += 1
      break
if f == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 20688
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
using namespace std;
int n, k;
long long chietre[200005] = {100000007};
long long height[200025] = {0};
void read()
{
 cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        height[i] = x;
    }

    for (int i = 0; i < n + k; i++) {
        chietre[i] = 1000000009;
    }
}
void solve()
{
    chietre[0]= 0;
    for(int i = 0; i < n; i++)
        for(int j = 1; j < k + 1; j++)
        {
            if(i + j + 1 > n)
            {
                continue;
            }
            if(chietre[i+j] > chietre[i] + abs(height[i] - height[i+j]))
                chietre[i + j] = chietre[i] + abs(height[i] - height[i+j]);
            else{
                chietre[i +j] = chietre[i +j];
            }
        }
}
int main()
{
read();
solve();

cout << chietre[n-1];
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for n in range(1, min(K,N)+1):
    m = min(K-n, n)
    for l in range(n+1):
        r = n-l
        A = V[:l] + (V[-r:] if r!=0 else [])
        A.sort()
        an = 0
        for i, a in enumerate(A):
            if i<m and a<0:
                continue
            else:
                an += a
        ans = max(ans, an)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5+7;
ll a[N];
map<ll, ll> c;
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        (a[i] += a[i-1]) %= m;
        c[a[i]]++;
    }
    ll add = 0, ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ans += c[a[i-1]];
        c[a[i]] -= 1;
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int t;
  int a1, a2, a4, a5;
  
  int sum = 0;
  for (int i = A; i < B + 1; i++) {
    t = i;
    int j = 0;
    while(t > 0) {
      if (j + 1 == 1) {
        a1 = t % 10;
      }
      else if (j + 1 == 2) {
        a2 = t % 10;
      }
      else if (j + 1 == 4) {
        a4 = t % 10;
      }
      else if (j + 1 == 5) {
        a5 = t % 10;
      }
      t /= 10;
      //if(j==4)cout << a5 << a4 << "?" << a2 << a1 << endl;
      j++;
    }
    
    if (a1 == a5 && a2 == a4) {
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

using B = vector<string>;

B hoge(string &s){
    int cnt = 0;
    for(char c: s) cnt += (c == '/');
    B ret(cnt+1);
    int i = 0;
    for(char c: s){
        if(c == '/'){
            ++i;
            continue;
        }
        if(c == 'b') ret[i] += "b";
        else{
            rep(_, c-'0') ret[i] += ".";
        }
    }
    return ret;
}

string fuga(B &a){
    string s;
    rep(i, a.size()){
        int l = 0;
        while(l < a[i].size()){
            if(a[i][l] == 'b'){
                s += "b";
                ++l;
                continue;
            }
            int r = l;
            while(r < a[i].size() && a[i][l] == a[i][r]) ++r;
            s += '0' + (r-l);
            l = r;
        }
        if(i < a.size()-1) s += "/";
    }
    return s;
}

int main(){
    string s;
    while(cin >> s && s != "#"){
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        auto tmp = hoge(s);
        tmp[a-1][b-1] = '.';
        tmp[c-1][d-1] = 'b';
        cout << fuga(tmp) << "\n";
    }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18

using namespace std;

void find(int x, int y);


int h, w;
char s[60][60];
int map_[50][50];
int dx[]={0, 1, 0, -1};
int dy[]={-1, 0, 1, 0};
int main(){
	cin >> h >> w;
	for(int i=0; i<h; i++){
	for(int j=0; j<w; j++){
		cin >> s[i][j];
		map_[i][j]=int_inf;
	}}
	map_[0][0]=1;
	find(0, 0);
	int white=0; int cost=map_[h-1][w-1];
	for(int i=0; i<h; i++){
	for(int j=0; j<w; j++){
		if(s[i][j]=='.') white+=1;
	}}
	
	if(cost==int_inf){ cout<<-1<<endl; return 0; }
	else{ cout<<white-cost<<endl; return 0; }
	return 0;
}

void find(int x, int y){
	int nx, ny;
	for(int i=0; i<4; i++){
		nx=x+dx[i]; ny=y+dy[i];
		if(nx>=0 && nx<h && ny>=0  && ny<w){
			if(s[nx][ny]=='.' && map_[nx][ny] > map_[x][y]+1){
				map_[nx][ny] = map_[x][y]+1;
				find(nx, ny);
			}
		}
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

int mod = 1000003;

/////////////         modの計算
long long mod_adjust(long long a) {//	余りをとる(0～mod-1に調整する)
	if (a > mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_adjust(int a) {//	余りをとる(0～mod-1に調整する)
	return (int)mod_adjust((long long)a);
}
int mod_add(int a, int b) {//	足し算
	a = mod_adjust(a), b = mod_adjust(b);
	long long k = a % mod; k += b % mod; k %= mod;
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	long long k = mod_adjust((long long)a); k += mod_adjust((long long)b); k %= mod;
	return (int)k;
}
int mod_multi(int a, int b) {//	掛け算
	long long k = mod_adjust((long long)a); k *= mod_adjust((long long)b); k %= mod;
	return (int)k;
}
int mod_inv(int a) {//	逆元
	a = mod_adjust(a);
	if (a == 1) { return 1; }
	long long p = mod, q = a, m = 0, n = 1, r, c;

	while (q > 1) {
		r = p % q;
		c = p / q;
		c = mod_adjust(m - n * c);
		p = q, m = n, q = r, n = c;
	}
	return n;
}
int mod_div(int a, int b) {//	割り算
	return mod_multi(a, mod_inv(b));
}
int mod_pow(int x, int n) {//	累乗(logNオーダーなので速い)
	if (n < 0) {
		return mod_pow(mod_div(1, x), -n);
	}
	if (n == 0) {
		return 1;
	}
	if (n == 1) {
		return x;
	}
	if (n % 2 == 0) {
		int k = mod_pow(x, n / 2);
		return mod_multi(k, k);
	}
	else {
		int k = mod_pow(x, n / 2);
		return mod_multi(mod_multi(k, k), x);
	}
}

int* factorial = NULL;			//	階乗
int* factorial_inv = NULL;		//	階乗の逆元

//	階乗を事前に計算しておく関数。
//	Nはmod_combination(n, r)で呼び出されうる最大の数。
void calc_factorial(int N) {////////////////////////// 初めに必ず呼び出すこと！！！
	factorial = new int[N + 1];
	factorial_inv = new int[N + 1];

	factorial[0] = 1;
	factorial_inv[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (i >= mod) {
			factorial[i] = 0;
			factorial_inv[i] = 0;
		}
		else {
			factorial[i] = mod_multi(factorial[i - 1], i);
			factorial_inv[i] = mod_inv(factorial[i]);
		}
	}
}
int mod_combination(int n, int r) {//	nCr	を計算する
	if (n < 0 || r < 0 || r > n) { return 0; }
	return mod_multi(factorial[n], mod_multi(factorial_inv[n - r], factorial_inv[r]));
}

int main() {
	calc_factorial(mod);

	int Q; cin >> Q;
	for (int q = 0; q < Q; q++) {
		int x, d, n; cin >> x >> d >> n;

		x = x % mod, d = d % mod;

		if (d == 0) {
			cout << mod_pow(x, n) << endl;
			continue;
		}
		x = mod_div(x, d);
		int a = x - 1, b = x + n - 1;
		if (b >= mod) { cout << 0 << endl; continue; }

		int prod = mod_div(factorial[b], factorial[a]);
		prod = mod_multi(prod, mod_pow(d, n));

		cout << prod << endl;
	}
	return 0;
}

Measured memory_bytes: 10240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k;
		int[] array=new int[m];
		int sum=0;
		for(int i=0;i<n;i++) {
			k=sc.nextInt();
			for(int j=0;j<k;j++) {
				array[sc.nextInt()-1]++;
			}
		}
		for(int i=0;i<m;i++) {
			if(array[i]==n) {
				sum++;
			}
		}

		System.out.println(sum);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 24404
A,B = list(map(int, input().split()))

list_A = []
list_B = []

for i in range(A):
    a = list(map(int, input().split()))
    list_A.append(a)

for i in range(B):
    b = int(input())
    list_B.append(b)

for i in list_A:
    output = []
    for (y,z) in zip(i,list_B):
        op = y*z
        output.append(op)
    sum_op = sum(output)
    print(sum_op)

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

int asc(const void *a, const void *b) {
  return *(long *)b - *(long *)a;
}

int main(){
   int n,i,k;
   long h[100001],m;
    
   scanf("%d%d",&n,&k);
   for (i=0;i<n;i++) scanf("%ld",&h[i]);
   qsort(h,n, sizeof(long),asc);
   k--;
   m=h[0]-h[k];
   for (i=1;i+k<n;i++)
      if (m>h[i]-h[i+k]) m=h[i]-h[i+k];
   printf("%ld\n",m);
   return 0;
}


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 累積和と連想配列
    vector<long long> s(N+1, 0);
    map<long long, long long> nums;
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
    for (int i = 0; i < N+1; ++i) nums[s[i]]++;

    // 集計処理
    long long res = 0;
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,m;
    cin>>n>>m;
    ll p=pow(2,m),x=1900*m+100*(n-m);
    cout<<x*p;
}

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>


using namespace std;

int main(){
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
bool ok[10005];
int d[10005];
int f[10005];
vector<int> e[10005];
int step=0;
void dfs(int i){
	ok[i]=1;
	step++;
	d[i]=step;
	for(int j=0;j<e[i].size();j++)
		if(!ok[e[i][j]])
			dfs(e[i][j]);
	step++;
	f[i]=step;
}
void solve(){
	for(int i=1;i<=n;i++)if(!ok[i])dfs(i);
	for(int i=1;i<=n;i++)
		cout<<i<<' '<<d[i]<<' '<<f[i]<<"\n";
}
int main(){
//	freopen("a.txt","r",stdin);
	cin>>n;
	int u,k,v;
	for(int i=1;i<=n;i++){
		cin>>u>>k;
		for(int j=0;j<k;j++)cin>>v,e[u].push_back(v);
	}
	solve();
	return 0;
}


Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vint ball(n, 1);
    vbool red(n, false);
    red[0] = true;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        ball[x]--;
        ball[y]++;
        if (red[x]) red[y] = true;
        if (ball[x] == 0) red[x] = false;
    }

    int ans = 0;
    rep(i, n) if (red[i]) ans++;

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

Measured memory_bytes: 640
def main():
    N, L = map(int, input().split())
    # 1-indexed
    apples = [L+i-1 for i in range(N+1)]
    taste = 0
    eaten = False
    for a in apples[1:]:
        if (not eaten) and a >= 0:
            eaten = True
            continue
        taste += a
    if not eaten:
        taste -= a
    print(taste)


main()

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, x float64
	fmt.Scanf("%g %g %g", &a, &b, &x)

	var rad float64
	if a*a*b/2 >= x {
		h := x / (b * a / 2)
		rad = math.Atan(b / h)
	} else {
		b = 2 * (b - x/(a*a))
		rad = math.Atan(b / a)
	}

	ans := rad * 180 / math.Pi
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll N=500001;
int n,q,c[N],l[N],r[N],a[N],b[N],ans[N];
vector<pair<int,int> > x[N];

void add(int x,int v){
  for(int i=x;i<=n;i+=i&(-i))
    b[i]+=v;
}

int sum(ll x){
  ll v=0;
  for(int i=x;i>0;i-=i&(-i))v+=b[i];
  return v;
}

int main(){
  ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
  cin>>n>>q;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=q;i++){
    cin>>l[i]>>r[i];
    x[r[i]].emplace_back(l[i],i);
  }
  for(int i=1;i<=n;i++){
    if(a[c[i]])add(a[c[i]],-1);
    a[c[i]]=i;
    add(i,1);
    for(auto [d,e]:x[i])ans[e]=sum(i)-sum(d-1);
  }
  for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 37084
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#include<set>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;

inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();
	}
	return v * c;
}
int main(){
	int a = read(),b = read(),c = read();
	if(a + b + c >= 22) puts("bust");
	else puts("win");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define forn(i,x,y) for(int i=x;i<y;++i)
#define fornr(i,x,y) for(long long i=x;i>=y;--i)
#define testcase int _t; cin >> _t; while(_t--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 2e5;


int main()
{
	ios_base :: sync_with_stdio(false);
  	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	string s,t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int dp[n+1][m+1];
	int ans = 0;
	forn(i,0,n+1)
		dp[i][0] = 0;
	forn(i,0,m+1)
		dp[0][i] = 0;
	int x,y;
	forn(i,1,n+1){
		forn(j,1,m+1){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
			if(dp[i][j] > ans){
				ans = dp[i][j];
				x = i, y = j;
			}
		}
	} 
	string tt = "";
//	cout << x << " " << y << '\n';
	if(!ans){
		cout << "";
	}else{
		while(x != 0 && y != 0){
//			cout << x << " " << y << '\n';
			if(s[x-1] == t[y-1]){
				tt += s[x-1];
				x--; y--;
//				cout << 1 << '\n';
			}else if(dp[x-1][y] > dp[x][y-1]){
				x--;
//				cout << 2 << '\n';
			}else if(dp[x][y-1] >= dp[x-1][y]){
				y--;
//				cout << 3 << '\n';
			}
		}
				
	}
	reverse(all(tt));
	cout << tt;  	      
	
  	return 0;
}

 	/* 















 	*/


Measured memory_bytes: 38808
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;

  std::vector<bool> foods(M, true);

  for (i64 i = 0; i < N; ++i) {
    i64 K_i;
    std::cin >> K_i;
    std::vector<bool> answers(M, false);
    for (i64 j = 0; j < K_i; ++j) {
      i64 A_ij;
      std::cin >> A_ij;
      --A_ij;
      answers[A_ij] = true;
    }
    for (i64 j = 0; j < M; ++j) {
      if (!answers[j]) foods[j] = false;
    }
  }

  std::cout << std::count_if(foods.begin(), foods.end(), [](const bool food) { return food; }) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool equal(char a, char b) {
    if (a=='?' || b=='?') return true;
    return a==b;
}

int main(){
    string s, t;
    cin >> s >> t;
    int ns = s.size();
    int nt = t.size();
    string x = "UNRESTORABLE";
    if (nt>ns) {
        cout << x << endl;
        return 0;
    }
    bool ok = false;
    int l = -1;
    for (int i=ns-nt; i>=0; i--) {
        bool z = true;
        rep(j, nt) {
            if (!equal(t[j], s[i+j])) z = false;
        }
        ok = z;
        if (ok) {
            l = i;
            break;
        }
    }
    if (!ok) {
        cout << x << endl;
        return 0;
    }
    string ans = "";
    rep(i, ns) {
        if (i>=l && i<l+nt) {
            ans += t[i-l];
        }
        else {
            if (s[i]=='?') ans += 'a';
            else ans += s[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int h = sc.nextInt();
            if (h >= K) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 45788
#include <iostream>
using namespace std;
int main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; ++i)
    {
        for (int j = 0; j <= B; ++j)
        {
            for (int k = 0; k <= C; ++k)
            {
                if (500 * i + 100 * j + 50 * k == X) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
g = [input() for _ in range(H)]
ans = 0
for bit in range(2**(H+W)):
    cnt = 0
    for h in range(H):
        if ((bit >> h) & 1):
            continue
        for w in range(W):
            if ((bit >> H + w) & 1):
                continue
            if g[h][w] == '#':
                cnt += 1
    if cnt == K:
        ans += 1
print(ans)


Measured memory_bytes: 8992
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	print $ n - k + 1

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

int main() {
  int a,b;
  cin >> a >> b;
  if ((max(a,b)-min(a,b))%2==0) cout << (max(a,b)-min(a,b))/2+min(a,b) << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

const int MAX_N = 1000007;
const int MOD = 1000000007;
int X, Y;

ll modpow(ll x, int y)
{
	ll res = 1;
	while(y){
		if(y & 1) (res*=x)%=MOD;
		(x *= x) %= MOD;
		y>>=1;
	}
	while(res < 0) res += MOD;
	return res % MOD;
}

ll fact[MAX_N];
ll invf[MAX_N];

int binom(ll n, ll k)
{
    return (((fact[n]*invf[k])%MOD)*invf[n-k])%MOD;
}

void solve()
{
    if((X+Y)%3){
        cout << 0 << '\n';
    }else{
        invf[0]=invf[1]=fact[0]=fact[1]=1;
        for(ll i=2;i<MAX_N;++i){
            fact[i] = (fact[i-1]*i)%MOD;
            invf[i] = modpow(fact[i],MOD-2);
        }
        ll n = (X+Y)/3;
        X -= n, Y -= n;
        if(X<0 || Y<0) cout << 0 << '\n';
        else{
            cout << binom(n,X) << '\n';
        }
    }
}

int main()
{
	cin >> X >> Y;
	solve();
	return 0;
}

Measured memory_bytes: 15872
N, X, Y = map(int, input().split())
l = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        #i j
        ij = j - i
        #i x y j
        ixyj = abs(X - i) + 1+ abs(Y -j)
        #i y x j
        iyxj = abs(Y - i) + 1 + abs(X- j)
        length = min(min(ij,ixyj),iyxj)
        l[length] +=1
for i in range(1,N):
    print(l[i])

Measured memory_bytes: 48732
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,double,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N)P[i]=(P[i]+1)/2;
  Vec(Q,double,N,0);
  Vec(R,double,0,0);
  Q[0]=P[0];
  rep(i,1,N)Q[i]=Q[i-1]+P[i];
  R.pb(Q[K-1]);
  rep(i,K,N)R.pb(Q[i]-Q[i-K]);
  Sort(R);
  HpOut(R[N-K]);
}


Measured memory_bytes: 5492
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    while(cin >> a >> b, a){
        int n;
        cin >> n;
        vector<int> xs{a}, ys{b};
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            ys.emplace_back(y); xs.emplace_back(x);
        }
        array<int, 9> dy{-1, -1, -1, 0, 0, 0, 1, 1, 1}, dx{-1, 0, 1, -1, 0, 1, -1, 0, 1};
        vector<array<int, 9>> dp(xs.size());
        dp[0][4] = 1;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 9; ++j) {
                if(!dp[i][j]) continue;
                int y = ys[i]+dy[j], x = xs[i]+dx[j];
                for (int k = 0; k < 9; ++k) {
                    int yy = ys[i+1]+dy[k], xx = xs[i+1]+dx[k];
                    if(0 <= yy && yy <= 9 && 0 <= xx && xx <= 9
                    && max(abs(x-xx), abs(y-yy)) == 2 && abs(x-xx)+abs(y-yy) != 4){
                        dp[i+1][k] = 1;
                    }
                }
            }
        }
        int ok = 0;
        for (int i = 0; i < 9; ++i) {
            if(dp.back()[i]) ok = 1;
        }
        puts(ok ? "OK" : "NA");
    }
    return 0;
}


Measured memory_bytes: 3040
#include<stdio.h>
    int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a == b)
        printf("a == b\n");
    else if(a > b)
        printf("a > b\n");
    else
        printf("a < b\n");
    return 0;
}

Measured memory_bytes: 580
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std::placeholders;

typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<bool, bool> pbb;
typedef std::pair<ld, ld> pdd;

const int inf = (int)1e9;
const ll linf = (ll) 1e18;
const ld eps = 1e-5;
const int mod = (int) 1e9 + 7;

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp std::make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

int main()
{
	std::ios_base::sync_with_stdio(false);
	int n;
	std::cin >> n;
	std::cout << 48 - n;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

signed main(){
    mdsaqib;
    string s;
    cin >> s;
    int mx=0;
    int r=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            r++;
            mx=max(mx,r);
        }
        else r=0;
    }
    cout << mx;
}

Measured memory_bytes: 3612
use std::io::*;
use std::str::*;
use std::collections::HashSet;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let k: usize = read().unwrap();
    let mut set: HashSet<usize> = HashSet::new();
    for _ in 0..k {
        let d: usize = read().unwrap();
        for _ in 0..d {
            let a: usize = read().unwrap();
            set.insert(a);
        }
    }
    println!("{:?}", n - set.len());
}

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

LL A, B, C, D;
map<LL, LL> memo;

LL llmin(LL A, LL B) {
    if (A < B) return A;
    else return B;
}

LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = llmin(res, llabs(l2-N)*D + A + solve(l2/2));
    res = llmin(res, llabs(r2-N)*D + A + solve(r2/2));

    res = llmin(res, llabs(l3-N)*D + B + solve(l3/3));
    res = llmin(res, llabs(r3-N)*D + B + solve(r3/3));

    res = llmin(res, llabs(l5-N)*D + C + solve(l5/5));
    res = llmin(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
	double a,b,x;
	cin >> a >> b >> x;
	double k = x/(a*a);
	if(k >= b/2){
		k = b-k;
		double ans = atan(a/2.0/k)*180/PI;
		printf("%.10lf",90.0-ans);
	}
	else{
		x /= a;
		double t = sin(PI*90.0/180.0);
		double k = x*2.0/t/b;
		double ans = atan(k/b)*180/PI;
		printf("%.10lf",90.0-ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll n,k,l=200200;cin>>n>>k;
	ll a[n],b[l];rep(i,l) b[i]=0;
	rep(i,n){
		cin>>a[i];
		b[a[i]]++;
	}
	sort(b,b+l);
	ll cnt=0;
	rep(i,l) if(b[i]>0) cnt++;
	//cout<<cnt<<endl;
	ll cnt2=0,ans=0;
	rep(i,l){
		if(b[i]>0) {
			cnt2++;
			//cout<<b[i]<<endl;
		}
		if(cnt-cnt2>=k){
			ans+=(ll)b[i];
			//cout<<b[i]<<endl;
		}
		//else break;
	}
	cout<<ans<<endl;
	}

Measured memory_bytes: 3328
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	string w;
	int count[26] = {};
	bool flag = true;

	cin >> w;

	FOR(i, 0, w.size() - 1) {
		count[w[i] - 'a']++;
	}

	FOR(i, 0, 25) {
		if (count[i] % 2 != 0) {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

const double EPS = 1e-10;

signed main() {
  int n;

  cin >> n;
  while (n--) {
    double x[4], y[4];
    for (int i = 0; i < 4; cin >> x[i] >> y[i], i++);
    double vx1 = x[1] - x[0], vy1 = y[1] - y[0],
           vx2 = x[3] - x[2], vy2 = y[3] - y[2];
    if (fabs(vx1 * vy2 - vy1 * vx2) < EPS) {
      puts("YES");
    } else {
      puts("NO");
    }
  }

  return 0;
}

Measured memory_bytes: 1192
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    import re
    pattern="[A,C,G,T]+"
    cmp=re.compile(pattern)
    S=input()
    res=cmp.findall(S)
    if res:
        print(max(len(s) for s in res))
    else:
        print(0)
resolve()

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


typedef long long ll;
const int INF = 1001001001;



int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	// int t;
	// cin >> t;
	// while (t--) {
	int n, m, x; cin >> n >> m >> x;
	vector<int> c(n);
	int a[12][12];

	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}

	int yen = INF;

	rep(p, 1 << n) {
		int cost = 0;
		vector<int> v(m);
		rep(i, n) {
			if ( p >> i & 1 ) {
				cost += c[i];
				rep(j, m) v[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(i, m) ok &= v[i] >= x;
		if (ok) yen = min(yen, cost);
	}
	if (yen == INF) cout << -1 << endl;
	else cout << yen << endl;
	// 	return 0;
	// }
	return 0;
}

Measured memory_bytes: 3604
#[allow(unused_imports)]
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input!(n: usize, mut s: [String; n]);
    s.sort_unstable();

    let mut sss: Vec<String> = Vec::new();

    for v in s {
        let mut a: Vec<char> = v.chars().collect::<Vec<char>>();
        a.sort_unstable();
        sss.push(a.into_iter().collect());
    }

    sss.sort_unstable();

    let mut count = 0;
    let mut map = HashMap::new();
    for i in 0..sss.len() {
        let buff = map.get(&sss[i]);
        if buff == None {
            map.insert(&sss[i], 1 as usize);
        } else {
            let a = buff.unwrap() + 1;
            map.insert(&sss[i], a);
        }
    }

    for (_k, v) in map {
        count += (v * (v - 1)) / 2;
    }

    println!("{}", count);
}


Measured memory_bytes: 13116
fun main(args: Array<String>) {
    val inputs = readLine()?.split(" ")?.map { it.toInt() } ?: return
    if(inputs.isEmpty()) return
    val width  = inputs[0]
    val height = inputs[1]
    val x      = inputs[2]
    val y      = inputs[3]
    val r      = inputs[4]
    when{
        (x <= 0 && r > 1 || y <= 0 && r > 1) -> println("No")
        ((x - r) + (2 * r) <= width && (y - r) + (2 * r) <= height) -> println("Yes")
        else ->  println("No")
    }
}


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

int main() {
	string a, b;
	cin >> a >> b;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	if(a < b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  LL;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline LL rd() {
	LL x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

/*ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }
*/

/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {
		x = 1; y = 0; return a;
	}
	ans = exgcd(b, a%b, x, y);
	ll t = x; x = y; y = t - a / b * y;
	return ans;
}
*/


int n,m;

 
LL quick_mod(LL a, LL b)
{
    LL ans = 1;
    a %= mod;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % mod;
            b--;
        }
        b >>= 1;
        a = a * a % mod;
    }
    return ans;
}
 
LL C(LL n, LL m)
{
    if(m > n) return 0;
    LL ans = 1;
    for(int i=1; i<=m; i++)
    {
        LL a = (n + i - m) % mod;
        LL b = i % mod;
        ans = ans * (a * quick_mod(b, mod-2) % mod) % mod;
    }
    return ans;
}
 
LL Lucas(LL n, LL m)
{
    if(m == 0) return 1;
    return C(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

int main() {
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m;
    LL ans=1;
    LL bs=min(n,m);
    if(abs(n-m)>1){
    	cout<<0<<endl;return 0;
	}
	if(m==n){
		ans=1;
		for(LL i=1;i<=n;i++)ans=ans*i%mod;
		for(LL i=1;i<=m;i++)ans=ans*i%mod;
		cout<<(2*ans)%mod<<endl;
	}
	else {
		LL maxx=max(m,n);
		LL minn=min(m,n);
		ans=1;
		for(LL i=1;i<=maxx;i++)ans=ans*i%mod;
		for(LL i=1;i<=minn;i++)ans=ans*i%mod;
		cout<<ans%mod<<endl;
	}
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, A, B, C, D;
map<ll, ll> memo;
ll f(ll n) {
	if (memo.count(n)) return memo[n];
	ll r = (double)D * n >= (1LL<<62) ? (1LL<<62) : D*n;
	if (n >= 2) {
		r = min(r, f(n / 2) + A + (n % 2) * D);
		if (n/2+1 < n) r = min(r, f(n/2+1) + A + (2-n%2) * D);
	}
	if (n >= 3) {
		r = min(r, f(n/3) + B + (n%3) * D);
		if (n/3+1 < n) r = min(r, f(n/3+1) + B + (3-n%3) * D);
	}
	if (n >= 5) {
		r = min(r, f(n/5) + C + (n%5) * D);
		if (n/5+1 < n) r = min(r, f(n/5+1) + C + (5-n%5) * D);
	}
	return memo[n] = r;
}
void solve() {
	cin >> N >> A >> B >> C >> D;
	memo.clear();
	cout << f(N) << endl;
}
int main() {
	int T;
	cin >> T;
	for (int tt = 0; tt < T; ++ tt) {
		solve();
	}
}


Measured memory_bytes: 4852
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>
#include <climits>

using lli = long long int;
using namespace std;
int inf = 1000000007;

int N, K;
lli x, y;

int main() {
	cin >> N >> K;
	vector<array<lli, 2>> xy(N);
	for (int i = 0; i < N; i++) {
		cin >> x >> y;
		xy[i] = { x,y };
	}
	lli ans = LLONG_MAX;
	for (int x1 = 0; x1 < N; x1++)
		for (int x2 = 0; x2 < N; x2++)
			for (int y1 = 0; y1 < N; y1++)
				for (int y2 = 0; y2 < N; y2++) {
					//4点選んで内包数カウント
					lli min_x = min(xy[x1][0], xy[x2][0]);
					lli max_x = max(xy[x1][0], xy[x2][0]);
					lli min_y = min(xy[y1][1], xy[y2][1]);
					lli max_y = max(xy[y1][1], xy[y2][1]);
					int val = 0;
					for (int i = 0; i < N; i++) {
						x = xy[i][0];
						y = xy[i][1];
						if (min_x <= x && x <= max_x && min_y <= y && y <= max_y)val++;
					}
					if (val == K) ans = min(ans, (max_x - min_x) * (max_y - min_y));
				}
	cout << ans << endl;
}


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

int main(){
    int T;
    cin >> T;
    while(T--){
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3660