akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  cin >> H;

  for(int i = 1; i <= H; i++) cin >> A[i];

  for(int i = H / 2; i >= 1; i--) maxHeapify(i);

  for(int i = 1; i <= H; i++){
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}

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

using namespace std;
int arr[13][13], cnt[13], duit, N, M, X, C[13], ans = 1e9;

void rek(int idx) {
	if (idx == N + 1) {
		bool cek = 1;
		for (int i = 1; i <= M; i++) {
			if (cnt[i] < X) cek = 0;
		}
		if (cek) ans = min(ans, duit);
	} else {
		duit += C[idx];
		for (int i = 1; i <= M; i++) {
			cnt[i] += arr[idx][i];
		}
		rek(idx + 1);
		duit -= C[idx];
		for (int i = 1; i <= M; i++) {
			cnt[i] -= arr[idx][i];
		}
		rek(idx + 1);
	}
}

int main() {
	scanf("%d%d%d", &N, &M, &X);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &C[i]);
		for (int j = 1; j <= M; j++) {
			scanf("%d", &arr[i][j]);
		}
	}
	rek(1);
	if (ans == 1e9) printf("-1\n");
	else printf("%d", ans);
}

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t l;
  std::cin >> l;
  std::vector<std::string> ss(n);
  for (int i = 0; i < n; i++) {
    std::cin >> ss[i];
  }
  std::sort(ss.begin(), ss.end());
  for (const auto& s : ss) {
    std::cout << s;
  }
  std::cout << std::endl;
  return 0;
}


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

