akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
typedef unsigned long long wolf;
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[4100];
char str[4100];
int main(){
	int a;
	scanf("%d%s",&a,in);
	int n=strlen(in);
	reverse(in,in+n);
 
	bitset<4020> x;
	for(int i=0;i<n;i++)if(in[i]=='1')x[i]=true;
	bitset<4020> y;
	int by,bz;
	for(int i=0;i<a;i++){
		scanf("%s",str);
		int m=strlen(str);
		bitset<4020> z;
		reverse(str,str+m);
		for(int j=0;j<m;j++)if(str[j]=='1')z[j]=true;
		//printf("%s %s\n",str+1990,z.to_string().c_str()+1990);
		if(i==0){
			y=z;
			by=strlen(str);
		}else{
			bz=strlen(str);
			while(bz){
				if(by>=bz){
					y^=(z<<(by-bz));
					while(by>0&&y[by-1]==false){
						by--;
					}
				}
				if(by<bz){
					swap(y,z);
					swap(by,bz);
				}
			}
		}
	}
	//printf("%s\n",y.to_string().c_str());
	long long ret=0;
	for(int i=0;i<=n-by;i++){
		ret=ret*2%mod;
		if(in[n-1-i]=='1')ret=(ret+1)%mod;
	}
	bitset<4020> tmp;
	for(int i=n-1;i>=by-1;i--){
		if(tmp[i]!=x[i])tmp^=(y<<(i-by+1));
	}
	//printf("%s\n",tmp.to_string().c_str());
	bool ok=true;
	for(int i=n-1;i>=0;i--){
		if(tmp[i]!=x[i]){
			if(tmp[i]){ok=false;break;}
			else {break;}
		}
	}
	if(ok)ret=(ret+1)%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])

def main():
    s = input()
    NG = 1
    NP = 0
    did = ["g"]
    point = 0
    for i in range(1,len(s)):
        if s[i] == "g":
            if NP + 1 <= NG:
                did.append("p")
                NP += 1
                point += 1
            else:
                did.append("g")
                NG += 1
        else:
            if NP + 1 <= NG:
                did.append("p")
                NP += 1
            else:
                did.append("g")
                NG += 1
                point -= 1
    print(point)

if __name__ == "__main__":
    main()

Measured memory_bytes: 47728
#include<iostream>
#include<stack>
using namespace std;
#include<stdio.h>
int main(void)
{
	while (1)
	{
		int a, b, i,j, n, x, y, m[18][18] = { 0 }, u= 0;
		pair<int, int> g, h;
		stack<pair<int, int> > q;
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
		{
			break;
		}
		for (i = 0; i <= a + 1; i++)
		{
			for (j = 0; j <= b + 1; j++)
			{
				if(i==0||i==a+1||j==0||j==b+1)
				{
					m[i][j] = 1;
				}
			}
		}
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d%d", &x, &y);
			m[x][y] = 1;
		}
		g.first = a;
		g.second = b;
		h.first = 1;
		h.second = 1;
		q.push(h);
		while (!q.empty())
		{
			h = q.top();
			q.pop();
			if (m[h.first + 1][h.second] != 1)
			{
				h.first++;
				q.push(h);
				h.first--;
			}
			if (m[h.first][h.second + 1] != 1)
			{
				h.second++;
				q.push(h);
				h.second--;
			}
			if (h == g)
			{
				u++;
			}
		}
		printf("%d\n", u);
	}
	return 0;
}

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

#define MOD 1000000007



