akhauriyash/Code-Regression huggingface dataset:
/*
  AOJ 0137
  Title:Middle-Square Method
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
char buf[9];
char buf2[5];
int n,s;

isempty(char *buf,int len)
{
  int i;
  for(i=0;i<len;i++)
    if(isdigit(buf[i]))
      return(0);
  return(-1);
}
main()
{
  int i,j;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      printf("Case %d:\n",i);
      scanf("%d",&s);
      for(j=0;j<10;j++)
	{
	  sprintf(buf,"%8d",s*s);
	  //printf("::%s\n",buf);
	  memset(buf2,5,0);
	  strncpy(buf2,buf+2,4);
	  //printf("*:%s\n",buf2);
	  if(isempty(buf2,5))
	    s=0;
	  else
	    sscanf(buf2,"%d",&s);
	  printf("%d\n",s);
	}
    }
  return(0);
}

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

void main_()
{
    ll H, W;
    cin >> H >> W;
    vector<ll> alnum(26);
    for (ll i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (auto ch : s) {
            alnum[ch - 'a']++;
        }
    }

    auto isOdd = [](ll num) { return num % 2 != 0; };

    ll mult4 = (H / 2) * (W / 2);
    ll mult2 = (isOdd(H) ? W / 2 : 0) + (isOdd(W) ? H / 2 : 0);

    while (mult4--) {
        auto it = find_if(begin(alnum), end(alnum), [](auto n) { return n >= 4; });
        if (it == end(alnum)) {
            cout << "No\n";
            return;
        }
        (*it) -= 4;
    }
    while (mult2--) {
        auto it = find_if(begin(alnum), end(alnum), [](auto n) { return n >= 2; });
        if (it == end(alnum)) {
            cout << "No\n";
            return;
        }
        (*it) -= 2;
    }
    cout << "Yes\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int firstk = min(n, k);
	int remainingnights = n - min(n, k);
	cout << (long long)firstk*x + remainingnights*y;
}


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define debp(a) cerr << #a << " => " <<"("<<a.fs<<", "<<a.sc<<") " << en;
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debpa(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int n; cin >> n;
	vector<int> freq(1e5 + 5);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		freq[x]++;
		sum += x;
	}
	int q; cin >> q;
	while (q--) {
		int b, x;
		cin >> b >> x;
		sum -= b * freq[b];
		sum += x * freq[b];
		int val = freq[b];
		freq[x] += val;
		freq[b] -= val;
		cout << sum << endl;
	}
	return 0;
}


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

int main(){
    int a[5],k;
    for(int i = 0;i < 5;i ++){
        cin >> a[i];
    }
    cin >> k;
    string ans = "Yay!";
    if(a[4]-a[0]>k) ans = ":(";
    cout << ans << endl;
    return 0;
}

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

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

	string s;

	cin >> s;// >> ;
	
	string ans="Sunny";
	
	if(s[0]=='S') ans="Cloudy";
	else if(s[0]=='C') ans="Rainy";

	cout << ans << "\n";

    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long

using namespace std;

inline long long read(){
   long long w=1,s=0;
   char ch=getchar();
   while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();} 
   while(ch>='0'&&ch<='9')  s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int a[1000000];

int main(){
    int n=read(),m=read();
    for(int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if (m<a[i]) {
            cout<<i-1;
            return 0;
        }
        m-=a[i];
    }
    cout<<n-(m!=0);
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d){
        cout << "Yes" << endl;
    }else if(abs(a-b)<=d&&abs(b-c)<=d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  //input
  int N, M;
  cin >> N >> M;
  //calc
  string answer = N == M ? "Yes" : "No";
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int n,tcnt=0,hcnt=0;
    cin>>n;
    for(int i=0;i<n;++i){
        string tar,han;
        cin>>tar>>han;
        for(int j=0;j<100;++j){
            if(tar[j]>han[j]){
                tcnt+=3;
                break;
            }
            else if(tar[j]<han[j]){
                hcnt+=3;
                break;
            }
            else{
                if(min(tar.size(),han.size())==j+1){
                    if(tar.size()>han.size()){
                        tcnt+=3;
                    }
                    else if(tar.size()<han.size()){
                        hcnt+=3;
                    }
                    else{
                        ++hcnt;
                        ++tcnt;
                    }
                    break;
                }
            }
        }
    }
    cout<<tcnt<<" "<<hcnt<<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

Vs vs = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

void solve() {
    string t; cin >> t;
    rep(i, 0, 7) if(t == vs[i]) cout << 7-i << endl;

    return;
}

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

    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

#define mk make_pair
#define pb push_back
#define sc(t) scanf("%d",&t)
#define sc3(t,u,v) scanf("%d %d %d",&t,&u,&v)
#define sc2(t,u) scanf("%d %d",&t,&u)
#define scL(t) scanf("%lld",&t)
#define scL3(t,u,v) scanf("%lld %lld %lld",&t,&u,&v)
#define scL2(t,u) scanf("%lld %lld",&t,&u)
#define mem(a,i) memset(a,i,sizeof a)
#define pcase(x,y) printf("Case %d: %d\n",x,y)
#define pcase2(x) printf("Case #%d:\n",x)
#define inf 1e18
#define sett(n) (mark[n>>5] |= (1<<(n&31)))
#define check(n) (mark[n>>5]&(1<<(n&31)))
#define endd printf("\n")

int main()
{
    int n=0,k,u,v,w,cas=1;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+') n++;
        else n--;
    }
    cout << n << endl;
    return 0;
}


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

using namespace std;

int main()
{
   // cout<<"Hello World";
   string s,t ;
   cin >> s >> t ;
   int ans = 0 ;
   for(int i=0;i<3;i++)
    if( s[i] == t[i] ) ans++ ;
    cout << ans ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm>

using namespace std;

struct pai{
	int p;
	int q;
};


int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		int x, y, s;
		cin >> x >> y >> s;
		if( x == 0 && y == 0 && s == 0 ) break;

		vector<pai> pairs;
		for(int i = 1; i < s; i++) {
			for(int j = 1; j < s; j++) {
				if( (int)( (double)( i * ( 100.0 + x )) / 100.0 ) + (int)( (double)( j * ( 100.0 + x )) / 100.0 ) == s ) {
					pai np;
					np.p = i;
					np.q = j;
					pairs.push_back(np);
				}
			}
		}
		vector<int> v;
		for(int i = 0; i < pairs.size(); i++)
			v.push_back(  (int)((double)( pairs.at(i).p * ( 100.0 + y )) / 100.0 )+ (int)((double)( pairs.at(i).q * ( 100.0 + y )) / 100.0 ) );

		int max = 0;
		for(int i = 0; i < v.size(); i++)
			if( v.at(i) > max ) max = v.at( i );

		cout << max << endl;

	}

	//while(1){}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define MP(a, b) make_pair(a, b)

const int MAX_VALUE = 1e9+1;
const int MIN_VALUE = 0;

int N;
vii balls;

ll min (ll a, ll b) {
  if (a > b) return b;
  return a;
}

ll max (ll a, ll b) {
  if (a < b) return b;
  return a;
}

int main() {

  cin >> N;
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    balls.push_back(MP(min(x, y), max(x, y)));
  }
  sort(balls.begin(), balls.end());

  ////////////////////////////
  // Rmax = MAX, Bmin = MIN //
  ////////////////////////////
  int Rmin, Rmax, Bmin, Bmax;
  Rmin = Bmin = MAX_VALUE;
  Rmax = Bmax = MIN_VALUE;

  REP (i, N) {
    Rmin = min(Rmin, balls[i].second);
    Bmin = min(Bmin, balls[i].first);
    Rmax = max(Rmax, balls[i].second);
    Bmax = max(Bmax, balls[i].first);
  }
  ll ans = 1l * (Rmax - Rmin) * (Bmax - Bmin);

  ////////////////////////////
  // Rmax = MAX, Rmin = MIN //
  ////////////////////////////
  ll Rdiff = Rmax - Bmin;
  int minF, minS, maxF, maxS;
  minF = balls[1].first;
  maxF = balls[N-1].first;
  minS = maxS = balls[0].second;

  REP (i, N-1) {
    minF = balls[i+1].first;
    minS = min(minS, balls[i].second);
    maxS = max(maxS, balls[i].second);
    int temp = max(maxF, maxS) - min(minF, minS);
    ans = min(ans, Rdiff * temp);
  }

  cout << ans << endl;

}

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execMain();
	}

	protected void execMain() {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		// 希望を受け付ける
		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt() % (2 * K);
			y[i] = scan.nextInt() % (2 * K);
			// 色を統一する
			if (scan.next().equals("W")) {
				y[i] += K;
				y[i] %= (2 * K);
			}
			int[] p = pos(x[i], y[i], K);
			x[i] = p[0];
			y[i] = p[1];
		}

//		int[][] count = new int[2 * K][3 * K];		// xはposメソッドでＫ以内のため、2倍で良い。
		int[][] count = new int[3 * K][3 * K];	// xはposメソッドで２Ｋ以内のため、３倍必要
		// 希望の座標をカウントアップ、右と上にＫ移動した座標もカウントアップ。右のみ上のみはカウントダウン。
		for (int i = 0; i < N; i++) {
			++count[x[i]] [y[i]];
			--count[x[i]] [y[i] + K];
			--count[x[i] + K] [y[i]];
			++count[x[i] + K] [y[i] + K];
		}
		// 二次元累積和を求める
		// ①横方向に累積
		for (int i = 0; i < count.length; ++i) {
			for (int j = 1; j < count[i].length; ++j) {		// 横
				count[j][i] += count[j - 1][i];
			}
		}

		// ②①の結果に対して縦方向に累積
		for (int i = 0; i < count[0].length; ++i) {
			for (int j = 1; j < count.length; ++j) {		// 縦
				count[i][j] += count[i][j - 1];
			}
		}

		// はみ出た部分を範囲内の配列に設定する
		for (int i = 0; i < count.length; ++i) {
			for (int j = 0; j < count[i].length; ++j) {
				if (j < 2 * K && i < K)
					continue;
				int[] pos = pos(j, i, K);
				count[pos[1]][pos[0]] += count[i][j];
			}
		}

		int ans = 0;
		for (int i = 0; i < K; ++i) {		// xのＫ以上を見ても同じ数値なため不要なループとなる
			for (int j = 0; j < 2 * K; ++j) {
				ans = Math.max(ans, count[i][j]);
			}
		}
		System.out.println(ans);
	}


	protected int[] pos(int x, int y, int K) {
		x %= (2 * K);
		y %= (2 * K);
		// 右上に移動しても同じ色
		if (y >= K) {
			x += K;
			y += K;
			x %= (2 * K);
			y %= (2 * K);
		}

		int[] p = {x, y};
		return p;
	}

}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, h, w; cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
struct dice dice2;
void init1(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void init2(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=n[i];
    }
}
void throwdice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int compare(){
    int i;
    for(i=0;i<6;i++){
        if(dice1.d[i]!=dice2.d[i]){
            return 0;
        }
    }
    return 1;
}
int main()
{
    int n[6];
    int i,j;
    int ok=0;
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init1(n);
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init2(n);
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            throwdice('N');
            throwdice('E');
            throwdice('S');
            if(compare()) ok=1;
        }
        throwdice('N');    
    }
    throwdice('E');
    for(i=0;i<2;i++){
        for(j=0;j<4;j++){
            throwdice('N');
            throwdice('E');
            throwdice('S');
            if(compare()) ok=1;
        }
        throwdice('W');    
        throwdice('W');    
    }
    if(ok) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>

int main()
{
	std::string sentence;
	std::getline(std::cin, sentence);
	for (std::string::iterator it = sentence.begin(); it != sentence.end(); it++) {
		if (*it >= 'A' && *it <= 'Z') 
			*it += ('a' - 'A');
		else if(*it >= 'a' && *it <= 'z')
			*it -= ('a' - 'A');
	}
	std::cout << sentence << "\n";
    return 0;
}





Measured memory_bytes: 3204
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	vi W, K;

	int tmp;
	REP(i, 10) {
		cin >> tmp;
		W.push_back(tmp);
	}
	REP(i, 10) {
		cin >> tmp;
		K.push_back(tmp);
	}

	sort(RALL(W));
	sort(RALL(K));

	int sW = 0, sK = 0;
	REP(i, 3) {
		sW += W[i];
		sK += K[i];
	}

	cout << sW << " " << sK << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int bit = 1 << n;
  bit <<= n;
  int l[n];
  for(int i=0; i<n; i++){
    cin >> l[i];
  }
  int ans = 1000000009;
  for(int i=1; i<bit; i++){
    int ta=0, tb=0, tc=0;
    int tmp = i;
    int cnt = 0;
    for(int j=0; j<n; j++){
      int k = tmp % 4;
      tmp >>= 2;
      if(k==0) continue;
      if(k==1){
        if(ta!=0) cnt++;
        ta += l[j];
      }
      if(k==2){
        if(tb!=0) cnt++;
        tb += l[j];
      }
      if(k==3){
        if(tc!=0) cnt++;
        tc += l[j];
      }
    }
    if(ta==0||tb==0||tc==0) continue;
    cnt *= 10;
    cnt += abs(ta-a) + abs(tb-b) + abs(tc-c);
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
class MaxHeap
  def initialize
    @heap = [nil]
    @size = 0
  end

  def insert(value)
    @heap << value
    @size += 1
    up_heap(@size / 2)
  end

  def up_heap(i)
    return if i.zero?
    l, r = i * 2, i * 2 + 1
    largest = (l <= @size && @heap[l] > @heap[i]) ? l : i
    largest = r if r <= @size && @heap[r] > @heap[largest]
    unless largest == i
      @heap[i], @heap[largest] = @heap[largest], @heap[i]
      up_heap(i / 2)
    end
  end

  def remove_root
    return nil if @size.zero?
    a = @heap[1]
    b = @heap.pop
    @size -= 1
    return b if @size.zero?
    @heap[1] = b
    down_heap(1)
    a
  end

  def down_heap(i)
    return if i > @size
    l, r = i * 2, i * 2 + 1
    largest = (l <= @size && @heap[l] > @heap[i]) ? l : i
    largest = r if r <= @size && @heap[r] > @heap[largest]
    unless largest == i
      @heap[i], @heap[largest] = @heap[largest], @heap[i]
      down_heap(largest)
    end
  end
end


k, t = gets.split.map(&:to_i)
cakes = gets.split.map(&:to_i)

mh = MaxHeap.new
cakes.each {|c| mh.insert(c)}

a = mh.remove_root
loop do
  a -= 1
  b = mh.remove_root
  break unless b
  mh.insert(a) if a.nonzero?
  a = b
end

puts a

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; FOR(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;
 
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    FOR(i, 0, n) if (!(a[i]&1) && a[i]%3 && a[i]%5) {
        cout << "DENIED";
        exit(0);
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100001];
int main()
{
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++)
    {
        ll d;
        cin >> d;
        for (int j = 1; j <= d; j++)
        {
            ll tmp;
            cin >> tmp;
            a[tmp]++;
        }
    }
    ll s = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] == 0)
            s++;
    }
    cout << s;
}

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int idx(PII p){
  return p.first*10+p.second+11;
}

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

  int N; cin >> N;
  REP(n,N){
	VI xs(32);
	REP(i,4){
	  REP(j,7) cin >> xs[i*8+j+1];
	  xs[i*8] = 0;
	}

	REP(i,32)
	  if(xs[i]%10 == 1){
		swap(xs[i], xs[(xs[i]/10-1)*8]);
	  }

	map<VI,int> memo;
	queue<VI> q;
	q.push(xs);
	memo[xs] = 0;

	int ans = -1;
	while(!q.empty()){
	  xs = q.front(); q.pop();
	  bool ok = true;
	  REP(y,4) REP(x,7)
		if(xs[y*8+x] != y*10+x+11){
		  ok = false;
		  x = y = 100;
		}
	  if(ok){
		ans = memo[xs];
		break;
	  }

	  int d = memo[xs];
	  REP(y,4) FOR(x,1,8){
		int idx = y*8+x;
		if(xs[idx] == 0 && xs[idx-1]%10 < 7){
		  REP(ty,4) FOR(tx,1,8){
			int tidx = ty*8+tx;
			if(xs[idx-1]+1 == xs[tidx]){
			  VI tmp = xs;
			  swap(tmp[idx], tmp[tidx]);

			  if(!memo.count(tmp)){
				q.emplace(tmp);
				memo[tmp] = d + 1;
			  }
			  ty = tx = 100;
			}
		  }
		}
	  }
	}
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 15984
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();

    int max = Math.max(A, B);
    int min = Math.min(A, B);
    
    long ans = max;
    while (ans % min != 0) ans += max;
    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define deb(x) cout << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define debv(x) cout<<#x<<": " ;tr(it,x) cout<<*it<<" "
#define inputv(v) for(auto& x : v) cin >> x
#define output(x) cout<<x<<endl
#define vll vector<ll>
#define fast ios_base :: sync_with_stdio(false); cin.tie(0)
#define sublime freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
const ll MOD = 1e9 + 7;
    
void test_case(){
	ll n;
	cin >> n;

	cout << !n ;
	
}


int main() {
    fast;
    // sublime;
    ll T = 1; 
    // cin >> T;
    while(T--)
        test_case(); 

}



Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        List<Key> list = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int keys = 0;
            for (int j = 0; j < b; j++) {
                keys |= pow(scan.nextInt() - 1);
            }
            Key key = new Key(i, a, b, keys);
            list.add(key);
        }
        list.sort(new KeyComparator());
        int max = pow(N)-1+1;
        int[] dp = new int[max];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < M; i++) {
            Key key = list.get(i);
            if (i == 0) {
                dp[key.keys] = key.cost;
                continue;
            }
            int[] next_dp = new int[max];
            Arrays.fill(next_dp, Integer.MAX_VALUE);
            next_dp[0] = 0;
            for (int j = 0; j < max; j++) {
                next_dp[j] = Math.min(next_dp[j], dp[j]);
                if (dp[j] == Integer.MAX_VALUE) {
                    continue;
                }
                next_dp[j | key.keys] = Math.min(next_dp[j | key.keys], dp[j] + key.cost);
            }
            dp = next_dp;
        }
        if (dp[max-1] == Integer.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(dp[max-1]);
        }
    }
    private int pow(int N) {
        if (N == 0) {
            return 1;
        }
        if (N % 2 == 1) {
            return 2 * pow(N - 1);
        }
        int half = pow(N / 2);
        return half * half;
    }
    class Key {
        int id;
        int cost;
        int keys;
        Key(int id, int cost, int total, int keys) {
            this.id = id;
            this.cost = cost;
            this.keys = keys;
        }
    }
    class KeyComparator implements Comparator<Key> {
        @Override
        public int compare(Key o1, Key o2) {
            if (o1.cost != o2.cost) {
                return Integer.compare(o1.cost, o2.cost);
            }
            return Integer.compare(o1.id, o2.id);
        }
    }
}


Measured memory_bytes: 42844
a, b, c = map(int, input().split())
k = int(input())
ok = False
for i in range(k):
    if k > 0:
        if b <= a:
            b *= 2
            k -= 1
        else:
            if c <= b:
                c *= 2
                k -= 1
            else:
                ok = True
    # print(c, b, a, k)

if c > b > a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#define f first
#define s second
#define pb push_back
using namespace std;
long long const inf=1e18+5;
int const maxn=1005;
typedef long long ll;
typedef pair<int,int>P;
vector<P>p;
char s[maxn];
int num[30];
int main(){
	int n;
	scanf("%d",&n);
	bool flag=0;
	while(n){
		if(n%10==7) flag=1;
		n/=10;
	}
	printf("%s",flag?"Yes":"No");
}


Measured memory_bytes: 3828
n,a,b=map(int,input().split())
Mod=10**9+7
c=max(a,b)
f=[1]*(c+1)
g=[n]*(c+1)
for i in range(2,c+1):
    f[i]=f[i-1]*i%Mod
    g[i]=g[i-1]*(n-i+1)%Mod
def f_inv(i):
    return pow(f[i],Mod-2,Mod)
def h(i):
    return g[i]*f_inv(i)%Mod
Ans=pow(2,n,Mod)-h(a)-h(b)-1
print(Ans%Mod)

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

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

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

unsigned long int a[2000];

int main(void){
    int N, Z, W;
    int i;
    scanf("%d %d %d", &N, &Z, &W);

    for (i = 0; i < N; i++){
        scanf("%ld", &a[i]);
    }



    if (abs((a[N-1] - W)) > abs((a[N-2] - a[N-1])) || N == 1){
        printf("%d\n", abs((a[N-1] - W)));
    }else{
        printf("%d\n",abs((a[N-2] - a[N-1])));
    }


    return 0;
}


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

int main(){
  int n;
  long long ans = 0;
  cin >> n;
  for(int i = 1;i <= n;i++){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal n = sc.nextBigDecimal();
		if (n == BigDecimal.ZERO) {
			System.out.println("Yes");
			return;
		}

		String nn = String.valueOf(n);

		int count = 0;

		for (int i = 0; i < nn.length(); i++) {
			count += Integer.valueOf(nn.substring(i, i + 1));
			count = count % 9;
		}

		if (count % 9 == 0) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");

	}
}

Measured memory_bytes: 65964
import java.util.Arrays
import java.util.ArrayList
import java.util.ArrayDeque

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    var (r, d, x) = reader.readLine()!!.split(" ").map{it.toLong()}

    for (i in 0..9) {
        x = r * x - d
        println(x)
    }
}


Measured memory_bytes: 35876
#include <iostream>
#include <algorithm>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,k,n) for(int i=k;i<n;i++)
using namespace std;

int main(){
	int n,m;
	while(cin>>n>>m and n>0){
		pair<int,int> a[n]; rep(i,n) cin>>a[i].second>>a[i].first;
		sort(a,a+n);
		int i=n-1;
		while(m>0 and i>=0){
			if(m-a[i].second>=0){
				m-=a[i].second; a[i].second=0;
			}else{
				a[i].second-=m; m=0;
			}
			i--;
		}
		long ans=0;
		rep(i,n) ans+=a[i].first*a[i].second;
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3112
N = int(input()) -1
B = list(map(int, input().split()))
ans = 0

if N == 1:
    ans = B[0]*2
else:
    ans += B[0] #min(B[0], B[1])

    num = 0
    for i in range(1, N-1):
        ans += min(B[i-1], B[i])
    else:
        ans += min(B[N-2], B[N-1])
        ans += B[N-1]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
unsigned long long perm(vector<int> &a, vector<int> &b)
{
  unsigned long long ans = 0;
  do {
    bool done = true;
    for(int i = 0; i < a.size(); ++i)
      if (b[i] != a[i])
        done = false;
    if (done)
      break;
    ++ans;
  } while (next_permutation(b.begin(), b.end()));
  return ans;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  for (int i = 0; i < n; ++i)
    cin >> b[i];
  bool f = true;
  for(int i = 0; i < n; ++i)
    if (a[i] != b[i]) {
      f = a[i] > b[i];
      break;
    }
  unsigned long long ans = f ? perm(a, b) : perm(b, a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
long long MOD = 998244353; 
int main(){
	long long A, B, C, D; cin >> A >> B >> C >> D; 
	long long dp[3010][3010] = {}; 
	dp[A][B] = 1LL; 
	for(int i = A + 1; i <= C; i++){
		dp[i][B] = dp[i-1][B] * B % MOD; 
	}
	for(int i = B + 1; i <= D; i++){
		dp[A][i] = dp[A][i-1] * A % MOD; 
	}
	for(long long i = A + 1; i <= C; i++){
		for(long long j = B + 1; j <= D; j++){
			dp[i][j] = (MOD * 10000000 + dp[i][j-1] * i + dp[i-1][j] * j - dp[i-1][j-1] * (i-1) * (j-1)) % MOD; 
		}	
	}
	cout << dp[C][D] << "\n"; 
}

Measured memory_bytes: 74416
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i] -= (i+1)
a.sort()
c = a[n//2]
if n % 2 == 0:
    c = int((a[n//2] + a[n//2-1]) // 2 + 0.5)
ans = 0
for i in range(n):
    ans += abs(a[i] - c)
print(ans)

Measured memory_bytes: 26180
s = gets.chomp.to_i

arr = Array.new(10**6 + 1, false)

i = 1
a = s
arr[a] = true
i += 1

while true
  if a.even?
    a /= 2
  else
    a = a * 3 + 1
  end
  if arr[a]
    puts i
    exit
  else
    arr[a] = true
  end
  i += 1
end


Measured memory_bytes: 11644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n;
	ll in, sum = 0;
	vector<ll> a, b;
	cin >> n;
	rep(i, n) {
		cin >> in;
		a.push_back(in);
	}
	sort(all(a));
	rep(i, n) {
		sum += a[i];
		b.push_back(sum);
	}
	for (int i = n - 1; i > 0; i--) {
		if (b[i - 1] * 2 < a[i]) {
			cout << n - i << endl;
			return 0;
		}
	}
	cout << n << endl;
}


Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string a, b;
    cin >> a >> b;
    
    bool flg = true;
    for (int i = 0; i < 3; i++) {
        if(a[i] != b[2 - i]) flg = false;
    }
    if(flg){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int A, B, m;
    cin >> A >> B >> m;
    vector<int> a(A), b(B);
    for(int i=0;i<A;i++) cin >> a[i];
    for(int i=0;i<B;i++) cin >> b[i];
    int ans = 0, mn = 1e9;
    for(int i=0;i<A;i++) if(a[i] < mn) mn = a[i];
    ans += mn;
    mn = 1e9;
    for(int i=0;i<B;i++) if(b[i] < mn) mn = b[i];
    ans += mn;
    for(int i=0;i<m;i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        int t = a[x] + b[y] - c;
        if(t < ans) ans = t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
#define int long long
int32_t main()
{
    int n,i;
    cin>>n;
    string s="ACL";
    for(i=1;i<=n;i++) cout<<s;

    return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a[]={"SAT","SUN","MON","TUE","WED","THU","FRI"};
    int c[]={1,7,6,5,4,3,2};
    string b;
    cin>>b;
    for(int i=0; i<7; i++)
    {
        if(a[i]==b)
        {
            cout<<c[i]<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long               ll;
const int mod = 1e9+7;
#ifndef M_PI
const double M_PI = acos(-1.0);
#endif

struct vert{
  int a;
  vector<vert *> con;
  int min_nc = 9999;
  vector<ll> best;
  void dfs(vert* par){
    if(a > 0)
      min_nc = 0;
    best.push_back(a);
    for(vert *nxt : con){
      if(nxt != par){
        nxt->dfs(this);
        if(a > 0){
          int add = nxt->min_nc;
          for(int i=0; i<nxt->best.size(); ++i){
            if(nxt->best[i] < 0){
              add = min(add, i+1);
              break;
            }
          }
          min_nc += add;
        }
        vector<ll> tmp(best.size()+nxt->best.size()-1, LLONG_MAX);
        for(int i=0; i<best.size(); ++i){
          for(int j=0; j<nxt->best.size(); ++j){
            tmp[i+j] = min(tmp[i+j], best[i]+nxt->best[j]);
          }
        }
        if(nxt->min_nc < 9999){
          for(int i=0; i<best.size(); ++i){
            while(i+nxt->min_nc+1 >= tmp.size())
              tmp.push_back(tmp.back());
            tmp[i+nxt->min_nc+1] = min(best[i], tmp[i+nxt->min_nc+1]);
          }
        }
        best = tmp;
      }
    }
  }
};

int main(){
  int n;
  cin>>n;
  vector<vert> graph(n+1);
  for(int i=1; i<=n; ++i){
    scanf("%d", &graph[i].a);
  }
  for(int i=1; i<n; ++i){
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u].con.push_back(&graph[v]);
    graph[v].con.push_back(&graph[u]);
  }
  graph[1].dfs(0);
  int res = graph[1].min_nc;
  for(int i=0; i<graph[1].best.size(); ++i){
    if(graph[1].best[i] < 0){
      res = min(res, i);
      break;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 76672
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli unsigned long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)

#define TATE 0
#define YOKO 1

/* 文字列→形式に変換*/

