akhauriyash/Code-Regression huggingface dataset:
from time import time
from random import randrange
start = time()
d = int(input())
c = list(map(int, input().split()))
s = []
for _ in range(d):
    s.append(list(map(int, input().split())))
t = []
v = 0
last = [-1]*26
for i in range(d):
    bst = -10**10
    for j in range(26):
        tmp = s[i][j]
        for k in range(26):
            if j!=k:
                tmp -= c[k]*(i-last[k])
        if tmp>bst:
            bst = tmp
            bst_idx = j
    last[bst_idx] = i
    t.append(bst_idx)
    v += s[i][bst_idx]
    for j in range(26):
        v -= c[j]*(i-last[j])
mx = v
while time()-start<1.85:
    newt = t[:]
    nd = randrange(d)
    now = newt[nd]
    nq = randrange(25)
    newt[nd] = nq if nq<now else nq+1
    v = 0
    last = [-1]*26
    for i in range(d):
        v += s[i][newt[i]]
        last[newt[i]] = i
        for j in range(26):
            v -= c[j]*(i-last[j])
    if v>mx:
        mx = v
        t = newt
for i in t:
    print(i+1)

Measured memory_bytes: 81084
import sys
from sys import stdin
input = stdin.readline
import math

th = math.pi/3.000000000000000

n = int(input())

p1 = [0.0000000000000000,0.00000000000000000]
p2 = [100.0000000000000,0.00000000000000000]

def koch(n,p1,p2):
    if n == 0:
        return
    s =[0,0]
    t =[0,0]
    u =[0,0]

    s[0] = (2.0 * p1[0] +1.0 * p2[0]) / 3.0
    s[1] = (2.0 * p1[1] +1.0 * p2[1]) / 3.0
    t[0] = (1.0 * p1[0] +2.0 * p2[0]) / 3.0
    t[1] = (1.0 * p1[1] +2.0 * p2[1]) / 3.0
    u[0] = (t[0] - s[0]) * math.cos(th) - (t[1] - s[1]) * math.sin(th) + s[0]
    u[1] = (t[0] - s[0]) * math.sin(th) + (t[1] - s[1]) * math.cos(th) + s[1]
      # p1,p2からs,t,uの座標を計算
    koch(n-1, p1, s)
    print(s[0],s[1])
    koch(n-1, s, u)
    print(u[0],u[1])
    koch(n-1, u, t)
    print(t[0],t[1])
    koch(n-1, t, p2)

print(0,0)
koch(n,p1,p2)
print(100,0)



Measured memory_bytes: 5784
#include <stdio.h>

