akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int findSum(int n){
  int sum = 0;
  while (n > 0){
    sum += n%10;
    n/=10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  
  int a = findSum(n);
  if (n%a == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007

// for using in pairs
#define F first
#define S second

// Macros
#define all(x) begin(x), end(x)

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Operator overloads.
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

#define int long long

//////////////////////////////////////////////////////////////////////////////////


void solve(int tc)
{
	int x, k, d;
	cin >> x >> k >> d;

	if (x > 0)
	{
		int t = x / d;
		t = min(k, t);

		x -= t * d;
		k -= t;
	}else
	{
		int t = -x / d;
		t = min(k, t);

		x += t * d;
		k -= t;
	}

	if (!k)
	{
		cout << abs(x);
		return;
	}

	if (k % 2 == 0)
	{
		cout << abs(x);
		return;
	}else
	{
		if (x > 0)
			x -= d;
		else
			x += d;
		cout << abs(x);
		return;
	}

}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3644
S = str(input())

counter = 0

T = len(S)
K = T//5+1

for i in range (0, K+1):
	T = len(S)
	if S[-5::] == 'dream':
		S = S[0:T-5]
	elif S[-5::] == 'erase':
		S = S[0:T-5]
	elif S[-7::] == 'dreamer':
		S = S[0:T-7]
	elif S[-6::] == 'eraser':
		S = S[0:T-6]

if len(S) == 0:
	print('YES')
else:
	print('NO')

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

void bomb(string s[], int a, int b){
	s[a][b] = '0';
	for(int i = 1; i <= 3; i++){
		if(b + i < 8 && s[a][b+i] == '1') bomb(s,a,b+i);
		if(b - i >= 0 && s[a][b-i] == '1') bomb(s,a,b-i);
		if(a + i < 8 && s[a+i][b] == '1') bomb(s,a+i,b);
		if(a - i >= 0 && s[a-i][b] == '1') bomb(s,a-i,b);
	}
}

int main(){
	int n;
	string area[8];
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 8; j++){
			cin >> area[j];
		}
		int a, b;
		cin >> a >> b;
		bomb(area,b-1,a-1);
		cout << "Data " << i << ":" << endl;
		for(int j = 0; j < 8; j++){
			cout << area[j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
from fractions import gcd

A, B, C, D = map(int, input().split(' '))

# 最小公倍数
lcm = (C * D) // gcd(C, D)

count = B
count -= B // C
count -= B // D
count += B // lcm
count -= (A - 1)
count += (A - 1) // C
count += (A - 1) // D
count -= (A - 1) // lcm

print(count)

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

using namespace std;
typedef long long ll;
const int N = 1e9 + 1;
int mod = 1e9 + 7;
#define INF 0x3f3f3f3f
typedef pair<int, int> pii;

int main()
{
#ifndef ONLINE_JUDGE  
   // freopen("in.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif 
   // ios::sync_with_stdio(0);
    int n, t;
    while (~scanf("%d%d", &n, &t))
    {
    	int a, b;
    	int ans = INF;
    	for (int i = 0; i < n; i++)
    	{
    		scanf("%d%d", &a, &b);
    		if (b <= t && a < ans)
    			ans = a;
    	}
    	if (INF == ans)
    		puts("TLE");
    	else
    		printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;
using Float = double;

int main()
{
  string S;
  cin >> S;
  Int Q;
  cin >> Q;

  bool flip = false;
  string prefix_flip, suffix;
  for(int q=1; q<=Q; ++q) {
    Int T;
    cin >> T;
    if (T==1) {
      flip = !flip;
    } else {
      Int F;
      cin >> F;
      char C;
      cin >> C;
      if ((!flip && F==1) || (flip && F==2)) {
        prefix_flip += C;
      } else {
        suffix += C;
      }
    }
  }
  
  if (!flip) {
	reverse(prefix_flip.begin(), prefix_flip.end());
    cout << prefix_flip << S << suffix << endl;
  } else {
    reverse(S.begin(), S.end());
    reverse(suffix.begin(), suffix.end());
    cout << suffix << S << prefix_flip << endl;
  }
  return 0;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

ll n, x, t;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> x >> t;
	ll dif = (n + x - 1) / x;
	cout << dif * t << '\n';
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    set<int> se;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (se.count(A)) {
            se.erase(A);
        } else {
            se.insert(A);
        }
    }
    cout << (int)se.size() << endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  string s=to_string(b);
  if(s.size()==1) a*=10;
  else if(s.size()==2) a*=100;
  else a*=1000;
  int ans=a+b;
  for(int i=1;i<500;i++){
    if(i*i==ans){ cout<<"Yes"; return 0; }
  }
  cout<<"No";


}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

const int N = 1000010;

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

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }

  int ans = 0;
  rep(i, n + 1) ans += h[i] > ma[i];
  cout << ans << endl;
  return 0;
}

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;
ll a;
ll n,X;
ll x[100100];

ll gcd(ll a, ll b){
  return a%b!=0 ? gcd(b, a%b): b;
}

int main() {
  std::cin >> n >> X;
  rep(i,1,n+1){
    std::cin >> x[i];
    x[i] = abs(X - x[i]);
  }
  ll tmp = x[1];
  rep(i,2,n+1){
    tmp = gcd(tmp, x[i]);
  }
  std::cout << tmp << '\n';

}


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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 



int main(){
	int N,x;
	unordered_set<int> S;
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>x;
		if(S.count(x)) S.erase(x);
		else S.insert(x);
	}
	cout<<(int)S.size()<<endl;
	return 0; 
}

Measured memory_bytes: 4388
n = gets.chomp.to_i
a_n = gets.chomp.split.map(&:to_i)

stock = 0
money = 1000

a_n.each.with_index(0) do |a_i, i|
  if i == a_n.length - 1
    money = money + stock * a_i
    stock = 0
    next
  end

  if a_i < a_n[i+1] && money >= a_i
    stock = money / a_i
    money = money - stock * a_i
  elsif a_i > a_n[i+1]
    money = money + stock * a_i
    stock = 0
  end
end

puts money

Measured memory_bytes: 14304
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n,m,q,a[2005][2005],b[2005][2005],c[2005][2005];
string s[2005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>q;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			a[i][j]=a[i][j-1]+s[i-1][j-1]-'0';
		}
		for(int j=1;j<=m;j++){
			a[i][j]+=a[i-1][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=2;j<=m;j++){
			b[i][j]=b[i][j-1]+(s[i-1][j-1]=='1' && s[i-1][j-2]=='1');
		}
		for(int j=2;j<=m;j++){
			b[i][j]+=b[i-1][j];
		}
	}
	for(int j=1;j<=m;j++){
		for(int i=2;i<=n;i++){
			c[i][j]=c[i-1][j]+(s[i-1][j-1]=='1' && s[i-2][j-1]=='1');
		}
		for(int i=2;i<=n;i++){
			c[i][j]+=c[i][j-1];
		}
	}
	while(q--){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		int a1=a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
		int b1=b[x2][y2]-b[x1-1][y2]-b[x2][y1]+b[x1-1][y1];
		int c1=c[x2][y2]-c[x1][y2]-c[x2][y1-1]+c[x1][y1-1];
		cout<<a1-b1-c1<<endl;
	}
	return 0;
}

Measured memory_bytes: 55416
// https://atcoder.jp/contests/abc177/tasks/abc177_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int D, T, S;
    cin >> D >> T >> S;
    if (S * T >= D) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	double s,l,h;
	s=0.5*a*b*sin((double)c*M_PI/180);
	l=a+b+sqrt(a*a+b*b-2*a*b*cos(c*M_PI/180));
	h=2*s/a;
	printf("%f\n%f\n%f\n",s,l,h);
	return 0;
}

Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

const int MAX=1e5+4;
int table[MAX];

int main(){ 
    int n,q;
    ll rta=0,aux1,aux2;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> aux1;
        table[aux1]++;
        rta+=aux1;
    }
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> aux1 >> aux2;
        rta+=(aux2*table[aux1])-(aux1*table[aux1]);
        table[aux2]+=table[aux1];
        table[aux1]=0;
        cout << rta << endl;
    }
}



Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<bool> so(56000,true);
    vector<int> ans;
    for(int i=2;i<56000;i++){
        if(!so[i]) continue;
        int num=i*2;
        while(num<56000){
            so[num]=false;
            num += i;
        }
    }
    for(int i=2;i<55555;i++){
        if(so[i]&&i%5==1){
            ans.push_back(i);
        }
    }
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
vector<int> t;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        t.push_back(temp);
    }
    sort(ALL(t));
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int sum = t[i] + t[j];
            auto iter = lower_bound(ALL(t), sum);
            ans += n - (t.end() - iter) - (j + 1);
        }
    }
    cout << ans << "\n";
}


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