lli calc(string str[2],lli now){
	if(str[0].at(now)==str[1].at(now))return 0;
	else return 1;
}

int main(){

	/*これをまとめると

	Rxx
	Ryy  →R * 2通り

	Rx
	Rx  → R * 2通り

	xxZZ
	yyWW → xxyy * 2通り

	xxR
	yyR → xxyy*1通り

	また初期値 data=0;
	R
	R →3通り

	xx       data~1;
	yy → 6通り
	*/

	
	lli n;

	string str[2];

	cin>>n;
	REP(i,2)cin>>str[i];

	lli data[100];
	REP(i,100)data[i]=-1;

	lli cnt=0;

	REP(i,n){
		lli d = calc(str,i);
		if(d)i++;
		data[cnt]=d;
		cnt++;
	}

	lli ans;

	if(DEBUG){
		cout<<"D"<<endl;
		REP(i,cnt){
			cout<<data[i];
			if(data[i])cout<<" ";
		}
		cout<<endl;
	}
	if(data[0]==0)ans = 3;
	else ans = 6;
	for(lli i=1;i<cnt;i++){
		if(data[i-1]==TATE){
			ans *= 2;
		}
		else{
			if(data[i]==TATE);
			else ans *= 3;
		}
		ans %= MOD;
		if(DEBUG)cout<<ans<<endl;
	}

	cout<<ans<<endl;

	return 0;
}
 

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

