akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_parityll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

int main()
{
   FAST/**/
   
   ll n,p;
   cin>>n>>p;
   
   string s;
   cin>>s;
   
   if(p == 2 || p == 5)
   {
       map<ll,ll> ma;
       ll ans = 0;
       for(ll i=n-1;i>-1;i--)
       {
           ll temp = ((ll)s[i]-'0');
           ma[temp%p]++;
           ans+=ma[0];
       }
       cout<<ans;
       return 0;
   }
   ll prev = 0;
   ll ans = 0;
   map<ll,ll> ma;
   ma[0] = 1;
   for(ll i=n-1;i>-1;i--)
   {
       ll curr = (powa(10,n-1-i,p)*((ll)s[i]-'0'))%p + prev;
       curr%=p;
       prev = curr;
       ans+=ma[curr];
       ma[curr]++;
   }
   cout<<ans;
   
   
   
   return 0;        
}  
   

Measured memory_bytes: 1044
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>
#include <utility>

using namespace std;
using myui = uint64_t;

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

    {
        myui N, M;
        cin >> N >> M;
        vector<pair<myui, myui>> v;
        for (myui i = 0; i < N; i++) {
            myui a,b;
            cin >> a >> b;
            v.push_back({a, b});
        }
        sort(v.begin(), v.end(), [](auto p1, auto p2){return p1.first < p2.first;});
        myui cnt = 0;
        myui cost = 0;
        for (auto it = v.cbegin(); it != v.cend() ;it++) {
            const myui needed = M-cnt;
            if (it->second <= needed) {
                cnt += it->second;
                cost += it->first*it->second;
            } else {
                cnt += needed;
                cost += it->first*needed;
            }

            if (M == cnt) break;
        }
        cout << cost << endl;
    }

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<int> p;
vector<int> isv(1000001,0);
bool sieve(int n){
  vector<bool> used(n+1,0);
  for(int i = 2;i <= n;i++){
    if(used[i])continue;
    p.push_back(i);
    int cnt = 0;
    for(int j = i;j <= n;j += i){
      used[j] = true;
      if(isv[j])cnt += isv[j];
    }
    if(cnt > 1)return false;
  }
  return true;
}

int main(){
  
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  int setwise = v[0];
  rep(i,n)setwise = __gcd(setwise,v[i]);
  rep(i,n)isv[v[i]]++;
  sieve(1000000);
  bool is = sieve(1000000);
  if(is){
    cout << "pairwise coprime\n";
  }else if(setwise == 1){
    cout << "setwise coprime\n";
  }else {
    cout << "not coprime\n";
  }

  

  return 0;
}

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

