akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll b;
ll a;
ll ans=0;

void addedge(ll u, ll v)

	{
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

bool dfs(ll node)
	{
		cout<<node<<endl;
		mark[node]=1;
		

		for(auto i:adj[node])
		{	
			if(!mark[i])
				dfs(i);
		}			

			
	}

void substring(string s,int n)
	{ 
		for(auto i=0;i<n;i++)
			{
				for(auto len=1;len<=n-i;len++)
					{	if(len==2)
						{
							string j="AB";
						if(s.substr(i,len).compare(j)==0)
							ans++;
						}
					}
			}
	}	

int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n;
string s;

ll a=0,b=0,c=0;

cin>>n;

for(auto i=1;i<=n;i++)
	{	
		cin>>s;
		
		ll z=s.length();
		
		
			if(s[0]=='B'&& s[z-1]=='A' )
				a++;
				
			if(s[0]=='B'&& s[z-1]!='A')
				b++;

			if(s[0]!='B'&& s[z-1]=='A')
				c++;
		substring(s,z);
	}

	if(a==0)
		cout<<ans + min(b,c)<<endl;

	else
	{
		if(b+c>0)
			cout<<ans+a+min(b,c)<<endl;
		else
			cout<<ans+a-1<<endl;
	}

	

	
}		





Measured memory_bytes: 2688
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,M;
vector<int> X(SIZE),P(SIZE);
map<int,int> V[SIZE];

void solve() {
    cin>>N>>M;
    REP(i,N) {
        cin>>X[i];
        int m = X[i]%M;
        P[m]++;
        V[m][X[i]]++;
    }
    int ans = 0;
    REP(i,M/2+1) {
        int j = (M-i)%M;
        if (i==j) {
            int cnt = P[i]/2;
            ans += cnt;
            P[i] -= cnt*2;
        } else {
            int cnt = min(P[i],P[j]);
            ans += cnt;
            P[i] -= cnt;
            P[j] -= cnt;
        }
    }
    REP(i,M) {
        for (auto p:V[i]) {
            if (P[i]<2) break;
            if (p.second<2) continue;
            int cnt = min(p.second/2, P[i]/2);
            ans += cnt;
            P[i] -= cnt*2;
        }
    }
    _PN(ans);
}



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

using namespace std;

const int M = 1e9 + 7;

int n;

long long a[2001];

int main()
{
    scanf("%d", &n);
    
    a[3] = 1;
    for(int i = 4; i <= n; i ++ )
    {
        for(int j = i - 3; j >= 3; j -- )
        {
            a[i] += a[j];
        }
        a[i] ++;
        a[i] %= M;
    }
    printf("%lld", a[n]);
    return 0;
}

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

