akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  float X;
  cin >> X;
  float deg = X;
  float T = 3.14159265/180;
  int t = 0;
  float x = 0, y = 0;
  float e = 0.001;
  while (true) {
    t++;
    x -= sin(deg*T);
    y -= cos(deg*T);
    deg += X;
    //cout << X << endl;
    //cout << x << " " << y << endl;
    if (-1*e <= x && x <= e && -1*e <= y && y <= e) {
      break;
    }
  }
  cout << t << endl;
}


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

int main(void){

    int n;

    scanf("%d", &n);

    int a[n];

    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    int b[n];
    int t = 0;

    for(int i = n-1; i >= 0; i--){
        if(i % 2 == 0){
            b[t] = a[i];
            t++;
        }
    }

    for(int i = 0; i < n; i++){
        if(i % 2 == 1){
            b[t] = a[i];
            t++;
        }
    }

    if(n % 2 == 0){
        for(int i = n-1; i > 0; i--){
            printf("%d ", b[i]);
        }
        printf("%d\n", b[0]);
    }else{
        for(int i = 0; i < n-1; i++){
            printf("%d ", b[i]);
        }
        printf("%d\n", b[n-1]);
    }

    return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#define int long long
typedef long long ll;
using namespace std;

signed main(){
    ll a, b, n, flag=1;
    cin >> n;
    for(b=0;b<500;b++){
        ll num = n + pow(b, 5);
        double dd = pow(num, 0.2);
        int d = dd;
        if(num==pow(d, 5)){
            a = (pow(num, 0.2));
            break;
        }
        num = n - pow(b, 5);
        
        if(num>0){
            d = pow(num, 0.2);
            if(num==pow(d, 5)){
                a = (pow(num, 0.2));
                flag = -1;
                break;
            }
        }
    }
    cout << a << " " << b*flag << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+5;
LL cnt[maxn]; LL a[maxn];
int main(void)
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		cnt[a[i]]++;
	}
	LL res=0;
	for(int i=1;i<=n;i++) res+=cnt[i]*(cnt[i]-1)/2;
	for(int i=1;i<=n;i++)
	{
		LL t=res-1ll*cnt[a[i]]*(cnt[a[i]]-1)/2;
		LL x=cnt[a[i]]-1;
		printf("%lld\n",t+x*(x-1)/2);
	}
	return 0;
}


Measured memory_bytes: 4736
import sys


sys.setrecursionlimit(10 ** 6)


def dfs(v):
    path.append(v)
    visited[v] = 1
    nv = A[v]
    if visited[nv] == 1:
        return nv
    return dfs(nv)


N, K = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))
visited = [0] * N
path = []
cycle_start = dfs(0)
cycle_len = len(path) - path.index(cycle_start)
head_len = len(path) - cycle_len
if K <= head_len:
    print(path[K] + 1)
else:
    K -= head_len
    print(path[head_len + K % cycle_len] + 1)


Measured memory_bytes: 177488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pair<pii,pair<int,pii> >, null_type, less<pair<pii,pair<int,pii> > >, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=1e4+5;
int dp[N];

int32_t main()
{
	fast;
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int val=i*i+j*j+k*k+i*j+j*k+i*k;
				if(val<N)
					dp[val]++;
			}
		}
	}

	int n;cin>>n;
	for(int i=1;i<=n;i++)
		cout<<dp[i]<<endl;
}

Measured memory_bytes: 3672
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    A, B, C, K = MI()
    
    na = min(A, K)
    K -= na
    
    nb = min(B, K)
    K -= nb
    
    nc = min(C, K)
    print(na - nc)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;cin>>n;
    long x[n],y[n],ans;
    for(int i=0;i<n;++i){
        cin>>x[i];
        y[i]=x[i];
    }
    sort(y,y+n);
    long mid1,mid2;
    mid1=y[n/2 - 1];
    mid2=y[n/2];
    for(int i=0;i<n;++i){
        if(x[i]>mid1)ans=mid1;
        else ans=mid2;
    cout<<ans<<endl;
    }    
//    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5248
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    System.out.println(50);
    long p = k/50;
    long q = k%50;
    for(long i=0;i<q;i++)System.out.print((49-(q-1)+p+50)+" ");
    for(long i=q;i<50;i++)System.out.print((49-q+p)+" ");
  }
}