typedef struct tree_t{
	int key;
	struct tree_t *left;
	struct tree_t *right;
}TREE_T;

TREE_T *TREE;


TREE_T *Find(int key)
{
	TREE_T *y = NULL;
	TREE_T *x = TREE;


	while(x != NULL){
		if(key == x->key)
			return x;
		y = x;
		if(key < x->key)
			x = x->left;
		else
			x = x->right;
	}

	return NULL;
}


int Insert(int key)
{
	TREE_T *p;
	TREE_T *y = NULL;
	TREE_T *x = TREE;


	if( (p = (TREE_T *)malloc(sizeof(TREE_T))) == NULL){
		printf("malloc error\n");
		return 0;
	}
	p->key = key;
	p->left = NULL;
	p->right = NULL;

	while(x != NULL){
		y = x;
		if(p->key < x->key)
			x = x->left;
		else
			x = x->right;
	}

	if(y == NULL)
		TREE = p;
	else if(p->key < y->key)
		y->left = p;
	else
		y->right = p;

	return 1;
}


TREE_T *Deletemin(TREE_T **p)
{
	TREE_T *x;

	while((*p)->left != NULL)
		p = &(*p)->left;
	x = *p;
	*p = (*p)->right;

	return x;
}


int Delete(int key)
{
	TREE_T **p, *x;

	p = &TREE;
	while(*p != NULL){
		if(key == (*p)->key){
			x = *p;
			if(x->left == NULL && x->right ==NULL)
				*p = NULL;
			else if(x->left == NULL)
				*p = x->right;
			else if(x->right == NULL)
				*p = x->left;
			else{
				*p = Deletemin(&x->right);
				(*p)->right = x->right;
				(*p)->left = x->left;
			}
			free(x);
			return 1;
		}else if(key < (*p)->key)
			p = &(*p)->left;
		else
			p= &(*p)->right;
	}
	return 0;
}