template <class T = long long int>
class Bit {
    private:
    unsigned len;
    T init;
    std::vector<T> arr;

    public:
    Bit(unsigned length, T initialValue = 0): len(length), init(initialValue), arr(len + 1, init) {}
    void update(unsigned a, T newval) {
        for (unsigned x = a; x <= len; x += x & -x) arr[x] += newval;
    }
    T query(unsigned a) const {
        if (!a) return 0;
        T ret = init;
        for (unsigned x = a; x > 0; x -= x & -x) ret += arr[x];
        return ret;
    }
};

int main() {
    int n, q;
    std::string s;
    std::cin >> n >> s >> q;

    std::vector<Bit<int>> bit(26, Bit<int>(n + 10));
    for (int i = 0; i < n; i++) bit[s[i] - 'a'].update(i + 1, 1);

    while (q--) {
        int t, l;
        std::cin >> t >> l;
        if (t == 1) {
            char r;
            std::cin >> r;
            bit[s[l - 1] - 'a'].update(l, -1);
            bit[r - 'a'].update(l, 1);
            s[l - 1] = r;
        } else {
            int r;
            std::cin >> r;
            int ret = 0;
            for (int i = 0; i < 26; i++) if (bit[i].query(l - 1) != bit[i].query(r)) ret++;
            std::cout << ret << '\n';
        }
    }

    std::cout << std::flush;

    return 0;
}


