akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    bool F[100][5][2];
    int p[100][11];

    for(int i = 0; i < N; ++i){
        for(int j = 0; j < 5; ++j){
                cin >> F[i][j][0] >> F[i][j][1];
        }
    }
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < 11; ++j){
            cin >> p[i][j];
        }
    }

    ll benefit = -INFL;
    bool all_0 = true;
    for(int a = 0; a < 2; ++a)
    for(int b = 0; b < 2; ++b)
    for(int c = 0; c < 2; ++c)
    for(int d = 0; d < 2; ++d)
    for(int e = 0; e < 2; ++e)
    for(int f = 0; f < 2; ++f)
    for(int g = 0; g < 2; ++g)
    for(int h = 0; h < 2; ++h)
    for(int i = 0; i < 2; ++i)
    for(int j = 0; j < 2; ++j)
    {
        if(all_0 == true){
            all_0 = false;
            break;
        }
        ll be = 0;
        for(int k = 0; k < N; ++k){
            int cnt = 0;
            if(a == 1 && F[k][0][0] == true) cnt++;
            if(b == 1 && F[k][0][1] == true) cnt++;
            if(c == 1 && F[k][1][0] == true) cnt++;
            if(d == 1 && F[k][1][1] == true) cnt++;
            if(e == 1 && F[k][2][0] == true) cnt++;
            if(f == 1 && F[k][2][1] == true) cnt++;
            if(g == 1 && F[k][3][0] == true) cnt++;
            if(h == 1 && F[k][3][1] == true) cnt++;
            if(i == 1 && F[k][4][0] == true) cnt++;
            if(j == 1 && F[k][4][1] == true) cnt++;
            be += p[k][cnt];
        }
        benefit = max(benefit, be);
    }
    cout << benefit << endl;

    return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 1e3 + 5, W = 1e5 + 5;

ll dp[N][W];
ll v[N];
int w[N];
int n;

ll sol(int i, int cap) {
    if(i == n) return 0;

    ll &ret = dp[i][cap];
    if(ret != -1) return ret;

    ret = sol(i + 1, cap);
    if(w[i] <= cap) ret = max(ret, sol(i + 1, cap - w[i]) + v[i]);

    return ret;
}

int main(){
    fIO

//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    memset(dp, -1, sizeof(dp));
    int cap;
    cin >> n >> cap;

    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];

    cout << sol(0, cap);
}








Measured memory_bytes: 785536
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#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 unsigned int uint;
typedef long long ll;

char board[12][10];
int  num[12][6];

void drop(){
  bool f = true;
  while(f){
    f=false;
    for(int i=11; i>0; i--)
      for(int j=0; j<6; j++)
	if(board[i][j] == '.' && board[i-1][j] != '.'){
	  f = true;
	  swap(board[i][j],board[i-1][j]);
	}
  }
}

void check(int x, int y, int c, int k){
  if(num[y][x] == 0 && board[y][x] == c){
    num[y][x] = k;
    if(x > 0)  check(x-1, y, c, k);
    if(y > 0)  check(x, y-1, c, k);
    if(x < 5)  check(x+1, y, c, k);
    if(y < 11) check(x, y+1, c, k);
  }
}

bool erase(){
  bool ret = false;
  int  c = 1;
  int cnt[12*6] = {0};
  memset(num, 0, sizeof(num));
  REP(i,12) REP(j,6)
    if(num[i][j] == 0) check(j,i,board[i][j],c++);
  REP(i,12) REP(j,6) cnt[num[i][j]]++;

  //REP(i,c) printf("cnt[%d] = %d\n",i,cnt[i]);
  //REP(i,12) {REP(j,6) printf("%2d",num[i][j]); puts("");}

  REP(i,12) REP(j,6)
    if(board[i][j]!='.' && board[i][j]!='O' && cnt[num[i][j]] >= 4){
      ret = true;
      board[i][j] = '.';
      if(i > 0  && board[i-1][j]=='O') board[i-1][j] = '.';
      if(j > 0  && board[i][j-1]=='O') board[i][j-1] = '.';
      if(i < 11 && board[i+1][j]=='O') board[i+1][j] = '.';
      if(j < 5  && board[i][j+1]=='O') board[i][j+1] = '.';
    }
  return ret;
}