int D;
long long G;
vector<long long> p, c;
int main(void){
    // Your code here!
    cin >> D >> G;
    p.resize(D);
    c.resize(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];
    
    long long res = 1<<29;
    for(int bit = 0; bit < (1<<D); bit++){
        long long sum = 0;
        long long num = 0;
        for(int i = 0; i < D; i++){
            if(bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
        }
        
        if(sum >= G) res = min(res, num);
        else{
            for(int i = D-1; i >= 0; i--){
                if(bit & (1<<i)) continue;
                for(int j = 0; j < p[i]; j++){
                    if(sum >= G) break;
                    sum += 100 * (i+1);
                    num++;
                }
            }
            res = min(res, num);
        }
    }
    
    cout <<res << endl;
}


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

int main(void) {
    int n, x=0;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++) {
        cin >> p[i];
    }
    for(int i=1; i<n-1; i++) {
        if(p[i-1]>p[i] && p[i]>p[i+1] || p[i-1]<p[i] && p[i]<p[i+1])
            x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
	int w, h, x ,y ,r;
	std::cin >> w >> h >> x >> y >> r;
	if (r <= x && x <= w - r && r <= y && y <= h - r) {
		std::cout << "Yes"  << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	if (((abs(A - B) <= D) && (abs(B - C) <= D)) || (abs(A - C) <= D))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;

int main(){
  int n, x;
  vector<int> nums;

  cin >> n >> x;

  for(int i=0; i<n; i++){
    int temp;
    cin >> temp;
    nums.push_back(temp);
  }

  sort(nums.begin(), nums.end());

  int ans = 0;
  int j=0;
  while(j<n && x > 0){
    x -= nums.at(j);
    if(x>=0){
      ans += 1;
      if(j == n-1 && x > 0){
        ans--;
      }
    }
    j++;
  }
  cout << ans;

  return 0;
}


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

using namespace std;

int main(void)
{
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> h;
    int64_t x;
    for (size_t i = 0; i < n; i++)
    {
        cin >> x;
        h.push_back(x);
    }
    sort(h.begin(), h.end(), greater<int64_t>());
    int64_t attack_cnt = 0;
    for (auto hp = h.begin(); hp != h.end(); ++hp)
    {
        if(k > 0){
            k--;
        }
        else{
            attack_cnt += *hp;
        }
    }
    cout << attack_cnt << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
bool operator< (const string &s1, const string &s2) {
  if(s2 == "*") {
    return false;
  } else if(s1 == "*") {
    return true;
  } else if((int)(s1.size()) == (int)(s2.size())) {
    for(int i=0;i<(int)(s1.size());++i) {
      if(s1[i] != s2[i]) {
        return s1[i] < s2[i];
      }
    }
    return false;
  } else {
    return (int)(s1.size()) < (int)(s2.size());
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  vector<int> v = {0, 2, 5, 5, 4, 5, 6, 3 ,7, 6};
  int n, m; cin >> n >> m;
  vector<int> a(m);
  for(int i=0;i<m;++i) {
    cin >> a[i];
  }
  vector<string> dp(n+1, "*");
  dp[0] = "";
  for(int i=0;i<n;++i) {
    if(dp[i] == "*") continue;
    for(int j=0;j<m;++j) {
      if(i + v[a[j]] > n) continue;
      if(dp[i+v[a[j]]] < dp[i] + to_string(a[j])) {
        dp[i+v[a[j]]] = dp[i] + to_string(a[j]);
      }
    }
  }
  cout << dp[n] << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	ll n,k;
	cin>>n>>k;
	int a[n];
	rep(i,n)cin>>a[i],a[i]--;

	int b[n]={};
	int i=0,s=0,c=0;
	while(true){
		if(b[i]!=0){
			s=i;
			c=c-b[i]+1;
			break;
		}
		b[i]=c+1;
		i=a[i];
		c++;
	}
	
	int ans=0;
	while(true){
		if(k==0)break;
		else if(ans==s)break;
		k--;
		ans=a[ans];
	}
	k=k%c;
	while(k>0){
		ans=a[ans];
		k--;
	}

	cout<<ans+1<<endl;

	return 0;
}


Measured memory_bytes: 5156
#include<iostream>
using namespace std;
int main(){
    
    int h,m,s,a;
    cin>>a;
    
    h=a/3600;
    
    m=(a-(h*3600))/60;
    
    s=((a-(h*3600))-(m*60));
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3092
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import qualified Data.IntMap as M

mapValuesFromList :: [(Int,String)] -> M.IntMap [String]
mapValuesFromList []         = M.empty
mapValuesFromList ((k,v):xs) = M.insertWith (\[a] b -> a:b) k [v]
                             $ mapValuesFromList xs

solve :: [(Int,String)] -> (Int,Int)
solve ps = let w = M.foldl f 0 m
            in (M.size m, w)
  where
    m = M.filter (elem "AC") $ mapValuesFromList ps
    f w vs = w + length (takeWhile (=="WA") vs)

main :: IO ()
main = do
    _ <- getLine
    ps <- map ((\[a,b] -> (read a,b)) . map BS.unpack . BS.words)
        . BS.lines <$> BS.getContents :: IO [(Int,String)]
    let (w,a) = solve ps
    print w
    print a

Measured memory_bytes: 40316
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int calc(int a, int tax) {
  return a*(tax+100)/100;
}

signed main() {
  int x, y, s;
  while (cin>>x>>y>>s,x+y+s!=0) {
    // わ　た　し　は　ご　さ　を　ゆ　る　さ　な　い
    //double tax1 = (x+100)/100.;
    //double tax2 = (y+100)/100.;
    int ans = 0;
    for (int a = 1; a < s; a++) {
      for (int b = 1; b < s; b++) {
        if (calc(a,x)+calc(b,x)==s) {
          ans = max(ans, calc(a,y)+calc(b,y));
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<li, li> pt;

#define fi first
#define se second
#define lson ((p<<1))
#define rson ((p<<1)+1)
#define mid ((L+R)>>1)
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll a, b, ans, x;
bool ok;

int main() {
    fastIO;
    cin >> a >> b;
    ll x = __gcd(a, b);
    ans = 1;
    for(li i = 2; i * i <= x; i ++) {
        ok = !(x % i);
        while(x % i == 0) x /= i;
        ans += ok;
    }
    if(x > 1) ans ++;
    cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<vector<int>> A(3,vector<int>(N+1));
    vector<vector<int>> dp(3,vector<int>(N+1));
    for(int i = 0; i < 2;i++){
        for(int j = 0; j < N;j++){
            cin >> A[i][j];
        }
    }
    dp[0][0] = 0;
    
    for(int i = 0; i < 2;i++){
        for(int j = 0; j < N;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j] + A[i][j]);
            dp[i][j+1] = max(dp[i][j+1],dp[i][j] + A[i][j]);
        }
    }
    
    cout << max(dp[2][N-1],dp[1][N]) << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long
int main()
{
   int N ;
   scanf("%d",&N);
   double x[N];

   char stringewi[10];
   char test[10]="JPY";
   double sum = 0;
   for (int i=0;i<N;i++)
   {
   scanf("%lf %s",&x[i],stringewi);

    if (strcmp(stringewi,"JPY")==0)
    {
        sum+=x[i];
        stringewi[0]='\0';
    }
    else
    {
        sum+=x[i]*380000;
        stringewi[0]='\0';
    }

   }

   printf("%.4lf",sum);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
ll mod = 1e9 + 7;
int main()
{
	static ll n, i, j, h[100000 + 10];
	ll k = 0,nmax;
	bool able = true;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	nmax = h[1];
	for (i = 2; i <= n; i++)
	{
		if (h[i] < nmax - 1) able = false;
		nmax = max(nmax, h[i]);
	}
	if (able)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1024
//AOJ 0568: Pasta
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX_N = 100, INF = 10000000;
int n, k, d, p, sch[MAX_N + 1], jud, jud2;
long long int dp[MAX_N + 1][4];
int main(){
	cin >> n >> k;
	for (int i = 0; i < k; i++){
		cin >> d >> p;
		sch[d] = p;
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= 3; j++){
			if (sch[i] == j){
				dp[i][j] = dp[i - 1][0];
				jud = 0;
				jud2 = 0;
				if (i >= 3){
					if (sch[i - 1] != 0)
						jud++;
					if (sch[i - 2] != 0)
						jud++;
					if (sch[i - 1] == j)
						jud2++;
					if (sch[i - 2] == j)
						jud2++;
					if (i == 3){
						if (jud == 0){
							dp[i][j] -= 1;
						}
						if (jud == 1 && jud2 == 1){
							dp[i][j] -= 1;
						}
					}
					if (i > 3){
						if (jud == 0){
							if (j == 1)
								dp[i][1] -= dp[i - 3][2] + dp[i - 3][3];
							if (j == 2)
								dp[i][2] -= dp[i - 3][1] + dp[i - 3][3];
							if (j == 3)
								dp[i][3] -= dp[i - 3][1] + dp[i - 3][2];
						}
						if (jud == 1 && jud2 == 1){
							if (j == 1)
								dp[i][1] -= dp[i - 3][2] + dp[i - 3][3];
							if (j == 2)
								dp[i][2] -= dp[i - 3][1] + dp[i - 3][3];
							if (j == 3)
								dp[i][3] -= dp[i - 3][1] + dp[i - 3][2];
						}
					}
				}
				dp[i][0] += dp[i][j];

			}
			if (sch[i] == 0){
				dp[i][j] = dp[i - 1][0];
				jud = 0;
				jud2 = 0;
				if (i >= 3){
					if (sch[i - 1] != 0)
						jud++;
					if (sch[i - 2] != 0)
						jud++;
					if (sch[i - 1] == j)
						jud2++;
					if (sch[i - 2] == j)
						jud2++;
					if (i == 3){
						if (jud == 0){
							dp[i][j] -= 1;
						}
						if (jud == 1 && jud2 == 1){
							dp[i][j] -= 1;
						}
						if (jud2 == 2){
							dp[i][j] -= 1;
						}
					}
					if (i > 3){
						if (jud == 0){
							if (j == 1)
								dp[i][1] -= dp[i - 3][2] + dp[i - 3][3];
							if (j == 2)
								dp[i][2] -= dp[i - 3][1] + dp[i - 3][3];
							if (j == 3)
								dp[i][3] -= dp[i - 3][1] + dp[i - 3][2];
						}
						if (jud == 1 && jud2 == 1){
							if (j == 1)
								dp[i][1] -= dp[i - 3][2] + dp[i - 3][3];
							if (j == 2)
								dp[i][2] -= dp[i - 3][1] + dp[i - 3][3];
							if (j == 3)
								dp[i][3] -= dp[i - 3][1] + dp[i - 3][2];
						}
						if (jud2 == 2){
							if (j == 1)
								dp[i][1] -= dp[i - 3][2] + dp[i - 3][3];
							if (j == 2)
								dp[i][2] -= dp[i - 3][1] + dp[i - 3][3];
							if (j == 3)
								dp[i][3] -= dp[i - 3][1] + dp[i - 3][2];
						}
					}
				}
				dp[i][0] += dp[i][j];
			}
		}
		dp[i][0]=dp[i][0]%10000;
	}
	cout << dp[n][0] % 10000 << endl;
	return 0;
}

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

int main()
{
    string s;
    cin>>s;
    int i=0;
    for(i=0;i<s.size();i++) {
        if(i%2==0) {
            if(s[i]=='L')
                break;
        }
        if(i%2==1) {
            if(s[i]=='R')
                break;
        }
    }
    if(i==s.size())
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

int main() {
    int i, j, h, w;
    cin >> h >> w;
    char d[h+2][w+2];

    for (j=0; j<h+2; j++) {
        for (i=0; i<w+2; i++) {
            if (i==0 || j==0 || j==h+1 || i==w+1) {
                d[j][i] = '#';
                continue;
            }
            cin >> d[j][i];
        }
    }

    for (j=0; j<h+2; j++) {
        for (i=0; i<w+2; i++) {
            cout << d[j][i];
        }
        cout << endl;
    }
    cout << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> H(n, 0);
    REP(i, n) cin >> H[i];

    int ans=0;
    queue<vector<int> > que;
    que.push(H);
    while(!que.empty()){
        vector<int> v = que.front();
        que.pop();
        // cout << "v is ";
        // REP(i, v.size()) cout << v[i];
        // cout << endl;
        if(v.size()==0)
            continue;
        if(v.size()==1){
            ans+=v[0];
            continue;
        }
        int mi = 1e9;
        REP(i, v.size()) mi = min(mi, v[i]);
        REP(i, v.size()) v[i]-=mi;
        ans+=mi;
        // cout << "ans " << ans << endl;
        int idx = 0;
        vector<int> tmp;
        for(int i=0; i<v.size(); i++){
            if(v[i]==0){
                que.push(tmp);
                // cout << "pushed ";
                // REP(i, tmp.size()) cout << tmp[i];
                // cout << endl;
                tmp.clear();
            }
            else
                tmp.push_back(v[i]);

        }
        if(tmp.size()!=0){
            que.push(tmp);
            // cout << "pushed "
            // REP(i, tmp.size()) cout << tmp[i];
            // cout << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */


int main(){
    ii2(n, k);
    vector<int> vec;
    rep(i, n){
        ii(x); vec.push_back(x);
    }

    int sum = 0, max_s;
    rep(i, k) sum += vec[i];
    max_s = sum;
    for(int i = k; i < n; i++){
        sum = sum - vec[i-k] + vec[i];
        if(max_s < sum) max_s = sum;
    }
    double ans = (double)(max_s + k) / 2;
    setpre(6); out(ans);
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define hell 998244353
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define pii pair<int,int>
#define L LLONG_MAX
#define all(v) (v).begin(),(v).end()
#define tcFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
//vector<int>prime(15000005,0);
ll mM(ll a,ll b,ll p=hell){ll res = 0;if(a>=p)a %= p;while(b){if (b & 1ll)res = (res + a);if(res>=p) res%= p;a = (2 * a); if(a>=p)a%=p;b >>= 1ll;}return res;}
ll fpow(ll x,ll y,ll p=hell){if(x>=p)x=x%p;ll res=1;while(y){if(y&1ll)res*=x;if(res<0)res+=p;if(res>=p)res%=p;y=y>>1ll;x*=x;if(x<0)x+=p;if(x>=p)x%=p;}return res;}
ll inv(ll n,ll p=hell){return fpow(n,p-2,p);}
ll modmul(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;return (x*y)%p;}
ll modadd(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;ll temp=x+y;if(temp>=p)temp%=p;return temp;}
/*void sieve(){
    prime[0] = -1;
    prime[1] = 0;
    for(int i=2;i<=15000000;i++)
        if(!prime[i])
            for(int j=i;j<=15000000;j+=i)
            	if(!prime[j])
            		prime[j] = i;
}*/
vector<vector<int>>adj(100005);
vector<int>dp(100005, 0), visited(100005, 0);
void dfs(int src) {
	visited[src]++;
	int ans = 0;
	for (auto e: adj[src]) {
		if (!visited[e])
			dfs(e);
		ans = max(ans, dp[e]);
	}
	if (adj[src].size())
		dp[src] = ans + 1;
} 
int main(){
	ios
	int t = 1,tc = 0;
	//cin >> t;
	while(t--){
		int n, m;
		cin >> n >> m;
		while (m--) {
			int xc, yc;
			cin >> xc >> yc;
			adj[xc].pb(yc);
		}
		for (int i = 1; i <= n; i++)
			if (!visited[i])
				dfs(i);
		int ans = 0;
		for (int i = 1; i <= n; i++)
			ans = max(ans, dp[i]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 12872
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>

int main() {
    int n, Y; std::cin >> n >> Y;
    for (int x = 0; x <= 2000; ++x) {
        for (int y = 0; y <= 2000; ++y) {
            if (n < (x+y)) continue;
            int z = n - (x+y);
            if (10000*x + 5000*y + 1000*z == Y) {
                std::cout << x << ' ' << y << ' ' << z << '\n';
                return 0;
            }
        }
    }
    std::cout << -1 << ' ' << -1 << ' ' << -1 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main () {
    	unsigned int n, x, c = 0, count = 1;
      
      	cin >> n >> x;
      	unsigned int arr[n];
      
      	for (unsigned int i = 0; i < n; ++i) {
        	cin >> arr[i];
          	
          	c += arr[i];
          
          	if (c <= x) count++;
        }
      
      	cout << count << "\n";
      
    }

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

#define rep(i, n) for(int i = 0; i < n; i++)
const double EPS = 1e-12;
 
double P, E, T;

double dfs(double R, double L, int K){
  if(K == 0){
    double T2 = (R + L) / 2;
    if(abs(T2 - T) < EPS + E){
      return 1.0;
    }
    else return 0.0;
  }
  double d1 = max(abs(T - R), abs(T - L));
  double d2 = min(abs(T - R), abs(T - L));

  if(d1 < E + EPS) return 1.0;
  if((T < R || L < T) && d2 > E) return 0.0;
  double m = (R + L) / 2;
 
  if(m < T){
    return (1 - P) * dfs(m, L, K - 1) + P * dfs(R, m, K - 1);
  }else{
    return P * dfs(m, L, K - 1) + (1 - P) * dfs(R, m, K - 1);
  }
}

int main(){
  int K, R, L;
  cin >> K >> R >> L;
  cin >> P >> E >> T;
  cout << fixed << setprecision(12) << dfs(R, L, K) << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	double ans=0.0;
	REP(i,n){
		double a;
		cin>>a;
		ans+=1.0/a;
	}
	
	ans=1.0/ans;
	
	printf("%.10f\n",ans);
	return 0;
}//解説参考.

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a,b,tmp,r;
  
  scanf("%d%d",&a,&b);
  
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  
  while(b>0){
    r = a%b;
    a = b;
    b = r;
  }
  
  printf("%d\n",a);

  return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: int):
    group = []
    if S[0] == '0':
        group.append(0)
    tmp = 1
    for i in range(1, N):
        if S[i] == S[i - 1]:
            tmp += 1
        else:
            group.append(tmp)
            tmp = 1
    group.append(tmp)
    if S[-1] == '0':
        group.append(0)
    #print(group)
    num = K * 2 + 1
    if len(group) <= num:
        print(N)
        return

    cum = [0] * len(group)
    cum[0] = group[0]
    for i in range(1, len(group)):
        cum[i] = cum[i - 1] + group[i]
    cum = [0] + cum
    #print(group)
    #print(cum)

    ret = 0
    for i in range(0, len(group) - num + 1, 2):
        cumsum = cum[i + num] - cum[i]
        #print(i, i + num, cumsum)
        ret = max(ret, cumsum)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: int
    solve(N, K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();
		int ans = 999999999;
		int[] dist = new int[n - k + 1];





		for (int i = 0; i < n - k + 1; i++) {
			dist[i] = Math.abs(x[i + k - 1] - x[i]);

			if (Math.abs(x[i + k - 1]) >= Math.abs(x[i])) {
				dist[i] += Math.abs(x[i]);
			} else {
				dist[i] += Math.abs(x[i + k - 1]);
			}
		}





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

			if (ans >= dist[i]) {
				ans = dist[i];
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 50200
#include<stdio.h>
int main()
{
  int y,ama,cou=0;
  while(1){
    cou=0;
    scanf("%d",&y);
    if(y==0){
      break;
    }
    ama=1000-y;
    if(ama>=500){
      cou+=ama/500;
      ama=ama%500;
    }
    if(ama>=100){
      cou+=ama/100;
      ama=ama%100;
    }
    if(ama>=50){
      cou+=ama/50;
      ama=ama%50;
    }
    if(ama>=10){
      cou+=ama/10;
      ama=ama%10;
    }
    if(ama>=5){
      cou+=ama/5;
      ama=ama%5;
    }
    if(ama>=1){
      cou+=ama/1;
      ama=ama%1;
    }
    printf("%d\n",cou);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	string w;
	cin>>w;
	for (int i=0;i<a;i++)
	{
		if (i==b-1)
			w[i]+=32;
		cout<<w[i];
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#ifndef KOTAISUU
#define KOTAISUU 18
#endif
#ifndef SEDAISUU
#define SEDAISUU 10000
#endif
#ifndef KAKURITU
#define KAKURITU 30 /* * 0.01 % */
#endif

static unsigned int x=123456789;
static unsigned int y=362436069;
static unsigned int z=521288629;
static unsigned int w=88675123;

void seed(unsigned int a,unsigned int b,unsigned int c,unsigned int d) {
	if((a|b|c|d)==0)return;
	x=a;y=b;z=c;w=d;
}

unsigned int randint(void) {
	unsigned int t;
	t=(x^(x<<11));
	x=y;y=z;z=w;
	w=(w^(w>>19))^(t^(t>>8));
	return w;
}

unsigned int randint2(unsigned int max) {
	unsigned int amari = ((UINT_MAX % max) + 1) % max;
	unsigned int ret;
	do {
		ret = randint();
	} while (ret < amari);
	return ret % max;
}

#define KIND 26
#define MAX 365

struct horieyui {
	int mamegu[MAX];
};

int D;
int c[KIND];
int s[MAX][KIND];

int mizuhasu(const struct horieyui* kitaeri) {
	int sumipe = 0;
	int i, j;
	int last[KIND] = {0};
	for (i = 0; i < D; i++) {
		sumipe += s[i][kitaeri->mamegu[i]];
		last[kitaeri->mamegu[i]] = i + 1;
		for (j = 0; j < KIND; j++) {
			sumipe -= c[j] * ((i + 1) - last[j]);
		}
	}
	return sumipe;
}

int main(void) {
	int i, j;
	struct horieyui otehon;
	struct horieyui saikyou;
	int saikyou_score = 0;
	if (scanf("%d", &D) != 1) return 1;
	for (i = 0; i < KIND; i++) {
		if (scanf("%d", &c[i]) != 1) return 1;
	}
	for (i = 0; i < D; i++) {
		for (j = 0; j < KIND; j++) {
			if (scanf("%d", &s[i][j]) != 1) return 1;
		}
	}

	for (i = 0; i < KIND; i++) {
		int score;
		for (j = 0; j < D; j++) otehon.mamegu[j] = (i + j) % KIND;
		score = mizuhasu(&otehon);
		if (i == 0 || score > saikyou_score) {
			saikyou = otehon;
			saikyou_score = score;
		}
	}
	otehon = saikyou;

	for (i = 0; i < SEDAISUU; i++) {
		struct horieyui saituyo;
		int saituyo_score = 0;
		for (j = 0; j < KOTAISUU; j++) {
			struct horieyui kore = otehon;
			int k;
			int score;
			for(k = 0; k < D; k++) {
				if (randint2(10000) < KAKURITU) {
					kore.mamegu[k] = randint2(KIND - 1);
					if (kore.mamegu[k] >= otehon.mamegu[k]) kore.mamegu[k]++;
				}
			}
			score = mizuhasu(&kore);
			if (j == 0 || score > saituyo_score) {
				saituyo = kore;
				saituyo_score = score;
			}
		}
		otehon = saituyo;
		if (saituyo_score > saikyou_score) {
			saikyou = saituyo;
			saikyou_score = saituyo_score;
		}
	}
	for (i = 0; i < D; i++) {
		printf("%d\n", saikyou.mamegu[i] + 1);
	}
#ifdef PRINT_SCORE
	printf("score = %d\n", saikyou_score < -1000000 ? 0 : 1000000 + saikyou_score);
#endif
	return 0;
}


Measured memory_bytes: 1772
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

pointSum(pointD, typeNum) = pointD + (typeNum * typeNum)

function main()
    n, k = readline() |> split |> parseMap
    sushi = zeros(Int, n, 2)
    for i in 1:n
        sushi[i,2], sushi[i,1] = readline() |> split |> parseMap
        # 種類が後の方が都合がよいので
    end
    sushi = sortrows(sushi, rev=true)

    pointD = 0
    typeNum = 0
    types = zeros(Int, n)
    for i in 1:k
        pointD += sushi[i, 1]
        types[sushi[i, 2]] += 1
        if types[sushi[i, 2]] == 1
            typeNum += 1
        end
    end

    ans = pointSum(pointD, typeNum)

    iRemove = k
    iAdd = k + 1

    while typeNum < k
        while iRemove > 1
            if types[sushi[iRemove, 2]] > 1
                pointD -= sushi[iRemove, 1]
                types[sushi[iRemove, 2]] -= 1
                break
            end
            iRemove -= 1
        end
        if iRemove == 1 break end
        iRemove -= 1

        while iAdd <= n
            if types[sushi[iAdd, 2]] == 0
                pointD += sushi[iAdd, 1]
                types[sushi[iAdd, 2]] += 1
                typeNum += 1
                break
            end
            iAdd += 1
        end
        if iAdd > n break end
        iAdd += 1

        ans = max(ans, pointSum(pointD, typeNum))
    end
    println(ans)
end

main()


Measured memory_bytes: 159820
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std; //
int main(){
	int S;
	cin>>S;
	cout<<S/3600<<":"<<(S%3600)/60<<":"<<(S%3600)%60<<endl;
	return 0;
}

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

int main()
{
   int a,b,c,k;
   cin>>a>>b>>c>>k;
    int ans=0;
    ans=ans+min(a,k);
    k=k-min(a,k);
    k=k-min(b,k);
    ans=ans-min(c,k);
    k=k-min(c,k);
    cout<<ans;

//    while(k>0)
//    {
//        while(a>0 && k>0)
//        {
//             ans++;
//             k--;
//             a--;
//        }
//        while(b>0 && k>0)
//        {
//             k--;
//             b--;
//        }
//        while(c>0 && k>0)
//        {
//             ans--;
//             k--;
//             c--;
//        }
//    }
//    cout<<ans;

    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N, W; cin>>N>>W;
    vector<ll> w(N), v(N);
    vector<vector<ll>> dp(N+10, vector<ll>(W+10, 0));
    for (int i = 0; i < N; i++) {
        cin>>w[i]>>v[i];
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
            if(j+w[i]<=W)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
        }
    }

    cout<<dp[N][W]<<endl;

    return 0;
}

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

const long long int INF = 1000000000000;

int main() {


    int v,e,s,t,d;

    cin >> v >> e;

    long long int table[v][v];

    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            table[i][j] = INF;
         }
    }

    for(int i=0;i<v;i++){
        table[i][i] = 0;
    }



    while(e--){
        cin >> s >> t >> d;
        table[s][t] = d;
    }

    for(int r=0;r<v;r++){
        for(int i=0;i<v;i++){
            for(int j=0;j<v;j++){
                if(table[i][j] > table[i][r] + table[r][j]){
                    if(  ( (table[i][r] == INF) && (table[r][j] < 0 ) ) || ( (table[r][j] == INF) && (table[i][r] < 0 ) ) ) {}
                    else{
                        table[i][j] = table[i][r] + table[r][j];
                    }

                }
            }
        }
    }

    for(int i=0;i<v;i++){
        if(table[i][i] != 0){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    
    for(int i=0;i<v;i++){
        if(table[i][0] != INF) {
            cout << table[i][0];
        }
        else{
            cout << "INF";
        }
        for(int j=1;j<v;j++){
            if(table[i][j] != INF) {
                cout << ' ' << table[i][j];
            }
            else{
                cout << ' ' << "INF";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define inf -(1LL<<51)
#define int long long
typedef long long ll;
#define ld long double
#define N 701
#define ff first
#define ss second
int32_t main()
{
    IOS;

   int n;
   cin >> n;
   int a[n],b[n]; 	 	
   for(int i = 0;i < n;i++)
   	cin >> a[i];
   for(int i = 0;i < n;i++)
   	cin >> b[i];
   set<pair<int,int>> s;
   for(int i = 0;i < n;i++)
   {
   		if(a[i] > b[i])
   			s.insert({a[i]-b[i],i});
   }
   int cnt = 0;
   int change[n];
   bool ch = 1;
   memset(change,0,sizeof(change));
   int d = 0;
   for(int i = 0; i < n;i++)
   {
   		if(a[i] < b[i])
   		{
   			cnt++;
   			while(a[i] < b[i])
   			{
   				if(d)
   				{
   					if(d >= b[i] - a[i])
   					{
   						d -= (b[i] - a[i]);
   						a[i] = b[i];
   						continue;
   					}
   					else
   					{
   						a[i]+=d;
   						d = 0;
   					}
   				}
   				if(s.empty())
   				{
   					ch = 0;
   					break;
   				}
   				pair<int,int> p = *s.rbegin();
   				set<pair<int,int>>::iterator it = s.end();
   				it--;
   				s.erase(it);
   				if(p.ff > b[i] - a[i])
   				{
   					p.ff -= (b[i]-a[i]);
   					a[i] = b[i];
   					d = p.ff;

   				}	
   				else
   					a[i] += p.ff;
   				change[p.ss] = 1;
   			}
   		}
   }
   if(ch == 0)
   		cout << -1;
   else
   {
   		for(int i =0;i < n;i++)
   			if(change[i])
   				cnt++;
   		cout<<cnt;
   }
    return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<vector>
#include<cassert>

using namespace std;
#define int long long
#define repeat(i,n) for(int i=0;i<(n);i++)
const int u=1e16+1000;

signed main(){
  int k; cin>> k;
  int n=50;
  vector<int> a;
  repeat(i, 50) a.push_back(i);
  repeat(i, 50) a[i]+=k/n;
  repeat(i, k%n){
    repeat(j, n){
      if(i==j) a[j]+=n;
      else a[j]-=1;
      assert(0<=a[j] and a[j]<=u);
    }
  }

  cout<< n<< endl;
  repeat(i, a.size()){
    if(i){
      cout<< " "<< a[i];
    }else{
      cout<< a[i];
    }
  }cout<< endl;

  return 0;
}


Measured memory_bytes: 256
//ABC070 D.Transit Tree Path
//
//
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
int const INF = 1001001001;

struct edge {
    int to,cost;
};
vector<edge> G[100010];
ll dist[100010];

void dfs(int v,int p,int d) {
    dist[v] = dist[p] + d;
    for(auto e: G[v]) {
        if(e.to == p) continue;
        dfs(e.to, v, e.cost);
    }
}

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

int N;
cin >> N;
rep(i,N-1) {
    int a,b,c;
    cin >> a >> b >> c;
    --a;--b;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
}
int Q,K;
cin >> Q >> K;
--K;

//適当に使わないところを利用する
dist[100005] = 0;
dfs(K,100005,0);

ll ans[100010];
rep(i,Q) {
    int x,y;
    cin >> x >> y;
    --x;--y;
    ans[i] = dist[x] + dist[y];
}

rep(i,Q) cout << ans[i] << endl;

return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
ll mo=998244353;

ll dp[303030];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	FORR(c,S) c-='0';
	
	/*
	set<int> T;
	FOR(i,1<<N) if(T.count(i)==0) {
		int mask=i;
		int cur=0;
		T.insert(i);
		for(x=0;x==0 || mask!=i;x++) {
			mask=(mask>>1) | (((mask&1)^1)<<N-1);
			T.insert(mask);
		}
		cout<<i<<" "<<x<<" ";
		FOR(x,N) cout<<(i>>x)%2;
		cout<<endl;
	}
	*/
	for(i=1;i<=N;i+=2) if(N%i==0) {
		int len=N/i;
		string T=S.substr(0,len);
		int le=0;
		x=0,y=0;
		FOR(j,N) {
			if(S[j]==0 && ((T[x]^y)==1)) {
				le=1;
				break;
			}
			if(S[j]==1 && ((T[x]^y)==0)) {
				break;
			}
			x++;
			if(x>=len) x=0,y^=1;
		}
		if(le) {
			for(y=len-1;y>=0;y--) {
				if(T[y]) {
					T[y]=0;
					le=0;
					for(y=y+1;y<len;y++) T[y]=1;
					break;
				}
			}
		}
		if(le) continue;
		ll tot=0;
		FOR(y,len) {
			tot=(tot*2+T[y])%mo;
		}
		tot++;
		dp[len]=tot;
		
	}
	ll ret=0;
	for(i=1;i<=N;i++) if(dp[i] && N%i==0) {
		for(j=i*2;j<=N;j+=i) (dp[j]+=mo-dp[i])%=mo;
		//cout<<i<<" "<<dp[i]<<"*"<<(2*i)<<endl;
		(ret+=dp[i]*(2*i))%=mo;
	}
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2128
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N,A,B;
int main(int argc, char const *argv[])
{
cin>>N>>A>>B;

cout<<min(A*N,B)<<endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    li = input().split()
    a = int(li[0])
    op = li[1]
    b = int(li[2])

    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(a // b)


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <queue>
#include <cassert>

class B {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m;
		in >> n >> m;
		std::priority_queue<std::pair<int,int>> remains;
		for (int i = 0; i < m; i++) {
			int x;
			in >> x;
			remains.push({x, i});
		}
		int result = 0;
		int previous = -1;
		for (int i = 0; i < n; i++) {
			auto best = remains.top();
			remains.pop();
			if (best.second != previous || remains.empty()) {
				result += previous == best.second;
				previous = best.second;
				--best.first;
				if (best.first > 0)
					remains.push(best);
			} else {
				auto new_best = remains.top();
				remains.pop();
				assert(new_best.second != previous);
				previous = new_best.second;
				--new_best.first;
				if (new_best.first > 0)
					remains.push(new_best);
				remains.push(best);
			}
		}
		out << result << "\n";
	}
};


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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << endl;
	return 0;
}



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


 
int main(){
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<endl;
	}else{
		cout<<"ABC"<<endl;
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>_;
    map<string,ll> mp;
    while(_--)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

}



Measured memory_bytes: 3676
M=998244353
g=lambda a,b:[(a[0]*b[0]+a[1]*b[2])%M,(a[0]*b[1]+a[1]*b[3])%M,(a[2]*b[0]+a[3]*b[2])%M,(a[2]*b[1]+a[3]*b[3])%M]
def f(n):
	e=[1,0,0,1];z=[1,1,1,0]
	while n:
		if n%2>0:e=g(e,z)
		z=g(z,z);n//=2
	return e[1]
n,m=map(int,input().split());I=[1,1];r=f(m+2*n-2);c=1
for i in range(2,n):I+=[(M-M//i)*I[M%i]%M]
for i in range(n-1):r=(r+c*(M-f(2*n-2-2*i)))%M;c=c*(m+i)*I[i+1]%M
print(r)

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

using namespace std;

int makeTime(int x){
    while(x%10 != 0){
        x++;
    }

    return x;
}

int main(void){
    int a, b, c, d, e, m;
    int aT, bT, cT, dT, eT;
    cin>>a>>b>>c>>d>>e;

    aT = makeTime(a);
    bT = makeTime(b);
    cT = makeTime(c);
    dT = makeTime(d);
    eT = makeTime(e);

    m = aT-a;
    if(m < bT-b) m = bT-b;
    if(m < cT-c) m = cT-c;
    if(m < dT-d) m = dT-d;
    if(m < eT-e) m = eT-e;
    
    cout<<aT+bT+cT+dT+eT-m<<endl;

}

Measured memory_bytes: 256
import java.io.*;

class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    while(true){
      String data[] = br.readLine().split(" ");
      int a = Integer.parseInt(data[0]);
      int b = Integer.parseInt(data[1]);
      if(a == 0 && b == 0)
    	  break;

      for(int i = 0; i < a; i++){
          for(int j = 0; j < b; j++){
              sb.append("#");
          }
          sb.append("\n");
      }
      sb.append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 25084
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static int n;
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		// input
		Scanner in = new Scanner(System.in);

		n = in.nextInt();
		List<List<Edge>> list = new ArrayList<>();
		Node[] nodeList = new Node[n];
		for (int i = 0; i < n; i++) {
			nodeList[i] = new Node(i, Integer.MAX_VALUE);
		}
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<Edge>());
		}
		for (int i = 0; i < n; i++) {
			int u = in.nextInt();
			int k = in.nextInt();
			for (int j = 0; j < k; j++) {
				int c = in.nextInt();
				int v = in.nextInt();
				list.get(u).add(new Edge(c, v));
			}
		}

		// solve
		PriorityQueue<Node> pq = new PriorityQueue<Node>(new MyComparator());
		boolean[] visited = new boolean[n];
		nodeList[0].cost = 0;
		pq.add(nodeList[0]);
		visited[0] = true;

		while (!pq.isEmpty()) {
			Node node = pq.poll();
			int fromNode = node.nodeNum;
			visited[node.nodeNum] = true;
			List<Edge> edges = list.get(fromNode);
			for (Edge edge : edges) {
				// 遷移先ノードのコストのほうが大きい場合は更新してキューに入れる
				if (nodeList[edge.toNodeNum].cost > nodeList[fromNode].cost + edge.weight) {
					nodeList[edge.toNodeNum].cost = nodeList[fromNode].cost + edge.weight;
					pq.add(nodeList[edge.toNodeNum]);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.println(i + " " + nodeList[i].cost);
		}





	}

	@SuppressWarnings("rawtypes")
	static class MyComparator implements Comparator {

		public int compare(Object o1, Object o2) {

			Node n1 = (Node) o1;
			Node n2 = (Node) o2;

			int cost1 = n1.cost;
			int cost2 = n2.cost;

			if (cost1 > cost2) {
				return 1;
			} else if (cost1 < cost2) {
				return -1;
			} else {
				return 0;
			}
		}
	}

	static class Node {
		int nodeNum;
		int cost;

		public Node(int nodeNum, int weight) {
			this.nodeNum = nodeNum;
			this.cost = weight;
		}
	}
	static class Edge {
		int toNodeNum;
		int weight;

		public Edge(int nodeNum, int weight) {
			this.toNodeNum = nodeNum;
			this.weight = weight;
		}
	}

}



Measured memory_bytes: 275352