akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
d = deque()
for i in range(n):
    if n%2 == 0:
        if i%2 == 0:
            d.append(a[i])
        else:
            d.appendleft(a[i])
    else:
        if i%2 == 0:
            d.appendleft(a[i])
        else:
            d.append(a[i])
print(" ".join(list(map(str, d))))

Measured memory_bytes: 120532
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
ll n,m;

int main(){
    cin >>n >>m;
    ll l = 0, r = 1e14;
    while(l < r){
        ll mid = (l+r)/2+1;
        ll s = n, c = m;
        if(s < mid) c -= (mid-s) * 2;
        if(c >= 2*mid) l = mid;
        else r = mid - 1;
    }
    cout <<l;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


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

using namespace std;

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

	int minv;
	cin >> minv;
	
	int diffMax = -1000000000;
	int r;
	for (int i = 1; i < n; i++) {
		cin >> r;
		diffMax = max(diffMax, r - minv);
		minv = min(minv, r);
	}

	cout << diffMax << endl;

	return 0;

}


Measured memory_bytes: 3116
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
A,B = [int(i) for i in input().split()]
if A == 1 and B==1:
    print(1)
else:
    ans = 1
    lia = factorization(A)
    lib = factorization(B)
    na = len(lia)
    nb = len(lib)
    a = [0] * na
    b = [0] * nb
    for i in range(na):
        a[i] = lia[i][0]
    for i in range(nb):
        b[i] = lib[i][0]
    a_ = set(a)
    b_ = set(b)
    if na >= nb:
        for i in range(nb):
            if b[i] in a_:
                ans+=1
        print(ans)
        exit()
    else:
        for i in range(na):
            if a[i] in b_:
                ans+=1
        print(ans)
        exit()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
int cnt[256];
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	string a;
	cin >> a;
	for (char i : a) cnt[i] = true;
	if ((cnt['N'] == cnt['S']) && (cnt['E'] == cnt['W']))
		puts("Yes");
	else
		puts("No");
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<ll> a(n);
    ll sa=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i%2){
            sa+=2LL*(a[i]-a[i-1]);
        }
    }
    ll sum=2LL*a[n-1];
    vector<ll> b(n);
    b[0]=(sum-sa)/2LL;
    for(int i=1;i<n;i++){
        b[i]=(a[i-1]-b[i-1]/2LL)*2LL;
    }
    cout<<b;
}