int main(void)
{
    string s, t;
    cin >> s >> t;

    int ans=0;

    rep(i,s.size()){
        if(s[i]!=t[i])ans++;
    }


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


Measured memory_bytes: 3828
from sys import stdin

def find(parent, i):
  if parent[i] == i:
    return i
  parent[i] = find(parent, parent[i])
  return parent[i]

def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[i] = j

n, k, l = map(int, stdin.readline().split())

roads = list(range(n))
rails = list(range(n))

for i in range(k):
  p, q = map(int, stdin.readline().split())
  unite(roads, p - 1, q - 1)

for i in range(l):
  p, q = map(int, stdin.readline().split())
  unite(rails, p - 1, q - 1)

d = {}
for i in range(n):
  t = (find(roads, i), find(rails, i))
  if t in d:
    d[t] += 1
  else:
    d[t] = 1

print(*[d[(find(roads, i), find(rails, i))] for i in range(n)])


Measured memory_bytes: 52716
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	ll n, sum=0, m;
	string ans="1";
	
	cin >> n;
	
	if (n==0){
		cout << 0 << endl;
		return 0;
	}
	
	int i = n>0 ? 0 : 1;
	while(1){
		sum += pow(-2, i);
		if (abs(sum)>=abs(n)) break;
		i += 2;
	}
	
//	cerr << i << endl;
	
	i--;
	
	for (; i>=0; i--){
		//cerr << i << ": sum=" << sum  << ", ans=" << ans << endl;
		if (n>0){
			if (sum-pow(2, i)>=n){
				ans += i%2==0 ? "0" : "1";
				sum -= pow(2, i);
			}else{
				ans += i%2==0 ? "1" : "0";
			}
		}else{
			if (sum+pow(2,i)<=n){
				ans += i%2==0 ? "1" : "0";
				sum += pow(2,i);
			}else{
				ans += i%2==0 ? "0" : "1";
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import math
def cal(x1, y1, x2, y2):
    return math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

N = int(input())
x = []
y = []
for i in range(N):
    tempx, tempy = map(int,input().split())
    x.append(tempx)
    y.append(tempy)
acc = 0
kaijou = 1
#N*(N-1)/2通りの経路パターン
for i in range(1, N+1):
    kaijou *= i
num_use = kaijou*(N-1) / (N*(N-1)/2)
for i in range(N):
    for j in range(i+1, N):
        val = cal(x[i], y[i], x[j], y[j])
        acc += val*num_use
print(str(acc/kaijou))


Measured memory_bytes: 3064
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 a, b;
    std::cin >> a >> b;
    std::cout << (10 <= a + b ? "error" : std::to_string(a+b)) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <cmath>
using namespace std;
 
int main()
{
    int n;
    cin >> n;    
    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end(), std::greater<int>());
    
    long long int sum = 0;
    long long int index = 1;
    for(int i=0; i<n; i++){
        if(i == 0){
            
        }else if(i == 1){
            sum += v[i-1];
        }else{
            sum += v[i-index];
            if(i%2 == 0) index++;
        }
        //cout << sum << endl;       
    }
    cout << sum << endl;       
    
    return 0;
}

Measured memory_bytes: 4316
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BTripleDots {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int K, N;
        string S;
        in>>K>>S;
        N = LEN(S);
        if(N<=K) out<<S<<'\n';
        else out<<S.substr(0, K)<<"...\n";
    }
};


int main() {
	BTripleDots solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int  main(void) {
  int cnt5 = 0, cnt7 = 0;
  int a[3];
  rep (i, 3) {
    cin >> a[i];
    if (a[i] == 5) cnt5++;
    if (a[i] == 7) cnt7++;
  }

  cout << (cnt5 == 2 && cnt7 == 1 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){
	cin.sync_with_stdio(0);
	cout << fixed << setprecision(8);
	// cin.tie(0);

	ll n;
	cin >> n;
	vector<double> vs(n);

	FOR(i,0,n) {
		cin >> vs[i];
	}
	while (vs.size() > 1) {
		sort(vs.begin(), vs.end(), [](double a, double b){return a > b;});
		double a = vs.back();
		vs.pop_back();
		double b = vs.back();
		vs.pop_back();

		double vn = (a+b)/2;
		vs.pb(vn);
	}

	cout << vs[0] << "\n";
}


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

int main(){
    int N; 
    cin >> N;
    vector<int64_t> vec(N-1);
    for(int i = 0; i < N-1; i++){
        cin >> vec.at(i);
    }
    int sum = 0;
    sum += vec.at(0) + vec.at(N-2);
    for(int i = 0; i < N-2; i++){
        sum += min(vec.at(i),vec.at(i+1));
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

// int main() {
//     ios::sync_with_stdio(false);
//     cin.tie(nullptr);
    
//     int n;
//     cin >> n;
//     vll a(n);
//     rep(i, n) cin >> a[i];
//     vll l(n+1), r(n+1);
//     l[n] = 2;
//     r[n] = 2;
//     for (int i = n-1; i >= 0; --i) {
//         ll mn = (l[i+1] + a[i] - 1) / a[i] * a[i];
//         ll mx = r[i+1] / a[i] * a[i];
//         if (!(mn <= mx)) {
//             cout << -1 << endl;
//             return 0;
//         }
//         l[i] = mn;
//         r[i] = mx + a[i] - 1;
//     }
//     cout << l[0] << " " << r[0] << endl;
// }

int main() {
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    
    auto f = [&](ll x) {
        for (int i = 0; i < n; ++i) {
            x = x - x%a[i];
        }
        return x;
    };
    ll mn, mx;
    ll sm = accumulate(all(a), 0LL);
    ll l = 0, r = 2 + sm;
    while (r - l > 1) {
        ll m = (l + r) >> 1;
        if (f(m) >= 2) r = m;
        else l = m; 
    }
    mn = r;
    l = 0, r = 2 + sm;
    while (r - l > 1) {
        ll m = (l + r) >> 1;
        if (f(m) <= 2) l = m;
        else r = m;
    }
    mx = l;
    if (mn > mx) cout << -1 << endl;
    else cout << mn << " " << mx << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    vector <int> s{a,b,c};
    int a5,a7=0;
    for (int i=0;i<3;i++){
        if (s[i]==5){
            a5+=1;
        }
        if (s[i]==7){
            a7+=1;
        }
    }
        if (a5==2 && a7==1){
            cout << "YES"<< endl;
        }else{
            cout << "NO" << endl;
        }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int n,a,b,h[100000],i,l,m,r;
long long x;
main(){
  for(scanf("%d%d%d",&n,&a,&b),a-=b;i<n;l=1,r=1e9)scanf("%d",h+i++);
  while(l<r){
    m=(l+r)/2;
    for(x=i=0;i<n;++i)h[i]>(long long)m*b?x+=(h[i]-m*b+a-1)/a:0;
    x<=m?r=m:l=m+1;
  }
  printf("%d\n",l);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	double l;
	cin>>l;
	l/=3;
	l=l*l*l;
	printf("%.9f",l);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int mn = min(x, y);
  int ab = min(a+b, 2*c);
  ll ans = ab * mn + (x-mn)*min(a,2*c) + (y-mn)*min(b,2*c);
  cout << ans << "\n";
  return 0;
}


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

int main(){
    int N;
    cin >> N ;
    vector<int> A(N),X(N);
    rep(i,N) cin >> A[i];
    X[0]=0;
    rep(i,N){
        X[0]+=pow(-1,i)*A[i];
    }
    cout << X[0] << " ";
    rep2(i,1,N){
        X[i]=2*A[i-1]-X[i-1];
        cout << X[i] << " ";
    }
    cout << endl;

   
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

  vector<int> l(n);
    for(int i=0; i<n; i++){
      cin >> l[i];
    }
    int ans = 1;
    int d = 0;
    for(int i=0; i<n; i++){
      d += l[i];
      if(d <= x) ans++;
    }

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

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

using namespace std ;

const int MAX = 2e5 + 10 ;

vector< vector<int> >adj1(MAX) , adj2(MAX) ;
vector< vector< pair<int , int> > >vp(MAX) ;

int n , k , l ;
int comp[MAX] , vis[MAX] , ans[MAX];
int cnt = 0 ;

void dfs1(int node)
{
	vis[node] = 1 ;
	comp[node] = cnt ;
	for(auto &child : adj1[node])
	{
		if(vis[child])
			continue ;
		dfs1(child) ;
	}
	return ;
}

void dfs2(int node)
{
	vis[node] = 1 ;
	vp[cnt].push_back({comp[node] , node}) ;
	for(auto &child : adj2[node])
	{
		if(vis[child])
			continue ;
		dfs2(child) ;
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k>>l ;
	for(int i = 0 ; i < k ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj1[x].push_back(y) ;
		adj1[y].push_back(x) ;
	}
	for(int i = 0 ; i < l ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj2[x].push_back(y) ;
		adj2[y].push_back(x) ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		if(vis[i])
			continue ;
		cnt++ ;
		dfs1(i) ;
	}
	memset(vis , 0 , sizeof(vis)) ;
	cnt = 0 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		if(vis[i])
			continue ;
		cnt++ ;
		dfs2(i) ;
		sort(vp[cnt].begin() , vp[cnt].end()) ;
		for(auto &node : vp[cnt])
		{
			int idx1 = lower_bound(vp[cnt].begin() , vp[cnt].end() , make_pair(node.first , -1)) - vp[cnt].begin() ;
			int idx2 = lower_bound(vp[cnt].begin() , vp[cnt].end() , make_pair(node.first+1 , -1)) - vp[cnt].begin() ;
			ans[node.second] = idx2 - idx1 ;
		}
	}
	for(int i = 1 ; i <= n ; ++i)
		cout<<ans[i]<<" ";
	return 0 ;
}

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

int main(){

        int x,y;

        cin >> x >> y;

        if(x<y){
                cout << "a < b" <<endl;
                return 0;
        }else if(x>y){
                cout << "a > b" <<endl;
                return 0;
        }else{
                cout << "a == b" <<endl;
                return 0;
        }

}


Measured memory_bytes: 3136
l1 = list(map(int,input().split()))

y = 0
for i in range(3):
    if l1[(i+0)%3] == l1[(i+1)%3] and l1[(i+1)%3] != l1[(i+2)%3]:
        y = 1
if y == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import numpy as np
H,W=map(int,input().split())
M=[list(list("."+input()+".")) for i in range(H)]
M=[[1 if s=='#' else 0 for s in M[h]] for h in range(H)]
L=np.array(M)
M=np.array(M)
N=[0]*(W+2)
M=np.vstack((M, N))
M=np.vstack((N, M))
Ans=np.zeros((H,W))
for h in range(H):
  for w in range(W):
    if M[h+1][w+1]==0:
      continue
    else:
      Ans[h][w]=M[h+1][w+1]+M[h][w+1]+M[h+2][w+1]+M[h+1][w]+M[h+1][w+2]
if np.any(Ans==1):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 12512
N,M=map(int,input().split())
H=list(map(int,input().split()))
ans=[1 for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())  
  if H[A-1]>H[B-1]:
    if H[A-1]!=0:
      ans[B-1]=0
  elif H[A-1]<H[B-1]:
    if H[B-1]!=0:
      ans[A-1]=0
  else:
    ans[A-1]=0
    ans[B-1]=0
print(ans.count(1))

Measured memory_bytes: 19884
package main

import (
	"fmt"
)

func main() {
	var flds string

	fmt.Scan(&flds)
	grid := []rune(flds)
	count := 0
	for _, v := range grid {
		if v == '1' {
			count++
		}
	}

	fmt.Printf("%d\n", count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll H[200005],P[200005]; 

ll c(ll x,ll y)
{
	if(x%y)
		return x/y+1;
	return x/y;
}

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m,d,a,lo=0,prev=0;

	cin >> n >> d >> a;
	vector<pll>v;
	for(i=1;i<=n;i++)
	{
		cin >> x >> y;
		v.pb(mp(x,y));
	}

	sort(all(v));
	for(i=1;i<=n;i++)
		P[i]=v[i-1].ff,H[i]=v[i-1].ss;

	vector<ll>sm,bombs;
	
	bombs.pb(P[1]+d),sm.pb(prev+c(H[1],a)),prev+=c(H[1],a);
	
	for(i=2;i<=n;i++)
	{
		ll idx=lower_bound(all(bombs),P[i]-d)-bombs.begin();
		ll idx1=upper_bound(all(bombs),P[i]+d)-bombs.begin();
		ll left=H[i];
		
		// cout<<idx<<" "<<idx1<<endl;

		left-=sm[idx1-1]*a;
		if(idx)
			left+=sm[idx-1]*a;
		if(left>0)
			bombs.pb(P[i]+d),sm.pb(prev+c(left,a)),prev+=c(left,a);
	}

	// cout<<sm[0]<<" "<<sm[1]<<" "<<sm[2]<<endl;
	cout<<prev<<endl;
}

Measured memory_bytes: 12524
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define llint long long
#define eps 1e-9

using namespace std;

llint n;
llint xs, ys, xt, yt;
llint x[1005], y[1005], r[1005];
vector<llint> vec;

llint V;
vector<llint> G[1005];
vector<llint> topo;
bool used[1005];
llint dp[1005];

void tpsort(llint v)
{
	used[v] = true;
	for(llint i = 0; i < G[v].size(); i++){
		if(used[G[v][i]]) continue;
		tpsort(G[v][i]);
	}
	topo.push_back(v);
}

llint dist2(llint x1, llint y1, llint x2, llint y2)
{
	llint ret2 = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
	return ret2;
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		cin >> xs >> ys >> xt >> yt;
		for(llint i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
		
		vec.clear();
		for(llint i = 0; i < n; i++){
			if(dist2(x[i], y[i], xs, ys) < r[i]*r[i] != dist2(x[i], y[i], xt, yt) < r[i]*r[i]){
				vec.push_back(i);
			}
		}
		V = vec.size();
		
		for(llint i = 0; i < V; i++){
			G[i].clear();
			for(llint j = 0; j < V; j++){
				if(i == j) continue;
				llint I = vec[i], J = vec[j];
				if(dist2(x[I], y[I], xs, ys) < r[I]*r[I] && dist2(x[J], y[J], xs, ys) < r[J] * r[J]){
					if(r[I] < r[J] && dist2(x[I], y[I], x[J], y[J]) < (r[J]-r[I])*(r[J]-r[I])) G[i].push_back(j);
				}
				if(dist2(x[I], y[I], xt, yt) < r[I]*r[I] && dist2(x[J], y[J], xt, yt) < r[J] * r[J]){
					if(r[I] > r[J] && dist2(x[I], y[I], x[J], y[J]) < (r[I]-r[J])*(r[I]-r[J])) G[i].push_back(j);
				}
				if(dist2(x[I], y[I], xs, ys) < r[I]*r[I] && dist2(x[J], y[J], xt, yt) < r[J]*r[J]){
					if(dist2(x[I], y[I], x[J], y[J]) > (r[I]+r[J])*(r[I]+r[J])) G[i].push_back(j);
				}
			}
		}
		G[V].clear();
		for(llint i = 0; i < V; i++) G[V].push_back(i);
		
		topo.clear();
		for(llint i = 0; i <= V; i++) used[i] = false;
		for(llint i = 0; i <= V; i++){
			if(!used[i]) tpsort(i);
		}
		reverse(topo.begin(), topo.end());
		
		for(llint i = 0; i <= V; i++) dp[i] = 0;
		for(llint i = 0; i < topo.size(); i++){
			llint v = topo[i];
			for(llint j = 0; j < G[v].size(); j++){
				dp[G[v][j]] = max(dp[G[v][j]], dp[v] + 1);
			}
		}
		
		llint ans = 0;
		for(llint i = 0; i <= V; i++) ans = max(ans, dp[i]);
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 11560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		String s = scanner.next();
		String t = scanner.next();

		int gcd = gcd(n, m);
		long lcm = (long)n/gcd*m;

		for(int kn=0; kn<n; kn+=n/gcd){
			int km = (int)((long)m*kn/n);
			if (s.charAt(kn)!=t.charAt(km)) {
				System.out.println(-1);
				System.exit(0);
			}
		}
		System.out.println(lcm);


	}

	static int gcd(int a, int b){
		if (a<b){	//a>=bほしょー
			int c = a;	a = b;	b = c;
		}
		while(a%b!=0) {
			int c = a%b;	a=b;	b=c;
		}
		return b;
	}

}

Measured memory_bytes: 26832
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
const int N = 1e5 + 5; 
int n,k;
int a[N];
int dp[N];
int func(int idx){
	if(idx >= n) return INT_MAX;
	if(idx == n-1) return 0;
	if(dp[idx] != -1) return dp[idx];
	int ans = INT_MAX;
	for(int i = 1; i<=k && (idx+i < n); i++){                  //(idx+i < n) this cond is important otheriwse youwould get runtime error
		ans = min(ans, abs(a[idx]-a[idx+i])+func(idx+i) );
	}	
	return dp[idx] = ans;
}


int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){
memset(dp,-1,sizeof(dp));
cin >> n >> k;
for(int i = 0; i<n;i++){
	cin >> a[i];
}
cout << func(0);








}
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

Measured memory_bytes: 12952
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if (n==3){
		puts("2 5 63");
		return 0;
	}
	for (int i=1;i<n;i++)
		if (i*2<=30000&&(n-i)*6<=30000&&i%3!=1&&(n-i)%2==0){
			for (int j=1;j<=i;j++)printf("%d ",j*2);
			for (int j=1;j<=n-i;j++)printf("%d ",j*6-3);
			return 0;
		}
} 

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a == 5 && b == 5 & c == 7)
    cout<<"YES"<<endl;
  else if(a == 5 && b == 7 & c == 5)
    cout<<"YES"<<endl;
  else if(a == 7 && b == 5 & c == 5)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::cmp::max;

fn main() {

    let stdin = io::stdin();
    let mut lines = stdin.lock().lines().map(|x| x.unwrap());

    let num_days: usize = lines.next().unwrap().trim().parse().unwrap();
    let mut days: Vec<Vec<u32>> = vec![];
    for _ in 0..num_days {
        let day = lines.next().unwrap().trim().split_whitespace().map(|x| x.parse().expect("Error")).collect();
        days.push(day);
    }

    let mut dp = vec![vec![0; 3]; num_days];

    for i in 0..3 {
        dp[0][i] = days[0][i];
    }

    for i in 1..num_days {
        for j in 0..3 {
            let mut max_prev = 0;
            for k in 0..3 {
                if j == k { continue }
                max_prev = max(max_prev, dp[i-1][k])
            }
            dp[i][j] = days[i][j] + max_prev;
        }
    }

    let result: &u32 = dp[num_days-1].iter().max().unwrap();
    println!("{}", result);
}

Measured memory_bytes: 14712
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 4;

int n, a[N];

bool winUp(int id) {
    int h = id + 1;
    return ((a[id] - h) & 1) ^ 1;
}

bool winR(int id) {
    int h = id + 1;
    int cnt = 0;
    for (int i = id + 1; a[i] == h && i < n; ++i) {
        ++cnt;
    }

    return (cnt & 1) ^ 1;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n, greater<int>());

    int id = n - 1, h = 1;
    for (int i = 0; i < n; ++i) {
        if (h > a[i]) {
            id = i - 1;
            break;
        }
        ++h;
    }

    bool winTwo = (winUp(id) && winR(id));
    if (winTwo) {
        cout << "Second\n";
    } else {
        cout << "First\n";
    }
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


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

int main() {
    long long A,B,N;
    cin >> A >> B >> N;
    long long ans=0;

    long long m=N;

    if(B-1<N) m=B-1;

    ans=(A*(m%B))/B;

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
 
using namespace std;
 
int solve(void);
int getValue(const vector<string> &v, int &itr, const int depth = 0);
 
int main(void) {
  
    while (solve()) {}
 
    return 0;
 
}
 
int solve(void) {
 
    int n;
 
    cin >> n;
 
    if ( !n ) { return 0; }
 
    vector<string> str(n);
     
    for (int i = 0; i < n; i++) {
        cin >> str[i];
    }
 
    int itr = 0;
 
    cout << getValue(str, itr) << endl;
    
    return 1;
}
 
int getValue(const vector<string>& v, int &itr, const int depth)
{
 
    int len = v[itr].length();
    char ch = v[itr][len - 1];
    int ret;
 
    itr++;
    if (ch == '*') {
        //multiply
        ret = 1;
        while (itr<v.size() && v[itr].length() - 1 > depth) {
            ret *= getValue(v, itr, v[itr].length() - 1);
        }
    }
    else if (ch == '+') {
        //plus
        ret = 0;
        while (itr < v.size() && v[itr].length() - 1 > depth) {
            ret += getValue(v, itr, v[itr].length() - 1);
        }
    }   
    else {
        //numbers
        ret = ch - '0';
    }
 
 
    return ret;
}

Measured memory_bytes: 3228
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n%2==0 || n%5 == 0){
			System.out.println("-1");
			return;
		}
		int tmp = 0;
		for(int i=0;i<n;i++){
			tmp = tmp * 10 + 7;
			if(tmp%n==0){
				System.out.println(i+1);
				return;
			}else{
				tmp = tmp % n;
			}
		}
		System.out.println("-1");
  }
}

Measured memory_bytes: 35636
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		StringBuilder sb = new StringBuilder();
		int sa = 'A' - 'a';
		sb.append((char)(a.charAt(0) + sa));
		sb.append((char)(b.charAt(0) + sa));
		sb.append((char)(c.charAt(0) + sa));
		System.out.println(sb);
	}
}

Measured memory_bytes: 21844
n = int(input())
data_1 = list(map(int,input().split()))
m = int(input())
data_2 = [input().split() for i in range(m)]


for i in range(m):
    sum = 0
    b = int(data_2[i][0]) - 1
    a = data_1[b]
    data_1[b] = int(data_2[i][1])
    for j in range(n):
        sum += data_1[j]
    print(sum)
    data_1[b] = a

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if (A > K) {
 cout << K << endl;
  
}
if (A <= K && K - A >= B && K - A - B <= C) {
  cout << A + B * 0 + (K - A - B) * (-1) << endl;
}
  if (A <= K && K - A >= B && K - A - B > C) {
  cout << A + B * 0 + C * (-1) << endl;
}
  
if (A <= K && K - A < B ) {
  cout << A + (K - A) * 0 << endl;  
  
}
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

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

	bool ok = false;
	for (int i = n; i >= 0 && !ok; i -= 4) {
		if (i % 7 == 0) {
			ok = true;
		}
	}
	
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

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

    cout << n*(n-1)/2+m*(m-1)/2 << endl ;
}

Measured memory_bytes: 3564
#include <stdio.h>

int GCD(int a, int b){
	int r = a % b;
	return r == 0 ? b : GCD(b, r);
}

int main(){
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	printf("%d\n", GCD(a, b));

	return 0;
}



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

int main() {
  string str;
  cin>> str;
  if(str=="A"||str=="B"||str=="C"||str=="D"||str=="E"||str=="F"||str=="G"||
     str=="H"||str=="I"||str=="J"||str=="K"||
     str=="L"||str=="M"||str=="N"||str=="O"||str=="P"||str=="Q"||str=="R"||
     str=="S"||str=="T"||str=="U"||str=="V"||
     str=="W"||str=="X"||str=="Y"||str=="Z"){
  cout << "A" << endl;
  }
  else
    cout << "a" << endl;
}


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

using namespace std;

int main() {
  // T: the idea is that dp[i][x] holds the number of
  // ways to form a permutation of (0, 1, ..., i-1) satisfying
  // the < and > constraints and ending with x.  Then future
  // states can be created by inserting into these permutations.
  //
  // Need prefix sums again to make it go fast enough

  cin.tie(0);
  cin.sync_with_stdio(0);

  int n; cin >> n;
  string s; cin >> s;
  long long MOD = 1e9+7;

  long long dp[n][n];
  for(int i = 0; i<n; ++i) {
    for(int j = 0; j<n; ++j) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for(int i = 1; i<n; ++i) {
    // Compute prefix sums
    long long pref[i+1];
    pref[0] = 0;
    for(int j = 0; j<i; ++j) {
      pref[j+1] = ((pref[j] + dp[i-1][j])%MOD + MOD) % MOD;
    }
    // So to get the sum from x to y of dp[i-1][j], you just
    // take dp[i-1][y+1] - dp[i-1][x]

    for(int x = 0; x<=i; ++x) {
      // suppose you've created 0 2 1 3, and are looking to
      // make the permutation go from 0 to 4 instead.
      // there's these 5 places to insert a number:
      //   0   1   2   3
      // |   |   |   |   |
      // and then shift the rest of the numbers over, forming
      // 1 3 2 4 0  (>)
      // 0 3 2 4 1  (>)
      // 0 3 1 4 2  (>)
      // 0 2 1 4 3  (>)
      // 0 2 1 3 4  (<)
      //
      // So > gets x to i-1, and < gets 0 to x-1
      if(s[i-1] == '<') {
        // dp[i][x] = sum of y from 0 to x-1 of dp[i-1][y]
        dp[i][x] = ((pref[x] - pref[0])%MOD + MOD) % MOD;
      }
      else {
        // dp[i][x] = sum of y from x to i-1 of dp[i-1][y]
        dp[i][x] = ((pref[i] - pref[x])%MOD + MOD) % MOD;
      }
    }
  }

  long long ret = 0;
  for(int i = 0; i<n; ++i) {
    ret = (ret + dp[n-1][i]) % MOD;
  }
  cout << ret << endl;
}


Measured memory_bytes: 70656
s = str(input())
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print("Yes")
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print("Yes")
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys
from collections import deque
s = input()
q = int(input())
dq = deque(s)
rev = False
for i in range(q):
    t = input().split()
    if t[0] == "1":
        rev = not rev
    else:
        if t[1] == "1":
            if rev:
                dq.append(t[2])
            else:
                dq.appendleft(t[2])
        else:
            if rev:
                dq.appendleft(t[2])
            else:
                dq.append(t[2])
s = "".join(list(dq))
if rev:
    print(s[::-1])
else:
    print(s)

Measured memory_bytes: 8692
#include <stdio.h>
int N, Q, S[100000], T[50000];
void input(void);
int bisearch(int s, int e, int k);
int counter(void);
int main(void) {
    //freopen("in.txt", "r", stdin);
    input();
    printf("%d\n", counter());
    return 0;
}
int counter(void){
    int i, cnt = 0;
    for(i = 0; i < Q; i++)
        if (bisearch(0, N - 1, T[i]) != -1) cnt++;
    return cnt;
}
int bisearch(int s, int e, int k){
    if (s <= e){
        int m = (s + e) / 2;
        if (k == S[m])
            return m;
        if (k < S[m])
            return bisearch(s, m - 1, k);
        if (k > S[m])
            return bisearch(m + 1, e, k);
    }
    return -1;
}
void input(void){
    int i;
    scanf("%d", &N);
    for(i = 0; i < N; i++) scanf("%d", &S[i]);
    scanf("%d", &Q);
    for(i = 0; i < Q; i++) scanf("%d", &T[i]);
}

Measured memory_bytes: 1616
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  myconst = 7 % k
  cnt = 1
  while True:
    if not myconst:
      print(cnt)
      break
    else:
      myconst = ((10 * myconst) + 7) % k
    cnt += 1
 
      


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

int check[1000000 + 5];

void sieve()
{
check[1] = 1;
for(int i = 4; i <= 1000000; i += 2)
check[i] = 1;
for(int i = 3; i <= 1000; i += 2)
for(int j = i * i; j <= 1000000; j += i + i)
check[j] = 1;
for(int i = 1; i <= 1000000; i++)
check[i] += check[i - 1];
}

int main()
{
sieve();
int n;
while(cin >> n)
cout << n - check[n] << endl;
return 0;
}

Measured memory_bytes: 6904
#include"bits/stdc++.h"
#define fastio ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define ict int t; cin >> t
#define lct ll t; cin >> t;
#define in(a) int a; cin >> a
#define ln(a) ll a; cin >> a
#define loop(i,n) for (ll i = 0; i < n; ++i) 
#define looprev(i,n) for (ll i=n-1; i>=0 ; --i)
#define LOOP(i,k,n) for (ll i = k; i <= n; ++i) 
#define LOOPREV(i,k,n) for (ll i = k; i >= n; --i) 
#define mp make_pair 
#define pa pair <ll,ll>
#define vec vector<ll>
#define vecpa vector<pa>
#define vec2D vector <ll<ll>>
#define que queue<ll>
#define deq deque<ll> 
#define stk stack<ll>
#define iterate vector<ll>::iterator
#define pub push_back
#define pob pop_back
#define pof pop_front
#define puf push_front
#define emp emplace_back
#define all(a) a.begin(),a.end();

using namespace std;

void solve(){
   ll n,k,t;
   cin >> n >> k >> t;
   if(n%k == 0) cout << (n/k)*t << endl;
   else    cout << (n/k+1)*t << endl;

}

int main()
{
    fastio;
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

string A(string s){
    reverse(s.begin(),s.end());
    return s;
}

string J(string s){
    string ss = s.substr(s.length()-1,1),sss=s.substr(0,s.length()-1);
    return ss+sss;
}

string C(string s){
    string ss = s.substr(0,1),sss=s.substr(1,s.length()-1);
    return sss+ss;
}

string E(string s){
    if(s.length()%2==0){
        string ss = s.substr(0,s.length()/2);
        string sss = s.substr(s.length()/2,s.length()/2);
        return sss+ss;
    }else{
        string ss = s.substr(0,s.length()/2);
        string tt = s.substr(s.length()/2,1);
        string sss = s.substr(s.length()/2+1,s.length()/2);
        return sss+tt+ss;
    }
}

string P(string s){
    for (int i=0; i<s.length(); i++) {
        if (s[i]=='9' or s[i]=='1' or s[i]=='2' or s[i]=='3' or s[i]=='4' or s[i]=='5' or s[i]=='6' or s[i]=='7' or s[i]=='8') {
            s[i]=(char)((int)s[i]-1);
            continue;
        }
        if (s[i]=='0') {
            s[i]='9';
        }
    }
    return s;
}

string M(string s){
    for (int i=0; i<s.length(); i++) {
        if (s[i]=='0' or s[i]=='1' or s[i]=='2' or s[i]=='3' or s[i]=='4' or s[i]=='5' or s[i]=='6' or s[i]=='7' or s[i]=='8') {
            s[i]=(char)((int)s[i]+1);
            continue;
        }
        if (s[i]=='9') {
            s[i]='0';
        }
    }
    return s;
}


int main(){
    int n;
    cin >> n;
    for (int wq=0; wq<n; wq++) {
        string t,s;
        cin >> t >>s;
        for (int i= t.length()-1; i>=0; i--) {
            if(t[i]=='J') s = J(s);
            if(t[i]=='C') s = C(s);
            if(t[i]=='E') s = E(s);
            if(t[i]=='A') s = A(s);
            if(t[i]=='P') s = P(s);
            if(t[i]=='M') s = M(s);
        }
        cout << s <<endl;
    }
}

Measured memory_bytes: 1212
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n, ans = 1, a;
    bool b0 = false, b1 = false;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a == 0)
            b0 = true;
        if (ans != 0 && (ll)1e18 / ans < a)
            ans = 0;
        else
            ans *= a;
    }
    if (b0 || ans)
        cout << ans;
    else
        cout << "-1";
    return 0;
}

