akhauriyash/Code-Regression huggingface dataset:
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 55
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");
	
	int n;
	scanf("%d", &n);
	int arr[MAX_N];
	for (int i = 0; i < n; i++) scanf("%d", arr + i);
	int res = 0;
	for (int i = 1; i < n - 1; i++) {
		if (arr[i - 1] < arr[i] and arr[i] < arr[i + 1]) res++;
		else if (arr[i - 1] > arr[i] and arr[i] > arr[i + 1]) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
typedef long long ll;
ll a[N], k;
int n;

bool judge(ll x) {
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] > x) {
            ll cnt = a[i] / x;
            if (a[i] % x == 0) {
                ans += cnt - 1;
            } else {
                ans += cnt;
            }

        }
    }
    //cout << x << " " << ans << endl;
    return ans <= k;
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    ll l = 1, r = 1e9 + 7;
    ll ans = 0;
    while (l <= r) {
        ll m = (l + r) / 2;
       // cout << "l " << l << " r= " << r << endl;
        if (judge(m)) {
          //  cout << m << endl;
            r = m - 1;
            ans = m;
        } else {
            l = m + 1;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
#define int long long

using namespace std;

int x, t;

main()
{
    cin >> x >> t;
    if (x <= t)
    {
        cout << 0;
        return 0;
    }
    if (x > t)
    {
        cout << x-t;
        return 0;
    }
}


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

int p[22];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < N - 1; i++) {
        int min_p = min(p[i - 1], p[i + 1]);
        int max_p = max(p[i - 1], p[i + 1]);
        if (min_p < p[i] && max_p > p[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------
int main(){
  int r,c;
  cin >> r >> c;
  vector<vector<int>> G(r,vector<int> (c));
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      cin >> G[i][j];
    }
  }
  int r_sum=0,sum=0;
  vector<int> c_sum(c);
  for(int i=0; i<r; i++){
    r_sum = 0;
    for(int j=0; j<c; j++){
      cout << G[i][j];
      r_sum += G[i][j];
      cout << " ";
      c_sum[j] += G[i][j];
    }
    cout << r_sum << endl;
  }
  for(int i=0; i<c; i++){
    cout << c_sum[i] << " ";
    sum += c_sum[i];
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

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

const ll INF = 1e18 + 100000;

ll mymul(ll a, ll b) {
    if (a == 0) return 0;
    b = min(b, INF);
    ll res = 0;
    if (a % 2) {
        res += b;
    }
    return min(res + mymul(a/2, b*2), INF);
}

const int MN = 110;
const int MM = 2300;

int main() {
    int n, m;
    ll k;
    cin >> n >> m >> k;
    string s[MN];
    int sz[MN];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sz[i] = (int)s[i].size();
    }

    ll dp[MM] = {};
    dp[0] = 1;
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < n; j++) {
            if (i < sz[j]) continue;
            dp[i] += dp[i-sz[j]];
            dp[i] = min(dp[i], INF);
        }
    }

    if (dp[m] < k) {
        cout << "-" << endl;
        return 0;
    }

    bool tabuu[MN][MM] = {};
    ll num[MM] = {};
    num[0] = 1;

    string result;
    for (int fe = 0; fe < m; fe++) {
        for (int i = 0; i < n; i++) {
            if (sz[i] <= fe && !tabuu[i][fe-sz[i]]) {
                num[fe] += num[fe-sz[i]];
                num[fe] = min(num[fe], INF);
            }
        }

        ll cnt[26] = {};
        for (int i = 0; i < n; i++) {
            for (int j = max(0, fe-sz[i]+1); j <= min(fe, m-sz[i]); j++) {
                if (tabuu[i][j]) continue;
                int c = s[i][fe-j] - 'a';
                cnt[c] += mymul(num[j], dp[m-(j+sz[i])]);
                cnt[c] = min(cnt[c], INF);
            }
        }
        for (int i = 0; i < 26; i++) {
            if (k <= cnt[i]) {
                result += i+'a';
                break;
            }
            k -= cnt[i];
        }

        for (int i = 0; i < n; i++) {
            for (int j = max(0, fe-sz[i]+1); j <= fe; j++) {
                if (s[i][fe - j] != result[fe]) {
                    tabuu[i][j] = true;
                }
            }
        }
    }

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

Measured memory_bytes: 3540
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
#include <ios>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
const ll InF = 1e15;

int main() {
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  if (S[K-1] == 'A') S[K-1] = 'a';
  else if (S[K-1] == 'B') S[K-1] = 'b';
  else S[K-1] = 'c';
  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   char number[1001];
   int i, sum;
   while(1){
       scanf("%s", number);
       if(number[0]==48)break;
       sum=0;
       for(i=0;number[i]!='\0';i++){
           sum+=number[i]-48;
       }
       printf("%d\n", sum);
   }

   return 0;
}


Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int a, b, n;
int f(int x) {
	return (a * x) / b - a * (x / b);
}

signed main() {
	cin >> a >> b >> n;
	
	/*for (int x = 0; x <= n; x++) {
		cout << (a * x) / b - a * (x / b) << endl;
	}*/
	
	if (n < b) {
		cout << f(n) << endl;
	}
	else {
		cout << f(b - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<vector>
#include<iostream>
#include<string>
#include <iostream>
#include <algorithm>

#define INF 100000000000000
using namespace std;
//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す
char str_table[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
    vector<long long> alphabet_table(26, 0);
    unsigned long long ascii_code;
    string S;

    while(getline(cin, S)){
        for(int i=0; i<S.size(); i++){
            //アルファベットかどうか
            if(isalpha(S.at(i))==false){
                continue;
            }
            if(isupper(S.at(i))){
                S.at(i) = tolower(S.at(i));
            }
            ascii_code = S.at(i);
            alphabet_table.at(ascii_code-'a') += 1;
        }
    }
    for(int i=0; i<alphabet_table.size(); i++){
        cout << str_table[i] << " : " << alphabet_table.at(i) << endl;
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
using namespace std;
int p[1005];
int root(int a) {
	if (p[a] == a) return a;
	return (p[a] = root(p[a]));
}
void unite(int a,int b){
	p[root(a)] = root(b);
}
void same(int a ,int b){
	if (root(a) == root(b)) cout << "1" <<endl;
	else cout << "0" << endl;
}
bool rcheck(int a){
	if (root(a) == a) return 1;
	else return 0;
}
long long int F[1005];
int main() {
	int V,D;
	F[0]=1, F[1] =2;
	for (int i = 2;i< 1005;i++ ){
		F[i] = F[i-1]%1001 + F[i-2]%1001; 
		F[i] = F[i]%1001;
	}
	while ( cin >> V >> D) {
		int cou = 0;
		for (int i = 0; i < 1001; i++){
		p[i] = i;
		}
		for (int i=1;i <= V;i++) {
			for (int j=i+1;j <= V;j++ ){
				if (F[j] - F[i] < D && F[j] - F[i] > - D )
					unite(i,j);
			}

			}
		for (int i = 1;i <= V;i++){
			if (rcheck(i) == 1) {
				cou += 1;
			}
		}
		cout << cou <<  endl;
}
	}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    int cnt=0;
    int now=1;
    vector<int> nums;
    for(int i=0;i<n;i++){
        if(s[i]==(char)('0'+now)) cnt++;
        else{
            nums.push_back(cnt);
            cnt=1;
            now=1-now;
        }
    }
    if(cnt!=0) nums.push_back(cnt);
    if(nums.size()%2==0) nums.push_back(0);
    int right=0;
    int add=2*k+1;
    int ans=0,tmp=0;
    vector<int> sum(nums.size()+1);
    for(int i=0;i<nums.size();i++){
        sum[i+1]=sum[i]+nums[i];
    }
    for(int i=0;i<nums.size();i+=2){
        int left=i;
        int right=min(left+add,(int)nums.size());
        ans=max(ans,sum[right]-sum[left]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string w, ans = "Yes";
    cin >> w;

    string data = "abcdefghijklmnopqrstuvwxyz";

    for (int i = 0; i < data.length(); ++i) {
        int count = 0;

        for (string::iterator it = w.begin(); it != w.end(); ++it) {
            if (*it == data[i]) count++;
        }

        if (count%2 == 1) {
            ans = "No";
            break;
        }
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string str;
    cin >> str;
    
    if(str.size()==2) {
        if(str[0]==str[1]){
            cout << 1 << " " << 2 << endl;
        } else {
            cout << -1 << " " << -1 << endl;
        }
        return 0;
        
    } else {
        for(int i=0; i<str.size()-2; i++) {
            if(str[i]==str[i+1] || str[i+1]==str[i+2] || str[i+2]==str[i]) {
                cout << i+1 << " " << i+3 << endl;
                return 0;
            }
        }
        
        cout << -1 << " " << -1 << endl;
        
        return 0;
        
    }

}

Measured memory_bytes: 512
#include<stdio.h>
#include <ctype.h>

int main(){
char s[3][12],t[3][12];
scanf("%s %s %s",s[1],s[2],s[3]);
t[1][0]= toupper(s[1][0]);
t[2][0]= toupper(s[2][0]);
t[3][0]= toupper(s[3][0]);
printf("%c%c%c\n",t[1][0],t[2][0],t[3][0]);
return 0;
}

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

int debug = 0;

int main()
{
    int n;
    cin >> n;
    cout << ceil(n / 2.0) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
long long read(){
	register long long x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
int n, a[200005], b[200005];
long long k;
bool check(long long md){
	long long s = 0;
	for (register int i = 1; i <= n; ++i)
		s += std :: max(0ll, a[i] - md / b[n - i + 1]);
	return s <= k;
}
int main(){
	n = read(), k = read();
	for (register int i = 1; i <= n; ++i) a[i] = read();
	for (register int i = 1; i <= n; ++i) b[i] = read();
	std :: sort(a + 1, a + 1 + n), std :: sort(b + 1, b + 1 + n);
	long long l = 0, r = 1e13, md, ans;
	while (l <= r)
		if (check(md = (l + r) >> 1)) r = md - 1, ans = md; else l = md + 1;
	printf("%lld\n", ans);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(j,i,n) for(int i=j;i<n;++i)
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	frr(1,i,n)	cin>>a[i];
	ll left=1,right=1e9;
	ll ans=1e10;
	while(left<=right)
	{
		ll moves=0;
		ll mid=(left+right)/2ll;
		frr(1,i,n)
		{
			if(a[i]%mid==0)
				moves+=((a[i]/mid)-1ll);
			else
				moves+=(a[i]/mid);
		}
		if(moves>k)
			left=mid+1ll;
		else
			ans=min(mid,ans),right=mid-1ll;
	}
	cout<<ans<<"\n";
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



Measured memory_bytes: 5116
def z_alg(S):
    N = len(S)
    Z = [0] * N
    Z[0] = N
    i, j = 1, 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        Z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < N and k + Z[k] < j:
            Z[i + k] = Z[k]
            k += 1
        i += k
        j -= k
    return Z


def main():
    S = input()
    T = input()
    REP_S = ''
    target_len = len(S) + len(T) - 1
    while len(REP_S) < target_len:
        REP_S += S

    # Z-algorithmでREP_S中に含まれるTの場所を調べる
    T_REP_S = T + REP_S
    z = z_alg(T_REP_S)
    location_list = list()
    for i in range(len(S)):
        if z[i + len(T)] >= len(T):
            location_list.append(i)

    # Tがなければ0を出力して終了
    if len(location_list) == 0:
        print(0)
        return

    # グラフを作り、最長パスに含まれるノード数が答え（ループがあったら-1）
    node_flag_list = [0] * len(S)
    for n in location_list:
        node_flag_list[n] = 1
    depth_list = [-1] * len(S)
    for n in location_list:
        if depth_list[n] >= 0:
            continue
        cur_node = n
        d, has_loop = 0, False
        while node_flag_list[cur_node] == 1:
            depth_list[cur_node] = d
            d += 1
            cur_node = (cur_node + len(T)) % len(S)
            if cur_node == n:
                has_loop = True
                break
        if has_loop:
            print(-1)
            return

    print(max(depth_list) + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 115476
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;


int main()
{
    ll sum = 0;
    ll N, A, B;
    cin >> N;
    cin >> A >> B;
    for (int i = 1; i <= N; i++) {
        ll tmp_sum = 0;
        ll tmp = i;
        tmp_sum += i % 10;
        while (true) {
            tmp /= 10;
            tmp_sum += tmp % 10;
            if (tmp < 10) {
                break;
            }
        }
        if (tmp_sum >= A && tmp_sum <= B) {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto S = readln.chomp;
    auto DP = new long[][](S.length+1, 4);
    DP[S.length][3] = 1;
    foreach_reverse (i; 0..S.length) {
        auto c = S[i];
        foreach (j; 0..4) {
            if (c == 'A' || c == '?') {
                DP[i][j] = (DP[i][j] + DP[i+1][j]) % P;
                if (j == 0) DP[i][j] = (DP[i][j] + DP[i+1][j+1]) % P;
            }
            if (c == 'B' || c == '?') {
                DP[i][j] = (DP[i][j] + DP[i+1][j]) % P;
                if (j == 1) DP[i][j] = (DP[i][j] + DP[i+1][j+1]) % P;
            }
            if (c == 'C' || c == '?') {
                DP[i][j] = (DP[i][j] + DP[i+1][j]) % P;
                if (j == 2) DP[i][j] = (DP[i][j] + DP[i+1][j+1]) % P;
            }
        }
    }
    writeln(DP[0][0]);
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int n;
vector<int> x, y, h;

int check(int a, int b, int c) {
    rep(i, n) {
        if (h[i] != max(c - abs(x[i] - a) - abs(y[i] - b), 0)) {
            return false;
        }
    }

    return true;
}

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

    cin >> n;
    x.resize(n);
    y.resize(n);
    h.resize(n);
    int si;
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) si = i;
    }

    rep(i, 101) {
        rep(j, 101) {
            if (check(i, j, h[si] + abs(x[si] - i) + abs(y[si] - j))) {
                cout << i << " " << j << " " << h[si] + abs(x[si] - i) + abs(y[si] - j) << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define ll long longz


int main(){
    int n;
    cin >>n;
    int a[n]={0};
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    int cnt1=0,cnt2=0;
    for(int i=0;i<n;i++){
        if(a[i]%4==0&&a[i]!=0)
            a[i]=0,cnt1++;
        if(a[i]%2==0&&a[i]!=0)
            a[i]=0,cnt2++;
    }
    if(cnt1==0&&cnt2!=n) cout<<"No"<<endl;
    else if(cnt2==0){
        if(cnt1>=n/2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else if(cnt2) {
        if(cnt1+(cnt2)/2>=n/2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }



}


Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

struct SegTree(alias fun, alias E, T)
if (is(typeof(E) : T))
{
    import std.functional : binaryFun;
    alias OP = binaryFun!fun;

    ///
    this(size_t n, T[] ts) {
        this.n = 1;
        while (this.n < n) this.n *= 2;
        this.tree.length = this.n * 2 - 1;
        foreach (ref e; this.tree) e = E;
        foreach (i, e; ts) this.update(i, e);
    }

    ///
    void replace(size_t i, T e) {
        i += this.n - 1;
        this.tree[i] = e;
        while (i > 0) {
            i = (i-1) / 2;
            this.tree[i] = OP(this.tree[i*2+1], this.tree[i*2+2]);
        }
    }

    ///
    void update(size_t i, T e) {
        replace(i, OP(e, tree[i + this.n - 1]));
    }

    ///
    T query(size_t a, size_t b) {
        T impl(size_t i, size_t l, size_t r) {
            if (r <= a || b <= l) return E;
            if (a <= l && r <= b) return this.tree[i];
            return OP(
                impl(i*2+1, l, (l+r)/2),
                impl(i*2+2, (l+r)/2, r)
            );
        }
        return impl(0, 0, this.n);
    }

private:
    size_t n;
    T[] tree;
}

///
auto seg_tree(alias f, alias E, T)(size_t n, T[] arr = [])
{
    return SegTree!(f, E, T)(n, arr);
}

///
auto seg_tree(alias f, alias E, T)(T[] arr)
{
    return SegTree!(f, E, T)(arr.length, arr);
}

auto sum_seg_tree(T)(size_t n, T[] arr = [])
{
    return seg_tree!("a + b", 0, T)(n, arr);
}

auto sum_seg_tree(T)(T[] arr)
{
    return sum_seg_tree!T(arr.length, arr);
}

alias Q = Tuple!(int, "i", int, "l", int, "r");

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto qc = nq[1];
    auto cs = readln.split.to!(int[]);

    Q[] qs;
    foreach (i; 0..qc) {
        auto lr = readln.split.to!(int[]);
        qs ~= Q(i, lr[0]-1, lr[1]);
    }
    sort!"a.r < b.r"(qs);
    auto ls = new int[](N+1);
    ls[] = -1;
    auto segt = sum_seg_tree!int(N);
    auto rs = new int[](qc);
    int last_r = 0;
    foreach (q; qs) {
        while (last_r < q.r) {
            auto c = cs[last_r];
            if (ls[c] != -1) {
                segt.replace(ls[c], 0);
            }
            ls[c] = last_r;
            segt.replace(last_r, 1);
            ++last_r;
        }
        rs[q.i] = segt.query(q.l, q.r);
    }
    foreach (ref r; rs) writeln(r);
}

Measured memory_bytes: 30816
n = int(input())
card = set()
for i in range(n):
    card_type, card_num = input().split()
    card.add(card_type + card_num)
for card_type in ["S", "H", "C", "D"]:
    for card_num in range(1, 14):
        if card_type + str(card_num) not in card:
            print(card_type + " " + str(card_num))

Measured memory_bytes: 7612
from fractions import gcd

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
key = a[0]
for i in range(1, n):
  key = gcd(key, a[i])

if k > max(a):
  ans = False
elif key == 1:
  ans = True
elif k%key == a[0]%key:
  ans = True
else:
  ans = False

if ans:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 16276
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;
 
int main()
{
string s[3];
for(int i=0;i<3;i++) cin>>s[i];
for(int i=0;i<3;i++) cout<<s[i].at(i);
return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
from collections import defaultdict
from functools import reduce
N = int(input())
A = list(map(int,input().split()))

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

def sieve_Eratosthenes(n):
    f = [True]*(n+1)
    f[0] = False
    f[1] = False
    m = int(n**0.5+1)
    for i in range(2,m):
        if f[i]:
            for j in range(i*i,n+1, i):
                f[j] = False
    return f

def getPrimeLists(n):
    table = sieve_Eratosthenes(n)
    return [x for x in range(2,n+1) if table[x]]

def primeFactorization(n):
    res = defaultdict(int)
    m = int(n**0.5)
    for i in range(2,m+1):
        while n % i == 0:
            n = n//i
            res[i] += 1
    if n > 1:
        res[n] = 1
    return res

table = [0] * (10**6+10)
f = False
for a in A:
    pf = primeFactorization(a).keys()
    for p in pf:
        if table[p] > 0:
            f = True
        table[p] += 1
    if f:
        break
else:
    print('pairwise coprime')
    exit()

allgcd = reduce(gcd, A)
if allgcd == 1:
    print('setwise coprime')
    exit()

print('not coprime')


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

public class Main
{
    static List<Edge>[] lEdge;

    @SuppressWarnings("unchecked")
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int V = in.nextInt();
        int E = in.nextInt();

        used = new boolean[V];
        lEdge = new List[V];
        for (int i = 0; i < V; i++)
        {
            lEdge[i] = new ArrayList<Edge>();
        }

        for (int i = 0; i < E; i++)
        {
            addEdge(in.nextInt(), in.nextInt(), in.nextInt());
        }

        int res = 0;
        while (true)
        {
            Arrays.fill(used, false);
            int ret = dfs(0, V - 1, Integer.MAX_VALUE);
            if (ret == 0) break;
            res += ret;
        }
        System.out.println(res);
    }

    static void addEdge(int fr, int to, int cap)
    {
        lEdge[fr].add(new Edge(to, cap, lEdge[to].size()));
        lEdge[to].add(new Edge(fr, 0, lEdge[fr].size() - 1));
    }

    static class Edge
    {
        int to, cap, rev;

        public Edge(int to, int cap, int rev)
        {
            this.to = to;
            this.cap = cap;
            this.rev = rev;
        }
    }

    static boolean[] used;

    static int dfs(int fr, int to, int f)
    {
        if (fr == to) return f;
        used[fr] = true;

        for (int i = 0; i < lEdge[fr].size(); i++)
        {
            Edge e = lEdge[fr].get(i);
            if (!used[e.to] && e.cap > 0)
            {
                int dist = dfs(e.to, to, Math.min(f, e.cap));
                if (dist > 0)
                {
                    e.cap -= dist;
                    lEdge[e.to].get(e.rev).cap += dist;
                    return dist;
                }
            }
        }
        return 0;
    }

}



Measured memory_bytes: 34860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct UnionFind{
    int sz;
    vector<int> par;

    UnionFind(int sz) : sz(sz), par(sz, -1){ }
    void init(int sz){ par.assign(sz, -1); }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        sz--;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }

    int num(){
        return sz;
    }
};
// デクリメント忘れない


int main(){
    ll n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        ll a, b; cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }
    cout << uf.num() - 1 << endl;
}


Measured memory_bytes: 3788
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	N100 := N / 100
	N10 := (N - N100*100) / 10
	N1 := (N - (N100 * 100) - (N10 * 10))

	if N100 == 7 || N10 == 7 || N1 == 7 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1768
#define REP(i, n) for (int i = 0; i < (n); i++)
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

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

    cin >> a;

    vector<ll> alph(26,0);
    
    REP(i, a.length()){
        alph[int(a[i])-97]++;
    }

    ll all = (a.length()*(a.length()-1))/2;
    ll ans = 0;
    for(ll i = 0; i < 26; i++){
        ans += (alph[i]*(alph[i]-1))/2;
    }
    cout << all - ans + 1 << endl;

    return 0;
}


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

#define all(x) (x).begin(), (x).end()

using namespace std;

int main(){

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

    int n;
    int m;
    int k;
    int cnt;
    int ans;
    vector< vector<int> > p;
    vector<int> l;

    while(cin >> n, n){

        p.resize(n);

        for (auto &x : p){

            cin >> m;
            x.resize(m);

            for (auto &y : x)
                cin >> y;

        }


        cin >> k;
        l.resize(k);

        for(auto &x : l)
            cin >> x;

        sort(all(l));

        cnt = 0;
        ans = 0;

        for (int i = 0; i < n; i++){

            sort(all(p[i]));

            if(includes(all(p[i]), all(l))){
                cnt++;
                ans = i + 1;
            }

        }

        if(cnt != 1)
            cout << -1 << endl;
        else
            cout << ans << endl;

    }

    return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
#define INF (1e18)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll C[200010];
    cin >> N;
    rep(i,0,N) cin >> C[i];
    ll ans = 0;
    ll dp[200010] = {};
    dp[0] = 1;
    map<ll, ll> mp;
    rep(i,0,200010){
        mp[i] = -1;
    }
    rep(i,0,N){
        if(mp[C[i]] == -1){
            dp[i+1] = dp[i];
            mp[C[i]] = i;
        }else{
            if(mp[C[i]] + 1 == i){
                mp[C[i]] = i;
                dp[i+1] = dp[i];
                continue;
            }
            // print2(mp[C[i]], i);
            dp[i+1] += (dp[i] + dp[mp[C[i]]+1]) % MOD;
            dp[i+1] %= MOD;
            mp[C[i]] = i;
            // print(dp[i+1]);
        }
    }
    print(dp[N]);


}

Measured memory_bytes: 15872
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scan() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := scan()
	min := scan()

	var r int
	max := math.MinInt64
	for i := 0; i < n-1; i++ {
		r = scan()
		if max < r-min {
			max = r - min
		}
		if min > r {
			min = r
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 4096
def conte(n,ab,p):
    a=ab[0]
    b=ab[1]
    cnt=0
    x=0
    y=0
    z=0
    for i in range(n):
        if p[i]<=a:
            x+=1
        elif p[i]<=b:
            y+=1
        else:
            z+=1
    return min(x,y,z)
print(conte(int(input()),[int(i) for i in input().split()],[int(i) for i in input().split()]))

Measured memory_bytes: 3064
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>
#include <set> 
#include <map> 

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	string s;
	cin >> s;
	int len = s.length();
	int tmp;
	bool clear = false;
	FOR(i,1, s.length()) {
		len--;
		tmp = len/2;
		clear = true;
		if (len % 2 == 0) {
			REP(j, tmp) {
				if (s[j] != s[tmp + j]) { clear = false;  break; }
			}
			if (clear == true) break;
		}
	}
	cout << len << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N;
	std::cin >> N;

	if (N == 1)
	{
		std::cout << "Hello World" << std::endl;
		return 0;
	}

	int A, B;
	std::cin >> A >> B;

	std::cout << A + B << std::endl;
}


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

int main() {
  int64_t h, w, n;
  cin >> h >> w >> n;
  map<pair<int, int>, int> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = -1; j <= 1; j++) {
      if (a + j <= 1 or h <= a + j) continue;
      for (int k = -1; k <= 1; k++) {
        if (b + k <= 1 or w <= b + k) continue;
        m[make_pair(a + j, b + k)]++;
      }
    }
  }
  vector<int64_t> ans(10);
  for (auto x : m) {
    ans.at(x.second)++;
  }
  ans.at(0) = (h - 2) * (w - 2) - m.size();
  for (int i = 0; i < 10; i++) {
    cout << ans.at(i) << endl;
  }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var N = NK[0];
            var K = NK[1];

            int count = 0;
            
            for (int i= 0; i < N; i++)
            {
                if (h[i] >= K)
                {
                    count++;
                }
            }

            Console.WriteLine(count);

        }
    }
}

Measured memory_bytes: 16096
#include <cstdio>
#include <vector>
#define MOD (1000000007)
#define AS_MOD(x) ((((x) % MOD) + MOD) % MOD)
using namespace std;

int main() {
  int N;
  char S[2][100];
  vector<int> SV;
  scanf("%d", &N);
  scanf("%s", S[0]);
  scanf("%s", S[1]);
  for(int i=0;i<N;++i) {
    if (S[0][i]==S[0][i+1]) {
      SV.push_back(2);
      ++i;
    } else {
      SV.push_back(1);
    }
  }
  long long answer;
  if (SV[0]==1) {
    answer = 3;
  } else {
    answer = 6;
  }
  for(int i=1;i<SV.size();++i) {
    if (SV[i-1] == 1 && SV[i] == 1) {
      answer *= 2;
      answer = AS_MOD(answer);
    }
    if (SV[i-1] == 1 && SV[i] == 2) {
      answer *= 2;
      answer = AS_MOD(answer);
    }
    if (SV[i-1] == 2 && SV[i] == 2) {
      answer *= 3;
      answer = AS_MOD(answer);
    }
  }
  printf("%lld\n", AS_MOD(answer));
  return 0;
}


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

int main() {
  int n;cin>>n;
  double cnt=0;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    cnt+=a[i];
  }
  cnt/=n;
  int ans;
  double cnt1=1e9;
  rep(i,n){
    if(abs(cnt-a[i])<cnt1){
      cnt1=abs(cnt-a[i]);
      ans=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    ll result = LLONG_MAX;
    erep3(i, 1, sqrt(n)) {
        if (n % i == 0) {
            result = min(result, i - 1 + n / i - 1);
        }
    }

    print(result);
    return 0;
}

Measured memory_bytes: 3608
#7 1 100
#40 43 45 105 108 115 124
n,a,b = map(int, raw_input().split())
xis = map(int ,raw_input().split())
cost = 0
for u,v in zip(xis,xis[1:]):
	cost += min((v-u)*a, b)
print cost 

Measured memory_bytes: 89556
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
int fa1[maxn],fa2[maxn];
int n,m;
void init()
{
    for(int i=0; i<=n; i++)
    {
        fa1[i]=0;
        fa2[i]=0;
    }
}
int findd(int x)
{
    if(fa1[x]==x)
        return x;
    else
        return fa1[x]=findd(fa1[x]);
}
struct node
{
    int x,y;
};
node a[maxn];
int main()
{
    cin>>n>>m;
    init();
    for(int i=0; i<m; i++)
    {
        cin>>a[i].x>>a[i].y;
        if(a[i].x==1)
        {
            fa1[a[i].y]=1;
        }
        if(a[i].y==n)
        {
            fa2[a[i].x]=1;
        }
    }
    bool flag=0;
    for(int i=2; i<n; i++)
    {
        if(fa1[i]==1&&fa2[i]==1)
            flag=true;
    }
    if(flag)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" <<endl;
        return 0;
}


Measured memory_bytes: 3328
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    import math
    N, K = read_values()
    d = math.log(N, K)
    print(math.floor(d) + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#import <stdio.h>
#import <stdlib.h>
typedef long long INT;

typedef struct Pair {
    INT index;
    INT value;
} Pair;

int compare_value(const void *a, const void *b) {
    INT diff = ((Pair*)a)->value - ((Pair*)b)->value;
    return diff>0 ? 1: diff<0 ? -1 : 0;
}

int compare_index(const void *a, const void *b) {
    INT diff = ((Pair*)a)->index - ((Pair*)b)->index;
    return diff>0 ? 1: diff<0 ? -1 : 0;
}

int main(){
    INT N;
    scanf("%lld",&N);
    Pair X[200002];
    for(INT i=0;i<N;i++){
        INT x;
        scanf("%lld",&x);
        Pair p = {i, x};
        X[i] = p;
    }
    qsort(X, N, sizeof(Pair), compare_value);
    INT mid1 = X[N/2].value;
    INT mid2 = X[N/2-1].value;
    for(INT i=0;i<N;i++){
        X[i].value = (i<N/2) ? mid1 : mid2;
    }
    qsort(X, N, sizeof(Pair), compare_index);
    for(INT i=0;i<N;i++){
        printf("%lld\n", X[i].value);
    }
}


Measured memory_bytes: 10300
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
else:
  if len([0 for i in a if i==0])!=1 or len(set(a))!=n//2+1:
    flg=False
if flg:
  print(2**(n//2)%(10**9+7))
else:
  print(0)



Measured memory_bytes: 54636
n,k = map(int,input().split())
li = list(map(int,input().split()))
licsum = [0]
for i in range(n):
    licsum.append(licsum[i] + li[i])
lia = []
for i in range(n-k+1):
    a = licsum[k+i] - licsum[i] + k
    lia.append(float(a)/2)
print(max(lia))

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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<pair<unsigned long, unsigned long>> work(N);
    for(auto& i : work)cin >> i.first >> i.second;
    sort(work.begin(), work.end());
    priority_queue<unsigned long> pue;
    unsigned long ans{0};
    auto it = work.begin(), edn = work.end();
    for(unsigned long i = 1; i <= M; ++i){
        while(it != edn && it -> first <= i){
            pue.push(it -> second);
            ++it;
        }
        if(!pue.empty()){
            ans += pue.top();
            pue.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2936
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int main()
{
	vi a,b;
	bool hoge[300050] = {};
	for (int i = 2; i <= 300000; i++)
	{
		if (i % 7 == 1 || i % 7 == 6)a.push_back(i);
	}
	for (int i = 0; i < a.size(); i++)
	{
		if (hoge[a[i]] == false)
		{
			b.push_back(a[i]);
			for (int j = a[i]; j <= 300000; j += a[i])
			{
				hoge[j] = true;
			}
		}
	}


	int s;
	while (cin >> s&&s!=1)
	{
		cout << s<<":";
		for (int i = 0; i < b.size(); i++)
		{
			if (s%b[i] == 0)
			{
				cout << " " << b[i];
			}
		}
		cout << endl;


	}
}

Measured memory_bytes: 3648
s = input()
ans = "AC"
if s[0] == "A":
  c_cnt = 0
  for i in range(2,len(s)-1):
    if s[i] == "C":
      c_cnt += 1
  if c_cnt == 1:
    for i in s:
      if i.lower() != "a" and i.lower() != "c" and i.lower() != i:
        ans = "WA"
        break
  else:
    ans = "WA"
else:
  ans = "WA"
print(ans)

Measured memory_bytes: 62028
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int D = 3;

void solve() {
	int n, m;
	int64 answ = -INF64;
	vector<vector<int64>> a;

	cin >> n >> m;

	for(int i = 0; i < n; ++i) {
		vector<int64> v(D);

		for(auto& elem: v) {
			cin >> elem;
		}

		a.push_back(v);
	}

	for(int msk = 0; msk < (1 << D); ++msk) {
		vector<int64> b;

		for(int i = 0; i < n; ++i) {
			int64 value = 0;

			for(int j = 0; j < D; ++j) {
				int64 to_add = a[i][j];

				if((msk >> j) & 1)
					to_add = -to_add;

				value += to_add;
			}

			b.push_back(value);
		}

		sort(b.rbegin(), b.rend());
		int64 local = 0;

		for(int i = 0; i < m; ++i) {
			local += b[i];
		}

		answ = std::max(answ, local);
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 384
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int a[maxn];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, k, q;
    cin>>n>>k>>q;
    f0(i,q)
    {
        int p; cin>>p;
        if(p==1) a[p+1]+=-1;
        else {
            a[p+1]+=-1;
            a[1]+=-1;
            a[p]+=1;
        }
    }
    f1(i,n)
    {
        a[i]+=a[i-1];
        //cout << a[i] << " ";
        if(a[i]+k>0)
            cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<pair<int, int>> op(m);
	for (auto &t : op) cin >> t.first >> t.second;
	sort(op.rbegin(), op.rend(), [&](pair<int, int> x, pair<int, int> y) {
		return x.second < y.second;
	});	
	sort(a.begin(), a.end());
	vector<int> ra = a;
	int pnt = 0;
	for (auto t : op) {
		while (pnt < n && a[pnt] < t.second && t.first > 0) {
			a[pnt] = t.second;
			pnt++;
			t.first--;
		}
	}
	int s = 0;
	for (int i = 0; i < n; i++) s += a[i];
	
	cout << s << endl;
}


Measured memory_bytes: 3456
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
    int k; scan(k);

    auto a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    writeln(a[k-1]);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 256