int main() {
  ll n;
  int min = 11;
  cin >> n;
  for(int i = 1;i <= sqrt(n);i++){
    if(n%i == 0){
      ll a = i,b = n/i;
      string aa = to_string(a),bb = to_string(b);
      if(max(aa.size(),bb.size()) < min) min = max(aa.size(),bb.size());
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
dp = [0]*(n)
for i in range(n-1):
    if i == 0:
        dp[1] = abs(h[1]-h[0])
    else:
        dp[i+1] = min(abs(h[i+1] - h[i]) + dp[i],abs(h[i+1] - h[i-1]) + dp[i-1])
print(dp[-1])

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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for (auto &&e : s)
    {
        cin >> e;
    }
    sort(s.begin(),s.end());
    for (auto &&e : s)
    {
        cout << e;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    ll m;
    cin >> n >> m;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(), a.end());
    int l = 0;
    int r = 1<<30;
    while(r - l > 1){
        int mid = (l + r) / 2;
        ll cnt = 0;
        rep(i,n){
            cnt += a.end() - lower_bound(a.begin(), a.end(), mid -a[i]);
        }
        if(cnt >= m){
            l = mid;
        }else{
            r = mid;
        }
    }
    show(l);
    vector<ll> sum(n+1);
    rep(i,n)sum[i+1] = sum[i] + a[i];
    ll ans = 0;
    rep(i,n){
        int id = (int) (upper_bound(a.begin(), a.end(), l - a[i]) - a.begin());
        ans += sum[n] - sum[id] + a[i] * (n - id);
        m -= n - id;
    }
    cout << ans + l * m << endl;
}


Measured memory_bytes: 1792
#include <stdio.h> 

int main(void) {

int i, j,k,a, tmp; 
int n[10]; 


for (k=1; k<=10; k++){ 
scanf("%d", &a);
n[k]=a;
} 

for (i=1; i<=10; i++) {
for (j=10; j>=i+1; j--) { 

if (n[j] > n[j-1]) { 
tmp =  n[j-1]; 
n[j-1] = n[j]; 
n[j] = tmp; 
}
}
}
for(i=1;i<=3;i++){
printf("%d\n", n[i]);
}

return 0;
} 



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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  for (int i = 0; i < n - k; i++){
    if(a[i] < a[i+ k]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

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

int main(){
  long long w,h,x,y; cin>>w>>h>>x>>y;

  long long area=w*h*1.0;

  if(x==w/2 && w%2==0 && y==h/2 && h%2==0)cout<<area/2<<" "<<1<<endl;
  else if(area%2==0)cout<<area/2<<" "<<0<<endl;
  else cout<<area/2<<".5"<<" "<<0<<endl;
}


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

using namespace std;

int main (){

  string s;
  cin>>s;
  
  if (s=="SUN") cout<<"7"<<endl;
  else if(s == "MON") cout<<"6"<<endl;
  else if(s == "TUE") cout<<"5"<<endl;
  else if(s == "WED") cout<<"4"<<endl;
  else if(s == "THU") cout<<"3"<<endl;
  else if(s == "FRI") cout<<"2"<<endl;
  else if(s == "SAT") cout<<"1"<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+20 , MaxlogN = 25 , INF = 0x3f3f3f3f;
struct node { int x,y; } a[N];
int n,w,h,ans,Min[N],Max[N];
int q[N],head,tail,border;
inline void input(void)
{
    scanf("%d%d%d",&w,&h,&n);
    for (int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].y);
}
inline void divide(int l,int r)
{
    if ( l == r ) return void();
    int mid = l + r >> 1 , y1 , y2;
    divide( l , mid ) , divide( mid+1 , r );
    y1 = 0 , y2 = h;
    for (int i=mid;i>=l;i--)
    {
        Max[i] = y1 , Min[i] = y2;
        if ( a[i].y <= border ) y1 = max( y1 , a[i].y );
        if ( a[i].y >= border ) y2 = min( y2 , a[i].y );
    }
    y1 = 0 , y2 = h;
    for (int i=mid+1;i<=r;i++)
    {
        Max[i] = y1 , Min[i] = y2;
        if ( a[i].y <= border ) y1 = max( y1 , a[i].y );
        if ( a[i].y >= border ) y2 = min( y2 , a[i].y );
    }
    head = 1 , tail = 0;
    for (int i=mid,j=mid+1;i>=l;i--)
    {
        while ( j <= r && Max[j] <= Max[i] )
        {
            while ( head <= tail && Min[q[tail]] + a[q[tail]].x <= Min[j] + a[j].x ) tail--;
            q[++tail] = j++;
        }
        while ( head < tail && Min[i] + a[q[head]].x <= Min[q[head+1]] + a[q[head+1]].x ) head++;
        ans = max( ans , 2 * ( a[q[head]].x - a[i].x + min( Min[i] , Min[q[head]] ) - Max[i] ) );
    }
    head = 1 , tail = 0;
    for (int i=mid+1,j=mid;i<=r;i++)
    {
        while ( j >= l && Max[j] <= Max[i] )
        {
            while ( head <= tail && Min[q[tail]] - a[q[tail]].x <= Min[j] - a[j].x ) tail--;
            q[++tail] = j--;
        }
        while ( head < tail && Min[i] - a[q[head]].x <= Min[q[head+1]] - a[q[head+1]].x ) head++;
        ans = max( ans , 2 * ( a[i].x - a[q[head]].x + min( Min[i] , Min[q[head]] ) - Max[i] ) );
    }
}
inline void solve(void)
{
    auto compare = [](node p1,node p2) { return p1.x < p2.x; };
    sort( a+1 , a+n+1 , compare );
    a[0] = (node){0,h/2} , a[n+1] = (node){w,h/2};
    border = h/2 , divide( 0 , n + 1 );
    for (int i=1;i<=n;i++)
        swap( a[i].x , a[i].y );
    swap( w , h );
    sort( a+1 , a+n+1 , compare );
    a[0] = (node){0,h/2} , a[n+1] = (node){w,h/2};
    border = h/2 , divide( 0 , n + 1 );
}
int main(void)
{
    input();
    ans = 2 * ( max(w,h) + 1 );
    solve();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

template <class T>
class SegTree {
    int n;
    vector<T> data;
    T def;
    function<T(T,T)> operation;
    function<T(T,T)> update;

    T _query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return data[k];
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }
  public:
    SegTree(size_t _n, T _def, function<T(T,T)> _operation, function<T(T,T)> _update)
    : def(_def), operation(_operation), update(_update) {
            n = 1;
            while(n < _n) {
                n *= 2;
            }
            data = vector<T>(2*n-1, def);
    }

    void change(int i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while(i > 0) {
            i = (i-1)/2;
            data[i] = operation(data[2*i+1], data[2*i+2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](int i) {
        return data[i+n-1];
    }
};


int main()
{
    int n,Q;
    string s;
    cin >> n >> s >> Q;
    SegTree<int> st(n,0,
    [](int a, int b){return a|b;},
    [](int a, int b){return b;}
    );
    rep(i,n) {
        int d = s[i] - 'a';
        st.change(i, (int)(1 << d));
    }

    while(Q--) {
        int type;
        cin >> type;
        if(type == 1) {
            int j; char c;
            cin >> j >> c;
            j--;
            int d = c - 'a';
            st.change(j, (int)(1 << d));
        }
        if(type == 2) {
            int l,r;
            cin >> l >> r;
            l--; r--;
            cout << __builtin_popcount(st.query(l,r+1)) << endl;
        }
    }


    return 0;
}

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

using namespace std;

const int N = 101000;

vector <int> adj[N];
int val[N];

// if fix 1, we have a green hackenbush

int dfs(int u, int l) {
	val[u] = 0;
	for (int x: adj[u]) {
		if (x == l) continue;
		val[u]^=(dfs(x, u)+1);
	}
	return val[u];
}

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

	for (int i = 0; i < n-1; ++i) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	
	dfs(1, -1);
	if(val[1] == 0) {
		printf("Bob\n");
	} else {
		printf("Alice\n");
	}

}

Measured memory_bytes: 10880
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  string Sa, Sb, Sc;
  cin >> Sa >> Sb >> Sc;
  // 次に何を調べるか
  bool a=true, b=false, c=false;
  while (true) {
    if (a) {
      if (Sa[0]=='b') a=false, b=true;
      else if (Sa[0]=='c') a=false, c=true;
      Sa.erase(Sa.begin());
    }
    else if (b) {
      if (Sb[0]=='a') a=true, b=false;
      else if (Sb[0]=='c') b=false, c=true;
      Sb.erase(Sb.begin());
    }
    else {
      if (Sc[0]=='a') a=true, c=false;
      else if (Sc[0]=='b') b=true, c=false;
      Sc.erase(Sc.begin());
    }
    if (a&&Sa.size()==0) {
      cout << 'A' << endl;
      break;
    }
    else if (b&&Sb.size()==0) {
      cout << 'B' << endl;
      break;
    }
    else if (c&&Sc.size()==0) {
      cout << 'C' << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n,m;cin>>n>>m;
  vector<int> a(m);rep(i,m)cin>>a[i];
  int ans = n - SUM(a);
  print(max(ans,-1));
  return 0; 
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <map>
#include <complex>
using namespace std;
typedef complex<double> P;

int col[1000] , row[1000] , val[1000][1000];

int main(){
	int H,W;
	cin >> H >> W;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){	
			int t;
			cin >> t;
			col[i] += t;
			row[j] += t;
			val[i][j] = t;
		}	
	}
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			cout << (col[i]+row[j]+val[i][j]+1)%2 << (char)(j == W-1 ? 10 : 32 );
		}
	}
}

Measured memory_bytes: 4776
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> as(N);
  multiset<ll> count;
  ll res = 0;
  for (auto i = 0; i < N; i++) {
    cin >> as[i];
    count.insert(as[i]);
  }

  while(!count.empty()) {
    auto x = (++count.rbegin()).base();
    auto val = *x;
    count.erase(x);
    ll twot = 1;
    for (; twot <= val; twot *= 2) {}
    ll target = twot - val;
    auto tit = count.lower_bound(target);
//    cout << "val=" << val << " target=" << target << " tit=" << *tit << endl;
    if (*tit == target) {
      res++;
      count.erase(tit);
    }
  }

  cout << res << endl;

  return 0;
}


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

int main(void){
  int a,b;
  cin >> a >> b;

  while(!cin.eof()){
    int m = a+b;
    int i;
    for(i=0;m!=0;i++){
      m /= 10;
    }
    cout << i << endl;
    cin >> a >> b;
  }
  return 0;
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	n+=2,m+=2;
	char c[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			c[i][j]='#';
		}
	}

	for(int i=1;i<n-1;i++){
		for(int j=1;j<m-1;j++){
			char g;
			cin>>g;
			c[i][j]=g;
		}
	}
	
for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<c[i][j];
		}
		cout<<'\n';
	}

	
	
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    S[K-1] = 'a' + (S[K-1] - 'A');
    cout << S << endl;
    
    return 0;
}


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