int main() {
    ll N; cin >> N;
    string S1, S2; cin >> S1 >> S2;
    vector<int> memo(N);
    ll ans = 3;
    int i = 1;
    if (S1[0] != S2[0]) {
        ans *= 2;
        memo[0] = memo[1] = 1;
        i++;
    }
    while (i < N) {
        if (S1[i] == S2[i]) {
            if (memo[i-1]) i++;
            else {
                ans *= 2;
                ans %= MOD;
                i++;
            }
        }
        else {
            if (memo[i-1]) ans *= 3;
            else ans *= 2;
            ans %= MOD;
            memo[i] = memo[i+1] = 1;
            i += 2;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b;
  b.resize(m);
  for(int i = 0; i < m; i++) cin >> b[i];
  int ret = 0;
  while(n--) {
    int curr = c;
    for(int i = 0; i < m; i++) {
      int t;
      cin >> t;
      curr += t * b[i];
    }
    if(curr > 0) ret++;
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000

int parent[MAX], left[MAX], right[MAX];
int n, D[MAX], H[MAX];

int getDepth(int u);

void setDepth(int u, int p);

int setHeight(int u);
  
int setSibling(int u);

  void printChildren(int u);

int main(){
  int i, a, b, l, r;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)  parent[i] = left[i] = right[i] = -1;

  for( i = 0 ; i < n ; i++){
    scanf("%d", &b);
    scanf("%d", &l);
    scanf("%d", &a);
    left[b] = l;
    right[b] = a;
    if(l != -1 ) parent[l] = b;
    if(a != -1 ) parent[a] = b;
  }
   for(i = 0; i < n; i++){
    if( parent[i] == -1) r = i;
  }

  setDepth(r, 0);
  setHeight(r);

  for(i = 0 ;i < n; i++) printChildren(i);

  return 0;
}

int getDepth(int u){
  int d = 0;
  while(parent[u] != -1){
    u = parent[u];
    d++;
  }
  return d;
}

void setDepth(int u, int p){
  D[u] = p;
  if(right[u] != -1){
    setDepth(right[u], p+1);
  }
  if(left[u] != -1){
    setDepth(left[u], p+1);
  }
}

int setHeight(int u){
  int h1 = 0;
  int h2 = 0;
  if( right[u] != -1){
    h1 = setHeight(right[u]) + 1;
  }
  if( left[u] != -1){
    h2 = setHeight(left[u]) + 1;
  }
  return H[u] =(h1 > h2 ? h1 : h2);
}
int setSibling(int u){
  if(parent[u] == -1) return -1;
  if(left[parent[u]] != u && left[parent[u]] != -1) return left[parent[u]];
  if(right[parent[u]] != u && right[parent[u]] != -1) return right[parent[u]];
  return -1;
}

void printChildren(int u){

  int i, c;
  int deg = 0;
   printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("sibling = %d, ", setSibling(u));

  if(left[u] != -1) deg++;
  if(right[u] != -1) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(parent[u] == -1) printf("root\n");
  else if(left[u] == -1 && right[u] == -1) printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 2148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	char str[150];
	int a[2];
	int n,i;
	while(scanf("%d",&n)!=EOF){
		getchar();
		memset(a,0,sizeof(a));
		for(i=0;i<n;i++){
			scanf("%c",&str[i]);
		}
		for(i=0;i<n;i++){
			if(str[i] == 'R'){
				a[0]++;
			}
			else{
				a[1]++;
			}
		}
		if(a[0]>a[1]){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
B=[]
for _ in range(m):
  a,b=map(int,input().split())
  B.append([a-1,b-1])
  
B=sorted(B,key=lambda x:x[1])
ans=m
for i in range(1,m):
  if B[i][0]<B[i-1][1]:
    ans-=1
    B[i][1]=B[i-1][1]
    
print(ans)

Measured memory_bytes: 92804
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    int ans = 0;
    for(int i=1;i<=N;i+=2){
        // 奇数iについて
        int count = 0;  // 約数の個数
        for(int j=1;j<=i;j++){
            if(i % j == 0)
                count++;
        }
        if(count == 8)
            ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
from collections import deque
from itertools import chain, combinations
import json
import numpy as np


def main():
    # N = int(input())
    A = [int(a) for a in input().split()]

    A = sorted(A)

    if A[0] == A[1] and A[0] == A[2]:
        print("No")
        return

    if A[0] != A[1] and A[0] != A[2] and A[1] != A[2]:
        print("No")
        return
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 12272
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> a(n), b(n), c(n-1);
  REP(i,n){
    cin >> a[i];
    a[i]--;
  }
  REP(i,n) cin >> b[i];
  REP(i,n-1) cin >> c[i];
  ll ans = 0;
  REP(i,n){
    ans += b[a[i]];
    if(i>0 && a[i] == a[i-1]+1)ans += c[a[i-1]];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
long X;
void f(long N)
{
	for(long A=N/2;;A++)
	{
		long B=A-N;
		long d=A*A*A*A*A-B*B*B*B*B;
		if(d==X)
		{
			cout<<A<<" "<<B<<endl;
			exit(0);
		}
		else if(d>X)return;
	}
}
main()
{
	cin>>X;
	for(long d=1;d*d<=X;d++)
	{
		if(X%d==0)
		{
			f(d);
			if(d<X/d)f(X/d);
		}
	}
}


Measured memory_bytes: 3632
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if A[0][i]+A[1][i]+A[2][i]==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")

Measured memory_bytes: 12508
#include<stdio.h>
#define N 100
int main(){
  int i,j;
  int out[N][N],num,n,u,k;
  
  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      out[i][j] = 0;
    }
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&num);
      out[u-1][num-1] = 1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      if(j!=0) printf(" ");
      printf("%d",out[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

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

int main()
{
	std::string s; std::cin >> s;
	int b = s.find_first_of("A");
	int e = s.find_last_of("Z");
	s.erase(s.begin()+e+1, s.end());
	s.erase(s.begin(), s.begin()+b);
	std::cout << s.size() << std::endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
A = [0] + A
Sam = []
Dif = []
D2= [0]*200000

for i in range(len(A)):
    Sam.append(i + A[i])
    if i - A[i] > 0:
        Dif.append(i - A[i])

for dif in Dif:
    D2[dif] += 1

count = 0
for sam in Sam:
    if sam < len(D2):
        count += D2[sam]

print(count)

Measured memory_bytes: 35188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool ifp(string s){
    ll n=s.size();
    rep(i,n){
        if(s[i]!=s[n-1-i]) return false;
    }
    return true;
}

int main(){
    string s; cin>>s;
    ll n=s.size();
    string sub1=s.substr(0,(n-1)/2), sub2=s.substr((n+3)/2-1, (n-1)/2);
    if(ifp(s) && ifp(sub1) && ifp(sub2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define m(a,b)(a=a<b?b:a)
long c,x[1<<17],v[1<<17],s,L,R,r,l;i;main(n){for(scanf("%d%ld",&n,&c);~scanf("%ld%d",x+i,v+i);)L+=v[i++];for(;i--;){L-=v[i];R+=v[i];m(s,L-x[i-1]*2+m(r,R-(c-x[i])));}for(;i<n;){L+=v[i];R-=v[i++];m(s,R-(i!=n)*(c-x[i])*2+m(l,L-x[i-1]));}printf("%ld",s);}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int n, k;
	long int count = 1;
	long int saigo = 0;
	long int saisyo = 0;
	long int sum = 0;
	long int ans = 0;
	char work;
	char str[200];
	
	scanf("%s%ld", str, &k);
	
	n = strlen(str);
	
	str[n] = '5';
	str[n + 1] = '\0';
	
	//printf("%ld %ld %s %ld\n", strlen(str), k, str, n);
	
	work = str[0];
	
	if(n == 1) {
		printf("%ld", k / 2);
		return 0;
	}
	
	if(str[0] == str[n - 1]) {
		count = 1;
		for(i = n - 2; i > 0; i--) {
			if(work == str[i]) {
				count++;
				continue;
			}
			break;
		}
		saigo = count;
		
		if(saigo == n - 1) {//全部同じ文字の場合
			ans = n * k / 2;
			printf("%ld", ans);
			return 0;
		} else {//最初と最後は同じ文字だけど間に必ず違う文字が入る場合
			count = 1;
			work = str[0];
			for(i = 1; i < n; i++) {
				if(work == str[i]) {
					count++;
					continue;
				}
				break;
			}
			
			saisyo = count;//最初の文字から同じ文字が何文字続いてるか
			count = 1;
			work = str[saisyo];
			
			sum = 0;
			//間の文字の連続具合
			for(i = saisyo + 1; i < n - saigo + 1; i++) {
				if(work == str[i]) {
					count++;
				} else {
					sum += (count / 2);
					count = 1;
					work = str[i];
				}
			}
			
			ans = (sum * k);
			ans +=  ( (saisyo + saigo) / 2 ) * (k - 1);
			ans += (saisyo / 2);
			ans += (saigo / 2);
			printf("%ld", ans);
			return 0;
		}
	} else {//最初と最後の文字が違う場合間の文字の連続具合を見ればいい
		sum = 0;
		count = 1;
		work = str[0];
		for(i = 1; i <= n; i++) {
			if(work == str[i]) {
				count++;
			} else {
				sum += (count / 2);
				count = 1;
				work = str[i];
			}
		}
		ans = sum * k;
		printf("%ld", ans);
		return 0;
	}
	
	printf("%ld", ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
signed main(void){
    int n,l;cin>>n>>l;
    vector<int>V(n);rep(i,n)cin>>V[i];
    int x;bool a=false;
    rep(i,n-1){
        if(V[i]+V[i+1]>=l){x=i;a=true;break;}
    }
    if(a){
        vector<int>Ans;
        Ans.push_back(x+1);
        for(int i=x;i<n-1;i++)Ans.push_back(i+1);
        for(int i=x-1;i>=0;i--)Ans.push_back(i+1);
        reverse(all(Ans));
        cout<<"Possible"<<endl;
        rep(i,n-1)cout<<Ans[i]<<endl;
    }
    else cout<<"Impossible"<<endl;
    
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int d;
  cin >> n;
  cin >> d;
    int count =0 ;
  for(int i=0;i<n;i++)
  {
   long long int c,k;
    cin >> c >> k;
    if(sqrt(c*c+k*k)<=d)count++;
  }
    cout << count << endl;
  return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int n; cin >>n;
    vector<int> a(n); cin >> a;

    for (int i=n-1; i >= 0; i-=2) {
        cout << a[i] << (n==1?"\n":" ");
    }
    int last = n%2+(n/2-1)*2;
    for (int i = n%2; i < n; i+=2) {
        cout << a[i] << (i==last?"\n":" ");
    }   
}


Measured memory_bytes: 2944
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	v := make([]int, 100000+1)
	s := 0
	for i := 0; i < n; i++ {
		var a int
		con.Scan(&a)
		v[a]++
		s += a
	}
	var q int
	con.Scan(&q)
	for i := 0; i < q; i++ {
		var b, c int
		con.Scan(&b, &c)
		s -= v[b] * b
		s += v[b] * c
		v[c] += v[b]
		v[b] = 0
		con.Println(s)
	}
	return nil
}


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

int a, b;

inline void up(int &x, int y){
	if (y <= x)++x;
}

ll mn(int m){
	int ma1 = m + 1 >> 1, ma2 = m + 2 >> 1, mb1 = ma1, mb2 = ma2;
	up(ma1, a);
	up(ma2, a);
	up(mb1, b);
	up(mb2, b);
	return max((ll)ma1 * mb2, (ll)ma2 * mb1);
}

int main(){
	int t;
	scanf("%d", &t);
	while (t--){
		scanf("%d%d", &a, &b);
		int l = 0, r = 2e9 + 100;
		while (r > l){
			int m = (ll)l + r + 1 >> 1;
			if (mn(m) < (ll)a * b)l = m;
			else r = m - 1;
		}
		printf("%d\n", l);
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int X;
  scanf("%d", &X);

  int fiv1Cnt = 0;
  int fiv2Cnt = 0;
  while (X >= 500) {
    X = X - 500;
    fiv1Cnt++;
  }
  while (X >= 5) {
    X = X - 5;
    fiv2Cnt++;
  }
  int sum = 0;
  sum = fiv1Cnt * 1000 + fiv2Cnt * 5;
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 1704
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const B : usize = 13;
const M : usize = 1000000007;

fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    let mut s = s;
    s.reverse();
    let mut count = vec![0; B];
    let mut count2 = vec![0; B];

    if s[0] == '?' {
        for d in 0..10 {
            count[d] += 1;
        }
    } else {
        count[s[0] as usize - '0' as usize] += 1;
    }

    let mut base = 10;
    for i in 1..n {
        for j in 0..B {
            count2[j] = 0;
        }
        if s[i] == '?' {
            for d in 0..10 {
                for j in 0..B {
                    let k = (d * base + j) % B;
                    count2[k] = (count2[k] + count[j]) % M;
                }
            }
        } else {
            let d = s[i] as usize - '0' as usize;
            for j in 0..B {
                let k = (d * base + j) % B;
                count2[k] = (count2[k] + count[j]) % M;
            }
        }
        for j in 0..B {
            count[j] = count2[j];
        }
        base = base * 10 % B;
    }
    println!("{}", count[5]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)
int const N=3e3+5;
int memo[N][N];
int n,m;
string s,t;
int dp(int i,int j){
if(i==n||j==m)
    return 0;
int &ret=memo[i][j];
if(ret!=-1)
    return ret;
int path1=0;
int path2=0;
int path3=0;
if(s[i]==t[j])
    path1=dp(i+1,j+1)+1;
path2=dp(i+1,j);
path3=dp(i,j+1);
return ret=max(path1,max(path2,path3));

}
void trace(int i,int j){
if(i==n||j==m)
    return ;
int path1=-1;
if(s[i]==t[j])
    path1=1+dp(i+1,j+1);
int path2=dp(i+1,j);
int path3=dp(i,j+1);
int optimal=max(path1,max(path2,path3));
if(optimal==path1){
    cout<<s[i];
    trace(i+1,j+1);}
    else if(optimal==path2)
        trace(i+1,j);
    else
        trace(i,j+1);

}
void solve()
{
    clr(memo,-1);

cin>>s>>t;
n=s.size();
m=t.size();
int ans=dp(0,0);
trace(0,0);
cout<<endl;
}
int main()
{
    fast;
    solve();

    return 0;
}


Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
ll b;
ll a;

void addedge(ll u, ll v)

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

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

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

			
	}

int main()
{    
 

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

 ll n,k;
 cin>>n>>k;
 cout<<n-k+1<<endl;
}		





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

int main() {
  string s;
  cin >> s;
  int check = 0;
  for (int i=0; i<3 ; i++){
    if (s.at(i) == s.at(i+1)){
      check ++;
    }
  }
  if (check != 0 ){
    cout << "Bad" << endl;
  }
  else cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
 
	ll A,B,C, K,an=0;
	cin >> A>>B>>C>>K ;
	
	rep(i, 101) {
		if (A < i && i <= B && C < i && i <= K) {
			an++;
		}
	}
	
	cout << an << endl;
}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys

N,W = map(int, input().split())
v = [0] * N
w = [0] * N
for i in range(N):
  w[i],v[i] = map(int, input().split())

dp = [float('inf')] * (sum(v)+1)
dp[0] = 0

MAX_V = 0
ans = 0
for i in range(N):
  MAX_V += v[i]
  for j in range(MAX_V,-1,-1):
    if j >= v[i] and dp[j-v[i]]+w[i] <= W:
      ans = max(ans,j)
      dp[j] = min(dp[j], dp[j-v[i]]+w[i])
print(ans)


Measured memory_bytes: 50492
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Union_Find_Tree{
	public:
	int n;
	vi Par;
	Union_Find_Tree(int n){
		Par=vi(n);
		for(int i=0;i<n;i++) Par[i]=i;
	}
	int Find_Par(int x){
		if(Par[x]==x) return x;
		return Par[x]=Find_Par(Par[x]);
	}
	bool Unite(int x,int y){
		x=Find_Par(x);
		y=Find_Par(y);
		if(x==y) return 0;
		Par[x]=y;
		return 1;
	}
	bool Same(int x,int y){
		return Find_Par(x)==Find_Par(y);
	}
};

class Graph{
	private:
	int n,t=0,id=0;
	vvp g;
	vi dis,low,par;
	vp br;
	void DFS(int v,int k,int pre){
		dis[v]=low[v]=k;
		for(auto p:g[v]){
			int u=p.first,I=p.second;
			if(!dis[u]){
				par[u]=v;
				DFS(u,k+1,I);
				low[v]=min(low[v],low[u]);
				if(dis[v]<low[u]) t++;
			}
			else if(I!=pre) low[v]=min(low[v],dis[u]);
		}
	}
	public:
	int Bridge(){
		dis=low=par=vi(n);
		for(int i=0;i<n;i++) if(!dis[i]) DFS(i,1,-1);
		return t;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t){
		g[s].push_back({t,id});
		g[t].push_back({s,id++});
	}
};

const int M=10001;
int n,m;
vi s[M],t[M];

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v,c;
		cin>>u>>v>>c;
		s[c].push_back(u-1);
		t[c].push_back(v-1);
	}
	Union_Find_Tree uft(n);
	int A=0,B=0;
	for(int i=0;i<M;i++){
		int cnt=0;
		map<int,int> mp;
		for(int j=0;j<s[i].size();j++){
			int u=uft.Find_Par(s[i][j]),v=uft.Find_Par(t[i][j]);
			if(u==v) continue;
			if(mp.find(u)==mp.end()) mp[u]=cnt++;
			if(mp.find(v)==mp.end()) mp[v]=cnt++;
		}
		if(!cnt) continue;
		Graph g(cnt);
		for(int j=0;j<s[i].size();j++){
			int u=uft.Find_Par(s[i][j]),v=uft.Find_Par(t[i][j]);
			u=mp[u];v=mp[v];
			g.add_edge(u,v);
		}
		int N=g.Bridge();
		A+=N;
		B+=N*i;
		for(int j=0;j<s[i].size();j++) uft.Unite(s[i][j],t[i][j]);
	}
	cout<<A<<' '<<B<<endl;
}


Measured memory_bytes: 4784
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

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

    int max_div = 0;
    int max_num = 0;

    for (int i = 1; i <= N; i++) {
        int n = i;
        int div = 0;
        while (n % 2 == 0) {
            n /= 2;
            div++;
        }
        if (max_div <= div) {
            max_num = i;
            max_div = div;
        }
    }
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w))
            visited = [[-1] * W for _ in range(H)]
            visited[h][w] = 0
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                ans = max(ans, visited[temp_h][temp_w])
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] < 0:
                    visited[temp_h + 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h + 1, temp_w))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] < 0:
                    visited[temp_h - 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h - 1, temp_w))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] < 0:
                    visited[temp_h][temp_w + 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] < 0:
                    visited[temp_h][temp_w - 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w - 1))

print(ans)

Measured memory_bytes: 110568
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    ll n; cin >> n;
    vec<ll> M(n),m(n);
    rep(i,n){
        ll x,y; cin >> x >> y;
        M[i] = x+y;
        m[i] = x-y;
    }
    sort(M.begin(),M.end());
    sort(m.begin(),m.end());
    cout << max(M[n-1] - M[0],m[n-1] - m[0]) << endl;
}

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

using namespace std;

int main(void)
{
    int s, m=1, i, a[1000010], judge=0;

    cin >> s;

    a[1] = s;

    while(1){
        m++;

        if(s % 2 == 0){
            s = s / 2;
        }

        else{
            s = s * 3 + 1;
        }

        a[m] = s;

        for(i=1; i<=m-1; i++){
            if(a[i] == a[m]){
                judge = 1;
            }
        }

        if(judge == 1){
            break;
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],Q,L,f[100010][31];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	scanf("%d",&L);
	for(int i=1,pos=2;i<=n;i++){
		while(pos<=n&&a[pos]-a[i]<=L) pos++;
		f[i][0]=pos-1;
	}
	for(int i=1;i<=30;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	scanf("%d",&Q);
	while(Q--){
		int x,y,num=0;
		scanf("%d%d",&x,&y);
		if(x>y) swap(x,y);
		for(int i=30;i>=0;i--){
			if(f[x][i]>=y) continue;
			num+=(1<<i); x=f[x][i];
		}
		printf("%d\n",num+1);
	}
	return 0;
}

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

int n;
int h[20];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> h[i];
	
	int ma = 0, cnt = 0;
	for (i = 0; i < n; i++) {
		if (ma <= h[i]) cnt++;
		ma = max(ma, h[i]);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char a[1005];
int e,w,s,n,l;
int main(){
	scanf("%s",a);
	l=strlen(a);
	for(int i=0;i<l;i++){
		if(a[i]=='S')
			s=1;
		else if(a[i]=='N')
			n=1;
		else if(a[i]=='E')
			e=1;
		else
			w=1;
	}
	if((n^s)||(e^w))
		printf("No");
	else
		printf("Yes"); 
}

Measured memory_bytes: 128
/**********************************************
 *Author*        :XzzF
 *Created Time*  : 2018/7/7 20:02:39
 *Ended  Time*  : 2018/7/7 20:04:14
*********************************************/

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;

int a, b;

int main()
{
	while(scanf("%d %d", &a, &b) != EOF)
	{
		if(a + b == 15)	printf("+\n");
		else if(a * b == 15) printf("*\n");
		else printf("x\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int h,i,pre,j;

	while(1){
		i=0;
		char s[200];
		while((s[i++]=getchar())!='\n')
		;
		
		if(s[0]=='E'&&s[1]=='N'&&s[2]=='D'&&s[3]==' '&&s[4]=='O'&&s[5]=='F'&&s[6]==' '&&s[7]=='I'&&s[8]=='N'&&s[9]=='P'&&s[10]=='U'&&s[11]=='T')
		break;
		pre=0;
		h=i-1;
		
		for(i=0;i<h+1;i++){
			if(s[i]==' '){
					printf("%d",i-pre);
					pre=i+1;
					if(s[i+1]==' '){
					printf("0");
					i++;
					pre++;
				}
			}
			else if(s[i]=='\n'){
				printf("%d",i-pre);
				break;
			}
		}
		printf("\n");
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  string input(s);
  set<char> ng = {'A', 'C', 'G', 'T'};

  set<int> counts;
  int cnt = 0;
  REP(i, s.size()) {
    if (ng.count(s[i]) != 1) {
      counts.insert(cnt);
      cnt = 0;
    } else {
      cnt++;
    }
  }
  counts.insert(cnt);
  print(*counts.rbegin());
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }

    ll ans = T[0];

    for (int i = 1; i < N; i++)
    {
        
        ans = lcm(ans, T[i]);
        
    }
    
    cout << ans << endl;   
    return 0;

}

Measured memory_bytes: 3588
#include<cstdio>

using namespace std;

const int N = 505;
const int C = 35;
int n, c, d[C][C], col, ans = 0x7fffffff;
int t[4], cnt[3][C];
bool used[C];

void updateAns(){
	int res = 0;
	t[0] = t[3];
	for(int i = 0; i < 3; i++)
		for(int j = 1; j <= c; j++)
			res += d[j][t[i]] * cnt[i][j];
	if(ans > res)	ans = res;
}

void dfs(int pos){
	if(pos == 3){
		updateAns();
		return;
	}
	for(int i = 1; i <= c; i++){
		if(used[i])	continue;
		t[pos+1] = i, used[i] = 1;
		dfs(pos+1);
		t[pos+1] = 0, used[i] = 0;
	}
}

int main(){
	scanf("%d%d", &n, &c);
	for(int i = 1; i <= c; i++){
		for(int j = 1; j <= c; j++)
			scanf("%d", &d[i][j]);
		d[i][i] = 0;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			scanf("%d", &col);
			cnt[(i+j)%3][col]++;
		}
	}
	dfs(0);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n - 1);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n - 1) cin >> c[i];
	int sum = 0;
	rep(i, n) sum += b[i];
	rep(i, n-1)
	{
		if (a[i]+1 == a[i + 1])
		{
			sum += c[a[i]-1];
		}
	}

	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3628
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]
M = [[0] * W for _ in range(H)]

for i in range(N):
  if xya[i][2] == 1:
    for a in range(H):
      for b in range(xya[i][0]):
        M[a][b] = 1
  elif xya[i][2] == 2:
    for a in range(H):
      for b in range(W-xya[i][0]):
        M[a][W-b-1] = 1
  elif xya[i][2] == 3:
    for a in range(xya[i][1]):
      for b in range(W):
        M[a][b] = 1
  else:
    for a in range(H-xya[i][1]):
      for b in range(W):
        M[H-a-1][b] = 1
#print(M)
c = 0
for i in range(H):
  c += M[i].count(0)
print(c)

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

int main(){
 int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int e,f,g,h;

    g=-(y2-y1)+x1;
    h=x2-x1+y1;
    e=x2-x1+g;
    f=y2-y1+h;
  cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;

}

Measured memory_bytes: 256
h, w = map(int, input().split())
s_input = []
for i in range(h):
    s_input.append(input())

can_draw = True

for i in range(h):
    for j in range(w):
        if s_input[i][j] == '#':
            if i - 1 >= 0:
                if s_input[i - 1][j] == '#':
                    #ok
                    continue
            if j - 1 >= 0:
                if s_input[i][j - 1] == '#':
                    #ok
                    continue
            if j + 1 < w:
                if s_input[i][j + 1] == '#':
                    #ok
                    continue
            if i + 1 < h:
                if s_input[i + 1][j] == '#':
                    #ok
                    continue
            can_draw = False
            break
    if not can_draw:
        break

print('Yes' if can_draw else 'No')

Measured memory_bytes: 3064
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
h={}
n.times do
  k = gets.chomp
  h[k] ||= 0
  h[k] += 1
end

max = 0
h.sort_by{|k,v| -v}.each do |k,v|
  max = v
  break
end
# p [h, max]
ans = []
h.sort_by{|k,v| -v}.each do |k,v|
  break if v != max
  ans.push k
end

ans.sort.each do |l|
  puts l
end

Measured memory_bytes: 48376
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
int n;
double dp[101][101];
int t[101];
int vm[101];

int main(int argc, char const* argv[])
{
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t[i];
  }
  for(int i = 0; i < n; i++){
    cin >> vm[i];
  }
  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 101; j++){
      dp[i][j] = -1.;
    }
  }
  dp[0][0] = 0.;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 101; j++){
      if(vm[i] < j){
        break;
      }
      dp[i + 1][j] = 0.;
      bool flag = false;
      for(int k = 0; k <= vm[i]; k++){
        if(dp[i][k] < 0)continue;
        double tmp = 0.;
        double at_t = 0.5 * (j - k + t[i]);
        if(at_t < 0 || at_t > t[i])continue;
        flag = true;
        double at_y = k + at_t;
        if(at_y < vm[i])tmp += 0.5 * at_t * (k + at_y) + 0.5 * (t[i] - at_t) * (j + at_y);
        else tmp += 0.5 * (vm[i] - k) * (vm[i] + k) + 0.5 * (vm[i] - j) * (vm[i] + j) + (t[i] - vm[i] + k - vm[i] + j) * vm[i];
        dp[i + 1][j] = max(dp[i + 1][j], tmp + dp[i][k]);
      }
      if(!flag)dp[i + 1][j] = -1.;
    }
  }
  cout << setprecision(12);
  cout << dp[n][0] << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int compare = Integer.compare(Integer.parseInt(scanner.next(), 16), Integer.parseInt(scanner.next(), 16));
        System.out.println(compare == 0 ? "=" : compare == 1 ? ">" : "<");
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int ans = 0;
            for(int i = 0; i < N - 2; i++)
            {
                if(S.Substring(i , 3) == "ABC")
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 27300
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll v(N);
  rep(i, N) {
    cin >> v[i];
  }
  SORT(v);

  ld before = v[0];
  rep(i, N) {
    before += v[i];
    before /= 2;
  }
  COUTF(before);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int N;
    cin>>N;
    string s[N];
    rep(i,N) cin>>s[i];
    rep(i,N) sort(s[i].begin(),s[i].end());
    map<string,int> kumi;
    rep(i,N) kumi[s[i]]++;
    ll ans=0;
    for(auto i=kumi.begin(); i!=kumi.end(); i++){
        ll as=(i->second);
        ans+=(as*(as-1))/2;
    }
    cout<<ans;

}

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

int main(){
    long long int a, b, c;
    cin >> a >> b >> c;
    if(c - a - b > 0 && (c - a - b) * (c - a - b) > 4 * a * b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
ll n, M = 1e9 + 7;
map<ll, ll> d;
ll f(ll p) {
	if (p == 0) return 1;
	if (p == 1) return 2;
	if (p == 2) return 4;
	if (d[p]) return d[p];
	if (p&1) return d[p] = (2 * f(p / 2) + f(p / 2 - 1)) % M;
	else return d[p] = (f(p / 2) + 2 * f(p / 2 -1)) % M;
}
int main()
{
	cin >> n;
	cout << f(n);
    return 0;
}


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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t*s) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll N,X,M; // N:個数
    cin>>N>>X>>M;
    map<ll,int> ma;
    vector<ll> v;
    ll a=X;
    int i=0;
    while(!ma.count(a)){
        v.push_back(a);
        ma[a]=i++;
        a=(a*a)%M;
    }
    v.push_back(a); // 忘れずに！
    ll c=i-ma[a]; // 循環周期
    ll s=ma[a]; // 循環スタート
    vector<ll> cv(c+1);
    cv[0]=0;
    for(int i=1;i<=c;i++) cv[i]=cv[i-1]+v[i+s]; // 巡回内累積
    ll ans=0;
    if(N<=s){ // 循環前
        rep(i,N) ans+=v[i];
    }
    else{
        for(int i=0;i<=s;i++) ans+=v[i]; // スタート位置まで
        ans+=(N-1-s)/c*cv[c];
        ans+=cv[(N-1-s)%c];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7196
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>
#include <string>
#include <map>
#include <iomanip>

bool is_valid(const std::vector<char>& str, const int pos) {
	return (pos >= 0 && pos + 2 < str.size()) && str[pos] == 'A' && str[pos + 1] == 'B' && str[pos + 2] == 'C';
}
bool can_make(const std::string& str) {
	std::vector<std::vector<char>> temp(2);
	for (const auto c : str) temp[0].push_back(c);
	for (auto i = 0; temp[i % 2].size() > 3; ++i) {
		bool a = true, b = true, c = true;
		bool exists_a = false, exists_b = false, exists_c = false;
		for (auto j = 0; j < temp[i % 2].size(); ++j) {
			switch (temp[i % 2][j]) {
			case 'A':
				exists_a = true;
				a &= is_valid(temp[i % 2], j); break;
			case 'B':
				exists_b = true;
				b &= is_valid(temp[i % 2], j - 1); break;
			case 'C':
				exists_c = true;
				c &= is_valid(temp[i % 2], j - 2); break;
			default: break;
			}
		}
		if (!exists_a || !exists_b || !exists_c) return false;
		auto count = 0;
		if (a) ++count; if (b) ++count; if (c) ++count;
		if (count != 1) return false;
		for (auto j = 0; j < temp[i % 2].size(); ++j) {
			switch (temp[i % 2][j]) {
			case 'A': 
				if (a) {
					for (auto k = 0; k < 3; ++k)
						temp[i % 2][j + k] = 'X';
					temp[i % 2][j] = 'A';
				}
				break;
			case 'B':
				if (b) {
					for (auto k = 0; k < 3; ++k)
						temp[i % 2][j + k - 1] = 'X';
					temp[i % 2][j - 1] = 'B';
				}
				break;
			case 'C':
				if (c) {
					for (auto k = 0; k < 3; ++k)
						temp[i % 2][j + k - 2] = 'X';
					temp[i % 2][j - 2] = 'C';
				}
				break;
			default: break;
			}
		}
		temp[(i + 1) % 2].clear();
		for (auto j = 0; j < temp[i % 2].size(); ++j) {
			if (temp[i % 2][j] != 'X') temp[(i + 1) % 2].push_back(temp[i % 2][j]);
		}
	}
	return is_valid(temp[0], 0) || is_valid(temp[1], 0);
}
int main() {
	std::string str; std::cin >> str;
	if (can_make(str)) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 3220