Measured memory_bytes: 3712
{-# LANGUAGE BangPatterns, MultiWayIf #-}

import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace (traceShow)
import qualified Data.ByteString.Char8 as B
readi b | Just (n, _) <- B.readInt b = n

solve :: String -> Bool
solve ss = go ss "AKIHABARA"
  where
    go ('A':xs) ('A':ys) = go xs ys
    go (x:xs)   ('A':ys) = go (x:xs) ys
    go (x:xs)   (y:ys)
        | x == y    = go xs ys
        | otherwise = False
    go "" ys
        | any (/= 'A') ys = False
        | otherwise       = True
    go _ _ = False

main :: IO ()
main = do
    ss <- getLine
    if solve ss
        then putStrLn "YES"
        else putStrLn "NO"

Measured memory_bytes: 380
#include<cstdio>
#include<bitset>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=505,maxm=100005;
int n,m,ans,x[maxm],y[maxm];bool pos[maxn];bool F[maxn][maxn];
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
bool DFS(int stp,int s)
{
	if(!stp) return true;
	if(F[s][x[stp]]&&F[s][y[stp]]) return false;
	if(F[s][x[stp]]) F[s][y[stp]]=1;
	if(F[s][y[stp]]) F[s][x[stp]]=1;
	return DFS(stp-1,s);
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++){x[i]=read();y[i]=read();}
	for(int i=1;i<=n;i++)
	{
		F[i][i]=1;
		pos[i]=DFS(m,i);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(pos[i]&&pos[j])
			{
				ans++;
				for(int k=1;k<=n;k++)
					if(F[i][k]&&F[j][k])
						{ans--;break;}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1152
N, M = gets.split.map(&:to_i)
a_board = N.times.map { gets.chomp.chars }
b_board = M.times.map { gets.chomp.chars }

if M > N
  puts 'No'
  exit 0
end

(0..(N - M)).each do |i|
  (0..(N - M)).each do |j|
    is_ok = M.times.all? do |k|
      M.times.all? do |l|
        a_board[i + k][j + l] == b_board[k][l]
      end
    end
    if is_ok
      puts 'Yes'
      exit 0
    end
  end
end
puts 'No'


Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 500000;
const int MaxM = MaxN * 2;

const int MaxSegN = MaxN * 4;

int n, nK;
int p[MaxN + 1];
int q[MaxN + 1];

int deg[MaxN + 1];

struct halfEdge
{
	int v;
	halfEdge *next;
};
halfEdge adj_pool[MaxM * 2], *adj_tail = adj_pool;
halfEdge *adj[MaxN + 1];

inline void addEdge(const int &u, const int &v)
{
	adj_tail->v = v, adj_tail->next = adj[u];
	adj[u] = adj_tail++, ++deg[v];
}

int val[MaxSegN];

inline void seg_update(int p)
{
	val[p] = min(val[p << 1 | 0], val[p << 1 | 1]);
}

void seg_init(int p, int pL, int pR)
{
	if (pL == pR)
		val[p] = n + 1;
	else
	{
		int pM = pL + pR >> 1;
		seg_init(p << 1 | 0, pL, pM);
		seg_init(p << 1 | 1, pM + 1, pR);
		seg_update(p);
	}
}

void seg_modify(int p, int pL, int pR, int q, int x)
{
	if (pL == pR)
	{
		val[p] = x;
		return;
	}

	int pM = pL + pR >> 1;
	if (q <= pM)
		seg_modify(p << 1 | 0, pL, pM, q, x);
	if (q > pM)
		seg_modify(p << 1 | 1, pM + 1, pR, q, x);

	seg_update(p);
}

int seg_query(int p, int pL, int pR, int qL, int qR)
{
	if (pL == qL && pR == qR)
		return val[p];

	int pM = pL + pR >> 1;
	if (qR <= pM)
		return seg_query(p << 1 | 0, pL, pM, qL, qR);
	else if (qL > pM)
		return seg_query(p << 1 | 1, pM + 1, pR, qL, qR);
	else
	{
		int l = seg_query(p << 1 | 0, pL, pM, qL, pM);
		int r = seg_query(p << 1 | 1, pM + 1, pR, pM + 1, qR);
		return min(l, r);
	}
}

priority_queue<int> h;

int main()
{
	cin >> n >> nK;
	for (int i = 1; i <= n; ++i)
		p[i] = getint(), q[p[i]] = i;

	seg_init(1, 1, n);

	for (int i = n; i >= 1; --i)
	{
		int u = seg_query(1, 1, n, max(q[i] - nK + 1, 1), q[i]);
		int v = seg_query(1, 1, n, q[i], min(q[i] + nK - 1, n));
		if (u <= n)
			addEdge(q[i], q[u]);
		if (v <= n)
			addEdge(q[i], q[v]);

		seg_modify(1, 1, n, q[i], i);
	}

	for (int u = 1; u <= n; ++u)
		if (!deg[u])
			h.push(-u);
	for (int i = 1; i <= n; ++i)
	{
		int u = -h.top();
		h.pop();

		q[i] = u;
		for (halfEdge *e = adj[u]; e; e = e->next)
			if (!--deg[e->v])
				h.push(-e->v);
	}

	for (int i = 1; i <= n; ++i)
		p[q[i]] = i;
	for (int i = 1; i <= n; ++i)
		printf("%d\n", p[i]);

	return 0;
}

Measured memory_bytes: 40192
"""
解説と提出 #5747380を参考に作成
"""

from collections import deque


def solve():
    H, W = map(int, input().split())
    # mass = [[False] * W for _ in range(H)]
    # queue1 = deque([])
    # queue2 = deque([])
    queue1 = []
    queue2 = []
    mass = []
    mass.append([False] * (W + 2))  # 外枠
    for Hi in range(1, H + 1):
        mass.append([False] + [s == '.' for s in list(input())] + [False])
        for Wi in range(1, W + 1):
            if not mass[Hi][Wi]:
                queue1.append((Hi, Wi))
    mass.append([False] * (W + 2))  # 外枠
    import datetime
    d = datetime.datetime.now()
    count = -1
    while True:
        # print('count: {}, queue:{}'.format(count, len(queue1)))
        if len(queue1) == 0:
            break
        for h, w in queue1:
            # left
            if mass[h][w - 1]:
                mass[h][w - 1] = False
                queue2.append((h, w - 1))
            # right
            if mass[h][w + 1]:
                mass[h][w + 1] = False
                queue2.append((h, w + 1))
            # top
            if mass[h + 1][w]:
                mass[h + 1][w] = False
                queue2.append((h + 1, w))
            # button
            if mass[h - 1][w]:
                mass[h - 1][w] = False
                queue2.append((h - 1, w))

        count += 1
        queue1 = queue2
        queue2 = []
    print(count)

    # print(datetime.datetime.now() - d)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 106608
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

enum DIR{
	None,
	Right,
	Left,
};

DIR dir_array[3] = {None,Right,Left};

struct Info{
	void set(ll arg_loc,DIR arg_dir){
		loc = arg_loc;
		dir = arg_dir;
	}
	ll loc,moved_loc;
	DIR dir;
	bool is_Moved;
};

int main(){

	int N,Q,tmp_dir;
	ll T,tmp_loc;
	scanf("%d %lld %d",&N,&T,&Q);

	int* most_left_to_left_Peron = new int[N+2];
	int* most_right_to_right_Person = new int[N+2];
	Info* info = (Info*)malloc(sizeof(Info)*(N+1));

	for(int i = 1; i <= N; i++){
		scanf("%lld %d",&tmp_loc,&tmp_dir);
		info[i].set(tmp_loc,dir_array[tmp_dir]);
		info[i].is_Moved = false;
	}

	most_left_to_left_Peron[N+1] = BIG_NUM;
	for(int i = N; i >= 1; i--){
		if(info[i].dir == Left){
			most_left_to_left_Peron[i] = i;
		}else{
			most_left_to_left_Peron[i] = most_left_to_left_Peron[i+1];
		}
	}

	most_right_to_right_Person[0] = 0;
	for(int i = 1; i <= N; i++){
		if(info[i].dir == Right){
			most_right_to_right_Person[i] = i;
		}else{
			most_right_to_right_Person[i] = most_right_to_right_Person[i-1];
		}
	}

	int tmp;

	for(int i = 1; i <= N; i++){
		if(info[i].dir == Right && most_left_to_left_Peron[i] != BIG_NUM && most_right_to_right_Person[most_left_to_left_Peron[i]] == i){
			tmp = most_left_to_left_Peron[i];
			if(info[tmp].loc-info[i].loc > 2*T){
				info[tmp].moved_loc = info[tmp].loc - T;
				info[i].moved_loc = info[i].loc + T;
			}else{
				info[tmp].moved_loc = (info[tmp].loc + info[i].loc)/2;
				info[i].moved_loc = (info[tmp].loc + info[i].loc)/2;
			}
			info[tmp].is_Moved = true;
			info[i].is_Moved = true;
		}
	}

	for(int i = 1; i <= N; i++){
		if(info[i].dir == Right && info[i].is_Moved == false){
			if(most_left_to_left_Peron[i] == BIG_NUM){
				info[i].moved_loc = info[i].loc + T;
			}else{
				tmp = most_left_to_left_Peron[i];
				if(info[tmp].moved_loc > info[i].loc+T){
					info[i].moved_loc = info[i].loc + T;
				}else{
					info[i].moved_loc = info[tmp].moved_loc;
				}
			}
		}else if(info[i].dir == Left  && info[i].is_Moved == false){
			if(most_right_to_right_Person[i] == 0){
				info[i].moved_loc = info[i].loc-T;
			}else{
				tmp = most_right_to_right_Person[i];
				if(info[tmp].moved_loc < info[i].loc-T){
					info[i].moved_loc = info[i].loc-T;
				}else{
					info[i].moved_loc = info[tmp].moved_loc;
				}
			}
		}
	}

	int person;

	for(int i = 0; i < Q; i++){
		scanf("%d",&person);

		printf("%lld\n",info[person].moved_loc);
	}

	return 0;
}

Measured memory_bytes: 5832
#include<iostream>
#include<algorithm>
using namespace std;
int H,A[500001];
void maxHeapify(int A[],int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}
void buildHeap(int A[]){
    for(int i=H/2;i>0;i--) maxHeapify(A,i);
}
int main(){
    cin>>H;
    for(int i=1;i<=H;i++)cin>>A[i];
    buildHeap(A);
    for(int i=1;i<=H;i++)cout<<" "<<A[i];
    cout<<endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    char a,b;
    cin>>a>>b;
    if(a-'A'>b-'A'){
        cout<<'>'<<endl;
    }
    else if(a==b){
        cout<<'='<<endl;
    }
    else
        cout<<'<'<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

class UnionFind{
public:
    //親の番号，親の場合-(その集合のサイズ)
    vector<int> Parent;
    
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A, int B){
        //root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if(A==B) return false;//すでにくっついてる

        //大きい方に小さい方をくっつける
        if(size(A) < size(B)) swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    UnionFind uf(n);
    vector<pair<LP,int>> v;
    priority_queue<pair<long long, LP>,
               vector<pair<long long, LP>>,
               greater<pair<long long, LP>>> pq;
    REP(i,n){
        ll x,y;
        cin>>x>>y;
        v.push_back({{x,y},i});
    }
    VSORT(v);
    for(int i=1;i<n;i++){
        ll now = min(abs(v[i-1].first.first-v[i].first.first),
                     abs(v[i-1].first.second-v[i].first.second));
        pq.push({now,{v[i-1].second,v[i].second}});
    }
    for(int i=0;i<n;++i) swap(v[i].first.first,v[i].first.second);
    VSORT(v);
    for(int i=1;i<n;i++){
        ll now = min(abs(v[i-1].first.first-v[i].first.first),
                     abs(v[i-1].first.second-v[i].first.second));
        pq.push({now,{v[i-1].second,v[i].second}});
    }
    ll ans=0;
    while(pq.size()>0){
       auto now = pq.top();
       pq.pop();
       if(uf.root(now.second.first)!=uf.root(now.second.second)){
           ans += now.first;
           uf.connect(now.second.first,now.second.second);
       }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11120
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
#define mod 1000000007

int n;
ll dp[205][205];
ll inv[205];
string s[205];

long long modpow(long long x,long long n){
	long long res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main() {
  cin >> n;
  for(int i=1;i<=n;i++) cin >> s[i];
  dp[0][0]=1;
  for(int i=1;i<=200;i++) inv[i]=modpow(1ll*i,mod-2ll);
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      if(!dp[i][j]) continue;
      //cout << dp[i][j] <<" " << i << " " << j << endl;
      if(s[i+1]=="-"){
        dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*1LL*(n-i-j))%mod*inv[n-i])%mod)%mod;
      }
      else if(s[i+1]=="D")
      {
  		dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*1LL*j*(n-i-j))%mod*inv[n-i])%mod)%mod;
  		if(j) dp[i+1][j-1] = (dp[i+1][j-1]+((dp[i][j]*1LL*j*j)%mod*inv[n-i])%mod)%mod;
      }
      else
      {
      	dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*1LL*j*(n-i-j))%mod*inv[n-i])%mod)%mod;
        dp[i+1][j+1] = (dp[i+1][j+1]+((dp[i][j]*1LL*(n-i-j)*(n-i-j-1))%mod*inv[n-i])%mod)%mod;
      }
      
    }
  }
  cout << dp[n][0] << endl;
}