int main(){
  int n; scanf("%d ",&n);
  while(n-->0){
    REP(i,12) fgets(board[i],sizeof(board[i]),stdin);
    int cnt = 0;
    while(erase()){ cnt++; drop(); }
    printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
ac = {}
wa = {}
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    else:
        if not ac.get(p, 0):
            wa[p] = wa.get(p, 0) + 1
pen = 0
for p in ac:
    pen += wa.get(p, 0)
print(len(ac), pen)


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

ll A,B;
 
int main(){
	cin >> A >> B;
	ll C = 0;
	if (A % 4 != 0){
		for (int i = 0; i <= (3 - A % 4); ++i){
			C ^= (A + i);
		}
	}
	if (B % 4 != 3){
		for (int i = 0; i <= (B % 4); ++i){
			C ^= (B - i);
		}
	}
	cout << C << '\n';
	return 0;
}

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

int main(int argc, char *argv[]){
  string S;
  cin>>S;
  int count=0;
  int length=S.length();
  if(length==1){
    cout<<count<<endl;
    return 0;
  }
  if(length==2){
    if(S[0]==S[1]){
	cout<<count+1<<endl;
      }
    else{
	cout<<count<<endl;
      }
    return 0;
    
  }
  
  for(int i=1; i<length;i++){
 
    if(S[i-1]==S[i]){
      count++;
      if(S[i-1]=='0') S[i]='1';
      else S[i]='0';
    }
  }
        
  cout<<count<<endl;
}


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

class Stack{
private:
  int sp;
  int S[100];

public:
  Stack(){sp=0;}
  bool isFull() const {return (sp==100);}
  bool isEmpty() const {return (sp==0);}
  void push(int d);
  int top();
  void pop();
};

void Stack::push(int d){
  if(isFull()){
    return;
  }
  S[sp++]=d;
}

int Stack::top(){
  if(isEmpty()){
    return -1;
  }
  return S[sp-1];
}

void Stack::pop(){
  if(isEmpty()){
    return;
  }
  sp--;
}


int main(){
  Stack s;
  string expr;
  getline(cin,expr);
  istringstream is(expr);

  while(!is.eof()){
    string op;
    is>>op;

    int tmp1,tmp2;

    switch(op[0]){
      case'+':
        tmp1=s.top();s.pop();
        tmp2=s.top();s.pop();
        s.push(tmp2+tmp1);
        break;
      case'-':
        tmp1=s.top();s.pop();
        tmp2=s.top();s.pop();
        s.push(tmp2-tmp1);
        break;
      case'*':
        tmp1=s.top();s.pop();
        tmp2=s.top();s.pop();
        s.push(tmp2*tmp1);
        break;
      default:
        istringstream is2(op);
        is2>>tmp1;
        s.push(tmp1);
        break;
    }
  }
  cout<<s.top()<<endl;
  return 0;
}



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

int main(){
    int64_t K;
    cin >> K;
    vector<int64_t> run;
    int sidx,eidx;
    for(int64_t i=1; i<=9; i++){
        run.push_back(i);
    }
    sidx = 0; eidx = run.size()-1;
    int x;
    while(run.size()<=K){
        for(int i = sidx; i<=eidx ; i++){
            x = run.at(i)%10;
            for(int jj=0;jj<10;jj++){
                if(abs(x-jj) <=1) run.push_back(run.at(i)*10 + jj);
            }
        }
        sidx = eidx+1;
        eidx = run.size()-1;
    }
    cout << run.at(K-1) << endl;;
}   

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

int main() {
    int n, q; cin >> n >> q;
    queue<pair<string, int>> que;
    
    for (int i = 0; i < n; ++i) {
        string name; cin >> name;
        int time; cin >> time;
        que.push(make_pair(name, time));
    }
    
    int elapsed_time = 0;
    while (!que.empty()) {
        string name = que.front().first;
        int time = que.front().second;
        que.pop();
        
        if (time <= q) {
            elapsed_time += time;
            cout << name << " " << elapsed_time << endl;
        }
        else {
            elapsed_time += q;
            time -= q;
            que.push(make_pair(name, time));
        }
    }
    
    return 0;
}


Measured memory_bytes: 6236
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int ai[n] = {};
    int total = 0;
    forn(i,n){
        cin >> ai[i];
        total += ai[i];
    }

    int m;
    cin >> m;
    int aix[m];
    fill_n(aix,m,total);
    forn(i,m){
        int p,x;
        cin >> p >> x;
        aix[i]+=(x-ai[p-1]);
    }

    forn(i,m){
        cout << aix[i] << "\n" ;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
//random_device seed_gen; mt19937_64 mtrand(seed_gen());
//////////////////////////////////////////

int p , a[3000] , ans[3000];
int inv(int i){
  return i == 1 ? 1 : p - inv(p % i) * (p / i) % p;
};

int main(){
  in(p);
  rep(i , p) in(a[i]);
  // k=0
  ans[0] = a[0];
  // k=1~p-2
  for(int l = 1; l <= p - 1; l++){
    if(a[l] == 0) continue;
    int cur = 1;
    for(int k = p - 1; k >= 1; k--){
      ans[k] += cur;
      cur = cur * l % p;
    }
  }
  for(int k = 1, x = inv(p-1); k <= p - 1; k++){
    ans[k] = (ans[k] % p) * x % p;
  }
  // k = p-1
  ans[p-1] = (ans[p-1] + p - a[0]) % p;

  rep(i,p) cout << (i?" ":"") << ans[i];
  cout << endl;
}

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

 using namespace std;

 
 int main(){
  
  int a,b;

  cin>>a>>b;


  if(a<b) cout<<"a < b"<<endl;

  if(a==b) cout<<"a == b"<<endl;

  if(a>b) cout<<"a > b"<<endl;

  return 0;

}


Measured memory_bytes: 3088
#include <stdio.h>
#include <math.h>

typedef struct {
	double x, y;
} Point;

int input_point(Point *p)
{
	return (scanf("%lf %lf", &p->x, &p->y));
}

int main(void)
{
	Point a, b, c, d;

	while (~input_point(&a)){
		input_point(&b);
		input_point(&c);
		input_point(&d);

		if ((a.x - b.x) * (c.x - d.x) + (a.y - b.y) * (c.y - d.y) == 0){
			puts("YES");
		}
		else puts("NO");
	}

	return (0);
}

Measured memory_bytes: 612
n = int(input())
six = []
for i in range(20):
    six.append(6 ** i)
nine = []
for i in range(20):
    nine.append(9 ** i)

res = 10 ** 10
for i in range(n + 1):
    j = n - i
    k = i
    # print(i,j )
    cnt = 0

    #6
    piv = 19
    while k > 0 and piv >= 0:
        cnt += k // six[piv]
        k %= six[piv]
        piv -= 1

    #9
    piv = 19
    while j > 0 and piv >= 0:
        cnt += j // nine[piv]
        j %= nine[piv]
        piv -= 1

    res = min(res,cnt)
print(res)


Measured memory_bytes: 42568
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(N):
    if(A[i]==B[i] and B[i]==C[i] and A[i]==C[i]):
        cnt+=0
    elif(A[i]!=B[i] and B[i]!=C[i] and A[i]!=C[i]):
        cnt+=2
    else:
        cnt+=1
print(cnt)


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

P p[2][400000];
int q[400000];

#define MAX_LOG 22
template<class T,class comp>
class SparseTable {
	vector<T>t[MAX_LOG];
	vector<int>l2;
public:
	T DEFAULT;
	int n;
	void init(int n_,T DEF) {
		DEFAULT=DEF;
		n = n_;
		rep(i, MAX_LOG)t[i].assign(n, DEFAULT);
		l2.assign(n + 1, 0);
		int k = 0;
		rep(i, n + 1) {
			while ((1 << (k + 1)) <= i)k++;
			l2[i] = k;
		}
	}
	void set_array(int n_, T*a,T DEF) {
		init(n_,DEF);
		rep(i, n)t[0][i] = a[i];
		for (int i = 1; i < MAX_LOG; i++) {
			for (int j = 0; j + (1 << (i - 1)) < n; j++){
				if(comp()(t[i-1][j],t[i-1][j+(1<<(i-1))]))t[i][j]=t[i-1][j];
				else t[i][j]=t[i-1][j+(1<<(i-1))];
			}
		}
	}
	T query(int a, int b) {
		int w = b - a;
		int l = l2[w];
		return comp()(t[l][a],t[l][b-(1<<l)])?t[l][a]:t[l][b - (1 << l)];
	}
};
SparseTable<P,less<P>>t[2];
struct st{
	int l,r;
	bool operator<(const st&b)const{
		return t[l%2].query(l,r)>t[b.l%2].query(b.l,b.r);
	}
};
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &p[i%2][i].first);
		p[!(i%2)][i].first=INT_MAX;
		p[i%2][i].second=i;
	}
	t[0].set_array(n,p[0],P(INT_MAX,0));t[1].set_array(n,p[1],P(INT_MAX,0));
	priority_queue<st>que;
	que.push({0,n});
	int d=0;
	while(!que.empty()){
		st p=que.top();que.pop();
		P a=t[p.l%2].query(p.l,p.r);
		P b=t[!(p.l%2)].query(a.second+1,p.r);
		q[d++]=a.first;q[d++]=b.first;
		if(p.l<a.second)que.push({p.l,a.second});
		if(a.second+1<b.second)que.push({a.second+1,b.second});
		if(b.second+1<p.r)que.push({b.second+1,p.r});
	}
	rep(i, n) {
		if (i)printf(" ");
		printf("%d", q[i]);
	}
	puts("");
}


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