Measured memory_bytes: 3196
#include "bits/stdc++.h"

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

using namespace std;
const long long MOD = 998244353;

long long modPow(int n, int num) {
	if (num == 0) return 1;
	long long res = modPow(n, num / 2);
	if (num % 2 == 0) res = (res * res) % MOD;
	else res = (((res * res) % MOD) * n) % MOD;
	return res;
}

// k回ループで、毎回逆元を掛けたやつを足していく
// その過程の値全部保存しておこう
long long modNck(int n, int k, vector<long long> &nums) {
	long long res = 1;
	nums.push_back(res);
	for (int i = 0; i < k; i++) {
		res = (res * ((long long)n - i) % MOD * modPow(i + 1, MOD - 2)) % MOD;
		nums.push_back(res);
	}
	return res;
}

int main() {
	int N, M, K;
	cin >> N >> M >> K;

	long long ans = 0;
	long long pow = M;
	vector<long long> nums;
	modNck(N - 1, K, nums);
	
	for (int i = N - 1; i >= 0; --i) {
		if (i <= K) {
			//cout << i << endl;
			long long num = (nums[i] * pow) % MOD;
			ans += num;
			ans %= MOD;
			//cout << ans << endl;
		}
		pow *= (long long)M - 1;
		pow %= MOD;
	}
	cout << ans;

}

Measured memory_bytes: 5284
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

int main()
{
    ios_base::sync_with_stdio(0);
    //ll n,c,cnt=0,prev;
    string s;
    cin>>s;
    set<char> ss;
    for(int i=0;i<s.size();i++)
    {
        ss.insert(s[i]);
    }
    if(ss.size()==s.size())
        cout<<"yes\n";
    else
        cout<<"no\n";
}




Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
use std::collections::BTreeSet;
fn main(){
    input!{
        n: usize,
        w: [chars; n]
    }
    let mut ans = "Yes";

    let mut set = BTreeSet::new();
    for w in w.iter(){
        if set.contains(w){
            ans = "No";
        }
        set.insert(w.clone());
    }

    for i in 0..n-1{
        if w[i].last() != w[i+1].first(){
            ans = "No";
        }
    }

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



Measured memory_bytes: 4352