Measured memory_bytes: 22868
n = int(input())
a = [0]*2
a[0] = list(map(int,input().split()))
a[1] = list(map(int,input().split()))
m = 0
c = 0
for i in range(n-1):
    c = sum(a[0][:i+1]) + sum(a[1][i:])
    m = max(m,c)
if n == 1:
    m = a[0][0] + a[1][0]
print(m)

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	lint n; cin>>n;
	lint ans = 1;
	REP(i,n){
		ans = (ans*(i+1))%divs;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

int main()
{
    string s;
    cin >> s;

    Tenki tommorow;
    if (s == "Sunny")
    {
        tommorow = Cloudy;
    }
    else if (s == "Cloudy")
    {
        tommorow = Rainy;
    }
    else if (s == "Rainy")
    {
        tommorow = Sunny;
    }

    switch (tommorow)
    {
    case Cloudy:
        cout << "Cloudy" << endl;
        break;
    case Rainy:
        cout << "Rainy" << endl;
        break;
    case Sunny:
        cout << "Sunny" << endl;
        break;
    default:
        break;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;



int n;
void dfs(string ssss, char mx) {
	if (ssss.size() == n) {
		cout << ssss << endl;
		return;
	}
	for (char c = 'a'; c <= mx + 1; c++) {
		string t = ssss;
		t += c;
		dfs(t, max(mx, c));
	}
}

vector<string> s;
void f(string str, char max) {
	if (str.length() == n) {
		s.push_back(str);
	}
	else {
		for (char c = 'a'; c <= max + 1; ++c) {
			string ss = str;
			ss.push_back(c);
			f(ss, c <= max ? max : c);
		}
	}
}

int main() {
	cin >> n;
	f("a", 'a');
	for (string sss : s) {
		printf(sss.c_str());
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 7796
S = input()
ltrs = "ACGT"
curr_max = 0
curr_len = 0
for ltr in S:
    if ltr in ltrs:
        curr_len += 1
    else:
        curr_max = max(curr_max, curr_len)
        curr_len = 0
print(max(curr_len, curr_max))

Measured memory_bytes: 2940
X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7

if (X+Y)%3==0 and X<= 2*Y and Y<= 2*X :
    r = (X+Y)//3
    l = min
    if r != X and r != Y:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
        ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
        print(ans%mod)   
    else:
        print(1)
else:
    print(0)

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

using namespace std;

int main() {
    int H, W;

    while (cin >> H >> W) {
        if (H == 0 && W == 0) break;

        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                if (h == 0 || h == H - 1 || w == 0 || w == W - 1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2996
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var v = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int count = 0;

        while (v[0] != v[1] || v[1] != v[2] || v[2] != v[0])
        {
            Array.Sort(v, (a, b) => a.CompareTo(b));
            if (v[0] == v[1])
            {
                v[0]++;
                v[1]++;
            }
            else
            {
                v[0] += 2;
            }

            count++;
        }

        Console.WriteLine(count);
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int N = 220, M=1e6+100, INF = 1e9+100;

vector<int> g[N];
int dis[N], cmp[N], mx[N], n;
bool col[N], mark[N];

ii e[M];

int mx_dis(int rt){
	for(int i=0 ; i<n ; i++)
		dis[i] = INF;
	dis[rt] = 0;
	queue<int> q;
	q.push(rt);
	int ret = 0;
	while(!q.empty()){
		int v = q.front();q.pop();
		ret = max(ret, dis[v]);
		for(auto u : g[v]){
			if(dis[u] > dis[v] + 1){
				dis[u] = dis[v] + 1;
				q.push(u);
			}
		}
	}
	return ret;
}

void dfs(int v, int c, int comp){
	mark[v] = true;
	cmp[v] = comp;
	col[v] = c;
	for(auto u : g[v])
		if(!mark[u])
			dfs(u, 1-c, comp);
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int sz=0, cmps=0;cin >> n;
	for(int i=0 ; i<n ; i++){
		string s;cin >> s;
		for(int j=0 ; j<n ; j++){
			if(s[j] == '0')
				continue;
			g[i].push_back(j);
			e[sz ++] = ii(i, j);
		}
	}
	for(int i=0 ; i<n ; i++){
		if(!mark[i])
			dfs(i, 0, cmps++);
		mx[cmp[i]] = max(mx[cmp[i]], 1+mx_dis(i));
	}
	for(int i=0 ; i<sz ; i++)
		if(col[e[i].first] == col[e[i].second]){
			cout << "-1\n";
			return 0;
		}
	int ans=0;
	for(int i=0 ; i<cmps ; i++)
		ans += mx[i];
	cout << ans << "\n";
}

























Measured memory_bytes: 768
#include <stdio.h>

int main() {
  long long  n,a,m,M,c,b,i;
  c = 0;
  m = 100000000;
  M =-100000000;
  scanf("%lld",&n);

  for(i=1; i<=n; i++){
    scanf("%lld",&a);
    if(a>M) {
      M = a;
    } 
    if(a < m){
      m = a;
    }
    c = c+a;
  }
    printf("%lld %lld %lld\n",m,M,c);

  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int dfs(vector<vector<int>> p, int s, int c){
  int ans = 0;
  int H = p.size();
  int W = p[0].size();
  for (int i = 1; i <= 6; i++){
    if (s == 4 && c != i){
      continue;
    }
    vector<vector<int>> q = p;
    queue<pair<int, int>> Q;
    Q.push(make_pair(1, 1));
    vector<vector<bool>> used(H, vector<bool>(W, false));
    used[1][1] = true;
    int cnt = 0;
    while (!Q.empty()){
      int y = Q.front().first;
      int x = Q.front().second;
      Q.pop();
      cnt++;
      for (int j = 0; j < 4; j++){
        if (p[y][x] == p[1][1] && q[y + dy[j]][x + dx[j]] == p[1][1] || q[y + dy[j]][x + dx[j]] == i){
          if (!used[y + dy[j]][x + dx[j]]){
            used[y + dy[j]][x + dx[j]] = true;
            q[y + dy[j]][x + dx[j]] = i;
            Q.push(make_pair(y + dy[j], x + dx[j]));
          }
        }
      }
    }
    q[1][1] = i;
    if (s == 4){
      ans = max(ans, cnt);
    } else {
      ans = max(ans, dfs(q, s + 1, c));
    }
  }
  return ans;
}
int main(){
  while (1){
    int h, w, c;
    cin >> h >> w >> c;
    if (h == 0 && w == 0 && c == 0){
      break;
    }
    vector<vector<int>> p(h + 2, vector<int>(w + 2, 0));
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        cin >> p[i][j];
      }
    }
    cout << dfs(p, 0, c) << endl;
  }
}


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

int main(void) {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  
  if(S==U) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
  
  return 0;
}


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

int main(){
  	int count=0;
	char a,b,c;cin>>a>>b>>c;
  	if(a=='1')++count;
  	if(b=='1')++count;
  	if(c=='1')++count;
  	cout<<count<<endl;
  	return 0;
}

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

ll A, P;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> A >> P;
    cout << (A*3+P)/2 << "\n";
    
}

Measured memory_bytes: 256
s=input()#1~100時
k=int(input())#sの5*10^16日後の k番目
for i in range(len(s)):
    if s[i]!="1":
        if i+1<=k:
            print(s[i])
            exit()
        else:
            print(1)
            exit()
print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int n, m, q, mx, cnt;
vector<int> v;
pair< pair<int, int> , pair<int, int> > p[200];

void solve(int idx){
    if(v.size() == n + 1){
        int tmp = 0;
        for(int i = 1; i <= q; i++){
            if(v[p[i].first.second] - v[p[i].first.first] == p[i].second.first)
                tmp += p[i].second.second;
        }
        mx = max(mx, tmp);
        return;
    }
    v.push_back(idx);
    solve(idx);
    v.pop_back();
    if(idx < m) solve(idx + 1);
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m >> q;
    for(int i = 1; i <= q; i++){
        cin >> p[i].first.first >> p[i].first.second >> p[i].second.first >> p[i].second.second;
    }
    v.push_back(0);
    solve(1);
    cout << mx;

    return 0;

}


Measured memory_bytes: 3672
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int f[3][100001];
int main() {
	int n, f = 0, v;
	cin >> n;
	deque<int> b;
	rep(i, 0, n) {
		cin >> v;
		f = f == 0;
		if (f) {
			b.push_back(v);
		}
		else {
			b.push_front(v);
		}
	}
	if (f)reverse(all(b));
	rep(i, 0, b.size())printf(i == b.size() - 1 ? "%d\n" : "%d ", b[i]);
	return 0;
}


Measured memory_bytes: 2944
A, B = map(int, input().split())

n = A // 2
m = B // 2
if (m-n)%2 == 0:
    c = 0
else:
    c = 1
if B % 2 == 0:
    c = c^B
else:
    c = c^1
if A % 2 == 1:
    c = c^(A-1)
print(c)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    double r;
    cin >> r;
    printf("%lf %lf\n", r * r * M_PI, r * 2 * M_PI);
}


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

int AdjM[101][101];

int main(){
    int N;
    cin>>N;
    int id,edgnum,adj;
    for(int i=0;i<N;++i){
        cin>>id;
        cin>>edgnum;
        for(int j=0;j<edgnum;++j){
            cin>>adj;
            AdjM[id-1][adj-1]=1;
        }

    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(j!=N-1){
                cout<<AdjM[i][j]<<" ";
            }
            else if(j==N-1){
                cout<<AdjM[i][j]<<"\n";
            }
        }
    }
}

Measured memory_bytes: 3128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

/////////////////////////////////////////////////////////////////
//[1,n]
#define max_n 400000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
ll bit[max_n+1],m;

ll sum(ll i){//a[1]~a[i]の和を求める
    ll s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}
void add(ll i,ll x){//a[i]にxを加える
    while(i<=m){
        bit[i]+=x;
        i+=i&-i;
    }
}
////////////////////////////////////////
ll n;
ll a[100010],b[100010];
bool che(ll x){
    memset(bit,0,sizeof(bit));
    bool f[n];
    rep(i,0,n-1){
        if(a[i]>=x)f[i]=true;
        else f[i]=false;
    }
    ll mid=200000;
    ll valmid=0;
    ll count=0;
    
    rep(i,0,n-1){
        if(f[i]){
            valmid++;
            add(mid-valmid+1,1);
            count+=sum(max_n)-sum(mid-valmid-1);
        }else{
            valmid--;
            add(mid-valmid-1,1);
            count+=sum(max_n)-sum(mid-valmid-1);
        }
    }
 //   cout<<x<<" "<<count<<endl;
    if(count*2>=n*(n+1)/2)return true;
    else return false;
}

int main(){
    m=max_n;
    
    cin>>n;
    rep(i,0,n-1){cin>>a[i];b[i]=a[i];}
    sort(b,b+n);
    
    ll lpos=0,rpos=n;
    while(lpos+1<rpos){
        ll mpos=(lpos+rpos)/2;
        if(che(b[mpos])){
            lpos=mpos;
        }else{
            rpos=mpos;
        }
    }
    
    cout<<b[lpos]<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=201000;
int p[N],q[N],n;
bool check(int x) {
	rep(i,1,2*n) if (p[i]>=x) q[i]=1; else q[i]=0;
	int pr=1;
//	rep(i,1,2*n) printf("%d",q[i]);
//	puts("");
	rep(i,2,2*n+1) {
		if (q[i]==q[i-1]||i==2*n) {
			if (pr==i-1) pr=i;
			else {
				if (q[pr]==q[i-1]) {
					rep(j,pr,i) q[j]=q[pr];
				} else {
					int md=(pr+i)/2;
					rep(j,pr,md) q[j]=q[pr];
					rep(j,md,i) q[j]=q[i-1];
				}
				pr=i;
			}
		}
	}
//	rep(i,1,2*n) printf("%d",q[i]);
//	puts("");
	return q[n];
}
int main() {
	scanf("%d",&n);
	rep(i,1,2*n) scanf("%d",p+i);
	int l=0,r=2*n-1;
	while (l+1<r) {
		int md=(l+r)>>1;
		if (check(md)==0) r=md; else l=md;
	}
	printf("%d\n",l);
}


Measured memory_bytes: 1920
// ABC153_E
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    // chmin: change minimum
    // a より b の方が小さかったら，a の値を b の値に置き換える．
    // 書き換えた場合，true を返す
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll H, N;
    cin >> H >> N;
    vector<pll> vec(N);
    rep(i, N) {
        cin >> vec[i].first >> vec[i].second;
    }
    
    // calculation
    vector<ll> dp(10010, INF);
    for (ll hp = 0; hp <= 10010; ++hp) {
        dp[hp] = INF;
    }
    
    for (ll i = 0; i <= 10010; ++i) {
        for (ll j = 0; j < N; ++j) {
            if (i - vec[j].first <= 0) {
                chmin(dp[i], vec[j].second);
            } else {
                chmin(dp[i], dp[i - vec[j].first] + vec[j].second);
            }
        }
    }
    cout << dp[H] << "\n";
    
    return 0;
}



Measured memory_bytes: 384
from itertools import *
from copy import *

H, W, K = map(int, input().split())

grid = list(
  i for i in ''.join(
  	str(input()) for i in range(H)
	)
)

H_p = list(product([0,1], repeat=H))
W_p = list(product([0,1], repeat=W))

#0:塗る, 1:塗らない

ans = 0

for h_p in H_p:
  for w_p in W_p:
    grid_ = copy(grid)
    
    for h in range(H):
      if h_p[h] == 0:
        for _w in range(W):
          grid_[_w + h*W] = '*'
    
    for w in range(W):
      if w_p[w] == 0:
        for _h in range(H):
          grid_[w + _h*W] = '*'
          
    if grid_.count('#') == K:
      ans += 1
      #print(w_p, h_p)
          
        

print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin >> v.at(i);
  int c = 1;
  string sorted = "";
  bool continuous = false;
  for(int i = 0; i < N - 1; i++){
    if(!continuous || sorted == ""){
      if(v.at(i) < v.at(i + 1)) sorted = "acs";
      else if(v.at(i) > v.at(i + 1)) sorted = "desc";
      continuous = true;
    }
    if(sorted == "acs" && v.at(i) > v.at(i + 1)){
      c++;
      sorted = "";
      continuous = false;
      continue;
    }
    if(sorted == "desc" && v.at(i) < v.at(i + 1)){
      c++;
      sorted = "";
      continuous = false;
      continue;
    }
  }
  cout << c << endl;
}

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

bool isPrime(int a) {
    if (a == 2) {
        return true;
    }
    if (a % 2 == 0) {
        return false;
    }
    for (int i = 3; i <= sqrt(a); i +=2 ) {
        if (a % i == 0) {
            return false;
        }
    }
    return true;
}

int main(void) {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (isPrime(a)) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 3208
S = input().strip()
C = {}
for i in range(len(S)):
    if S[i] not in C:
        C[S[i]] = 0
    C[S[i]] += 1
if len(C)==2:
    flag = 0
    for a in C:
        if C[a]!=2:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main()
{
    int N, sum;
    sum = 1;
    cin >> N;
    vector<string> S(N);
    for (int j = 0; j < N; j++)
    {
        cin >> S.at(j);
    }
    sort(S.begin(), S.end());

    //何もらったか判定
    for (int i = 1; i < N; i++)
    {
        if(S.at(i-1) != S.at(i))
        {
            sum++;
        }
    }

    cout << sum << endl;

}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll
int n;int a[2030];

int main(){
  int n;string s;cin>>s;n = s.length();
  /*int dp[200100];dp[0] = 0;
  repd(i,1,n){
    dp[i] = dp[i-1];
    if(s[i] == 'W'){

    }else{

    }
  }
  cout << dp[n-1] << endl;*/
  ll ans = 0;int count = 0;
  rep(i,n){
    if(s[i] == 'W'){
      ans += count;
    }else{
      count++;
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, L;
int num[100002];
int dp[100002];
int ans = 0;

int Search(int fig) {
	if (dp[fig])return dp[fig];
	dp[fig] = L - num[fig];
	if (num[fig] < num[fig - 1])dp[fig] = max(dp[fig], Search(fig - 1) + L - num[fig]);
	if (num[fig] < num[fig + 1])dp[fig] = max(dp[fig], Search(fig + 1) + L - num[fig]);
	return dp[fig];
}

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> L;
	for (int i = 1; i <= N; i++)cin >> num[i];
	for (int i = 1; i <= N; i++)ans = max(ans, Search(i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5136
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, X, x[100000], ans=1e10;
	cin >> n >> X;
	for(int i=0; i<n; i++){
		cin >> x[i];
		ans=min(ans, abs(x[i]-X));
	}
	sort(x, x+n);
	for(int i=1; i<n; i++){
		while((x[i]-x[i-1])%ans){
			ans--;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A,B;
	char op;
	cin >> A >> op >> B;
	switch(op){
		case '+':
			cout << A+B << endl;
		break;
		case '-':
			cout << A-B << endl;
		break;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    long long int arr[n];
    for(int i=0;i<n;i++)
        cin >> arr[i];
    sort(arr,arr+n);
    long long int count1 = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k] && arr[i]+arr[j]>arr[k])
                    count1++;
            }
        }
    }
    cout << count1 << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  stack<char> L;
  for(int i=0;i<n;i++){
    if(L.empty()==1){
      L.push(s[i]);
    }
    else if(s[i]==L.top()){

    }
    else{
      L.push(s[i]);
    }
  }
  cout<<L.size();
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

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

#ifdef MARX
	freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
#endif

	int n;
	string s;

	cin >> n >> s;

	s += s[0];

	vector<bool> sol(n + 2);

	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j){
			sol[0] = i, sol[1] = j;

			for (int k = 2; k <= n + 1; ++k)
				sol[k] = sol[k - 2] ^ (s[k - 1] == 'o') ^ sol[k - 1];

			if (sol[n] == sol[0] && sol[n + 1] == sol[1]){
				for (int k = 0; k < n; ++k)
					cout << "WS"[ sol[k] ];
				cout << endl;
				return 0;
			}
		}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 592
// MOHIT KUMAR
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i, a, b) for ( ll i = (b)-1; i >= a; i--)
#define ffr(i, a, b) for ( ll i = b ; i >= a; i--)
#define vl vector < ll >
#define vp vector < pl >
#define endl "\n"
#define sz(x) (ll)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const ld pi = acos(-1) ;
const ll maxn = 1e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll INF = 1e18 ;
const int MX = 2000000001 ; // check the limits, dummy

int main() {
  ios_base::sync_with_stdio(0) , cin.tie(0);
  ll t, q, n, a, b, c, d, k, l, m, r,  x = 0, y = 0, z = 0 , sum = 0, ans = 0, temp = 0, res = 0 ;
  cin >> n >> k >> t ;

  cout << ((n + k - 1) / k ) * t << endl ;
}


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

using namespace std ;

#define inf 99999999
#define N 1000007
#define ls x<<1
#define rs x<<1|1

priority_queue< int , vector<int> , greater<int> > q ;

int tot , n , m , cnt , k ;
int nex[2*N] , fire[N] , to[2*N] ;
int To[N] , Mn[4*N] , in[N] , Ans[N] ;

inline int read()
{
    int x = 0 , f = 1 ; char c = getchar();
    while( c < '0' || c > '9' ) { if( c == '-' ) f = -1; c = getchar() ; }
    while( c >= '0' && c <= '9' ) x = x * 10 + c - 48 , c = getchar() ;
    return x * f ;
}

void add(int u , int v){
    nex[++tot] = fire[u] ;
    fire[u] = tot ;
    to[tot] = v ;
    in[v]++ ;
    return ;
}

void build(int x , int l , int r){
    Mn[x] = inf ;
    if( l == r ) return ;
    int mid = l + r >> 1 ;
    build( ls , l , mid ) ; build( rs , mid + 1 , r ) ;
}

void update(int x , int l , int r , int pos , int t ){
    Mn[x] = min( Mn[x] , t ) ;
    if( l == r ) return ;
    int mid = l + r >> 1 ;
    if( pos <= mid ) update( ls , l , mid , pos , t ) ;
    else update( rs , mid + 1 , r , pos , t ) ;
}

int Ask(int x , int l , int r , int ll , int rr){
    if( ll > rr ) return inf ;
    if( l > rr || r < ll ) return inf ;
    if( ll <= l && r <= rr ) return Mn[x] ;
    int mid = l + r >> 1 ;
    return min( Ask( ls , l , mid , ll , rr ) , Ask( rs , mid + 1 , r , ll , rr ) ) ;
}

void topo(){
    for(int i = 1 ; i <= n ; i++ ) if( !in[i] ) q.push( i ) ;
    while( !q.empty() ){
        int u = q.top() ; q.pop() ;
        Ans[u] = ++cnt ;
        for(int i = fire[u] ; i ; i = nex[i] ){
            int v = to[i] ;
            in[v]-- ;
            if( !in[v] ) q.push( v ) ;
        }
    }
    return ;
}

int main()
{
    scanf("%d%d" , &n , &k ) ;
    for(int i = 1 ; i <= n ; i++ ) To[read()] = i ;
    build( 1 , 1 , n ) ;
    for(int i = n ; i >= 1 ; i-- ){
        int now = Ask( 1 , 1 , n , To[i] + 1 , min( To[i] + k - 1 , n ) ) ;
        if( now != inf ) add( To[i] , To[now] ) ;
        now = Ask( 1 , 1 , n , max( 1 , To[i] - k + 1 ) , To[i] - 1 ) ;
        if( now != inf ) add( To[i] , To[now] ) ;
        update( 1 , 1 , n , To[i] , i ) ;
    }
    topo() ;
    for(int i = 1 ; i <= n ; i++ ) printf("%d\n" , Ans[i] ) ;
    return 0 ;
}

Measured memory_bytes: 34432
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz                size()
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define T                 int t;scanf("%lld",&t);while(t--)
#define F                 first
#define S                 second
#define deb(x) cout << #x << " " << x << endl
#define inf INT_MAX
const ll N = 200010;
const ll MOD = 998244353;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}
 

vector<int> v[1000001];
int vis[1000001];
int par[1000001];


void bfs(int node){
    queue<int> q;
    q.push(node);
    vis[node] = 1;
    par[node] = -1;
    while(!q.empty()){
        int curr = q.front();
        q.pop();
        for(int child : v[curr]){
            if(vis[child] == 0){
                q.push(child);
                vis[child] = 1;
                par[child] = curr;
            }
        }
    }
}
 
int main(){
//T{
  
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    ll cc_count = 0;
    for(int i=1;i<=n;i++){
        if(vis[i] == 0){
            bfs(i);
            cc_count++;
        }
    }
    if(cc_count > 1)
        cout << "No";
    else{
        cout << "Yes\n";
        for(int i=2;i<=n;i++)
            cout << par[i] << "\n";
    }

//}

}

Measured memory_bytes: 31932
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		String b=" ",n="\n";
        String[] rc=br.readLine().split(b);
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[][] h=new int[r+1][c+1];
        
        for(int i=0;i<r;i++){
        	String[] row=br.readLine().split(b);
        	for(int j=0;j<c;j++){
        		h[i][j]=Integer.parseInt(row[j]);
        		sb.append(h[i][j]+b);
        		h[i][c]+=h[i][j];
        		h[r][j]+=h[i][j];
        		h[r][c]+=h[i][j];
        	}
        	sb.append(h[i][c]+n);
        }
    	for(int j=0;j<c;j++) sb.append(h[r][j]+b);
        sb.append(h[r][c]);
        System.out.println(sb);
	}
}

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

int main() {
  int a;
  cin>>a;
  if(a==2) cout<<"2";
  else{
  for(int i=0;i<1000000;i++){
    bool ans=true;
    for(int j=1;j<pow(a,0.5);j++){
      if((a+i)%(j+1)==0){
        ans=false;
      }
    }
      if(ans){
        cout<<a+i<<endl;
        break;
      }
  }
  }
    
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n+1, 0);
    for(int i = 0; i < n; i++) cin >> a[i];
    while(true)
    {
        vector<ll> imos(n+1, 0);
        for(int i = 0; i < n; i++)
        {
            ll num = a[i];
            ll l = max(0LL, i - num);
            ll r = min(n-1, i + num);
            imos[l]++;
            imos[r+1]--;
        }
        bool flag = true;
        for(int i = 0; i < n; i++)
        {
            imos[i+1]+=imos[i];
            a[i] = imos[i];
            if(a[i] < n) flag = false;
        }
        k--;
        if(flag) break;
        if(k == 0) break;
    }
    for(int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}



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

#define fi first
#define se second
#define endl '\n'
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=1000010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<typename T>inline void gmax(T &A,T B) {(A<B)&&(A=B);}
template<typename T>inline void gmin(T &A,T B) {(A>B)&&(A=B);}

template <class T>
inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

int cnt[33];

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    int n,m;
    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int k;
        cin>>k;
        while(k--)
        {
            int t;
            cin>>t;
            cnt[t]++;
        }
    }
    int ans=0;
    for(int i=1; i<=m; i++) if(cnt[i]==n) ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=103;
const ll LINF=100000000000000000;

int main(){
  int N;
  string s,ans;
  int a=0;
  cin >> N ;
  cin >> s ;
  int sum=0;
  rep(i,N){
    if(s[i]=='('){
      ++sum;
    }else{
      --sum;
      a=min(a,sum);
    }
  }
  ans="";
  if(a<0){
    rep(i,(-1)*a) ans+='(';
  }
  sum-=a;
  ans+=s;
  rep(i,sum) ans+=')';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  
  if (c.at(2) == c.at(3) && c.at(4) == c.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

bool cmp(pair<pair<string,int>,int> a, pair<pair<string,int>,int> b)
{
  	if(a.first.first==b.first.first)
	return a.first.second>b.first.second;
  	return a.first.first<b.first.first;
}

int main()
{
	int n;
  	cin>>n;
  	vector<pair<pair<string,int>,int> > rec;
  	string name;
  	int rate;
  	for(int i=0 ; i<n ; ++i)
    {
    	cin>>name>>rate;
      	rec.push_back({{name,rate},i+1});
    }
  	sort(rec.begin(),rec.end(),cmp);
  	for(int i=0 ; i<n ; ++i)
    {
    	cout<<rec[i].second<<endl;
    }
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
ll mod;
char f[2005][2005];
ll x[2005][2005],y[2005][2005],z[2005][2005],num[2005][2005];
int main(){
    scanf("%d%d%lld",&n,&m,&mod);
    for(int i=0;i<n;i++) scanf("%s",&f[i]);
    x[0][0] = 0; y[0][0] = f[0][0]-'0'; z[0][0] = 1; num[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int dx[2]={0,1};
            int dy[2]={1,0};
            rep(k,2){
                int nx = i+dx[k], ny = j+dy[k];
                if(0<=nx && nx < n && 0<=ny && ny<m){
                    int v = f[nx][ny]-'0';
                    if(1<=v && v<=9){
                        x[nx][ny] = (x[nx][ny]+x[i][j])%mod;
                        y[nx][ny] = (y[nx][ny]+y[i][j]*10LL%mod+z[i][j]*v%mod)%mod;
                        z[nx][ny] = (z[nx][ny]+z[i][j])%mod;
                        num[nx][ny] = (num[nx][ny]+num[i][j])%mod;
                    }
                    else if(f[nx][ny] == '+'){
                        x[nx][ny] = (x[nx][ny]+x[i][j]+y[i][j])%mod;
                        z[nx][ny] = (z[nx][ny]+num[i][j])%mod;
                        num[nx][ny] = (num[nx][ny]+num[i][j])%mod;
                    }
                    else{
                        x[nx][ny] = (x[nx][ny]+x[i][j])%mod;
                        z[nx][ny] = (z[nx][ny]+y[i][j])%mod;
                        num[nx][ny] = (num[nx][ny]+num[i][j])%mod;
                    }
                }
                
            }
        }
    }
    ll ans = x[n-1][m-1]+y[n-1][m-1];
    cout << (ans%mod+mod)%mod << endl;
}


Measured memory_bytes: 132172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  ll N,M,C;
  cin>>N>>M>>C;
  ll B[M+1];
  ll A[N+1][M+1];
  rep(i,M) cin>>B[i];
  rep(i,N) rep(j,M) cin>>A[i][j];
  ll ans=0;
  rep(i,N){
    ll X=C;
    rep(j,M) X+=B[j]*A[i][j];
    if(X>0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int x, y;
  while(1){
    scanf("%d%d",&x, &y);
    if(x == 0 && y == 0)break;
    if(x <= y){
      printf("%d %d\n",x, y);
    }
    else{
      printf("%d %d\n",y, x);
    }
  }
  return 0;
}
  

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF = 1e9;

double EPS = 1e-10;

int d[15][10010];

int main(){
	int r, c, ans = 0;
	int a, s, t;
	while(cin>>r>>c){
		if(r==0&&c==0) break;
		rep(i, r){
			rep(j, c) cin>>d[i][j];
		}
		ans = 0;
		for(int i = 0; i < (1<<r); i++){
			a = 0;
			for(int j = 0; j < c; j++){
				s = t = 0;
				for(int k = 0; k < r; k++){
					if((1<<k)&i){
						if(d[k][j]==1) s++;
						else t++;
					}
					else {
						if(d[k][j]==0) s++;
						else t++;
					}
				}
				a+=max(s, t);
			}
			ans = max(ans, a);
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 1552