// kind = 0:通りがけ 1:行きがけ
void Walk_tree(TREE_T *p, int kind)
{
	if(p == NULL)
		return;

	if(kind == 1)
		printf(" %d", p->key);

	Walk_tree(p->left, kind);

	if(kind == 0)
		printf(" %d", p->key);

	Walk_tree(p->right, kind);
}


int main()
{
	TREE_T *p;
	int n;
	char command[10];
	int key;
	int i;

	TREE = NULL;

	scanf("%d", &n);

	for(i = 0; i < n; i++){
		scanf("%s", command);

		if(!strcmp(command, "insert")){
			scanf("%d", &key);
			Insert(key);
		}else if(!strcmp(command, "print")){
			Walk_tree(TREE, 0);
			printf("\n");
			Walk_tree(TREE, 1);
			printf("\n");
		}else if(!strcmp(command, "find")){
			scanf("%d", &key);
			if(Find(key))
				printf("yes\n");
			else
				printf("no\n");
		}else if(!strcmp(command, "delete")){
			scanf("%d", &key);
			Delete(key);
		}
	}


	return 0;
}


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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

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


const int mod = 1e9 + 7;

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, x;
    cin >> n;
    string ans = "APPROVED";
    rep(i, n)
    {
        cin >> x;
        if (x % 2 == 0)
        {
            if (x % 3 != 0 && x % 5 != 0)
            {
                ans = "DENIED";
                break;
            }
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)
# define swap_int(a,b) int t=a;a=b;b=t;

int main()
{
   int n;cin >> n;
   int d[100];

   for(int i=0;i<n;i++) cin >> d[i];

   for(int i=0;i<n;i++){
      for(int j=n-1;j>i;j--){
         if(d[j]>d[j-1]) {
            swap_int(d[j],d[j-1])
         }
      }
   }

   int c=1;
   int m=d[0];
   for(int i=1;i<n;i++){
      if(m>d[i]){
         m=d[i];
         c++;
      }
   }
   p(c)
}

Measured memory_bytes: 256
import collections

n, k = map(int, input().split())
ls = list(map(str, input().split()))

c = collections.Counter(ls)
ls_s = c.most_common()

l = len(ls_s)
ans = 0

if l <= k:
	print(0)
else:
	for i in range(l - k):
		ans += ls_s[-1][1]
		del ls_s[-1]
	print(ans)

Measured memory_bytes: 44056
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
int m,d,ans; 
int main()
{
	scanf("%d %d",&m,&d);
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
			if(i==j%10*(j-j%10)/10&&j%10>1&&(j-j%10)/10>1)
				ans++;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;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 SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	if (n < m)Swap(&n, &m);
	ll ans;
	if (n == 1 && m == 1) {
		ans = 1;
	}
	else if (m == 1) {
		ans = n - 2;
	}
	else {
		ans = (ll)(n - 2)*(m - 2);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
t = input()

for _ in range(len(s)):
    s = s[-1] + s[:len(s)-1]
    if s == t:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 61996
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        n: usize,
        h: [i64; n]
    }
    
    if h.len() == 1 {
        println!("0");
        return;
    }

    let mut it = h.into_iter();
    let first = it.next().unwrap();
    let ans = it.scan((first, 0i64), |state, h|{
        let (prev, cnt) = *state;
        if prev >= h {
            *state = (h, cnt+1);
            Some(cnt+1)
        } else {
            *state = (h, 0);
            Some(0)
        }
    }).max().unwrap();

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


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std ;
typedef long long int ll ; 
int inf = -1e9;
const ll w = 1e9 ;



int main()
{
    /* #ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/
     int n ,t  ;
     cin >> n >> t ;
     //cout<<n<<" "<<t<<endl;
     int ans = 100000;
     for(int i = 1; i <= n ; i++)
     {
       int tt , cc ;
       cin >> cc >> tt ;
       if(tt <= t )ans = min(ans,cc) ;
     }
     
     if(ans == 1e5 )
     {
      cout<<"TLE";
     }
     else cout<<ans;

   }

Measured memory_bytes: 384
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        String s = in.nextToken();
        String t = in.nextToken();
        int start = -1;
        for (int i = 0; i <= s.length() - t.length(); i++) {
            boolean works = true;
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i + j) != t.charAt(j) && s.charAt(i + j) != '?') {
                    works = false;
                }
            }
            if (works) start = i;
        }
        if (start == -1) {
            System.out.println("UNRESTORABLE");
            return;
        }
        StringBuilder r = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            r.append(s.charAt(i));
            if (s.charAt(i) == '?') r.setCharAt(i, 'a');
        }
        for (int i = 0; i < t.length(); i++) {
            r.setCharAt(i + start, t.charAt(i));
        }
        System.out.println(r.toString());
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

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

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

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


Measured memory_bytes: 22484
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    
    int main(){
        int a,b,c;cin>>a>>b>>c;
        set<int>s{a,b,c};
        cout<<(s.size()==2 ? "Yes":"No")<<endl;
    }
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false;

struct edge {
  ll cost;
  ll to;
  ll from;
};

bool operator> (const edge &edge1, const edge &edge2){
    return edge1.cost > edge2.cost;
};

bool operator< (const edge &edge1, const edge &edge2){
    return edge1.cost < edge2.cost;
};

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1) {}

  //functions
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return -d[find(x)];
  }
};

ll kruskal(vector<edge>&edges, UnionFind &uf) {
  sort(edges.begin(), edges.end());

  ll ans = 0;
  for (edge e: edges) {
    if (!uf.same(e.from, e.to)) {
      uf.unite(e.from, e.to);
      ans += e.cost;
    }
  }
  return ans;
}

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

  int n;
  cin >> n;
  vector<pii> towns(n);
  vector<pii> xs(n), ys(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    towns[i] = pii(x, y);
    xs[i] = pii(x, i);
    ys[i] = pii(y, i);
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  vector<edge> edges;
  for (int i = 0; i < n-1; i++) {
    edge e;
    e.cost = xs[i+1].first - xs[i].first;
    e.from = xs[i].second;
    e.to = xs[i+1].second;
    edges.emplace_back(e);
  }
  for (int i = 0; i < n-1; i++) {
    edge e;
    e.cost = ys[i+1].first - ys[i].first;
    e.from = ys[i].second;
    e.to = ys[i+1].second;
    edges.emplace_back(e);
  }

  UnionFind uf(n);
  ll ans = kruskal(edges, uf);

  cout << ans << endl;
}


Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int k;
    bool can = false;
    for(int i = 1; ; i++){
        if(i * (i + 1) / 2 == n){
            can = true;
            k = i + 1;
        }
        if(i * (i + 1) / 2 >= n){
            break;
        }
    }
    if(!can){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << k << endl;
    int ans[k][k - 1];
    int now = 1;
    rep(i,k - 1){
        for(int j = i; j < k - 1; j++){
            ans[i][j] = now;
            now++;
        }
    }
    now = 1;
    rep(j,k - 1){
        for(int i = j + 1; i < k; i++){
            ans[i][j] = now;
            now++;
        }
    }
    rep(i,k){
        cout << k - 1 << " ";
        rep(j,k - 1){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <cstdint>

using Int = std::int64_t;

constexpr Int Mod = 1e9 + 7;

int main() {
	Int n;
	std::cin >> n;

	Int ans = 1;
	Int depth = 0;
	for (int i = 0; i < 2 * n; ++i) {
		char c;
		std::cin >> c;

		const Int cur = (c == 'B');

		if ((depth + cur) % 2 == 1) {
			++depth;
			ans = (ans * depth) % Mod;
		}
		else
			--depth;

		if (depth < 0) {
			ans = 0;
			break;
		}
	}
	if (depth != 0)
		ans = 0;

	for (int i = 2; i <= n; ++i)
		ans = (ans * i) % Mod;

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	int n;
	Integer w[];

	public Main(int n, Integer w[]) {
		this.n = n;
		this.w = w;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		Integer w[] = new Integer[n];
		for (int i = 0; i < n; i++) {
			w[i] = s.nextInt();
		}
		System.out.println(new Main(n, w).calc());
	}

	public int calc() {
		int res = Integer.MAX_VALUE;
		for (int ti = 0; ti < w.length; ti++) {
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i <= ti; i++) {
				s1 += w[i];
			}
			for (int i = w.length - 1; ti < i; i--) {
				s2 += w[i];
			}
			res = Math.min(Math.abs(s1 - s2), res);
		}
		return res;
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
 
int main(void)
{
  int n, m;
  int route[1001], dice[1001];
  int i, j;
  int now;
 
  while (scanf("%d%d", &n, &m), n || m){
    now = 1;
    for (i = 1; i <= n; i++){
      scanf("%d", &route[i]);
    }
    for (i = 1; i <= m; i++){
      scanf("%d", &dice[i]);
    }
 
    for (i = 1; now < n; i++){
      now += dice[i];
      now += route[now];
    }
 
    printf("%d\n", i - 1);
  }
 
  return (0);
}

Measured memory_bytes: 604
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let m: usize = iterator.next().unwrap().parse().unwrap();
    let d: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    for i in 1..=m {
        for j in 1..=d {
            let d10 = j / 10;
            let d1 = j % 10;
            if d10 < 2 || d1 < 2 {
                continue;
            }
            if d1 * d10 == i {
                ans += 1;
            }
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2160
#include <iostream>
#include <iomanip>

#define debug(x) cout << #x << "==" << x << endl;

const int INF = 1e+9 + 7;

using namespace std;

typedef long long ll;

//入力
ll a, b, x;

ll quotient(ll n, ll x){
  if ( n == -1 ) { return 0; }
  else           { return n / x + 1; }

}


int main() {
  ios::sync_with_stdio(false);

  cin >> a >> b >> x;

  cout << quotient(b, x) - quotient(a-1, x) << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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

    for(int i=0; i<3; i++){
        if(N.at(i) == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
#include<queue>
using namespace std;

long long int mod = 1000000007;


int main(void) {

  long long int n;
  cin >> n;
  int ans = 0;
  while( n != 0 ){
    n /= 2;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;

int main()
{
	string X, Y;
	cin >> hex >> X >> Y;

	if (X > Y)
		cout << ">" << endl;
	else if (X < Y)
		cout << "<" << endl;
	else cout << "=" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	string s; cin >> s;
	int n = s.size();
	vector<vector<int>> nxt(n, vector<int>(50));
	for (int i = 0; i < n; i++) {
		nxt[i][0] = s[i] == 'R' ? i + 1 : i - 1;
	}
	for (int t = 1; t < 50; t++) {
		for (int i = 0; i < n; i++) {
			nxt[i][t] = nxt[nxt[i][t - 1]][t - 1];
		}
	}
	vector<int> cnt(n);
	for (int i = 0; i < n; i++) {
		int w = 2e5, cur = i;
		for (int t = 0; t < 20; t++) {
			if ((w >> t) & 1) {
				cur = nxt[cur][t];
			}
		}
		cnt[cur]++;
	}
	for (int i = 0; i < n; i++) cout << cnt[i] << " \n"[i == n - 1];
	return 0;
}



Measured memory_bytes: 23552
##SPEED TEST##

import heapq,sys
input=sys.stdin.readline
INF=float('inf')
heappush=heapq.heappush
heappop=heapq.heappop

n,m=map(int,input().split())
graph=[[] for _ in range(n)]
minway=[]
bridges=[]
ans=0
for _ in range(m):
    a,b,c=map(int,input().split())
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))
    bridges.append((a-1,b-1,c))

def dijkstra(graph,n,start):
    Q=[]
    distance=[]
    dappend=distance.append
    for i in range(n):
        dappend([INF,i])
    distance[start][0]=0
    for j in distance:
        heappush(Q,j)
    while Q!=[]:
        q=heappop(Q)
        for v,vl in graph[q[1]]:
            alt=vl+q[0]
            if alt<distance[v][0]:
                distance[v][0]=alt
                heappush(Q,[alt,v])
    return distance

for k in range(n):
    minway.append(dijkstra(graph,n,k))

for l in bridges:
    x,y,z=l[0],l[1],l[2]
    flag=True
    for p in range(n):
        if minway[x][p][0]+z==minway[y][p][0] or minway[y][p][0]+z==minway[x][p][0]:
            flag=False
            break
    if flag:
        ans+=1

print(ans)

Measured memory_bytes: 4592
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque

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

# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def count2(a):
    count = 0
    while 1:
        if a % 2 == 0:
            count += 1
            a //= 2
        else:
            break
    return count

def main():
    num, m = map(int, input().split())
    data = list(map(int, input().split()))

    min_koubaisuu = data[0]

    for i in range(1, num):
        min_koubaisuu = lcm(min_koubaisuu, data[i])

    baisuu = min_koubaisuu // 2

    ans = ((m // baisuu) + 1) // 2

    count2_num = count2(data[0])
    for i in range(1, num):
        if count2_num != count2(data[i]):
            print(0)
            sys.exit()

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 92776
#include<stdio.h>
#include<string.h>
int main (){
	int n;
	int AC=0;
	int WA =0;
	int TLE=0;
	int RE=0;
	char kata[100];
	
	scanf("%d", &n);
while(n--){

        scanf("%s", &kata);
        if(kata[0]=='A'){
            AC++;
        }else if(kata[0]=='W'){
            WA++;
        }else if(kata[0]=='T'){
            TLE++;
        }else if(kata[0]=='R'){
            RE++;
        }
    }	
//	for(int i=0;i<n;i++){
//		scanf("%s", &kata[i]);
//	for(int i=0;i<n;i++){
//		
//		if(kata[i]=='A'&&kata[i+1]=='C'){
//			AC++;
//			continue;
//		}else if(kata[i]=='W'&&kata[i+1]=='A'){
//			WA++;
//			continue;
//		}else if(kata[i]=='T'&&kata[i+1]=='L'&&kata[i+2]=='E'){
//			TLE++;
//			continue;
//		}else if(kata[i]=='R'&&kata[i+1]=='E'){
//			RE++;
//			continue;
//		}	
// }
//	}
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n" ,TLE);
	printf("RE x %d\n", RE);
	
	
	return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
int ans[7] = {0, 0, 0, 0, 0, 0, 0};
int num[10][7] = {
	{0, 1, 1, 1, 1, 1, 1},
	{0, 0, 0, 0, 1, 1, 0},
	{1, 0, 1, 1, 0, 1, 1},
	{1, 0, 0, 1, 1, 1, 1},
	{1, 1, 0, 0, 1, 1, 0},
	{1, 1, 0, 1, 1, 0, 1},
	{1, 1, 1, 1, 1, 0, 1},
	{0, 1, 0, 0, 1, 1, 1},
	{1, 1, 1, 1, 1, 1, 1},
	{1, 1, 0, 1, 1, 1, 1}
};
int main() {
	int I, N;
	int i, n;
	for(;;) {
		scanf("%d", &N);
		if(N == -1) break;
		for(i = 0; i < 7; ++ i) ans[i] = 0;
		for(I = 0; I < N; ++ I) {
			scanf("%d", &n);
			for(i = 0; i < 7; ++ i) {
				printf("%d", ans[i] ^ num[n][i]);
				ans[i] = num[n][i];
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 604
import math

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

# 全体のGCDを求める
all_gcd = A[0]
for m in A:
    all_gcd = math.gcd(all_gcd, m)

# Aの最大値より大きい数は作れない
# all_gcdの倍数でない数は作れない
if K <= max(A) and K % all_gcd == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 20376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            string[] stra = Console.ReadLine().Split(' ');
            int[] a = new int[n];

            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(stra[i]);
            }

            var group = a
                .GroupBy(x => x)
                .Select(x => new { item = x.Key, count = x.Count() })
                .OrderByDescending(x => x.count)
                .ToList();
            int ans = 0;
            for(int i = 0;i<group.Count()-k;i++)
            {
                ans += group[k + i].count;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 57488
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	int t=0;
	for(int i=1;i<n-1;i++) if(a[i-1]<a[i]^a[i+1]<a[i]) t++;
	cout<<t<<endl;
}

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

/**
 * 解説どおりに作成したソースコード<br/>
 * https://atcoder.jp/contests/abc086/submissions/2279952 にも参照
 */
public class Main {

	/** 白の定数 */
	private static final String WHITE = "W";

	/** 四角の差分を計算用 */
	private static final int[] X_DIFFS = { 0, 0, 1, 1, 1, 1, 2, 2 };
	private static final int[] Y_DIFFS = { 0, 1, 0, 1, 1, 2, 1, 2 };
	private static final int[] COUNT_DIFFS = { 1, -1, -1, 1, 1, -1, -1, 1 };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			int w = 4 * k + 1;
			int k2 = 2 * k;
			int[][] count = new int[w][w];
			IntStream.range(0, n).forEach(i -> {
				int x = scanner.nextInt();
				int y = scanner.nextInt();
				if (WHITE.equals(scanner.next())) {
					y += k;
				}
				x %= 2 * k;
				y %= 2 * k;
				for (int j = 0; j < X_DIFFS.length; j++) {
					count[x + X_DIFFS[j] * k][y + Y_DIFFS[j] * k] += COUNT_DIFFS[j];
				}
			});
			// 横方向への累積和
			IntStream.range(0, w).forEach(i -> IntStream.range(1, w).forEach(j -> count[i][j] += count[i][j - 1]));
			// 縦方向への累積和
			IntStream.range(1, w).forEach(i -> IntStream.range(0, w).forEach(j -> count[i][j] += count[i - 1][j]));
			// 2k x 2k 範囲を超えたcountを2k x 2k範囲に加算
			IntStream.range(1, w).forEach(i -> IntStream.range(0, w).filter(j -> (i >= k2) || (j >= k2))
					.forEach(j -> count[i % k2][j % k2] += count[i][j]));
			// 2k x 2k 範囲の最大値を出力
			System.out.println(IntStream.range(0, k2)
					.map(i -> IntStream.range(0, k2).map(j -> count[i][j]).max().getAsInt()).max().getAsInt());
		}
	}
}


Measured memory_bytes: 166600
// Confessions of a Dangerous Mind

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 2e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 3e-16;

/*
	Keep moving forward. Take the Leap of Faith
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

	string s; cin >> s;
	
	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
    
    return 0;
}

Measured memory_bytes: 3624
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) ll(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 2e5 + 5;

int p[N],pref[N];

signed main(){
    fastio;
    int i,n,k;
    cin>>n>>k;
    for(i=0;i<n;++i){
        cin>>p[i];
        pref[i+1]=pref[i]+p[i];
    }
    double ans=-1;
    for(i=k;i<=n;++i){
    	double res=(pref[i]-pref[i-k]+k)/2.0;
    	ans=max(ans,res);
    }
    cout<<fixed<<setprecision(12)<<ans;
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		
	    StringTokenizer st =
	    		new StringTokenizer(str, " ");
	    
	    String str1 = st.nextToken(); 
	    String str2 = st.nextToken();
	    
	    int num1 = Integer.parseInt(str1);
	    int num2 = Integer.parseInt(str2);
	    
	    if(num1<num2)
	    	System.out.println("a < b");
	    else if(num1>num2)
	    	System.out.println("a > b");
	    else
	    	System.out.println("a == b");    
	    
	    
	}

}

Measured memory_bytes: 24148
#include<iostream>
using namespace std;
int main(void){
    char b;
    cin >> b;
    if(b == 'A'){
        cout << 'T';
    }else if(b == 'C'){
        cout << 'G';
    }else if(b == 'G'){
        cout << 'C';
    }else{
        cout << 'A';
    }
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, A, B = MAP()

print("Alice" if (abs(A-B)-1)%2 else "Borys")

Measured memory_bytes: 5712