akhauriyash/Code-Regression huggingface dataset:
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2):
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9880
n,q=map(int,input().split())

qs = [[] for _ in range(n)]

for _ in range(q):
	op = list(map(int,input().split()))
	stack = qs[op[1]]
	if op[0] == 0:
		stack.append(op[2])
	elif op[0] == 1:
		if len(stack)>0:
			print(stack[len(stack)-1])
	else:
		if len(stack)>0:
			stack.pop()



Measured memory_bytes: 13684
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define rep(i,n) for (int i=0; i<(n); ++i)
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    ll w,h;
    cin >> h >> w;

    if(h==1||w==1){
        cout << 1;
    }
    else {
        cout << (h*w+1) /2;
    }
}

Measured memory_bytes: 256
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>

#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll n, count = 1;
    string s;
    cin >> n >> s;
    string v;
    for(int i = 0 ; i < n-1; i++){
        if( s[i] == s[i + 1]){
            continue;
        }
        else{
            v += s[i];
            count++;
        }
    }
    cout << count;
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min( int a, int b) { return a < b ? a : b;}

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for ( int i = 1; i <= n; i++) {
		scanf("%s", Q[i].name); //Q.name??????????????????? name[100]??????????????????
		scanf("%d", &Q[i].t);
		}
head = 1; tail = n + 1;

while(head != tail ) {
	u = dequeue();
	c = min(q, u.t);
	u.t -= c;
	elaps += c;
	if( u.t > 0 ) enqueue(u);
	else {
		printf("%s %d\n", u.name, elaps);
	}
}

return 0;
}

Measured memory_bytes: 12772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define MOD 1000000007
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INFll (1LL << 60)

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

    string s;
    cin >> s;
    int n = s.size();
    int memo = 0;
    s += "xxxxx";
    int dame = 0;
    while (memo < n)
    {
        //cout << memo << endl;
        string t = s.substr(memo, 5);
        if (t == "dream")
        {
            string u = s.substr(memo + 5, 2);
            if (u == "er")
            {
                //cout<<u<<endl;
                string v = s.substr(memo + 5 + 2, 2);
                if (v == "as")
                { //dreamでおけ
                    memo += 5;
                    //cout << v << endl;
                }
                else
                { //dreamer
                    memo += 7;
                }
            }
            else
            { //dream
                memo += 5;
            }
        }
        else if (t == "erase")
        {
            string u = s.substr(memo + 4, 2);
            if (u == "er")
            { //eraser
                memo += 6;
            }
            else
            { //erase
                memo += 5;
            }
        }
        else
        {
            dame++;
            break;
        }
        if (memo >= n)
        {
            break;
        }
    }

    if (dame == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
[n,w] = [int(i) for i in input().split()]
w_v = []
for i in range(n):
    w_v.append([int(j) for j in input().split()])

"""
dp[i][v] = w
i : 何番目までのものを使うか
v : ちょうどその価値になる
w : その時の重さ
最後に後ろから全探索して重さ超えてないやつ探す？
"""
INF = 10 ** 9 + 7
v_max = 10**3 * n + 1
dp = [[INF] * (v_max) for i in range(n)]
##print(dp)
#価値0になるところの重さは0
for i in range(n):
    dp[i][0] = 0
if n != 1:
    for i in range(n):
        #print("step",i)
        if i != 0:
            for v_zantei in range(v_max):
                if v_zantei >= w_v[i][1]:
                    dp[i][v_zantei] = min(dp[i-1][v_zantei],dp[i-1][v_zantei - w_v[i][1]] + w_v[i][0])
                else:
                    dp[i][v_zantei] = dp[i-1][v_zantei]
            #print(dp[i])
        else:
            dp[i][w_v[i][1]] = w_v[i][0]
            #print(dp[i])
    ans = -1
    for v in range(v_max-1,-1,-1):
        #print(w,dp[n-1][v],ans)
        if dp[n-1][v] <= w and ans < v:
            ##print(v)
            ans = v
    print(ans)
else:
    print(w_v[0][1])


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

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

using namespace std;

int main(){
  string s;cin>>s;
  int result=0;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()-1-i])result++;
  }
  cout<<result;

  return 0;
}

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