#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 5e6 + 41;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e16;
const int inf = 1e9;

int c[25][25];

long long dp[26][N];

int main () {
	boost;
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		for (int j = 0 ; j < n ; ++ j) {
			cin >> c[i][j];
		}
	}
	dp[0][0] = 1;
	for (int i = 0 ; i < (1 << n) ; ++ i) {
		int bits = 0;
		for (int j = 0 ; j < n ; ++ j) {
			if (i & (1 << j)) {
				++bits;
			}
		}
		for (int j = 0 ; j < n ; ++ j) {
			if (!(i & (1 << j)) && c[bits][j]) {
				dp[bits + 1][i | (1 << j)] += dp[bits][i];
				dp[bits + 1][i | (1 << j)] %= mod;
			}
		}
	}
	cout << dp[n][(1 << n) - 1];
}

Measured memory_bytes: 336128
#include <cstdio>
#include <cstring>
using namespace std;

int main() {

    double sum, temp; 
    int N;
    char t[4];
    scanf("%d", &N);

    for (int i = 0; i < N; i++) {
        scanf("%lf %s", &temp, t);
        if (strcmp(t, "JPY") == 0) {
            sum += temp;
        } else {
            sum += temp * 380000;
        }
    }

    printf("%lf\n", sum);

    return 0;

}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (N, D) = listOfInt()
    val X = Array<List<Int>>(N) { listOfInt() }
    var ans = 0
    for (a in 0 until N-1) {
        for (b in a+1 until N) {
            var sum = 0
            for (n in 0 until D) {
                val d = Math.abs(X[a][n] - X[b][n])
                sum += (d * d)
            }
            val q = Math.floor(Math.sqrt(sum.toDouble())).toInt()
            if (sum == (q * q)) ans++
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 37780
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll Powb(ll b,ll n,ll m);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l=0,r=0,a=1,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n >> m;
    vector<vector<char> > A(n+2,vector<char>(m+2,'#'));
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++) {cin >> A[i][j];
    }
    for(i=0;i<= n+1 ; i++)
    {
        for(j=0;j<=m+1;j++)
            cout << A[i][j];
        cout << endl;
    }}

    return 0;
}

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

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3640
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n);
  if(n < 1200)
    EN(ABC);
  if(n < 2800)
    EN(ARC);
    EN(AGC);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
	int a,b,i,n;
	std::cin>>n;
	a=100000;
	for(i=0;i<n;i++){
		a=a*1.05;
	if(a%1000!=0){
	a=a-a%1000;
	a=a+1000;
	}
}
	std::cout<<a<<std::endl;
	return 0;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	P := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &P[i])
	}

	ans := 0
	for i := 1; i < n-1; i++ {
		if P[i] > P[i-1] && P[i] < P[i+1] {
			ans++
		} else if P[i] < P[i-1] && P[i] > P[i+1] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll a = 0, b = 0, c = 0, a_ = 0, b_ = 0, c_ = 0;
	string s; cin >> s;
	ll cnt = 1;
	for( char t : s ){
		if( t == 'A' ) a += cnt;
		else if( t == 'B' ) b += a;
		else if( t == 'C' ) c += b;
		else {
			c *= 3;
			c += b;
			b *= 3;
			b += a;
			a = a*3+cnt;
			cnt *= 3;
		}
		a %= mod; b %= mod; c %= mod; cnt %= mod;
	}
	cout << c << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX 1000000007
int main(void){
    // Your code here!
    
    char today[10];
    
    scanf("%s",&today);

    if(today[0] == 'S') printf("Cloudy\n");
    if(today[0] == 'C') printf("Rainy\n");
    if(today[0] == 'R') printf("Sunny\n");
    
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	static int mod = 1000000000 + 7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int N = sc.nextInt();
			double[] p = new double[N];
			for(int i = 0; i < N; i++) p[i] = sc.nextDouble();
			double[][] dp = new double[N + 1][N + 1];
			dp[0][0] = 1;
			for(int i = 0; i < N; i++) {
				for(int j = 0; j < N; j++) {
					if(dp[i][j] == 0) continue;
					dp[i + 1][j + 1] += dp[i][j] * p[i];
					dp[i + 1][j] += dp[i][j] * (1 - p[i]);
				}
			}
			double ans = 0;
			for(int i = (N + 1) / 2; i <= N; i++) {
				ans += dp[N][i];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 123656
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010

int main(void){
	char S[1001];
	scanf("%s",S);
	int l=strlen(S);
	int n,w,s,e;
	n=w=s=e=0;
	for(int i=0;i<l;i++){
		if(S[i]=='N')n=1;
		if(S[i]=='W')w=1;
		if(S[i]=='S')s=1;
		if(S[i]=='E')e=1;
	}
	if((n+s==1)||(w+e==1))printf("No");
	else printf("Yes");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b && b == c) {
            System.out.println(1);
        } else if (a != b && b != c && a != c) {
            System.out.println(3);
        } else {
            System.out.println(2);
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    scanf("%d", &a);
    if(a == 1){
        printf("2\n");
        return 0;
    }
    for(int i = a; i < 101000; i++){
        bool state = true;
        for(int j = 2; j*j <= i; j++){
            if(i % j == 0){
                state = false;
                break;
            }
        }
        if(state){
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)
 
int main() {
  int n,k,ans=0;
  cin>>n>>k;
  
  vector<int> l;
  rep(i,0,n){
    int tmp;
    cin>>tmp;
    l.emplace_back(tmp);
  }
  
  sort(l.begin(),l.end());
  
  for(int i=n-1;i>n-k-1;i--){ans+=l[i];}

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

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int venda[20],custo[20];
    int n,lucro = 0;
    cin >> n;
    for (int i = 0 ; i<n ; i++)
    {
        cin >> venda[i];
    }
    for (int i = 0 ; i<n ; i++)
    {
        cin >> custo[i];
    }
    for (int i = 0 ; i<n ; i++)
    {
        if(venda[i] > custo[i])
        {
            lucro += venda[i] - custo[i];
        }
    }
    cout << lucro << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	if (x + y + z <= 21) {
		cout << "win" << endl;
	}
	else cout << "bust" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> list;
  for (int i=0; i<3; i++) {
    int t;
    cin >> t;
    list.insert(t);
  }
  if (list.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl; 
  }
}

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

int main() {
  long n;
  cin>>n;
  if(n%2==1) cout<<0<<endl;
  else{
  long ans=0;
  long base=10;
  while(base<=n){
    ans+=n/base;
    base*=5;
  }
  cout<<ans<<endl;
}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a, B;
  cin >> a >> B;

  if(a >= 13) cout << B << endl;
  else if(6 <= a && a <= 12) cout << B / 2 << endl;
  else if(a <= 5) cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

// 定数定義
#define MAX_PIECE   (2000)

#define MAX(a,b)    ((a)>(b)?(a):(b))

// 汎用型宣言
typedef unsigned long long U8;
typedef unsigned long  U4;
typedef unsigned short U2;
typedef unsigned char  U1;

// 関数宣言
U8 dfs(U2 u2Lower, U2 u2Upper);

// グローバル変数（入力とメモ）
static U2 u2Num;
static U4 au4Size[MAX_PIECE * 2];

static U8 au8Memo[MAX_PIECE][MAX_PIECE] = {{0}}; // 初期化処理は省略

int main(){
    U2 u2Cnt;
    U8 u8Score;
    U8 u8Max;

    // 入力
    // ケーキのサイズは2週分のデータを格納して処理を簡略化する
    scanf("%hd",&u2Num);
    for(u2Cnt = 0; u2Cnt < u2Num; u2Cnt++){
        scanf("%ld",&au4Size[u2Cnt]);
        au4Size[u2Num + u2Cnt] = au4Size[u2Cnt];
    }

    // 初手は全探索 以降はメモ化再帰
    u8Max = 0;
    for(u2Cnt = 0; u2Cnt < u2Num; u2Cnt++){
        u8Score = au4Size[u2Cnt] + dfs(u2Cnt+1,u2Cnt+u2Num-1);
        u8Max = MAX(u8Max, u8Score);
    }

    // 出力
    printf("%lld\n", u8Max);

    return 0;
}


// 深さ優先探索（再帰）
// 残りのケーキの左右のインデックスを受け取り、そこから得られる最大点数を返す
U8 dfs(U2 u2Lower, U2 u2Upper){
    U8 u8Sum1;
    U8 u8Sum2;
    U2 u2NextLo;
    U2 u2NextUp;
    U8 u8Ans;

    // すでに計算済み
    if(au8Memo[u2Lower % u2Num][u2Upper % u2Num] > 0){
        return au8Memo[u2Lower % u2Num][u2Upper % u2Num];
    }

    // 残りケーキが0～1個だともう取れない
    if(u2Lower >= u2Upper){
        return 0;
    }

    // 相手が大きいほうを取る
    u2NextLo = u2Lower;
    u2NextUp = u2Upper;
    if(au4Size[u2NextLo] > au4Size[u2NextUp]){
        u2NextLo++;
    }else{
        u2NextUp--;
    }

    // 自分がどちらを取ればよいかは再帰して確認し結果が大きいほうを選ぶ
    u8Sum1 = au4Size[u2NextLo] + dfs(u2NextLo+1, u2NextUp);
    u8Sum2 = au4Size[u2NextUp] + dfs(u2NextLo, u2NextUp-1);
    u8Ans = MAX(u8Sum1, u8Sum2);

    // 計算結果を記憶
    au8Memo[u2Lower % u2Num][u2Upper % u2Num] = u8Ans;

    return u8Ans;
}



Measured memory_bytes: 33112
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

const MAX: usize = 1_000_000_000;
fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, m: usize, d: [usize; n]);
    let mut g = vec![vec![]; n];
    for i in 0..m {
        parse!(it, u: usize, v: usize);
        g[u - 1].push((v - 1, i));
        g[v - 1].push((u - 1, i));
    }
    let mut retv: Vec<Option<bool>> = vec![None; n];
    let mut rete = vec![MAX; m];
    let mut e = d
        .iter()
        .enumerate()
        .map(|(i, x)| (*x, i))
        .collect::<Vec<_>>();
    e.sort();
    'outer: for &(di, i) in e.iter() {
        if retv[i] != None {
            continue;
        }
        for &(j, ei) in g[i].iter() {
            if d[j] > di {
                continue;
            }
            if let Some(b) = retv[j] {
                retv[i] = Some(!b);
                rete[ei] = di;
            } else {
                assert_eq!(di, d[j]);
                retv[i] = Some(true);
                retv[j] = Some(false);
                rete[ei] = di;
            }
            continue 'outer;
        }
        println!("{}", -1);
        return;
    }
    println!(
        "{}",
        retv.into_iter()
            .map(|x| if x.unwrap() { "B" } else { "W" })
            .collect::<Vec<_>>()
            .join("")
    );
    for i in 0..m {
        println!("{}", rete[i]);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 30068
import java.io.*;
import java.util.*;

import static java.lang.System.out;


public final class Main {
	public static void main(String[] args) throws IOException {
		var istr = new InputStreamReader(System.in);
		var br = new BufferedReader(istr);
		int k = Integer.parseInt(br.readLine());
		var st = new StringTokenizer(br.readLine());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		for (int score = a; score <= b; score++) {
			if (score % k == 0) {
				out.printf("OK%n");
				return;
			}
		}
		out.printf("NG%n");
	}
}


Measured memory_bytes: 33980
// ABC157 C

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

class unionfind{
    public:
        vector<int> d;
        unionfind(int n=0){
            d = vector<int>(n, -1);
        }
        int find(int x){
            if(d.at(x) < 0) return x;
            else return d.at(x) = find(d.at(x));
        }
        bool unite(int x, int y){
            x = find(x);
            y = find(y);
            if(x == y) return false;
            if(d.at(x) > d.at(y)) swap(x, y);
            d.at(x) += d.at(y);
            d.at(y) = x;
            return true;
        }
        bool same(int x, int y){ return find(x) == find(y);}
        int size(int x){ return -d.at(find(x));}
};

int deg[100005];
vector<int> to[100005];

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    unionfind uf(n);
    vector<pair<int, int>> sns_friend, sns_block;

    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        deg[a]++;
        deg[b]++;
        uf.unite(a, b);
    }

    for(int i=0; i<k; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    for(int i=0; i<n; i++){
        int anw = uf.size(i)-1-deg[i];
        for(int u: to[i]){
            if(uf.same(i, u)) anw--;
        }
        cout << anw << " ";
    }


    return 0;
}

Measured memory_bytes: 6784
a,b,c,d,e=input().split()
w = int(a)
h = int(b)
x = int(c)
y = int(d)
r = int(e)
if y + r>h:
	print("No")
elif x + r>w:
	print("No")
elif x - r<0:
	print("No")
elif y - r<0:
	print("No")
else:
	print("Yes")


Measured memory_bytes: 5596
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1] += ('a'-'A');

    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
int A[100000];

int main()
{
    int en = 0;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int t;
        cin >> t;
        t--;
        if (A[t] == 1)
        {
            en++;
        }
        else
        {
            A[t] = 1;
        }
    }

    int ans;

    if (en % 2 == 0)
    {
        ans = N - en;
    }
    else
    {
        ans = N - (en + 1);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(void) {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    if(N == 1) cout << abs(a[N-1] - W) << endl;
    else cout << max(abs(a[N-1] - W), abs(a[N-2] - a[N-1])) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

ll bit[200002], n, a[200002], k;
int c[200002];

class Solution {
public:
    long long sum(int i)
    {
        long long s = 0;
        while (0 < i)
        {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, long long x)
    {
        while (i <= 200002)
        {
            bit[i] += x;
            i += i & -i;
        }
    }

    void solve(std::istream& in, std::ostream& out) {
        vector<ll> b;
        in >> n >> k;
        a[0] = 0;
        b.push_back(0);
        bit[0] = 0;
        for (int i = 1; i <= n; i++)
        {
            int t = 0;
            in >> t;
            a[i] = t - k;
            a[i] += a[i - 1];
            b.push_back(a[i]);
            bit[i] = 0;
        }

        sort(b.begin(), b.end());
        b.erase(unique(b.begin(), b.end()), b.end());

        ll ans = 0;
        for (int i = 0; i <= n; i++)
        {
            c[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 1;
            ans += sum(c[i]);
            add(c[i], 1);
        }

        out << ans;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 5872
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	
 
 
using namespace std;
 
 
typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 	
/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+10;
const ll inf = 1e9;
 
string t[30],aux;
int main(){
	fastio;
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans = 0;
	f(i,0,n) cin>>t[i];
	f(i,0,(1LL<<n)){
		f(j,0,(1LL<<m)){
			ll c = 0;
			f(x,0,n){
				f(y,0,m){
					if( !(i&(1LL<<x)) && !(j&(1LL<<y)) && t[x][y] == '#'  )
						c++;
				}
			}
			if(c==k) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int now = 0;
    int tmp = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (a[i] != now){
            if (tmp >= now) ans += tmp - now;
            else ans += tmp;
            now = a[i];
            tmp = 1;
        }
        else tmp++;
    }
    if (tmp >= now) ans += tmp - now;
    else ans += tmp;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int table[][7] = {{ 0, 300, 500, 600, 700, 1350, 1650},
                      { 6,   0, 350, 450, 600, 1150, 1500},
                      {13,   7,   0, 250, 400, 1000, 1350},
                      {18,  12,   5,   0, 250,  850, 1300},
                      {23,  17,  10,   5,   0,  600, 1150},
                      {43,  37,  30,  25,  20,    0,  500},
                      {58,  52,  45,  40,  35,   15,    0}};
    int a = 17 * 60 + 30;
    int b = 19 * 60 + 30;

    for(;;){
        int ic[2];
        bool half = false;
        for(int i=0; i<2; ++i){
            int h, m;
            cin >> ic[i] >> h >> m;
            if(ic[i] == 0)
                return 0;
            -- ic[i];

            m += h * 60;
            if(a <= m && m <= b)
                half = true;
        }
        if(ic[1] < ic[0])
            swap(ic[0], ic[1]);

        if(table[ic[1]][ic[0]] > 40)
            half = false;

        int ret = table[ic[0]][ic[1]];
        if(half){
            if(ret % 100 != 0)
                ret += 50;
            ret /= 2;
        }
        cout << ret << endl;
    }
}

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

int main() {
	string s;
	int flag=0;
	int flag2=0;
	cin>>s;
	for(int i=2;i<s.length()-1;i++)
    {
        if(s[i]=='C')
        {
            flag++;
        }
    }
    for(int i=1;i<s.length();i++)
    {
        if(islower(s[i]))
        {
            flag2++;
        }
    }
    if(s[0]=='A'&&flag==1&&flag2==s.length()-2)
        cout<<"AC"<<endl;
    else
        cout<<"WA"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000000000000001;
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N/=a;
        }
        //その結果をpush
        res.push_back({a,ex});
    }
    //残った数について
    if(N!=1)res.push_back({N,1});
    return res;
}
int main(){
    ll n;cin>>n;
    vector<ll> ex(n+1,0);
    ll cnt=0;
    for(ll i=0;i<=n;i++){
        vector<pair<ll,ll>> res=prime_factorize(i);
        for(auto p:res){
            ex[p.first]+=p.second;
        }
    }
    ll b[5]={0};
    for(ll i=2;i<=n;i++){
      if(ex[i]>=74)b[4]++;
      if(ex[i]>=24)b[3]++;
      if(ex[i]>=14)b[2]++;
      if(ex[i]>=4)b[1]++;
      if(ex[i]>=2)b[0]++;
    }
    ll ans=0;
        ans=b[4]+(b[0]-1)*b[3]+(b[1]-1)*b[2]+(b[0]-2)*(b[1]-1)*(b[1])/2;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
ll W[ll(2e5+1)],V[ll(2e5+1)],n,w;
ll dp[ll(200)][ll(2e5+1)];
ll solve(ll idx,ll value){
if(value>w)return -1e16;
if(idx>=n)return 0;
ll ans=0;
if(dp[idx][value]!=-1)return dp[idx][value];
ans=max(ans,solve(idx+1,value));
ans=max(ans,solve(idx+1,value+W[idx])+V[idx]);
return dp[idx][value]=ans;
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    cin>>n>>w;
    for(ll i=0;i<n;i++)cin>>W[i]>>V[i];
    for(ll i=0;i<200;i++)for(ll j=0;j<=2e5;j++)dp[i][j]=-1;
    cout<<solve(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 315648
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){ 
 int R[MAX],n;
 
 cin >> n;
 for(int i = 0; i < n; i++) cin >> R[i];
 
 int maxv = -2000000000;
 int minv = R[0];
	
 for(int i = 1; i < n; i++){
 	maxv = max(maxv,R[i]-minv);
 	minv = min(minv,R[i]);
 }
	
 cout << maxv <<endl;

 return 0;
}

Measured memory_bytes: 3880
#include <stdio.h>
  
int main()
{
    int x, y;
    int i , j, k, l ;
    int count=0  ;
     
    for ( l = 0 ; l < 100 ; l++) {   
     scanf("%d %d", &x, &y);
    
     if (x + y == 0) 
        break ;
  
      for ( i = 1 ; i <= x - 2; i++ ) {
        for ( j = i +1 ; j <= x - 1 ; j++ ) {
            for ( k= j + 1 ; k <= x ; k++) {
                if ( i + j + k == y ) {
                    count++;
                }
            }
        }
      }
      printf("%d\n", count) ;
      count = 0 ;
     }
  
return 0;
}

Measured memory_bytes: 600
N, Q = map(int, input().split())
S = input()
imosu = [0] * (N + 1)
for i in range(N):
    imosu[i + 1] = imosu[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(imosu[r-1]-imosu[l-1])


Measured memory_bytes: 9412