Measured memory_bytes: 53764
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}



int32_t main()
{
    //freopen("C:/Users/Joe/Desktop/tests/in11.txt", "r", stdin);
    //freopen("C:/Users/Joe/Desktop/tests/out11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int t=1;
    //cin >> t;
    while(t--)
    {
        int n,k;
        cin >> n >> k;
        string str;
        cin >> str;
        str[k-1]+=32;
        cout << str << endl;



    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b; scanf("%d%d",&a,&b);
  int ans=0;
  for(int i=0; i<a; i++){
    int t; scanf("%d\n",&t);
    if(t>=b) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
s = input()
S = [0]*len(s)
for i in range(len(s)):
    S[i] = int(s[i])

# 0:-, 1:+
op = [0]*(len(S) - 1)
for i in range(2**len(op)):
    op = [0]*(len(S) - 1)
    for j in range(len(op)):
        if (i >> j & 1):
            op[j] = 1
    tmp = S[0]
    for j in range(len(op)):
        if op[j] == 0:
            tmp -= S[j+1]
        else:
            tmp += S[j+1]
    if tmp == 7:
        ans = op[:]
ans_str = s[0]
for i in range(len(S)-1):
    if ans[i] == 0:
        ans_str = ans_str + "-"
    else:
        ans_str = ans_str + "+"
    ans_str = ans_str + s[i+1]
ans_str = ans_str + "=7"
print(ans_str)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;


int main(){

    FASTIO;
    PRECISION; 

    int n,k;
    cin>>n>>k;

    if(n==0){
        if(k==0)
            cout<<0<<" "<<0<<"\n";
        else
        {
            cout<<-1<<"\n";
        }
        
    }else if(n==1){
        if(k==0){
            cout<<0<<" "<<0<<" "<<1<<" "<<1<<"\n";
        }else{
            cout<<-1<<"\n";
        }
    }else{
        if(k>=(1<<n)){
            cout<<-1<<"\n";
            return 0;
        }

        vector<int>b;
        for(int i=0;i<(1<<n);i++){
            if(i!=k)
            b.push_back(i);
        }

        for(auto x: b){
            cout<<x<<" ";
        }
        cout<<k<<" ";
        reverse(b.begin(),b.end());

        for(auto x: b){
            cout<<x<<" ";
        }
        cout<<k<<" ";
    }
    
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
#define FIND(v,i) find(v.begin(),v.end(),i);

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,k;
    cin >> n >> k;
    cout << fixed << setprecision(0) << k*pow(k-1,n-1) << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 384
#include <stdio.h>

int selectionSort(int A[], int N){
    int i, j, t, sw =0, minj;
    for(i = 0; i<N-1;i++){
        minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        t = A[i];
        A[i] = A[minj];
        A[minj] = t;
        if(i != minj) sw++;
    }
    return sw;
}

int main(){
    int A[100], N, i, sw;

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

    sw = selectionSort(A, N);

    for(i = 0; i < N; i++){
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    double L,A,B,C,D;
    cin>>L>>A>>B>>C>>D;
    cout<<L-max(ceil(A/C),ceil(B/D))<<endl;
    return 0;
}

Measured memory_bytes: 3292
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;

int main(){
        ll a,b,i,t,la=0,lb=0,d,cnt,ans=0;
        vector<ll> bin_a(40);
        vector<ll> bin_b(40);
        cin >> a >> b; --a;
        t = a;
        while(t!=0){
                t /= 2;
                ++la;
        }
        t = b;
        while(t!=0){
                t /= 2;
                ++lb;
        }
        for(i=0;i<40;++i){
                if(i+1>la) break;
                d = pow(2,i+1);
                cnt = (d/2)*((a+1)/d);
                if((a+1)%d>0){
                        cnt += max((a+1)%d-d/2, 0ll);
                }
                bin_a.at(i) = cnt;
        }
        for(i=0;i<40;++i){
                if(i+1>lb) break;
                d = pow(2,i+1);
                cnt = (d/2)*((b+1)/d);
                if((b+1)%d>0){
                        cnt += max((b+1)%d-d/2, 0ll);
                }
                bin_b.at(i) = cnt;
        }
        for(i=0;i<40;++i) ans += (bin_b.at(i)-bin_a.at(i))%2==0 ? 0 : pow(2,i);
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>

int main(){
	int H, W, h, w;
	while(1){
		scanf("%d %d", &H, &W);
		if (H==0 && W==0) break;
		for (h=0; ++h<=H;){
			for (w=0; ++w<=W;)
				putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
}


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

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

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void)
{
    int N, i, j, judge=0;

    cin >> N;

    for(i=0; i<=25; i++){
        for(j=0; j<=25; j++){
            if(4*i+7*j == N){
                judge = 1;
                break;
            }
        }
    }

    if(judge == 1){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256