Measured memory_bytes: 1540
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include <cmath>
#include <limits>

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

long long gcd(long long a,long long b){
while(1){
if(a<b)swap(a,b);
if(!b)break;
a%=b;
}
return a;
}

int main(){
long long A,B;
cin>>A>>B;

long long ans=1;
map<long long ,long long >prime;
vector<long long >v;
long long  b=sqrt(A);
for(long long  i=2;i<=b;i++){
    if(A%i==0){
        prime.insert(make_pair(i,0));
        v.push_back(i);
    }
    while(A%i==0){
        A/=i;
    }
    if(A==1)break;
}
long long  a=sqrt(B);

for(long long  i=0;i<v.size();i++){
    if(B%v[i]==0){
        ans++;
    }
}
if(gcd(A,B)>1){
    ans++;
}
cout<<ans<<endl;
 return 0;
}
/*
12 18

3

420 660

4

1 2019

1

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    cout << n << ":";
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            cout << " " << i;
            n /= i;
        }
    }
    if (n != 1) {
        cout << " " << n;
    }
    cout << endl;
}



Measured memory_bytes: 3076
#include <cstdio>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

struct UnionFind {
	vector<int> parent;
	UnionFind(int size) : parent(size, -1) {}
	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (parent[y] < parent[x]) swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return parent[x] < 0 ? x : parent[x] = root(parent[x]);
	}
	int size(int x) {
		return -parent[root(x)];
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	struct UnionFind uf(n);
	int com[q], x[q], y[q];
	rep(i,0,q) {
		cin >> com[i] >> x[i] >> y[i];
	}
	rep(i,0,q) {
		if (com[i] == 0) {
			uf.unionSet(x[i], y[i]);
		} else {
			cout << (uf.findSet(x[i], y[i]) ? "1" : "0") << endl;
		}
	}
}

Measured memory_bytes: 4272
N, L = (int(i) for i in input().split())

if L >= 0:
    aji = L + 1
    ajiTotal = 0
    for i in range(N - 1):
        ajiTotal = ajiTotal + aji
        aji = aji + 1
    print(ajiTotal)

else:
    if N + L > 0:
        aji = L
        ajiTotal = 0
        for i in range(N):
            ajiTotal = ajiTotal + aji
            aji = aji + 1
        print(ajiTotal)
    else:
        aji = L
        ajiTotal = 0
        for i in range(N - 1):
            ajiTotal = ajiTotal + aji
            aji = aji + 1
        print(ajiTotal)

Measured memory_bytes: 3064
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
using Graph = vector<vector<int>>;
queue<long>que;

int main(){
    int n;
    bool ans =false;
    cin >>n;
    
    rep(i,3){
        if(n%10==7){
            ans =true;
            break;}
        else
            n = n/10;
        }
    if(ans)
        cout<< "Yes" <<endl;
    else
        cout<< "No" <<endl;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>

using namespace std;

int v[200009];

int main(){
    int n, t;
    scanf("%d%d", &n, &t);

    int ans=t;
    for(int i=1; i<=n; i++){
        scanf("%d", &v[i]);
    }

    for(int i=1; i<n; i++)
        ans+=min(v[i+1]-v[i], t);

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}

int main(){
	ll n, p, a[50];
	cin >> n >> p;
	for(int i = 0;i < n;i++) cin >> a[i];

	ll odd = 0, even = 0;
	for(int i = 0;i < n;i++){
		if(a[i] % 2 == 0) even++;
		else odd++;
	}

	if(p == 0){
		ll ans = pow(2, even);
		// cout << ans << endl;
		ll cnt = 0, sum = 0;
		while(cnt <= odd){
			sum += nCr(odd, cnt);
			cnt += 2;
		}
		cout << ans * sum << endl;
	}
	else{
		ll ans = pow(2, even);
		// cout << ans << endl;
		ll cnt = 1, sum = 0;
		while(cnt <= odd){
			sum += nCr(odd, cnt);
			cnt += 2;
		}
		cout << ans * sum << endl;
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int AA;
      cin >> AA;
      A.at(AA-1)++;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define sf(i,s) for(i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define inf INT_MAX
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,i) for(typeof(v).begin() i = v.begin(); i != v.end(); i++)
#define pre(v,x) (v.find(x) != v.end())
#define vpre(v,x) (find(all(v),x) != v.end())
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    else
    {
        ll t=power(a,b/2);
        if(b%2==0)
        return ((t%mod)*(t%mod))%mod;
        else
        return ((((t%mod)*(t%mod))%mod)*((a%mod)%mod))%mod;
    }
}
void solve()
{
 ll n,ac=0,wa=0,tle=0,re=0,i;
 string s;
 cin>>n;
 f(i,0,n)
 {
     cin>>s;
     if(s=="AC")
        ac++;
     else if(s=="WA")
        wa++;
     else if(s=="RE")
        re++;
     else
        tle++;
 }
  cout<<"AC x "<<ac<<"\n";
  cout<<"WA x "<<wa<<"\n";
  cout<<"TLE x "<<tle<<"\n";
  cout<<"RE x "<<re<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3544
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    long long a, b;
    cin >> a >> b;
    ++ b;

    long long ans = 0;
    if(((b / 2) - (a / 2)) % 2 != 0)
        ans = 1;
    if(a % 2 != 0)
        ans ^= a & ~1;
    if(b % 2 != 0)
        ans ^= b & ~1;
    cout << ans << endl;

    return 0;
}


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

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

  string str = S.substr(0, N / 2) + S.substr(0, N / 2);

  if (S == str) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int t;
	//int cntl[40],cntr[40],cntx[40],cnty[40],z1[40],z2[40];
	cin>>t;
	int ans=t%10;
	if(ans==2|| ans==4 || ans==5 || ans==7 || ans==9){
		cout<<"hon\n";
	}
	else if(ans==3){
		cout<<"bon\n";
	}
	else{
		cout<<"pon\n";
	}
	return 0;
}

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

using namespace std;

const int MOD = (int)1e9+7;

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

  vector<int> cnt={3,5,7};
  int st=0;
  int ed=cnt.size();
  bool flag=true;
  while(cnt.at(cnt.size()-1)<1e8){
    for(int i=st;i<ed;i++){
      int x=cnt.at(i)*10+3;
      int y=cnt.at(i)*10+5;
      int z=cnt.at(i)*10+7;
      cnt.push_back(x);
      cnt.push_back(y);
      cnt.push_back(z);
    }
    st=ed;
    ed=cnt.size();
  }

  vector<int> ans;
  for(int i=0;i<cnt.size();i++){
    bool f3=false;
    bool f5=false;
    bool f7=false;
    int x=cnt.at(i);
    while(x>0){
      if(x%10==3) f3=true;
      else if(x%10==5) f5=true;
      else if(x%10==7) f7=true;
      x/=10;
    }
    if(f3 && f5 && f7) ans.push_back(cnt.at(i));
  }
  sort(ans.begin(),ans.end());
  ans.push_back(1e9);

  for(int i=0;i<ans.size();i++){
    if(ans.at(i)>N){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 576
# input
a,b,q = gets.chomp.split.map(&:to_i)
a_ary = []
a.times do |i|
    a_ary << gets.chomp.to_i
end
b_ary = []
b.times do |i|
    b_ary << gets.chomp.to_i
end
q_ary = []
q.times do |i|
    q_ary << gets.chomp.to_i
end
a_ary.sort!
b_ary.sort!


def nibuntansaku(ary, kensakuchi)
    if ary[0] >= kensakuchi
        return [0,0]
    end
    if ary[-1] <= kensakuchi
        return [-1,-1]
    end
    ok = 0
    ng = ary.length
    while ((ok-ng).abs > 1)
        mid = (ok+ng)/2
        if ary[mid] < kensakuchi
            ok = mid
        else
            ng = mid
        end
    end
    return [ok,ng]
end
q_ary.each do |i|
    a_tmp = nibuntansaku(a_ary, i)
    b_tmp = nibuntansaku(b_ary, i)

    # p a_tmp
    # p b_tmp
    a_sita = (a_ary[a_tmp[0]] - i).abs
    a_ue = (a_ary[a_tmp[1]] - i).abs
    b_sita = (b_ary[b_tmp[0]] - i).abs
    b_ue = (b_ary[b_tmp[1]] - i).abs
    
    if a_tmp == [0,0]
        a_sita = 10**11
    elsif a_tmp == [-1,-1]
        a_ue = 10**11
    end
    if b_tmp == [0,0]
        b_sita = 10**11
    elsif b_tmp == [-1,-1]
        b_ue = 10**11
    end


    # kokokara4tooritamesu
    ans = [
        a_sita + b_sita - [a_sita, b_sita].min,
        a_ue + b_ue - [a_ue, b_ue].min,
        a_sita + b_ue + [a_sita, b_ue].min,
        a_ue + b_sita + [a_ue, b_sita].min
    ]
    # p [a_sita, a_ue]
    # p [b_sita, b_ue]
    p ans.min
    # puts
end

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

int main()
{
    int K, N;
    int ans;
    int h;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }

    //一番目出発
    h = abs(A[N - 1] - A[0]);
    ans = h;
    //cout << "1Start-Right" << h << endl;
    //逆
    h = abs(K + A[0] - A[1]);
    ans = min(ans, h);
    //cout << "1Start-Left" << h << endl;

    h = abs(K + A[N - 2] - A[N - 1]);
    ans = min(ans, h);
    //cout << "LastStart-Right" << h << endl;
    //逆
    h = abs(A[N - 1] - A[0]);
    ans = min(ans, h);
    //cout << "LastStart-Left" << h << endl;
    
    REP(i, N - 1)
    {
        //一番目出発
        h = abs(K - A[i] + A[i - 1]);
        ans = min(h,ans);
        //cout << "1Start-Right" << h << endl;
        //逆
        h = abs(A[i] + K - A[i + 1]);
        ans = min(ans, h);
        //cout << "1Start-Left" << h << endl;

    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#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>;

vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      to[a].push_back(b);
      to[b].push_back(a);
    }
    vector<int> num(n, -1);
    queue<int> q;
    num[0] = 0;
    q.push(0);
    while (!q.empty()) {
      int i = q.front(); q.pop();
      for (int j : to[i]) {
        if (num[j] != -1) continue;
        num[j] = i;
        q.push(j);
      }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) cout << num[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 10132
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

int n,m,k;
int dark[105];
int road[105][105];
int dp[1<<16];
int d[16];
int main(int argc,char const* argv[])
{
  cin >> n >> m >> k;
  memset(dark,-1,sizeof(dark));
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<m;i++)
    {
      cin >> d[i];
      d[i]--;
      dark[d[i]]=i;
    }
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<k;j++)
	{
	  cin >> road[i][j];
	  road[i][j]--;
	}
    }
  dp[(1<<m)-1]=0;
  queue<int> que;
  que.push((1<<m) -1);
  while(!que.empty())
    {
      int now=que.front();
      que.pop();
      for(int j=0;j<k;j++)
	{
	  int next=0;
	  for(int l=0;l<m;l++)
	    {
	      if((now & (1<<l))==0) continue;
	      int nextroom=road[d[l]][j];
	      if(dark[nextroom]>=0) next|=(1<<dark[nextroom]);
	    }
	  if(dp[next]==-1)
	    {
	      dp[next]=dp[now]+1;
	      que.push(next);
	    }
	}
    }
  cout << dp[0] << endl;
  return 0;
}



Measured memory_bytes: 3588
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, x, d := scanInt(), scanInt(), scanInt()

	if d == 0 {
		if x == 0 {
			fmt.Fprintln(wr, 1)
		} else {
			fmt.Fprintln(wr, n+1)
		}
		return
	}

	a := map[int]ps{}

	for i := 0; i <= n; i++ {
		p := i * x % d
		l := i*x/d + i*(i-1)/2
		r := i*x/d + n*(n-1)/2 - (n-i)*(n-1-i)/2
		a[p] = append(a[p], pii{l, r})
	}

	ans := 0

	for i := range a {
		sort.Sort(a[i])
		l, r := 0, 0
		b := a[i][0].b
		for l < len(a[i]) {
			if r == len(a[i]) || b < a[i][r].a {
				ans += b - a[i][l].a + 1
				l = r
				if r < len(a[i]) {
					b = a[i][r].b
				}
			} else {
				if r < len(a[i]) {
					b = max(b, a[i][r].b)
				}
				r++
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

type pii struct{ a, b int }

type ps []pii

func (a ps) Len() int           { return len(a) }
func (a ps) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ps) Less(i, j int) bool { return a[i].a < a[j].a }


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

int main(){
  int s;
  string t,k;
  cin >> s >> t >> k;
  int len = t.size();
  for(int i = 0;i < len;++i) cout << t[i] << k[i];
  cout << "\n";
  
}


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

using namespace std;

int main()
{
  string s1,s2;
  cin>>s1>>s2;
  int step =0;
  int len1 = s1.size();
  int len2 = s2.size();
  int len = (len1>len2)?len2: len1;
  for(int i =0; i<len; i++)
  {
    if(s1[i] != s2[i]){
      step ++;
    }
  }
  int dif = len1 - len2;
  if(dif)
  {
    step += dif;
  }
  cout<<step;
  return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  int ans = 1;
  for(int i=1; i<n; i++){
    if(s[i] != s[i-1]) ans++;
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	string s, t; cin >> s >> t;
	int ans = 0;

	rep(i, s.size()) if(s[i]!= t[i]) ans++;
	

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


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

using namespace std;

int main()
{
             int n;
            cin >> n;
            vector<int> h(n);
            vector<int> dp(n);
            for (int i = 0; i < n; i++)
                cin >> h[i];
            dp[1] = abs(h[1] - h[0]);
            for (int i = 2; i < n; i++)
                dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]) , dp[i - 2] + abs(h[i] - h[i-2]));
            cout << dp[n - 1] << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    ll count = 0;
    for(char c : s){
        if(c == 'g'){
            count++;
        }else{
            count--;
        }
    }
    cout << count / 2 << endl;
    return 0;
}


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

int a[100050];

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    int b;
    for(int i=0;i<q;i++){
        cin >> b;
        a[b-1]++;
    }
    int border= q-k;
    for(int i=0;i<n;i++){
        if(a[i]<=border) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    int n,m,i=0,j,k=0,p,c=0,l=0;
    string s;
    cin>>s;
    string s2 = s;
    reverse(s.begin(),s.end());
    while(s[i]!='\0')
    {
        if(s[i]!=s2[i])
        {
            k++;
            break;
        }
        i++;
    }
    if(k!=0)
    {
        cout<<"No";
        return 0;
    }
    p = s2.size();
    int q = (p-1)/2;
    int r = (p+3)/2;
    string s4;
    for(i=q-1; i>=0; i--)
    {
        s4[l] = s2[i];
        l++;
    }
    s4[l] = NULL;
    i=0;
    k=0;
    while(s4[i]!='\0')
    {
        //cout<<s2[i];
        if(s4[i]!=s2[i])
        {
            k++;
            break;
        }
        i++;
    }
    if(k>0)
    {
        cout<<"No";
        return 0;
    }
    l=0;
    for(i=p-1; i>=r-1; i--)
    {
        s[l] = s2[i];
        l++;
    }
    s[l] = NULL;
    i=0;
    k=0;
    l = r-1;
    while(s[i]!='\0')
    {
        if(s[i]!=s2[l])
        {
            k++;
            break;
        }
        i++;
        l++;
    }
    if(k>0)
    {
        cout<<"No";
        return 0;
    }
        cout<<"Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

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

int N, M;
vector<pair<int,string>> p;
vector<pair<int, string>> pq;

int main() {	

	cin >> N >> M;

	rep(i, M) {
		int pi;
		string pS;
		cin >> pi >> pS;
		p.push_back(make_pair(pi, pS));
	}

	int Q[100005];

	rep(i, 100005)Q[i] = 0;

	int mistake = 0;
	int truen = 0;

	rep(i,M){
		if (Q[p[i].first] == -1)continue;
		if (Q[p[i].first] >= 0) {
			if (p[i].second == "AC") {
				mistake += Q[p[i].first];
				Q[p[i].first] = -1;
				truen++;
			}
			else
			{
				Q[p[i].first] ++;
			}
		}
	
	}
	


	cout << truen << " " << mistake << endl;
	

	return 0;
}


Measured memory_bytes: 6896
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] no = new int[3];
        no[0] = sc.nextInt();
        no[1] = sc.nextInt();
        no[2] = sc.nextInt();
        
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 3; j++) {
                if (no[i] > no[j]) {
                    int tmp = no[i];
                    no[i] = no[j];
                    no[j] = tmp;
                }
            }
        }
        
        System.out.println(no[0] + " " + no[1] + " " + no[2]);
    }

}



Measured memory_bytes: 26120
#include<stdio.h>
int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    int i;
    int a[102];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int p;
    for (i = 0; i < n - 1; i++)
        if (a[i] > a[i + 1])
        {
            p = a[i];
            a[i] = a[i + 1];
            a[i + 1] = p;
            if (i > 0)
                i -= 2;
        }
    int ans = 0;
    i = 0;
    while (a[i] <= x && i < n)
    {
        x -= a[i];
        i++;
        ans++;
    }
    if (i == n && x > 0)
        ans--;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  double N,T,A,ans=100000,site;cin>>N>>T>>A;
  vector<double> temperature(N);
  for(int i=0;i<N;i++){
    cin>>temperature.at(i);
    temperature.at(i)=abs(T-temperature.at(i)*0.006-A);
    if(ans>temperature.at(i)){
      ans=temperature.at(i);
      site=i+1;
    }
  }
  cout<<site<<endl;
}

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

int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    int mx = max(r,max(g,b));
    int mn = min(r,min(g,b));
    int a = n/mx;
    int mid = r + g + b - mx - mn;
    for(int i=0;i<=a;i++) {
        int b = n - (mx*i);
        int c = b/mid;
        for(int j=0;j<=c;j++){
            int d = b - (mid*j);
            if(d%mn == 0){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split(" ")))

ab = []
cd = []

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    ab.append([a, b])
    
for _ in range(M):
    c, d = list(map(int, input().split(" ")))
    cd.append([c, d])

for i in range(N):
    best = 1e9
    best_idx = 0
    for j in range(M):
        manhattan = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if manhattan < best:
            best = manhattan
            best_idx = j
            
    print(best_idx+1)
    

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

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(30,0);
  vector<vector <int> > a(30,vector<int>(30,0));
  for(int i=0; i<m; i++){
    cin >> b[i];
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    int s = 0;
    for(int j=0; j<m; j++){
      s += a[i][j]*b[j];
    }
    s += c;
    if(s > 0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B,C,D=map(int,input().split())
    while True:
        C-=B
        if C<=0:
            YesNo(1)
            exit()
        A-=D
        if A<=0:
            YesNo(0)
            exit()

if __name__ == '__main__':
    main()


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

namespace AtCorder1
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.WriteLine(Test(Console.ReadLine().ToList()));
		}

		private static String Test(IEnumerable<char> s)
		{
			var ls = new List<int>();

			do
			{
				var r = s.TakeWhile(t => t == 'R').Count();
				var l = s.Skip(r).TakeWhile(t => t == 'L').Count();
				int h = (r + l) / 2;
				var e = (r + l) % 2 == 0;
				ls.AddRange(Enumerable.Repeat(0, r - 1)
					.Append(e ? h : h + (r % 2))
					.Append(e ? h : h + (l % 2))
					.Concat(Enumerable.Repeat(0, l - 1)));

				s = s.Skip(r + l);
			} while (s.Any());

			return String.Join(" ", ls);
		}
	}
}


Measured memory_bytes: 25104
comb=Array.new(100){Array.new(100, 0)}
(0...100).each do |i|
    comb[i][0]=comb[i][i]=1
end
(1...100).each do |i|
    (1...100).each do |j|
        comb[i][j]=comb[i-1][j]+comb[i-1][j-1]
    end
end

n, a, b=gets.split.map &:to_i
v=gets.split.map &:to_i

v.sort!{|x, y|y<=>x}
puts sprintf("%.10f", v.slice(0...a).inject(:+)/a.to_f)

if v[0]!=v[a-1]
    s=v.count(v[a-1])
    t=v.slice(0...a).count(v[a-1])
    puts comb[s][t]
else
    s=v.count(v[0])
    puts (a..[b, s].min).inject(0){|sum, i| sum+comb[s][i]} 
end


Measured memory_bytes: 1916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			//サイコロの値を取る。
			String[] strDice = insBR.readLine().split(" ");
			int[] intDice = new int[strDice.length];
			for(int i = 0; i < intDice.length; i++){
				intDice[i] = Integer.parseInt(strDice[i]);
			}

			//サイコロ作成。
			Dice insDice = new Dice();
			insDice.setDice(intDice[0], intDice[1], intDice[2], intDice[3], intDice[4], intDice[5]);

			//方角。
			String[] strDirection = insBR.readLine().split("");


			//転がす。
			for(int i = 0; i < strDirection.length; i++){
				insDice.roll(strDirection[i]);
			}

			//出力。
			System.out.println(insDice.getDice());


		}catch(IOException e){
		 	e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}

	}

}

class Dice{

	//使用の対象となるサイコロ。
	private int[] intObjectDice;
	//仮のサイコロ。
	private int[] intActDice;

	//インスタンスの初期化。
	Dice(){
		intObjectDice = new int[6];
		intActDice = new int[6];
	}

	//サイコロをつくる set メソッド。
	public void setDice(int i, int j, int k, int l, int m, int n) {

		this.intObjectDice[0] = i;
		this.intObjectDice[1] = j;
		this.intObjectDice[2] = k;
		this.intObjectDice[3] = l;
		this.intObjectDice[4] = m;
		this.intObjectDice[5] = n;

	}

	//サイコロの上の目の数値を得る get メソッド。
	public int getDice(){
		return intObjectDice[0];
	}

	//転がす。
	public void roll(String strOrder){

		//サイコロの値をgetし、仮のサイコロに格納。
		for(int i = 0; i < 6; i++){
			intActDice[i] = intObjectDice[i];
		}
		switch(strOrder){

		case "N":
			setDice(intObjectDice[1], intObjectDice[5], intObjectDice[2], intObjectDice[3], intObjectDice[0], intObjectDice[4]);
			break;

		case "E":
			setDice(intObjectDice[3], intObjectDice[1], intObjectDice[0], intObjectDice[5], intObjectDice[4], intObjectDice[2]);
			break;

		case "S":
			setDice(intObjectDice[4], intObjectDice[0], intObjectDice[2], intObjectDice[3], intObjectDice[5], intObjectDice[1]);
			break;

		default:
			setDice(intObjectDice[2], intObjectDice[1], intObjectDice[5], intObjectDice[0], intObjectDice[4], intObjectDice[3]);
			break;

		}
	}

}




Measured memory_bytes: 24416
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string s, t;
    cin >> s >> t;

    ll cnt(0);
    rep(i,0,s.size())
        if (s[i]!=t[i])
            cnt++;

    cout << cnt << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int Z = S.size();
  bool b = true;
  
  if (Z == 1) {
    cout << S << endl;
    return 0;
  }
  
  for (int i = 1; i < Z; i++) {
    if (S[i] != '9') {
      b = false;
      break;
    }
  }
  
  int max = S[0] - '0' + 9 * (Z-1);
  if (b) {
    cout << max << endl;
    return 0;
  }
  cout << max - 1 << endl;
}

Measured memory_bytes: 256