namespace AtCoder_Core
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            if (S[2] == S[3] && S[4] == S[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

using namespace std;

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

const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

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

    vector<long long> weight(MAX_N), value(MAX_N);
    for (int i = 0; i < N; ++i)
        cin >> weight[i] >> value[i];

    vector<vector<long long>> dp(MAX_N, vector<long long>(MAX_V, INF));

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0)
                chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 87296
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    char s[300][600];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        memcpy(&s[i][n], &s[i][0], n);
    }

    int r = 0;
    for (int x = 0; x < n; x++) {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (s[i][j + x] != s[j][i + x]) goto chigau;
            }
        }
        r++;
        continue;
    chigau:
        continue;
    }

    cout << r * n << endl;

    return 0;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 2e6 + 41;
int const MOD = 1e9 + 7;

int add(int a, int b) {
	a += b;
	while (a >= MOD) a -= MOD;
	while (a < 0) a += MOD;
	return a;
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

int bp(int x, int d) {
	int res = 1;
	while (d) {
		if (d & 1) res = mult(res, x);
		x = mult(x, x);
		d >>= 1;
	}
	return res;
}

int inv(int x) {
	return bp(x, MOD - 2);
}

int f[MAX];
int invf[MAX];

void init() {
	f[0] = 1;
	fi(1, MAX - 1) {
		f[i] = mult(f[i - 1], i);
	}
	fi(0, MAX - 1) {
		invf[i] = inv(f[i]);
	}
}

int getc(int n, int k) {
	if (k > n) return 0;
	return mult(f[n], mult(invf[k], invf[n - k]));
}

int ans;
int n;

int getways(int a, int b) {
	if (b == 0) return 1;
	int rema = a - (b - 1);
	return getc(b + rema, rema);
}

void solve1() {
	int res = 0;
	fdi(n, 2) {
		int a = i - 2;
		int b = n - i;
		if (b - 1 > a) continue;
		int v1 = f[a];
		int v2 = f[b];
		int v3 = getways(a, b);
		int v4 = i - 1;
		int v = mult(v1, mult(v2, mult(v3, v4)));
		v = mult(v, i);
		res = add(res, v);
		/*
		err("i = %d v = %d\n", i, v);
		err("v1 = %d v2 = %d v3 = %d v4 = %d\n", v1, v2, v3, v4);
		*/
	}
	res = mult(res, 2);
	ans = add(ans, res);
}

void solve2() {
	int res = 0;
	fdi(n, 3) {
		int a = i - 2 - 1;
		int b = n - i;
		if (b - 1 <= a) {
			int v1 = f[a];
			int v2 = f[b];
			int v3 = getways(a, b);
			int v4 = mult(i - 1, i - 2);
			int v5 = mult(b, 2);
			int v = mult(v1, mult(v2, mult(v3, mult(v4, v5))));
			v = mult(v, i);
//			err("i = %d v1 = %d\n", i, v);
			res = add(res, v);
		}

		b--;
		if (b - 1 <= a) {
			int v1 = f[a];
			int v2 = f[b + 1];
			int v3 = getways(a, b);
			int v4 = mult(i - 1, i - 2);
			int v5 = b;
			int v = mult(v1, mult(v2, mult(v3, mult(v4, v5))));
			v = mult(v, i);
			res = add(res, v);
//			err("i = %d v2 = %d\n", i, v);
		}
	}
	ans = add(ans, res);
}

void solve() {
	if (n == 1) {
		printf("1\n");
		return;
	}
	solve1();
	solve2();
	
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	init();
	scanf("%d", &n);  
	n--;
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin()
#define en end()
#define vvl(n,m) vector<vector<ll> > a( n , vector<ll> (m))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = -1000000000000000, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 
ll countPairs(ll arr[], ll n) 
{ 
    map<ll, ll> map; 
    for (ll i = 0; i < n; i++) {
        if (map.find(arr[i]-i) == map.end()) { 
            map[arr[i]-i] = 1; 
        } 
        else { 
            map[arr[i]-i]++; 
        } 
    }
    ll res = 0; 
    for (auto x : map) { 
        ll cnt = x.second; 

        res += ((cnt * (cnt - 1)) / 2); 
    } 
  
    return res; 
} 
ll findSubarraySum(ll arr[], ll n, ll sum) 
{ 
    unordered_map<ll, ll> prevSum; 
  
    int res = 0; 
  
    int currsum = 0; 
  
    for (int i = 0; i < n; i++) { 
        currsum += arr[i]; 
        if (currsum == sum)  
            res++;         
  
        if (prevSum.find(currsum - sum) !=  
                                  prevSum.end())  
            res += (prevSum[currsum - sum]);
        prevSum[currsum]++; 
    } 
  
    return res; 
} 
ll sod(ll x){
    ll r,sum=0;
    while(x>0){
        r=x%10;
        x/=10;
        sum+=r;
    }
    return sum;
}
long long modpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    fast
    ll n,k,i,j;
    cin>>n>>k;
    ll a[n],min1=1e18,s;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n];
    for(i=0;i<min(k,n);i++){
        dp[i]=abs(a[i]-a[0]);
    }
    for(i=k;i<n;i++){
        min1=1e18;
        for(j=1;j<=k;j++){
            s=dp[i-j]+abs(a[i]-a[i-j]);
            if(s<min1)
            min1=s;
        }
        dp[i]=min1;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 5148
AA=input()

if AA == "a":
	print("b")
elif AA == "b":
	print("c")
elif AA == "c":
	print("d")
elif AA == "d":
	print("e")
elif AA == "e":
	print("f")
elif AA == "f":
	print("g")
elif AA == "g":
	print("h")
elif AA == "h":
	print("i")
elif AA == "i":
	print("j")
elif AA == "j":
	print("k")
elif AA == "k":
	print("l")
elif AA == "l":
	print("m")
elif AA == "m":
	print("n")
elif AA == "n":
	print("o")
elif AA == "o":
	print("p")
elif AA == "p":
	print("q")
elif AA == "q":
	print("r")
elif AA == "r":
	print("s")
elif AA == "s":
	print("t")
elif AA == "t":
	print("u")
elif AA == "u":
	print("v")
elif AA == "v":
	print("w")
elif AA == "w":
	print("x")
elif AA == "x":
	print("y")
elif AA == "y":
	print("z")
else:
	print("a")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

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

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT n;
	cin >> n;
	vector<INT> a(n), c(8, 0);
	INT free = 0, t = 0;

	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] / 400 >= 8)
		{
			free++;
		}
		else
		{
			c[a[i] / 400]++;
		}
	}

	for (size_t i = 0; i < 8; i++)
	{
		if (c[i] > 0)
		{
			t++;
		}
	}

	if (t == 0)
	{
		cout << "1 " << min(free, 8LL) << endl;
		return 0;
	}
	else
	{
		cout << t << " " << t + free << endl;
	}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n) {
        int a;
        cin >> a;
        p[i] = {a, i + 1};
    }
    sort(p.begin(), p.end());
    rep(i, n) {
        if (i != 0)
            cout << " ";
        cout << p[i].second;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4056
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    a, b, c, d = map(int,input().split())
    count[a - 1][b - 1][c - 1] += d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" {}".format(count[i][j][k]) , end="")
        print()
    if i < 3:
        print("#" * 20)