int main(void) {
	long long a[5000];
	long long ask[5001];
	int max;
	int i;
	int j;
	int sign;
	long long saidaiti;
	long long now;
	while(1) {
		scanf("%d",&max);
		if(max==0)break;
		for(i=0;i<max;i++)scanf("%lld",&a[i]);
		for(i=0,j=0,sign=0;i<max;i++) {
			if(a[i]*sign<=0 && a[i]!=0) {
				sign=(a[i]>0)?1:-1;
				j++;
				ask[j]=0;
			}
			ask[j]+=a[i];
		}
		for(i=1;i<=j;i++) {
			if(ask[i]>=0)break;
		}
		if(i>j) {
			saidaiti=a[0];
			for(i=1;i<max;i++) {
				if(a[i]>saidaiti)saidaiti=a[i];
			}
		} else {
			max=j+1;
			saidaiti=ask[1];
			for(i=1;i<max;i++)ask[i]+=ask[i-1];
			for(i=1;i<=max;i++) {
				for(j=0;j<=max-i;j++) {
					now=ask[j+i]-ask[j];
					if(now>saidaiti)saidaiti=now;
				}
			}
		}
		printf("%lld\n",saidaiti);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
const int MAX_T = 3000, MAX_M=300;
int M, start, goal,dice[6], *N;
 
bool isPositionValid(int p){return 0<=p && p<M;}
 
int* MakePath(int *path, int from){
    static bool visit[MAX_M] = {};
    static auto checkPath = [&path](int moveto)->int{
        if(!isPositionValid(moveto))	return 2*MAX_T;
        else{
            int position = moveto+ N[moveto];
            if(!visit[position]) MakePath(path, position);
            return  path[position]+1;
        }
    };
 
    if(path==NULL){
        path = new int[M];
        for(int m=0; m<M; m++) path[m] = MAX_T+1;
    }
 
    visit[from] = true;
    int bestpath = MAX_T;
    if(from==goal)  bestpath = 0;
    else{
        for(int d : dice){
            bestpath = min(bestpath, checkPath(from + d));
            bestpath = min(bestpath, checkPath(from - d));
        }
    }
    path[from] = bestpath;
    return path;
}
 
int main(){
    // 入力
    cin >> M;
    for(int r=0; r<6; r++)   cin >> dice[r];
    cin >> start >> goal;
	start--, goal--;
	N = new int[M];
    for(int m=0; m<M; m++)   cin >> N[m];
    
    int* path = MakePath(NULL, start);
     
    //本番
    int position = start;
    for(int t=0; t<MAX_T; t++){
        if(position == goal) break;
     
        int r;
        cin >> r;
        int d = dice[r-1];
 
        static auto tryMove = [&path](int moveto, int& position)->bool{
			if(isPositionValid(moveto)){
				int new_position = moveto + N[moveto];
                if(path[position] > path[new_position]){
					position = new_position;
					return true;
				}
			}
            return false;
        };
     
		int output;
        if     (tryMove(position + d, position)) output = 1;
		else if(tryMove(position - d, position)) output = -1;
		else output = 0;
		cout << output << endl;
    }
 
    delete[] N;
    delete[] path;
    return 0;
}

Measured memory_bytes: 1304
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from operator import itemgetter

n = ni()
ab = [tuple(li()) for i in range(n)]
cd = [tuple(li()) for i in range(n)]

ab.sort(key=itemgetter(0), reverse=True)
cd.sort(key=itemgetter(1))

cd_used = [False]*n

ans = 0
for ai, bi in ab:
    for j, (cj, dj) in enumerate(cd):
        if ai < cj and bi < dj and (not cd_used[j]):
            cd_used[j] = True
            ans += 1

            break

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
	int i = 0;
	char str[21];

	while(scanf("%s",str) != EOF)
	{
		while(str[i + 1] != '\0'){
					i++;
				   }
		for(;i >= 0;i--){
					printf("%c",str[i]);
				}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 524
fun main(args: Array<String>) {
    abc136d()
}

fun abc136d() {
    val isRight = readLine()!!.map { it == 'R' }.toBooleanArray()

    // RR...LL でグルーピング
    val grouped = mutableListOf<Pair<BooleanArray, Int>>()
    var left = 0
    while (left in isRight.indices) {
        var right = left
        // Lの左端まで移動
        while (right in isRight.indices && isRight[right]) right++
        // Rの右端を取っておく
        val rightestOfR = right - left - 1
        // Rの左端まで移動(次のグループの始点)
        while (right in isRight.indices && !isRight[right]) right++
        grouped.add(Pair(isRight.slice(left until right).toBooleanArray(), rightestOfR))

        left = right
    }

    var currentLeft = 0
    val answer = grouped.map { pair ->
        val (booleans, rightestOfR) = pair
        // .. RL .. にすべて集まる
        // それぞれ偶数マス離れたものが最終的に集約される
        val rIndexIsEven = rightestOfR % 2 == 0
        val r = booleans.filterIndexed { index, b -> (index % 2 == 0) == rIndexIsEven }.count()
        val l = booleans.filterIndexed { index, b -> (index % 2 == 0) != rIndexIsEven }.count()
        val ret = IntArray(booleans.size) { 0 }
        ret[rightestOfR] = r
        ret[rightestOfR + 1] = l
        currentLeft += booleans.size
        ret
    }.flatMap { it.asIterable() }.joinToString(" ")

    println(answer)
}


Measured memory_bytes: 55204
#include <bits/stdc++.h>
 using namespace std;
 bool sortbysec(pair<long long int,long long int> a,pair<long long int,long long int> b)
 {
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
 }     
 int main()
{
   // #define long long int long long long long int
    int n,m,i,j,c,d;
    string s1,s2,s;
    cin >> s1 >> s2;
    n=s1.length(),m=s2.length();
    int mat[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            mat[i][j]=0;
    }
    if(s1[0]==s2[0])
        mat[0][0]=1;
    for(i=1;i<n;i++)
    {
        if(mat[i-1][0]==1)
            mat[i][0]=mat[i-1][0];
        else
        {
            if(s1[i]==s2[0])
                mat[i][0]=1;
        }
    }
    for(j=1;j<m;j++)
    {
        if(mat[0][j-1]==1)
            mat[0][j]=mat[0][j-1];
        else
        {
            if(s1[0]==s2[j])
                mat[0][j]=1;
        }
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(s1[i]==s2[j])
                mat[i][j]=mat[i-1][j-1]+1;
            else
            {
                mat[i][j]=max(mat[i-1][j],mat[i][j-1]);
            }
        }
    }
    i=n-1;j=m-1;s="";
    while(i>=0 && j>=0)
    {
        if(s1[i]==s2[j])
        {
            s=s1[i]+s;
            i--;j--;
        }
        else
        {
            if(j-1>=0 && mat[i][j]==mat[i][j-1])
                j--;
            else if(i-1>=0)
                i--;
            else
            {
                i--;
                j--;
            }
        }
    }

    cout << s;

    
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 1999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
stringstream input(R"(
5
3
3
1
1
5
)");
#define cin input
#endif

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

	vector<int> a(n);
	REP(i,n)
		cin >> a[i];
	sort(a.begin(), a.end());

	int p, q, ap, aq;
	p = a[0];
	q = a[n-1];
	a.pop_back();
	a.erase(a.begin());
	ll mx = q-p;

	if(n>2)
	{
		REP(i, n-2)
		{
			ap = a[0];
			aq = a[n-3-i];
			if(max(abs(ap-p), abs(ap-q)) > max(abs(aq-p), abs(aq-q)))
			{
				if(abs(ap-p)<abs(ap-q))
				{
					mx += abs(ap-q);
					q = ap;
				}
				else
				{
					mx += abs(ap-p);
					p = ap;
				}
				a.erase(a.begin());	
			}
			else
			{
				if(abs(aq-p)<abs(aq-q))
				{
					mx += abs(aq-q);
					q = aq;
				}
				else
				{
					mx += abs(aq-p);
					p = aq;
				}
				a.pop_back();
			}
		}
	}
	cout << mx << endl;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.naturalOrder());
        int N = sc.nextInt();

        for (int i=0; i<N; i++) {
            queue.add(sc.nextInt());
        }
        for (int i=0; i<N/2-1; i++) {
            queue.poll();
        }
        int before = queue.poll();
        int after = queue.poll();

        out.println(after - before);
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



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

using namespace std;

const int N=2e5+5;
int n,dem[N],a[N];

long long calc(int x)
{
    return 1ll*x*(x-1)/2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    long long res=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        res-=calc(dem[a[i]]);
        dem[a[i]]++;
        res+=calc(dem[a[i]]);
    }
    for(int i=1;i<=n;i++) cout<<res-calc(dem[a[i]])+calc(dem[a[i]]-1)<<'\n';
}


Measured memory_bytes: 3712
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
double a[101];
int main() {
  int n;
  cin >> n;
  rep(i,n)
    cin >> a[i];
  double sum = 0;
  rep(i,n)
    sum += a[i];
  int av = round(sum / n);
  int ans = 0;
  rep(i,n)
    ans += pow((int)a[i]-av, 2);
  cout << ans << endl;
}


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

#define int long long

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e3 + 3;

pp t[2];
int P[N],W[N],w,n,i,j,x;

signed main(){
    cin >> n;
    t[0].st = t[1].st = -(1LL << 55);
    for(i=1;i<=n;i++){
        cin >> x;
        j = i&1;
        if(t[j].st > 0){
            P[i] = t[j].nd;
            x += t[j].st;
        }
        t[i&1] = max(t[i&1] , mp(x,i));
    }
    
    cout << max(t[0].st , t[1].st) << endl;
    
    j = t[ t[1].st > t[0].st ].nd;
    for(i=n; i>j; i--) W[++w] = i;
    for(; P[j] ; j = P[j]){
        x = j-P[j] >> 1;
        for(i=j+P[j]>>1 ;x--; i--)
            W[++w] = i;
    }
    for(;--j;) W[++w] = 1;
    
    cout << w << endl;
    for(i=1;i<=w;i++) cout << W[i] << endl;
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
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 K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<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;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#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 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int A,B,C,X,Y; cin >>A>>B>>C>>X>>Y;

    int ans = INT_MAX;

    chmin(ans, A*X + B*Y);
    chmin(ans, C * 2* max(X, Y));
    if (X > Y) {
        chmin(ans, C*2*Y + A*(X-Y));
    } else {
        chmin(ans, C*2*X + B*(Y-X));
    }

    cout << ans << endl;
}


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

int main() {
  int n, l; cin >> n >> l;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  sort(s.begin(), s.end());
  string ans = "";
  rep(i,n) ans += s[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3496
import sys
import itertools
tokens = itertools.chain.from_iterable(map(str.split, sys.stdin))

no = 'IMPOSSIBLE'
a = int(next(tokens))
b = int(next(tokens))

# k = (a^2 - b^2) / {2 (a - b)}
k = (a**2 - b**2) // (2 * (a - b))
if abs(a - k) != abs(b - k):
    print(no)
else:
    print(k)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;

int main(){
  int n; scanf("%d", &n);
  vector<P> data(n);
  for(int i = 0; i < n; i++) scanf("%lld %lld", &data[i].second, &data[i].first);
  sort(data.begin(), data.end());
  ll now = 0;
  bool ok = true;
  for(int i = 0; i < n; i++){
    now += data[i].second;
    if(now > data[i].first) ok = false;
  }
  if(ok) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
int n;
int v[100100][3];
int dp[100100][3];

void run(int i) {
	if(i == n - 1) {
		dp[i][0] = v[i][0];
		dp[i][1] = v[i][1];
		dp[i][2] = v[i][2];
		return;
	}
	run(i + 1);
	dp[i][0] = v[i][0] + max(dp[i + 1][1], dp[i + 1][2]);
	dp[i][1] = v[i][1] + max(dp[i + 1][0], dp[i + 1][2]);
	dp[i][2] = v[i][2] + max(dp[i + 1][0], dp[i + 1][1]);
}

int main() {
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	run(0);
	int ans = max(
		dp[0][0],
		max(dp[0][1], dp[0][2])
	);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 5760
import sys

input = sys.stdin.readline


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = input().rstrip()

    if C < D:
        is_ok = True
        for i in range(A, D):
            if S[i:i + 2] == "##":
                is_ok = False
                break
        ans = "Yes" if is_ok else "No"
    else:
        is_ok = True
        for i in range(A, C):
            if S[i:i + 2] == "##":
                is_ok = False
                break
        if not is_ok:
            ans = "No"
        else:
            is_ok = False
            for i in range(B, D + 1):
                if S[i - 1:i + 2] == "...":
                    is_ok = True
                    break
            ans = "Yes" if is_ok else "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9516
from collections import defaultdict
n,k = map(int,input().split())
l = list(map(int,input().split()))

mod = [0]
for i in range(n):
    a = (l[i]-1)%k
    mod.append((mod[-1]+a)%k)
dic = defaultdict(int)
ans = 0
for i in range(n+1):
    if i < k:
        ans += dic[mod[i]]
        dic[mod[i]] += 1
    else:
        dic[mod[i-k]] -= 1
        ans += dic[mod[i]]
        dic[mod[i]] += 1
    
print(ans)


Measured memory_bytes: 41352
#include <stdio.h>
#include <string.h>
#include <math.h>
#define MAX (a>b?a:b)

long long int fact(int n)
{
    if(n==1)
        return 1;
    else
        return n * fact(n-1);
}

long long int combination(int n, int r)
{
    if(n>r)
        return fact(n) / (fact(r)*fact(n-r));
    else if(n==r)
        return 1;
    else
        return 0;
}

int main()
{
    int i, j, n, count[101]={0};
    int yakusu2=0, yakusu4=0, yakusu14=0, yakusu24=0, yakusu74=0;

    scanf("%d",&n);
    for(i=2; i<=n; i++) {
        int temp = i;
        for(j=2; j<=i; j++) {
            while(temp%j==0) {
                temp /= j;
                count[j]++;
            }
        }
    }

    for(i=2; i<=n; i++) {
        if(count[i]>=74)yakusu74++;
        if(count[i]>=24)yakusu24++;
        if(count[i]>=14)yakusu14++;
        if(count[i]>= 4)yakusu4++;
        if(count[i]>= 2)yakusu2++;
        //if(count[i]>0)printf("count[%d] = %d\n",i,count[i]);
    }  

    long long int ans=0;

    ans += yakusu74;
    ans += (yakusu2-1)*(yakusu24);
    ans += (yakusu4-1)*(yakusu14);
    ans += (yakusu2-2)*combination(yakusu4, 2);

    //printf("nCr = %lld\n",(yakusu2-2)*combination(yakusu4, 2));

    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>

using namespace std;

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

  string s, t;
  cin >> s >> t;
  
  int len = t.length();
  int range = s.length() - len + 1;
  int min = len, cnt;
  for (int i = 0; i < range; i++)
  {
    cnt = 0;
    for (int j = 0, k = i; j < len; j++, k++)
      s[k] != t[j] && cnt++;
    min = min > cnt ? cnt : min;
  }
  cout << min;
  
  return 0;
}


Measured memory_bytes: 3192
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = input()
cnt_1 = 0
cnt_2 = len(s) - 1
ans = 0
m = len(s)
end = m // 2
for i in range(cnt_2 + 1):
    if s[cnt_1] == s[cnt_2]:
        if end != cnt_1:
            cnt_1 += 1
        if end != cnt_2:
            cnt_2 -= 1
    elif s[cnt_1] == 'x':
        cnt_1 += 1
        ans += 1
        m += 1
    elif s[cnt_2] == 'x':
        cnt_2 -= 1
        ans += 1
        m -= 1
    else:
        print(-1)
        exit()
    end = m // 2
    if end == cnt_1 and end == cnt_2:
        break
print(ans)


Measured memory_bytes: 3316
n, m, x, y = list(map(int, input().split()))
xn = list(map(int, input().split()))
yn = list(map(int, input().split()))
maxx = max(xn)
miny = min(yn)
if x < miny and miny <= y and miny > maxx:
    print("No War")
else:
    print("War")


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef pair <int, int> pii;
typedef pair <int, pii> piii;

piii a[100010];
int fa[200010], size[200010];

int find(int x) {return x == fa[x] ? x : fa[x] = find(fa[x]);}

void merge(int x, int y) {
	size[x] += size[y], fa[y] = x;
}

bool check(int x, int y) {
	x = find(x), y = find(y);
	if (x != y) merge(x, y);
	if (size[x]) {
		size[x]--;
		return 1;
	}
	return 0;
}

int main() {
	int n, h, w; scanf("%d%d%d", &n, &h, &w);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &a[i].se.fi, &a[i].se.se, &a[i].fi);
		a[i].se.se += h;
	}
	sort(a, a + n), reverse(a, a + n);
	for (int i = 1; i <= h + w; i++) {
		fa[i] = i, size[i] = 1;
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (check(a[i].se.fi, a[i].se.se)) ans += a[i].fi;
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
    string S;
    string ans = "";
    cin >> S;
    rep(i,S.size()) ans = ans + "x";
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  
  vector<int> a(100,0);
  for(int i = 0; i < s.size(); i++){
    a[s[i] - 'a']++;
  }
  bool is_ugly = false;
  for(int i = 0; i < a.size(); i++){
    if(a[i] % 2 == 1){
      is_ugly = true;
      break;
    }
  }
  if(!is_ugly) cout << "Yes";
  else cout << "No";
}


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

typedef long long ll;
 
int main(){
  int h1, h2, m1, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int wu = h2*60 - h1*60 + m2 - m1;
  int ans = wu - k;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int a,b;
    cin >> a >> b;
    cout << (a+b) % 24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
ll dp1[5005]={0},dp2[25000005]={0};
const ll inf=174417441744;
signed main(){
  ll n;
  cin>>n;
  ll ga,sa,ba,gb,sb,bb;
  cin>>ga>>sa>>ba>>gb>>sb>>bb;

  for(int i=0;i<5005;i++) dp1[i]=-inf;
  dp1[n]=n;
  for(int i=n;i>=1;i--){
    if(i-ga>=0&&gb>ga) dp1[i-ga]=max(dp1[i-ga],dp1[i]+gb-ga);
    if(i-sa>=0&&sb>sa) dp1[i-sa]=max(dp1[i-sa],dp1[i]+sb-sa);
    if(i-ba>=0&&bb>ba) dp1[i-ba]=max(dp1[i-ba],dp1[i]+bb-ba);
  }
  for(int i=0;i<25000005;i++) dp2[i]=-inf;
  for(int i=0;i<5005;i++){
    if(dp1[i]>=0) dp2[dp1[i]]=dp1[i];
  }
  for(int i=25000000;i>=1;i--){
    if(i-gb>=0&&ga>gb) dp2[i-gb]=max(dp2[i-gb],dp2[i]+ga-gb);
    if(i-sb>=0&&sa>sb) dp2[i-sb]=max(dp2[i-sb],dp2[i]+sa-sb);
    if(i-bb>=0&&ba>bb) dp2[i-bb]=max(dp2[i-bb],dp2[i]+ba-bb);
  }
  ll ans=0;
  for(int i=0;i<25000005;i++){
    ans=max(ans,dp2[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 195712
#include<iostream>
using namespace std;
int main()
{
    string s;
    int i,n=0;
    cin>>s;
    for(i=0;i<s.size();i++){

        if(s[i]=='+'){
            n++;
        }if(s[i]=='-'){
            n--;
        }
    }
    cout<<n<<endl;

    return 0;
}


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

using namespace std;

int n,m;
map<int,int> mpp;

void solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mpp[x]++;     
    }
    cin>>m;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        if(mpp.find(x)!=mpp.end()){
            mpp[x]--;       
        }else{
            cout<<"NO";
            return ;         
        }
        if(mpp[x]==0){
            mpp.erase(x);    
        }
    }
    cout<<"YES";
}

int main(){
    solve();
    return 0;                                                                                                                                             
 }

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, M;
  cin >> H >> W >> M;
  vector<vector<int>> Y(H + 1), X(W + 1);
  vector<int> countY(H + 1, 0), countX(W + 1, 0);
  for (int i = 0; i < M; i++) {
    int y, x;
    cin >> y >> x;
    x--, y--;
    Y[y].emplace_back(x);
    countY[y]++;
    X[x].emplace_back(y);
    countX[x]++;
  }
  for (int i = 0; i < H; i++) {
    sort(Y[i].begin(), Y[i].end());
  }
  for (int i = 0; i < W; i++) {
    sort(X[i].begin(), X[i].end());
  }
  vector<map<int, int>> YC(M + 1);
  vector<int> YCC(M + 1, 0);
  for (int i = 0; i < H; i++) {
    if (Y[i].empty()) continue;
    YCC[countY[i]]++;
    for (int j : Y[i]) {
      YC[countY[i]][j]++;
    }
  }
  int a = -1, b = -1;
  for (int i = M; i > -1; i--) {
    if (YC[i].empty()) continue;
    if (a == -1) {
      a = i;
    } else if (b == -1) {
      b = i;
    }
  }
  int res = 0;
  for (int w = 0; w < W; w++) {
    int tot = countX[w];
    int x = 0, y = 0;
    if (a != -1) {
      x = a;
      if (YC[a][w] == YCC[a]) x--;
    }
    if (b != -1) {
      y = b;
      if (YC[b][w] == YCC[b]) y--;
    }
    tot += max(x, y);
    res = max(res, tot);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 95736
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int n;

int main(){
  cin >> n;
  vector<int> h(n);
  rep(i,n){
    cin >> h.at(i);
  }

  int ans=0;
  int active=0;
  for(int i=0;i<n;i++){
    if(active>=h[i]){
      active=h[i];
    }else{
      ans+=h[i]-active;
      active=h[i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
// atcoder/abc143/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> v(n);
    cin >> v;
    lli sum = 0;
    for (int i = 0; i < v.size(); ++i) {
      for (int j = i + 1; j < v.size(); ++j) {
        sum += v[i] * v[j];
      }
    }
    cout << sum << endl;
  }

  return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int count[M];
    for (int i = 0; i < M;i++){
        count[i] = 0;
    }

    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            int Aij;
            cin >> Aij;
            count[Aij - 1] += 1;
        }
    }

    int samecount = 0;
    for (int i = 0; i < M; i++)
    {
        if(count[i]==N){
            samecount++;
        }
    }
    cout << samecount << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<String> S = new List<String>();
            List<int> P = new List<int>();
            List<int> lank = new List<int>();

            for (int i = 0; i < N; i++)
            {
                String SL = Console.ReadLine();
                String[] line = SL.Split(' ');

                String Si = line[0];
                int Pi = int.Parse(line[1]);
                int j = 0;

                if (i > 0)
                {
                    for (j = 0; j < i; j++)
                    {

                        if (String.Compare(Si, S[j]) == -1)
                        {
                            S.Insert(j, Si);
                            P.Insert(j, Pi);
                            lank.Insert(j, i);
                            break;
                        }
                        else if (String.Equals(Si, S[j]) == true)
                        {
                            if (Pi > P[j])
                            {
                                S.Insert(j, Si);
                                P.Insert(j, Pi);
                                lank.Insert(j, i);
                                break;
                            }
                        }
                    }
                    if (j == i)
                    {
                        S.Add(Si);
                        P.Add(Pi);
                        lank.Add(i);
                    }

                }
                else
                {
                    S.Add(Si);
                    P.Add(Pi);
                    lank.Add(i);
                }



            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(lank[i] + 1);
            }




        }
    }
}

Measured memory_bytes: 11360
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

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

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
//#define int ll

using namespace std;
//using namespace __gnu_pbds;

//template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 40, T = 4 * N, inf = 1e9 + 7;

ll n, m, f, r, l, e, w, o, z, test, id, mx = -inf;
ll a[N], d[N], b[N];

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

void boos()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

main()
{
    //freop();
    boos();
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int j = 0; j < n; j++)
    {
        for (int i = m; i >= 0; i--)
        {
            if (!i || d[i])
            {
                d[i + a[j]] = max(d[i + a[j]], d[i] + b[j]);
            }
        }
    }
    for (int i = 0; i <= m; i++)
    {
        f = max(f, d[i]);
    }
    cout << f;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
main()
{
    int a[3],k,sum,max=0;

    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    cin>>k;
     for(int i=0;i<k;i++)
    {
    sum=a[0]+a[1]+a[2]*2;
    a[2]=a[2]*2;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 256
use std::collections::HashMap;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let t: String = read(&mut stdin_lock, &mut buf, b'\n');
    let sv: Vec<char> = s.chars().collect();
    let tv: Vec<char> = t.chars().collect();

    let mut ans = true;
    let mut sm = HashMap::new();
    let mut tm = HashMap::new();
    for i in 0..sv.len() {
        if sm.get(&sv[i]) != tm.get(&tv[i]) {
            ans = false;
            break;
        }
        if !sm.contains_key(&sv[i]) {
            let c = sm.len();
            sm.insert(sv[i], c);
            tm.insert(tv[i], c);
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 6396
import fractions
n=int(input())
a=list(map(int,input().split()))

ans=a[0]
for i in range(1,n):
    ans = fractions.gcd(ans,a[i])

count = 0

while ans % 2 ==0:
    count +=1
    ans = ans //2
    
print(count)



Measured memory_bytes: 5432
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int cnt=0,cnt1=0,cnt2=0,cnt3=0;
	if(s[0]=='R')
	{
		cnt1++;
		if(s[1]=='R')
		{	cnt1++;
            if(s[2]=='R')
            	cnt1++;
		}

	}
	if(s[1]=='R')
	{
		cnt2++;
		if(s[2]=='R')
			cnt2++;
	}
	if(s[2]=='R')
		cnt3++;
	cnt=max({cnt1,cnt2,cnt3});
	cout<<cnt;
}

Measured memory_bytes: 3620
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());

            var A = new int[N];
            var xy = new int[N][][];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
                xy[i] = new int[A[i]][];
                for (int j = 0; j < A[i]; j++)
                {
                    xy[i][j] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                }
            }

            var result = 0;
            for (int i = (int)(Math.Pow(2, N) - 1); i >= 0; i--)
            {
                var flag = true;
                var str = Convert.ToString(i, 2).PadLeft(N, '0');

                for (int j = 0; j < N; j++)
                {
                    if (str[j] == '0')
                    {
                        continue;
                    }
                    for (int k = 0; k < A[j]; k++)
                    {
                        if (xy[j][k][1] != str[xy[j][k][0] - 1] - '0')
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    if (str.Count(x => x == '1') > result)
                    {
                        result = str.Count(x => x == '1');
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 15696
X = gets.to_i

if X <= 599
  p 8
elsif X <= 799
  p 7
elsif X <= 999
  p 6
elsif X <= 1199
  p 5
elsif X <= 1399
  p 4
elsif X <= 1599
  p 3
elsif X <= 1799
  p 2
else
  p 1
end

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

int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<vector<int>> pt(Q, vector<int>(2));
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> pt.at(i).at(j);
    }
  }
  vector<int> count(N, 0);
  int num = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) == 'A' && S.at(i) == 'C') {
      num++;
      count.at(i) = num;
    } else {
      count.at(i) = num;
    }
  }
  num = 0;
  for (int i = 0; i < Q; i++) {
    /*for (int j = pt.at(i).at(0) - 1; j < pt.at(i).at(1) - 1; j++) {
      if (S.at(j) == 'A' && S.at(j + 1) == 'C') {
        num++;
        j++;
      }
    }*/
    if (pt.at(i).at(0) == 1) {
      num = count.at(pt.at(i).at(1) - 1);
    } else if (S.at(pt.at(i).at(0) - 1) == 'C' && S.at(pt.at(i).at(0) - 2) == 'A') {
      num = count.at(pt.at(i).at(1) - 1) - count.at(pt.at(i).at(0) - 2) - 1;
    } else {
      num = count.at(pt.at(i).at(1) - 1) - count.at(pt.at(i).at(0) - 1);
    }
    cout << num << endl;
    num = 0;
  }
}

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

int main(){

    int N;
    cin >> N;
    long long A[N],B[N];
    for(int i = 0 ; i < N;i++)cin >> A[i] >> B[i];
    
    sort(A,A+N);
    sort(B,B+N);
    
    if(N%2!=0){
        // cout << B[N/2] <<endl;
        // cout << A[N/2] <<endl;
        cout << B[N/2]-A[N/2] +1 <<endl;

    }else {
        // cout << N/2 <<endl;
        // cout << A[0] <<endl;
        // cout << A[1] <<endl;
        // cout << B[0] <<endl;
        // cout << B[1] <<endl;
        cout << (B[N/2 - 1] + B[N/2])-(A[N/2 - 1] + A[N/2]) + 1 <<endl;
        
        
    }

}


Measured memory_bytes: 6724
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )

int N;
ull A[200010];
//int BIT[200010][21];
int B[21];


int main() {
    cin >> N;
    rep(i, 0, N) {
        cin >> A[i];
    }

    ull j = 0;
    ull XORA = 0;
    ull allcount = 0;
    ullrep(i, 0, N) {
        while ((j < N) && ((XORA & A[j]) == 0)) {
            XORA |= A[j];
            j++;
        }
        allcount += j - i;
        XORA ^= A[i];
    }
    cout << allcount << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){
  int w,h,count;
  queue<int> que;
  int xx[4]={1,0,-1,0};
  int yy[4]={0,1,0,-1};
  int pos;
  string tt;
  while(true){
    cin >> w >> h;
    if(!w&&!h)
      break;
    int mmap[w+2][h+2];
    for(int x=0;x<w+2;x++){
      mmap[x][0] = -1;
      mmap[x][h+1] = -1;
    }
    for(int y=0;y<h+2;y++){
      mmap[0][y] = -1;
      mmap[w+1][y] = -1;
    }
        
    for(int y=0;y<h;y++){
      cin >> tt;
      for(int x=0;x<w;x++){
	switch(tt[x]){
	case '.':
	  mmap[x+1][y+1] = 0;
	  break;
	case '#':
	  mmap[x+1][y+1] = -1;	  
	  break;
	case '@':
	  mmap[x+1][y+1] = 1;
	  que.push(y*w+x);
	  break;
	}
      }
    }
    count = 1;
    while(!que.empty()){
      pos = que.front();
      for(int dir=0;dir<4;dir++){
	if (mmap[pos%w+xx[dir]+1][pos/w+yy[dir]+1]==0){
	  que.push(pos+yy[dir]*w+xx[dir]);
	  mmap[pos%w+xx[dir]+1][pos/w+yy[dir]+1] = 1;
	  count++;
	}
      }
      que.pop();
    }
    cout << count << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2) {
        cout << "Borys";
    } else {
        cout << "Alice";
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N; // 1 <= N <= 100

  // int restaurant_num;
  // 市名、点数、都市番号
  vector<tuple<string, int, int>> v;
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    v.push_back(make_tuple(s, (p * -1), i));
  }
  // 市名の昇順、点数の降順でソート
  // 点数は予め -1 で逆転させているので、昇順のソートが降順になる
  sort(v.begin(), v.end());

  for (int i = 0; i < N; i++) {
    int restaurant_num = get<2>(v.at(i)) + 1; // 1-indexed
    cout << restaurant_num << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_160_Coffee
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if (s[2] == s[3] && s[4] == s[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25740
#include <stdio.h>

void muri();

int main(int argc, char const *argv[]) {
  int n=0,j=0;//loop回数//
  scanf("%d",&n);
  int a[n]={};//要素//

  for (size_t i = 1; i <= n; i++) {
    scanf("%d",&a[i]); //添字はボタン番号と同じ
  }

  for (size_t i = 1; i <= n; i++) {
    if(a[i]==2){
      j++;//メモには2行きの添字(ボタン番号)が入ってる//
    }
  }
  if(j==0){
    muri();//ひとつも2行きがないので落ち//
    return 0;
  }

  int temp=a[1];
  for (size_t i = 0; i < 100000000; i++) {
    if(temp==2){
      printf("%d\n",i+1);
      return 0;
    }
    temp=a[temp];
  }

  muri();
  return 0;
}


void muri(){
  printf("-1\n");
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(0<=x-r && 0<=y-r && x+r<=w && y+r<=h){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] > 1) {
			if (a[i] % 2 == 0) a[i]=a[i]/2,ans++;
			else break;
		}
	}
	cout << ans;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b && b == c) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

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

lli n, m;

int main(void){
	cin >> n >> m;
	vector<pair<lli, lli>> d(n);
	rep(i, n){
		int a, b;
		cin >> a >> b;
		d[i] = {a, b};
	}
	sort(d.begin(), d.end());
	lli ans = 0;
	rep(i, n){
		if(m == 0) break;
		ans += d[i].first*min(d[i].second, m);
		m-=min(d[i].second, m);
	}
	cout << ans << endl;
	return 0;
}


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

namespace AtCoderBeginnerContest100
{
    class QA
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int d = Math.Abs(A - B);
            int e = (16 - (Math.Min(A, B) * 2)) / 2;
            if (e < d) Console.WriteLine(":(");
            else Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 11092
from sys import stdin
from collections import deque
H,W = [int(x) for x in stdin.readline().rstrip().split()]
grid = [input() for i in range(H)]

visited = [[False for i in range(W)] for i in range(H)]
visit_p = deque()
ans = 0

for h,i in enumerate(grid):
    for w, j in enumerate(i):
        if j != "#":
            visited[h][w] = True
            visit_p.append((h, w, 0))
        while visit_p:
            nh,nw,num = visit_p.popleft()
            
            for dh,dw in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
                if not (0 <= nh+dh < H) or not (0 <= nw+dw < W):
                    # 範囲外
                    continue

                if visited[nh+dh][nw+dw] or grid[nh+dh][nw+dw] == '#':
                    # 壁または訪問済み
                    continue

                visit_p.append((nh+dh,nw+dw,num+1))
                visited[nh+dh][nw+dw] = True
                ans = max(ans,num+1)
        visited = [[False for i in range(W)] for i in range(H)]
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cmath>

using namespace std;

int main() {

    int n, k;
    int arr[200];
    cin >> n;
    double total = 0, avg = 0;
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        total += arr[i];
    }
    avg = total / n;

    int min = 200;
    double ming = 100;
    for(int i = 0; i < n; i++) {
        if(abs(arr[i] - avg) < ming) {
            ming = abs(arr[i] - avg);
            min = i;
        }
    }
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(map(int, input().split()))[1:])

flags = [0 for _ in range(M)]
counter = 0
for i in range(M):
    i += 1
    for j in range(N):
        if not i in A[j]:
            flags[i-1] = 0
            break
        else:
            flags[i-1] = 1
    i += 1
print(flags.count(1))


Measured memory_bytes: 3064