int main(){
    const double EPS = 1e-12;
    double x[4];
    double y[4];
    double s;
    double t;
    double u;
    double v;
    double m;
    int n;
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
        s = x[1] - x[0];
        t = y[1] - y[0];
        u = x[3] - x[2];
        v = y[3] - y[2];
        if(s * v - t * u > 0){
            m = s * v - t * u;
        }
        else{
            m = t * u - s * v;
        }
        if(m < EPS){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
package main

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

func main() {
	nextReader = newScanner()
	x := nextInt()
	fmt.Println((x / 500 * 1000) + (x % 500 / 5 * 5))
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
object Main extends App {
  var a = readInt
  var b = readLine.split(" ").map(_.toInt).sorted.reverse
  var alice = 0
  for(i <- 0 until a) {
    if(i%2==0) {
      alice = alice + b(i)
    } else {
      alice = alice - b(i)
    }
  }
  print(alice)
}

Measured memory_bytes: 27076
#include<iostream>
using namespace std;
int main() {
	int N, dummy;
	cin >> N >> dummy;
	int *much;
	much = new int[N];
	for (int i = 0; i < N; ++i) {
		cin >> much[i];
	}
	int nmax=much[N-1], buy=0;
	for (int i = N - 2; i >= 0; --i) {
		if (buy < nmax - much[i]) {
			buy = nmax - much[i];
		}
		if (nmax < much[i]) {
			nmax = much[i];
		}
	}
	int maxp=N-1,answer=0;
	for (int i = N - 2; i >= 0; --i) {
		if (much[maxp] - much[i] == buy) {
			++answer;
			--much[maxp];
		}
		if (much[maxp] < much[i]) {
			maxp = i;
		}
	}
	cout << answer << endl;
	return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	int s=0;
	for(int i=1; i<=n-1; ++i){
		s+=i;
	}
	int su=0;
	for(int i=1; i<=m-1; ++i){
		su+=i;
	}
	int sum=0;
	sum=su+s;
	cout<<sum<<endl;
	return 0;
}

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

int main()
{
    std::string str;
    std::cin >> str;

    int pref[2025][2] = { 0 };
    int cur = str[0] - '0';
    ++pref[cur][0];
    ++pref[0][0];
    long long int ans = 0;
    int bit = 1;
    for (int i = 1; i < str.length(); ++i)
    {
        for (int j = 0; j < 2019; ++j)
            pref[j][bit] = 0;
        for (int j = 0; j < 2019; ++j)
        {
            pref[(j*10)%2019][bit] += pref[j][!bit];
        }
        cur = (cur * 10) % 2019;
        cur += str[i] - '0';
        cur %= 2019;
        ans += pref[cur][bit];
        ++pref[cur][bit];
        bit = !bit;
    }

    std::cout << ans;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000000
#define INF 1000000
#define M 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 
int main(){
    fast_io 
    ll n;
    cin>>n;
    map<string,ll> mp;
    mp["AC"] = 0;
    mp["TLE"] = 0;
    mp["WA"] = 0;
    mp["RE"] = 0;
    while(n--){
        string s;
        cin>>s;
        mp[s]++;
    }
    for(auto x : mp){
        if(x.first == "AC"){
            cout<<x.first<<" "<<"x"<<" "<<x.second<<endl;
            break;
        }
    }
    for(auto x : mp){
        if(x.first == "WA"){
            cout<<x.first<<" "<<"x"<<" "<<x.second<<endl;
            break;
        }
    }
    for(auto x : mp){
        if(x.first == "TLE"){
            cout<<x.first<<" "<<"x"<<" "<<x.second<<endl;
            break;
        }
    }
    for(auto x : mp){
        if(x.first == "RE"){
            cout<<x.first<<" "<<"x"<<" "<<x.second<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

struct Union_Find {
  vector<int> data;
  Union_Find(int size) { data = vector<int>(size, -1); }
  bool union_set(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  GI2(N, M);
  vector<vector<int>> L(M);
  FOR(i, N) {
    GI(K);
    FOR(j, K) {
      GI(l);
      L[l - 1].push_back(i);
    }
  }
  Union_Find uf(N);
  FOR(i, M) {
    FOR(j, L[i].size() - 1) { uf.union_set(L[i][j], L[i][j + 1]); }
  }
  bool f = 0;
  FOR(i, N) if (uf.data[i] == -N) f = 1;
  print(f ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 4608
n = int(input())
l = [int(input()) for i in range(n)]
wa = sum(l)
cnt = 0
for i in l:
    if i % 10 == 0:
        cnt += 1
        
if cnt == n:
    print(0)
    exit()
    
if wa % 10 != 0:
    print(wa)
else:
    l.sort()
    for i in l:
        if i % 10 != 0:
            print(wa - i)
            break

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    string a, b;
    cin >> a >> b;
    string ans;
    for (int i = 0; i < min(a.length(), b.length()); i++) {
        ans += a[i];
        ans += b[i];
    }
    if (a.length() != b.length()) {
        ans += (a.length() > b.length() ? a[a.length()-1] : b[b.length()-1]);
    }
    cout << ans << "\n";
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define F first
#define S second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lld I64d
#define ii  pair<int,int>
int main()
{
    ios
    ll n,m,i,j,k,num,test=1,pdt=1,sum=0;
    cin>>n;
    k=0; m=n;
    while(m){
        k+= m%10;
        m/=10;
    }
    if(n%k==0)
        cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> data(H, vector<char>(W));
  vector<char> kara(W,'x');
 
   for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){
    bool A=true;
    for(int j=0;j<W;j++){
      if(data.at(i).at(j)=='#')
        A=false;
    }
    if(A){
      for(int j=0;j<W;j++)
        data.at(i).at(j)='x';
    }
  }
  for(int i=0;i<W;i++){
    bool A=true;
    for(int j=0;j<H;j++){
      if(data.at(j).at(i)=='#')
        A=false;
    }
    if(A){
      for(int j=0;j<H;j++)
        data.at(j).at(i)='x';
    }
  }
  for(int i=0;i<H;i++){
    if(data.at(i)==kara)
      continue;
    for(int j=0;j<W;j++){
      if(data.at(i).at(j)=='x')
        continue;
      cout<<data.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 250
#define NIL -2000000000

int key[MAX];
int pk(int k),rk(int k),lk(int k);

int main(void){
  int i,n,H;
  scanf("%d",&n);

  for(i=0;i<MAX;i++){
    key[i]=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d",&H);
    key[i]=H;
  }
  for(i=0;i<n;i++){
    printf("node %d: key = %d, ",i+1,key[i]);
    if(key[pk(i)]!=NIL&&i!=0)
      printf("parent key = %d, ",key[pk(i)]);
    if(MAX>lk(i)&&key[lk(i)]!=NIL)
      printf("left key = %d, ",key[lk(i)]);
    if(MAX>rk(i)&&key[rk(i)]!=NIL)
      printf("right key = %d, ",key[rk(i)]);

    printf("\n");
  }
  return 0;
}

int pk(int k){
  return (k-1)/2;
}

int rk(int k){
  return 2*k+2;
}

int lk(int k){
  return 2*k+1;
}



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

int main(){
  int N,Q;
  cin >> N >> Q;
  dsu D(N);
  
  for(int i=0;i<Q;i++){
    int t,u,v;
    cin >> t >> u >> v;
    if(t==0){
      D.merge(u,v);
    }
    if(t==1){
      if(D.same(u,v)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
#define forn(i,n) for(ll i=0;i<ll(n);++i)
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define pb push_back
#define fst first
#define snd second

const int N = 200100;

ll xs[N];

ll min4(ll a, ll b, ll c, ll d) {
    return min(min(a, b), min(c, d));
}

ll max4(ll a, ll b, ll c, ll d) {
    return max(max(a, b), max(c, d));
}

int main() {
    int n;
    scanf("%d", &n);
    forn(i, n) scanf("%lld", xs+i);
    int L = 1;
    int R = 3;
    ll A = xs[0];
    ll B = xs[1];
    ll C = xs[2];
    ll D = accumulate(xs+3, xs+n, 0ll);
    // [A, A, A, B, B, C, C, C, C, D, D]
    //           L     M           R
    ll best = 1ll << 50;
    for (int M = 2; M+1 < n; ++M) {
        while (L+1 < M && A+xs[L] <= B-xs[L]) A+=xs[L], B-=xs[L], ++L;
        while (R+1 < n && C+xs[R] <= D-xs[R]) C+=xs[R], D-=xs[R], ++R;
        best = min(best, max4(A, B, C, D) - min4(A, B, C, D));
        if (L+1 < M)
            best = min(best, max4(A+xs[L], B-xs[L], C, D) -
                             min4(A+xs[L], B-xs[L], C, D));
        if (R+1 < n)
            best = min(best, max4(A, B, C+xs[R], D-xs[R]) -
                             min4(A, B, C+xs[R], D-xs[R]));
        if (L+1 < M && R+1 < n)
            best = min(best, max4(A+xs[L], B-xs[L], C+xs[R], D-xs[R]) -
                             min4(A+xs[L], B-xs[L], C+xs[R], D-xs[R]));
        B += xs[M];
        C -= xs[M];
        if (M+1 == R) C+=xs[R], D-=xs[R], R++;
    }
    printf("%lld\n", best);
}


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

char getGrade (int m, int f, int r) {
    int sum = m + f;
    char grade;
    if (m == -1 || f == -1) grade = 'F';
    else if (80 <= sum) grade = 'A';
    else if (65 <= sum && sum < 80) grade = 'B';
    else if (50 <= sum && sum < 65) grade = 'C';
    else if (30 <= sum && sum < 50) {
        if (50 <= r) grade = 'C';
        else grade = 'D';
    }
    else if (sum < 30) grade = 'F';

    return grade;
}

int main() {
    int m, f, r;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        cout << getGrade (m, f, r) << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
class MergeFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
        self.lista = [[_] for _ in range(n)]

    def find(self, a):
        to_update = []
        while a != self.parent[a]:
            to_update.append(a)
            a = self.parent[a]
        for b in to_update:
            self.parent[b] = a
        return self.parent[a]

    def merge(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        if self.size[a] < self.size[b]:
            a, b = b, a
        self.num_sets -= 1
        self.parent[b] = a
        self.size[a] += self.size[b]
        self.lista[a] += self.lista[b]
        self.lista[b] = []

    def set_size(self, a):
        return self.size[self.find(a)]

    def __len__(self):
        return self.num_sets


n,m=map(int,input().strip().split(" "))
ar=[]
for _ in range(m):
    ar.append((int(i) - 1 for i in input().strip().split(" ")))
ans=[]

d=MergeFind(n)

for i in range(m-1,-1,-1):
    a,b=ar[i]
    A=d.find(a)
    B=d.find(b)
    if A==B:
        ans.append(0)
    else:
        ans.append(d.size[A]*d.size[B])
        d.merge(a,b)
fin=[ans[-1]]
for i in range(m-2,-1,-1):
    fin.append(fin[-1]+ans[i])
for i in fin:
    print(i)



Measured memory_bytes: 154060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int> P;
typedef pair<double,double> P_f;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define bitrep(bit,n) for(int bit=0; bit<=(1<<n);bit++)
#define MAX 100100
#define MAX_N 200100
#define MAX_T 2001001
#define SENTINEL 20010010010
#define NIL -1
static const int INF = 1 << 29;
const ll INFTY = 1LL<<50;
const int MOD=1e9+7;
int k,s;
int main(){
    cin>>k>>s;
    int count=0;
    rep(x,k+1)
        rep(y,k+1){
            int z=s-x-y;
            if(0<=z && z<=k)count++;
        }
                
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX 1000000

long long fac[MAX], finv[MAX], inv[MAX];

//テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

//二項係数計算
long long COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
    ll x,y;
    cin >> x >> y;
    ll sum = x + y;
    if(sum % 3 == 0 && sum / 3 <= x && x <= sum / 3 * 2 && sum / 3 <= y && y <= sum / 3 * 2){
        ll mn = min(x, y);
        COMinit();
        cout << COM(sum / 3, mn - sum / 3) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int intervals[m][2];
	for(int i=0;i<m;i++)
		cin>>intervals[i][0]>>intervals[i][1];
    int l = intervals[0][0]; 
    int r = intervals[0][1]; 
     for (int i = 1; i < m; i++)
      { 
         if (intervals[i][0] > r || intervals[i][1] < l) { 
            cout <<0<<endl;
            return 0;
        } 
         else { 
            l = max(l, intervals[i][0]); 
            r = min(r, intervals[i][1]); 
        } 
    } 
  
    int res=0;
    for(int i=1;i<=n;i++)
    {
    	 if(i>=l&&i<=r)
    	 	res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>

/*
 
 #####
 #   #
 # # #
 # # #
 # ###
 
 ######
 #    #
 # ## #
 # #  #
 # #  #
 # ####
 
 */
using namespace std;


void f(char guruguru[100][100], int l, int d, int x, int y){
    while(1){
        if(l<=0)return;
        
        if(d==0){//右下
            for(int i=0; i<l; i++){
                guruguru[y][x+i]='#';
            }
            x=x+(l-1);
            
            if(l==2)return;
            
            for(int i=0; i<l; i++){
                guruguru[y+i][x]='#';
            }
            y=y+(l-1);
            l=l-2;
            d=1;
            //f(guruguru,l,d,x,y);
        }
        
        if(d==1){//左上
            
            
            for(int i=0; i<l; i++){
                guruguru[y][x-i]='#';
            }
            x=x-(l-1);
            
            if(l<=2)return;
            
            for(int i=0; i<l; i++){
                guruguru[y-i][x]='#';
            }
            y=y-(l-1);
            
            l=l-2;
            d=0;
            //f(guruguru,l,d,x,y);
        }
    }
}

void f0(char guruguru[100][100], int l, int d, int x, int y){
    for(int i=0; i<l; i++){
        guruguru[i][0]='#';
    }
    
    f(guruguru,l,0,0,0);
}

/*
 int main(){
 
 for(int i=0; i<100; i++){
 for(int j=0; j<100; j++){
 guruguru_0[i][j]=' ';
 guruguru_1[i][j]=' ';
 guruguru_2[i][j]=' ';
 guruguru_3[i][j]=' ';
 }
 }
 
 
 //f0(guruguru_0, 100, 0, 0, 0);
 //f0(guruguru_3, 99, 0, 0, 0);
 //f0(guruguru_2, 98, 0, 0, 0);
 //f0(guruguru_1, 97, 0, 0, 0);
 
 
 
 int n;
 cin>>n;
 for(int roop=0; roop<n; roop++){
 int l;
 cin>>l;
 if(l%4==0){
 int x=50-l/2;
 int y=50-l/2;
 for(int i=y; i<y+l; i++){
 for(int j=x; j<x+l; j++){
 cout<<guruguru_0[i][j];
 }
 cout<<endl;
 }
 cout<<endl;
 }else if(l%4==1){
 int x=50-l/2-2;
 int y=50-l/2-2;
 for(int i=y; i<y+l; i++){
 for(int j=x; j<x+l; j++){
 cout<<guruguru_1[i][j];
 }
 cout<<endl;
 }
 cout<<endl;
 } else if(l%4==2){
 int x=50-l/2-1;
 int y=50-l/2-1;
 for(int i=y; i<y+l; i++){
 for(int j=x; j<x+l; j++){
 cout<<guruguru_2[i][j];
 }
 cout<<endl;
 }
 cout<<endl;
 }else if(l%4==3){
 int x=50-l/2-1;
 int y=50-l/2-1;
 for(int i=y; i<y+l; i++){
 for(int j=x; j<x+l; j++){
 cout<<guruguru_3[i][j];
 }
 cout<<endl;
 }
 cout<<endl;
 }
 }
 
 }
 */
int main(){
    
    int n;
    cin>>n;
    for(int roop=0; roop<n; roop++){
        int l;
        cin>>l;
        char guruguru[100][100];
        //memcpy(guruguru,init,sizeof(init));
        for(int i=0; i<l; i++){
            for(int j=0; j<l; j++){
                guruguru[i][j]=' ';
            }
        }
        
        f0(guruguru,l,0,0,0);
        
        for(int i=0; i<l; i++){
            for(int j=0; j<l; j++){
                cout<<guruguru[i][j];
            }
            cout<<endl;
        }
        if(roop==n-1)break;
        cout<<endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n,m,k,fa[100010],a[100010],b[100010],c[100010],d[100010],cnt[100010],ans[100010];
int f(int pos) {
	if(fa[pos]==pos) return pos;
	return fa[pos]=f(fa[pos]);
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;++i) fa[i]=i,cnt[i]=1;
	for(int i=1;i<=m;++i) {
		scanf("%d%d",&a[i],&b[i]);
		int x=f(a[i]),y=f(b[i]);
		if(x==y) continue;
		cnt[x]+=cnt[y];
		fa[y]=x;
	}
	for(int i=1;i<=k;++i) scanf("%d%d",&c[i],&d[i]);
	for(int i=1;i<=n;++i) ans[i]=cnt[f(i)]-1;
//	for(int i=1;i<=n;++i) printf("%d %d    ",f(i),cnt[f(i)]);
//	printf("\n");
	for(int i=1;i<=m;++i) {
		int x=f(a[i]),y=f(b[i]);
		if(x==y) ans[a[i]]--,ans[b[i]]--;
	}
	for(int i=1;i<=k;++i) {
		int x=f(c[i]),y=f(d[i]);
		if(x==y) ans[c[i]]--,ans[d[i]]--;
	}
	for(int i=1;i<=n;++i) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
set<int>  st[125];
int main()
{
  //freopen("input.txt","r",stdin);
   string s,t;
   cin>>s>>t;
   for(int i = 0;i<s.size();++i)
   {
       st[s[i]].insert(i);//储存s中每个字符发生的位置
   }
   int a = 0,b = 0;
   for(int i = 0;i<t.size();++i)
   {
       if(st[t[i]].empty()) return cout<<-1,0;//如果没有出现在s中的字符，肯定无解
       if(st[t[i]].lower_bound(b)==st[t[i]].end()) a++,b = 0;//二分查找>=b的位置是否存在t[i]，
                                                         //若没有则加一个字符串
       b = *st[t[i]].lower_bound(b);//找到该字符出现的下标位置
       b++;
   }
   cout<<a*s.size()+b<<endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  for(int i=0; i<1000; i++){
    if(pow(K,i)>N){
      cout << i << endl;
      return 0;
    }
  }
      
 
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 896
a,b=map(int,input().split())
def z(n):
    d=0
    while n>=1:
        d+=1
        n-=1
    return d

def x(n):
    d=0
    while n>1:
        d+=1
        n-=1
    return d+1

an=[]
a1=a*12.5
a2=(a+0.99999999999)*12.5
b1=b*10
b2=(b+0.99999999999)*10
for i in range(x(a1),z(a2)+1):
    an.append(i)



ans=-1
for i in range(x(b1),z(b2)+1):
    if i in an:
        ans=i
        break
print(ans)


Measured memory_bytes: 3064
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
elif x5 == 0:
    print(5)

Measured memory_bytes: 61508
#include<bits/stdc++.h>
#define ll long long
#define pub push_back 
#define pob pop_back 
#define puf push_front
#define pof pop_front
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
using namespace std ;
int main()
{
	string str ;
	cin >> str ;
	ll n = str.size() ;
	ll dp[n][13] ; 
	fo(i , n)
	{
		fo(j , 13)
			dp[i][j] = 0 ;
	}
	if(str[0] == '?')
	{
		fo(i , 10)
			dp[0][i] = 1 ;
	}
	else
		dp[0][str[0] - '0'] = 1 ;
	for(ll i = 1 ; i < n ; i++)
	{
		for(int j = 0 ; j < 13 ; j++)
		{
			
			if(str[i] == '?')
			{
				for(int k = 0 ; k < 10 ; k++)
				{
					ll m = (10*j)+k ;
					m %= 13 ;
					dp[i][m] += dp[i-1][j] ; 
					dp[i][m] %= 1000000007 ;
				}
			}
			else
			{
				ll m = (10*j) + (str[i] - '0') ;
				m %= 13 ;
				dp[i][m] += dp[i-1][j] ; 
				dp[i][m] %= 1000000007 ;
			}
		}
	}
	cout << dp[n-1][5] << endl;
	return 0;
}

Measured memory_bytes: 10624
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n, m = map(int, input().split())
s = input()
t = input()

if s[0] != t[0]:
    print(-1)
    exit()
    
l = lcm(n, m)
k = lcm(l//n, l//m)

for i in range(1, l//k):
    if s[i*k*n // l] != t[i*k*m // l]:
        print(-1)
        exit()
        
print(l)

Measured memory_bytes: 65260
'''
import statistics

a, b, c = map(int, input().split(' '))
max_abc = max(a, b, c)
min_abc = min(a, b, c)
med_abc = statistics.median([a, b, c])
print(str(min_abc) + ' ' + str(med_abc) + ' ' + str(max_abc))
'''
a, b, c = map(int, input().split(' '))
sort_abc = sorted([a, b, c], reverse = False)
print(str(sort_abc[0]) + ' ' + str(sort_abc[1]) + ' ' +  str(sort_abc[2]))



Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int main()
{
    int t = 1;
    while (t--)
    {
        int h, w;
        cin >> h >> w;
        int m;
        cin >> m;
        int maxCol = 0, maxRow = 0;
        vector<int> hc(h + 1, 0), wc(w + 1, 0);
        map<pair<int, int>, int> mp;
        for (int i = 0; i < m; i++)
        {
            int x, y;
            cin >> y >> x;
            hc[y]++;
            wc[x]++;
            maxCol = max(maxCol, hc[y]);
            maxRow = max(maxRow, wc[x]);
            mp[{y, x}]++;
        }

        vector<int> colsWithMax, rowsWithMax;

        for (int i = 1; i <= h; i++)
        {
            if (hc[i] == maxCol)
                colsWithMax.push_back(i);
        }

        for (int i = 1; i <= w; i++)
        {
            if (wc[i] == maxRow)
                rowsWithMax.push_back(i);
        }

        int ans = maxCol + maxRow - 1;

        for (auto i : colsWithMax)
        {
            for (auto j : rowsWithMax)
            {
                if (mp.find({i, j}) == mp.end())
                {
                    ans++;
                    goto outer;
                }
            }
        }

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


Measured memory_bytes: 28540
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	vector<ll> cnt(n,0);
	ll ans = 1;
	for(int i = 0; i < n; i++) {
		if (a[i] != 0){
			if (cnt[a[i] - 1] <= cnt[a[i]]){
				cout << 0 << endl;
				return 0;
			}
			ans *= (cnt[a[i] - 1] - cnt[a[i]]);
			ans %= mod;
			cnt[a[i]]++;
		}
		else{
			cnt[0]++;
		}
	}
	if (cnt[0] == 1){
		ans *= 3;
		ans %= mod;
	}
	else{
		ans *= 6;
		ans %= mod;
	}
	for(int i = 0; i < n; i++) {
		if (cnt[i] > 3){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import copy

a = int(input())
l = list(map(int, input().split()))
l2 = sorted(copy.deepcopy(l))

#print(l2)

for i in l:
  if i < l2[a//2]:
    print(l2[a//2])
  else:
    print(l2[a//2 - 1])


Measured memory_bytes: 27156
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,h,m;
    long double p,l;
    double pi = 3.141592653589793;
    cin >> a >> b >> h >> m;
    p = (long double)(6*m-30*(h+(double)m/60))/180;
    if(p<0){
        p = p + 2;
    }
    l = (long double)(a*a + b*b - 2*a*b*cos(p*pi));
    cout << fixed << setprecision(15) << sqrt(l);
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N, M;
	cin >> N >> M;
	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }.sorted()

    var ans = 0

    for (i in 0 until n - 2) {
        val a = xs[i]
        for (j in i + 1 until n - 1) {
            val b = xs[j]

            ans += xs.binarySearch(a + b, Comparator { o1, o2 -> if (o1 >= o2) 1 else -1 }, j + 1)
                    .let { -(it + 1) - 1 }
                    .let { it - j }
        }
    }

    println(ans)
}


Measured memory_bytes: 45268
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	fastio;
	int n;
	cin >> n;
	cout << (n+1)/2 << endl;

	return 0;
}


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

int main(){
    int X;
    cin >> X;
    int maxs = 1;
    int sums = 1;
    for (int i = 1; i <= sqrt(X); i++){
        sums = 1;
        for (int j = 1; j <= sqrt(X); j++){
            if(sums * i > X){
                break;
            }else{
                sums *= i;
            }
        }
        maxs = max(maxs, sums);
    }
    cout << maxs << endl;
}

Measured memory_bytes: 256
n = int(input())

c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(n):
    num = str(i+1)
    st = int(num[0])
    en = int(num[-1])
    #print(st,en)
    c[st][en] += 1
#print(*c,sep = "\n")

ans = 0
for i in range(10):
    for j in range(10):
        if not(i == 0 and j == 0):
            ans += c[i][j]*c[j][i]


print(ans)

    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
ll modexp(ll a, ll b, ll mod)
{
	if(a <= 1)
		return a;
	if(b==0)
		return 1;
	if(b % 2 == 0)
	{
		ll res = modexp(a, b / 2, mod);
		return (res * res) % mod;
	}
	return (a * modexp(a, b - 1, mod)) % mod;
}
int main()
{
	sync;
	ll n;
	string s;
	cin >> n >> s;
	ll cnt = 0;
	for(ll i = 0; i < n; i++)
		if(s[i] == '1')
			cnt++;
	ll prev = 0, now = 0, next = 0;
	reverse(s.begin(), s.end());
	for(ll i = 0; i < n; i++)
	{
		if(s[i] == '1')
		{
			if(cnt - 1 > 0)
				prev = (prev + modexp(2ll, i, cnt - 1)) % (cnt - 1);
			if(cnt > 0)
				now = (now + modexp(2ll, i, cnt)) % cnt;
				
			next = (next + modexp(2ll, i, cnt + 1)) % (cnt + 1);	
		}
	}
	ll val[n] = {0};
	for(ll i = 0 ; i < n; i++)
	{	
		ll ans = 0;
		if(s[i] == '0')
		{
			ans++;
			ll x = (next + modexp(2ll, i, cnt + 1)) %  (cnt + 1);
			while(x)
			{
				ans++;
				x = x % __builtin_popcount(x);
			}
		}
		else
		{
			if(cnt != 1)
			{
				ans++;
				ll x  = (prev - modexp(2ll, i, cnt - 1) + cnt - 1) % (cnt - 1);
				while(x)
				{
					ans++;
					x = x % __builtin_popcount(x);
				}
			}
		}
		val[i] = ans;
	}
	for(ll i = 0; i < n ; i++)	
		cout << val[n - i -1] << "\n";
}
	

Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, ans = 0, i = 0;
    string s;
    cin>>n>>s;
    while(i < n){
        int j = i + 1;
        ans++;
        while(j < n && s[j] == s[i])j++;
        i = j;
    }
    cout<<ans;
}


int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 512