Measured memory_bytes: 5628
# ARC095C - Many Medians (ABC094C)
def main():
    n = int(input())
    x = tuple(map(int, input().rstrip().split()))
    l, h = sorted(x)[n // 2 - 1 : n // 2 + 1]
    for i in x:
        print(h if i <= l else l)

if __name__ == "__main__":
    main()

Measured memory_bytes: 25356
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string date,a,b;
	int n, ans,k;
	cin >> date;
	cin >> n;
	ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		for (int m = 1; m <= 10; m++) {
			k = 0;
			for (int x = 0; x <= date.size() - 1; x++) {
				if (date[x] == a[x]) {
					k = k + 1;
				}
				if (k == date.size()) {
					k = 0;
					ans = ans + 1;
					goto a;
				}
			}
			b = a;
			for (int z = 0; z <= 9; z++) {
				if (z <= 8) {
					a[z] = b[z + 1];
				}
				else {
					a[9] = b[0];
				}
			}
		}
	a:;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;
long long int mpown(long long int m, int n);

int bitCount(int bits);
int main()
{
    int n;
    cin >> n;
    vector<long long int> s(n);
    for(int i=0;i<n;i++)cin >> s.at(i);
    long long int ans=0;
    for(int c=1;c<=n-1;c++){
        // int kup=(n-1)/(c+1);
        int kup;
        // int kup=n1c;
        if((n-1) %c ==0)
        {
            
                kup=min((n-1)/c-2,((n-1)/c-1)/2);}
        else{
            kup=(n-1)/c-1;
        }

        long long int tempf=0;
        for(int k=1;k<=kup;k++){
            tempf=tempf+s.at(n-1-k*c)+s.at(k*c);
            if(tempf>ans)ans=tempf;
        }
    }
    cout << ans << endl;
    return 0;
    // cout << ans << endl;
}

int bitCount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);             //  32ビット分を計算
}
long long int mpown(long long int m, int n)
{
    if (n == 0)
        return 1;
    else if (n == 1)
        return m;
    else
    {
        long long int temp = mpown(m, n / 2);
        return temp * temp * (n & 1 ? m : 1);
    }
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;

	int a[] = { 0,1,2,1,3,1,3,1,1,3,1,3,1 };

	if (a[x] == a[y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <cstdio>
#include <string>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

typedef long long ll;

using namespace std;
int main()
{
    string N;
    cin >> N;
    int cnt = 0;
    REP(i, SIZE(N))
    {
        cnt += N[i] - '0';
    }
    if (atoi(N.c_str()) % cnt == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll K,X;
    string S;
    cin >> K >>X;

    if(500*K>=X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

const int MAXN = 3e3 + 10;
int table[MAXN][MAXN], used[MAXN][MAXN], a[MAXN];
int n;

int get(int l, int r) {
    if (r < l) {
        return 0;
    }

    if (used[l][r] == 1) {
        return table[l][r];
    }

    used[l][r] = 1;

    if ((n - (r - l))%2 == 0) {
        table[l][r] = min(get(l + 1, r) - a[l], get(l, r - 1) - a[r]);
    }else {
        table[l][r] = max(get(l + 1, r) + a[l], get(l, r - 1) + a[r]);
    }
    return table[l][r];
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    cin >> n;
    for (int i = 0;i < n;i++) {
        cin >> a[i];
    }
    cout << get(0, n - 1);
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 200010;

int N;
string X_s;
vector<int> X;

// [0]: 2^i % (x_cnt - 1)
// [1]: 2^i % (x_cnt + 1)
int pow2[2][MAX_N];

// f(n) 
int func(int n) {
    int cur = n;
    int ret = 0;
    while(cur > 0) {
        int cnt = __builtin_popcountll(cur);
        cur %= cnt;
        ret++;
    }
    return ret;
}

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

    cin >> N >> X_s;
    X.resize(N);

    // X の立っているビットの数
    int x_cnt = 0;
    REP(i, N) {
        X[i] = X_s[i] - '0';
        if(X[i] == 1) { x_cnt++; }
    }

    // pow2 の作成
    int mod = x_cnt - 1;
    if(mod > 1) {
        pow2[0][0] = 1;
        for(int i = 1; i < N; ++i) {
            pow2[0][i] = pow2[0][i-1] * 2;
            pow2[0][i] %= mod;
        }
    }

    mod = x_cnt + 1;
    pow2[1][0] = 1 % mod;
    for(int i = 1; i < N; ++i) {
        pow2[1][i] = pow2[1][i-1] * 2;
        pow2[1][i] %= mod;
    }

    // X の各ビット全ての剰余を足したもの
    int x_bit_sum[2] = {};
    reverse(X.begin(), X.end());
    REP(i, N) {
        if(X[i] == 1) {
            x_bit_sum[0] += pow2[0][i];
            x_bit_sum[1] += pow2[1][i];
        }
    }

    reverse(X.begin(), X.end());
    REP(i, N) {
        int ans;
        if(X[i] == 0) {
            // ビットが増える
            int val = x_bit_sum[1] + pow2[1][N - 1 - i];
            int mod = x_cnt + 1;
            DBG("x_bit_sum[1]: %lld pow2[1][i]: %lld\n", x_bit_sum[1], pow2[1][N - i]);
            val %= mod;
            DBG("val: %lld mod: %lld\n", val, mod);
            ans = func(val) + 1;
        }
        else {
            // ビットが減る
            if(x_cnt > 1) {
                int val = x_bit_sum[0] - pow2[0][N - 1 - i];
                int mod = x_cnt - 1;
                DBG("x_bit_sum[0]: %lld pow2[0][i]: %lld\n", x_bit_sum[0], pow2[0][N - i]);
                val %= mod;
                DBG("val: %lld mod: %lld\n", val, mod);
                ans = func(val) + 1;
            }
            else {
                ans = 0;
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}



Measured memory_bytes: 8280
n = int(input())
cnt = 0
frag = False
for i in range(n):
    a, b = map(int, input().split())
    if(a == b):
        cnt += 1
    else:
        cnt = 0
    if(cnt == 3):
        frag = True
    if(frag):
        break
if(frag):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
#include <cstdio>
#include <queue>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
const lli INF = 1e12;
int N;
int A[300][300];
lli dist[300][300];
int parent[301];	//-1로 초기화시켜둠

lli min(lli a, lli b) {
	return a < b ? a : b;
}

int ufFind(int u)
{
	if (parent[u] < 0)
		return u;
	return parent[u] = ufFind(parent[u]);
}

bool ufUnion(int u, int v)
{
	u = ufFind(u);
	v = ufFind(v);
	if (u == v)
		return false;
	parent[u] = v;
	return true;
}


int main()
{
	priority_queue<pip> pq;
	long long int ans = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			scanf("%d", &A[i][j]);
			if (j < i) {
				pq.push(make_pair(-A[i][j], make_pair(i, j)));
				dist[i][j] = dist[j][i] = INF;
			}
		}
		parent[i] = -1;
	}
	while (!pq.empty()) {
		int length = -pq.top().first;
		int i = pq.top().second.first;
		int j = pq.top().second.second;
		pq.pop();
		if (ufUnion(i, j) || dist[i][j] > length) {
			dist[i][j] = dist[j][i] = (lli)length;
			ans += length;
			int group = ufFind(i);
			for (int k = 0; k < N; k++) {
				if (ufFind(k) != group)
					continue;
				if (k == i || k == j)
					continue;
				dist[i][k] = dist[k][i] = min(dist[i][k], dist[i][j] + dist[j][k]);
				dist[j][k] = dist[k][j] = min(dist[j][k], dist[j][i] + dist[i][k]);
				for (int t = 0; t < N; t++) {
					if (ufFind(t) != group)
						continue;
					if (t == i || t == j || t == k)
						continue;
					dist[k][t] = dist[t][k] = min(dist[t][k], min(dist[t][j] + dist[j][i] + dist[i][k]
							, dist[t][i] + dist[i][j] + dist[j][k]));
				}
			}
		}
		else if (dist[i][j] < length) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[i][j] != dist[i][j]) {
				printf("-1\n");
				return 0;
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2044
n, m = map(int, input().split())
h = list(map(int, input().split()))
det = [1] * n
for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    det[b-1] = 0
  elif h[a-1] < h[b-1]:
    det[a-1] = 0
  else:
    det[b-1] = 0
    det[a-1] = 0
print(sum(det))
  

Measured memory_bytes: 20112
#include<stdio.h>
#include<string.h>
int main(){
  int n,i;
  scanf("%d",&n);
  const char c[2][2]={"#","."};
  char s[2][110]={0};
  char t[110],w[10];
  for(i=0;i<4;i++){
    printf("%s%s\n%s%s\n",s[0],c[i/2],s[1],c[i%2]);
    fflush(stdout);
    scanf("%s",w);
    if(w[0]=='e')return 0;
    if(w[0]=='T'){
      strcat(s[0],c[i/2]);
      strcat(s[1],c[i%2]);
      i=-1;
    }
  }
  for(i=0;i<4;i++){
    printf("%s%s\n%s%s\n",c[i/2],s[0],c[i%2],s[1]);
    fflush(stdout);
    scanf("%s",w);
    if(w[0]=='e')return 0;
    if(w[0]=='T'){
      strcpy(t,c[i/2]);
      strcat(t,s[0]);
      strcpy(s[0],t);
      strcpy(t,c[i%2]);
      strcat(t,s[1]);
      strcpy(s[1],t);
      i=-1;
    }
  }
}
   


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

l = 2
a = [2]

if n == 1:
    print(1)
    exit()
    
for i in range(1, n+1):
    if i == 1:
        a.append(1)
    else:
        l = sum(a)
        a.pop(0)
        a.append(l)

print(l)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
strongly_connected_component

DFS2回で出せはしそう。大変だけど。
ライブラリ見るか
https://kopricky.github.io/code/GraphDecomposition/strongly_connected_component.html

トポロジカルソート
https://hkawabata.github.io/technical-note/note/Algorithm/graph/scc.html
1 -> 2 -> 3 -> 1 -> 2 ...
ってなっているときに、2 1 3と出してはいけないとか、そういうことかな

出力する順番がわからないぞ・・・
ループする集団はcmpからもってこれそう。

classの中に固定長の配列宣言する方法わかんない。
*/
vector<vector<int>> topo(500000, vector<int>(0, 0));

class SCC {
private:
    const int V;
    vector<vector<int> > G;
    vector<int> ord, low;
    stack<int> st;
    void dfs(const int u, int& tm){
        ord[u] = low[u] = tm++, st.push(u);
        for(int v : G[u]){
            if(ord[v] < 0){
                dfs(v, tm);
                low[u] = min(low[u], low[v]);
            }else if(cmp[v] < 0){
                low[u] = min(low[u], ord[v]);
            }
        }
        if(ord[u] == low[u]){
            while(true){
                const int v = st.top();
                st.pop();
                cmp[v] = cnt;
//cout << "v:" << v << " cmp[" << v << "]:" << cmp[v]
//  << " cnt:" << cnt << endl;
                topo[cnt].push_back(v);
                if(v == u) break;
            }
            ++cnt;
        }
    }
public:
    vector<vector<int> > graph;
    vector<int> cmp;
    int cnt;
    SCC(const int node_size)
        : V(node_size), G(V), ord(V, -1), low(V), cmp(V, -1), cnt(0){}
    void add_edge(const int from, const int to){
        G[from].push_back(to);
    }
    int solve(){
        int tm = 0;
        for(int i = 0; i < V; ++i){
            if(ord[i] < 0) dfs(i, tm);
        }
        for(int i = 0; i < V; ++i) cmp[i] = cnt - 1 - cmp[i];
        return cnt;
    }
    void make_graph(){ //ループしてない辺をgraphに抽出
        graph.resize(cnt);
        for(int i = 0; i < V; ++i){
            for(int j : G[i]){
                if(cmp[i] != cmp[j]){
                    graph[cmp[i]].push_back(cmp[j]);
                }
            }
        }
    }
};

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

  int N, M;
  cin >> N >> M;
  SCC scc(N);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    scc.add_edge(A, B);
  }
  int scc_num = scc.solve();
  scc.make_graph();
  
  cout << scc_num << endl;
  for (int i = scc_num-1; i >= 0; i--){
    int tsz = topo[i].size();
    cout << tsz << " ";
    rep(j, tsz){
      cout << topo[i][j];
      if (j == tsz - 1)
        cout << endl;
      else
        cout << " ";
    }
  }
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI v(n);
	rep(i, n) cin >>v[i];
	
	map<int, int> me, mo;
	rep(i, n){
		if(i%2) mo[v[i]]++;
		else me[v[i]]++;
	}
	vector<pii> ve, vo;
	for(auto q: me) ve.emplace_back(q.second, q.first);
	for(auto q: mo) vo.emplace_back(q.second, q.first);
	sort(rbegin(ve), rend(ve));
	sort(rbegin(vo), rend(vo));
	int ans = min(n - ve[0].first, n - vo[0].first);
	rep(i, min(sz(ve),4)) rep(j, min(sz(vo),4)){
		if(ve[i].second == vo[j].second) continue;
		int ct = n - ve[i].first - vo[j].first;
		
		//dbg(i,j,ct);
		ans = min(ans, ct);
	} 
	cout << ans <<"\n";
	return 0;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    for (int i = 0; i < N; i++){
        cin >> B[i];
    }

    vector<ll> Aq;
    ll Bl = 0;
    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < N; i++){
        ll tmp = A[i]-B[i];
        sum += tmp;
        if (tmp > 0){
            Aq.push_back(tmp);
        } else if (tmp < 0){
            Bl += abs(tmp);
            ans++;
        }
    }

    if (Bl == 0){
        cout << 0 << endl;
        return 0;
    } else if (sum < 0){
        cout << -1 << endl;
        return 0;
    }

    sort(Aq.rbegin(), Aq.rend());
    ll t_sum = 0;
    for (int i = 0; i < (int)Aq.size(); i++){
        t_sum += Aq[i];
        ans++;
        if (t_sum >= Bl){
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2428
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

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

	bool yes = true;
	map<char, char> check;
	map<char, char> check2;
	for (size_t i = 0; i < s.size(); ++i) {
		if (check.find(s[i]) == check.end()) {
			check[s[i]] = t[i];
		}
		else if(check[s[i]] != t[i]){
			yes = false;
			break;
		}

		if (check2.find(t[i]) == check2.end()) {
			check2[t[i]] = s[i];
		}
		else if (check2[t[i]] != s[i]) {
			yes = false;
			break;
		}
	}

	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
    int X, t;
    cin >> X >> t;
    int ans;
    if(X < t) ans = 0;
    else ans = X - t;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    long long int N,dd,d;
    scanf("%lld",&N);
    long long int A[N],B[N],C[N],c=0;
    for(int j=0;j<N;j++){scanf("%lld",A+j);}
    for(int j=0;j<N;j++){scanf("%lld",B+j);}
    for(int j=0;j<N;j++){scanf("%lld",C+j);}
    sort(A,A+N);
    sort(C,C+N);
    for(int i=0;i<N;i++){
        dd=lower_bound(A,A+N,B[i])-A;
        d=N-(upper_bound(C,C+N,B[i])-C);
        c+=dd*d;
    }
    printf("%lld\n",c);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 ==0) {
		std::cout << "Possible\n";
	} else {
		std::cout << "Impossible\n";
	}
}


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

int main(){
    long long n,m;
    cin>>n>>m;
    string str,t;
    cin>>str>>t;
    long long g=__gcd(n,m);
    long long l=n/g*m;
    bool flag=true;
    n/=g;
    m/=g;
    for(long long i=0;i<g;i++){
        if(str[i*n]!=t[i*m]){
            flag=false;
            break;
        }
    }
    if(flag) 
      cout<<l;
    else 
      cout<<-1;
  return 0;
}


Measured memory_bytes: 3740
import itertools

def main():
    input_lines = []
    input_lines.append(input())
    N, K = [int(x) for x in input_lines[0].split(' ')]
    for i in range(N):
        input_lines.append(input())

    grid = [set() for i in range(3)]
    data = []
    for line in input_lines[1:]:
        x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
        data.append((x1, y1, d1, x2, y2, d2))
        grid[0].add(x1)
        grid[0].add(x2)
        grid[1].add(y1)
        grid[1].add(y2)
        grid[2].add(d1)
        grid[2].add(d2)

    grid = [sorted(g) for g in grid]
    grid_index = [{x[1]:x[0] for x in enumerate(g)} for g in grid]
    grid_len = [len(g) for g in grid]

    fish_dist = [[[0 for i in range(grid_len[2])] for i in range(grid_len[1])] for i in range(grid_len[0])]

    for x1, y1, d1, x2, y2, d2 in data:
        x1_index = grid_index[0][x1]
        x2_index = grid_index[0][x2]
        y1_index = grid_index[1][y1]
        y2_index = grid_index[1][y2]
        d1_index = grid_index[2][d1]
        d2_index = grid_index[2][d2]
        for x_index, y_index, d_index in itertools.product( range(x1_index, x2_index), range(y1_index, y2_index), range(d1_index, d2_index) ):
            fish_dist[x_index][y_index][d_index] += 1

    volume = 0
    for x_index, y_index, d_index in itertools.product(range(grid_len[0]), range(grid_len[1]), range(grid_len[2])):
        if fish_dist[x_index][y_index][d_index] >= K:
            x_begin = grid[0][x_index]
            y_begin = grid[1][y_index]
            d_begin = grid[2][d_index]
            x_end = grid[0][x_index + 1]
            y_end = grid[1][y_index + 1]
            d_end = grid[2][d_index + 1]
            volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
    print(volume)

main()

Measured memory_bytes: 15800
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)

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

    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
}

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

 int main(){
     int N,M;cin>>N>>M;
     vector<int> p(M);
     vector<string> s(M);
     int ac_count=0;
     vector<bool> ac_ok(N,false);
     for(int i=0;i<M;i++){
         cin>>p[i]>>s[i];
         p[i]--;
         if(s[i]=="AC"){ac_count++;
         ac_ok[p[i]]=true;
         }
     }
    int ac=0,wa=0;
    vector<bool> ok(N,false);
     for(int i=0;i<M;i++){
         if(ac==ac_count)break;
         if(s[i]=="AC"){
             if(ok[p[i]]==false){
                 ac++;
                 ok[p[i]]=true;
             }
         }else if(s[i]=="WA"){
             if(ac_ok[p[i]]==true&&ok[p[i]]==false){
                 wa++;
             }
         }
     }
     cout<<ac<<" "<<wa<<endl;
 }

 
    

Measured memory_bytes: 6144
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, Y = LI()

m = [10000, 5000, 1000]


"""
2000枚をどうふりわけるかで考える？
2000 0 0
1999 1 0
1998 2 0
的な
左端を固定、残りを右側でdfsしたら、
例えば1000なら、1000通り試せば良い
10**6ぐらいで終わるか？
"""
for i in range(N + 1):
    # i は1万円札の数
    ten = m[0] * i
    rest = N - i
    # 残りを5000/1000の振り分けを行う
    for j in range(rest + 1):
        five = m[1] * j
        one = m[2] * (rest - j)
        if ten + five + one == Y:
            print(i, j, rest - j)
            exit()
else:
    print(-1, -1, -1)


Measured memory_bytes: 66536
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    ll A,V,B,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    // 現在離れているだけ
    ll d = abs(A-B);

    // 一秒間に詰められる距離
    ll sd = V-W;

    if (sd <= 0) {
        cout << "NO" << endl;
        return;
    }

    if (d <= (sd*T) ) {
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;

}

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

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

using namespace std;

//#define FILE_IO

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

int N, M, C, K;
int f[100005];
int fth[100005];
int binode[100005];
vector <int> nodes;
vector <pii> edg[1000005];
vector <int> biedg[2][200005];

int d[2][200005];

int F(int x)
{
    if(x == fth[x]) return x;
    return fth[x] = F(fth[x]);
}

int BFS(int st, int fn)
{
    for(int i = 1; i <= N; i++)
        d[0][i] = 1 << 30;
    for(int i = 1; i <= K; i++)
        d[1][i] = 1 << 30;

    queue <pii> q;
    d[0][st] = 0;
    q.push({0, st});
    while(!q.empty())
    {
        int side = q.front().first;
        int nod = q.front().second;
        q.pop();

        if(side == 0 && nod == fn)   return d[0][N];

        for(auto nxt: biedg[side][nod])
            if(d[side ^ 1][nxt] > d[side][nod] + 1)
            {
                d[side ^ 1][nxt] = d[side][nod] + 1;
                q.push({side ^ 1, nxt});
            }
    }
    return -2;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= M; i++)
    {
        int x, y, c;
        scanf("%d%d%d", &x, &y, &c);
        C = max(C, c);
        edg[c].push_back({x, y});
    }

    for(int i = 1; i <= C; i++)
    {
        nodes.clear();
        for(auto e: edg[i])
        {
            int x = e.first;
            int y = e.second;
            if(f[x] != i)
            {
                f[x] = i;
                nodes.push_back(x);
            }
            if(f[y] != i)
            {
                f[y] = i;
                nodes.push_back(y);
            }
        }

        for(auto x: nodes)
            fth[x] = x;

        for(auto e: edg[i])
        {
            int x = e.first;
            int y = e.second;

            int f1 = F(x);
            int f2 = F(y);
            if(f1 == f2)    continue;

            fth[f1] = f2;
        }

        for(auto x: nodes)
            if( F(x) == x )
                binode[x] = ++K;

        for(auto x: nodes)
        {
            int y = binode[ F(x) ];
            biedg[0][x].push_back(y);
            biedg[1][y].push_back(x);
        }
    }

    int ans = BFS(1, N);
    ans /= 2;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 51712
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    _ <- getLine
    -- スペース区切り整数の入力
    ts <- map strToInt . words <$> getLine
    m <- readLn
    -- 改行数列
    ns <- replicateM m $ do
        [p, q] <- map strToInt . words <$> getLine
        return (p, q)
    let s = sum ts
        ans = map (\a -> s - (ts !! (fst a - 1)) + (snd a)) ns
    -- 出力
    mapM_ (putStrLn . show) ans


Measured memory_bytes: 1020
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// parameter "input" gets all data
function FavoriteSound(input) {
    // the first line is assigned to input[0], the second line is assigned to input[1] similarly.
    var _a = input.split("\n")[0].split(" ").map(Number), A = _a[0], B = _a[1], C = _a[2];
    // convert string from integer using "parseInt"
    var count = Math.min(C, Math.floor(B / A));
    //output
    console.log('%d', count);
}
exports.FavoriteSound = FavoriteSound;
// Don't edit this line!
try {
    FavoriteSound(require("fs").readFileSync("/dev/stdin", "utf8"));
}
catch (e) {
    // ignore, so importing in local unit tests would work
}
//# sourceMappingURL=FavoriteSound.js.map

Measured memory_bytes: 11468
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int ans = MAX;
int c[12],a[12][12];
int n,m,x;
int exp1[12];

void func(int num, int cost){
  if(num == -1){
    bool flag = true;
    rep(i,m){
      //cout << exp1[i] << " ";
      if(exp1[i] < x){
	flag = false;
      }
    }
    //cout << endl;
    if(flag && cost < ans){
      //cout << "aaaaaaaaaaaaaa";
      ans = cost;
    }
    return;
  }
  rep(i,m){
    exp1[i] += a[num][i];
  }
  func(num-1,cost+c[num]);
  rep(i,m){
    exp1[i] -= a[num][i];
  }
  func(num-1,cost);
}

int main(void){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double angle1 = h/6*M_PI+m/2*M_PI/180;
  double angle2 = m/30*M_PI;

  double angle3 = abs(angle1-angle2);

  printf("%.16lf\n",sqrt(a*a+b*b-2*a*b*cos(angle3)));
  return 0;
}


Measured memory_bytes: 4192
N = int(input())
H = [int(h) for h in input().split()]
H.append(1e10)
m, c = 0, 0
for i in range(N):
  d = H[i + 1] - H[i]
  if d <= 0:
    c += 1
  else:
    if c > m:
      m = c
    c = 0
print(m)

Measured memory_bytes: 14252