akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define MAX_N 100
#define MAX_H 25
#define INF (1<<29)

struct Edge {
    int to, c, h, r;
    Edge (int to, int c, int h, int r) :
        to(to), c(c), h(h), r(r) {}
};

struct State {
    int c, v, h;
    State (int c, int v, int h) :
        c(c), v(v), h(h) {}

    bool operator < (const State &s) const {
        return c > s.c;
    }
};

int main()
{
    int N, M, H, K, S, T, P;
    while (cin >> N >> M >> H >> K, N) {
        vector<Edge> G[MAX_N];
        for (int i = 0; i < M; i++) {
            int a, b, c, h, r;
            cin >> a >> b >> c >> h >> r;
            a--; b--; r--;
            G[a].push_back(Edge(b, c, h, r));
            G[b].push_back(Edge(a, c, h, r));
        }
        cin >> S >> T >> P; S--; T--;
        vector<int> d(P), bit(P);
        for (int i = 0; i < P; i++) {
            int l, k;
            cin >> l >> d[i];
            for (int j = 0; j < l; j++) {
                cin >> k; k--;
                bit[i] |= (1<<k);
            }            
        }

        int dp[1<<8];
        fill(dp, dp + (1<<8), INF);
        dp[0] = 0;
        for (int i = 0; i < (1<<K); i++) {
            if (dp[i] == INF) continue;              
            for (int j = 0; j < P; j++) {
                int ni = (i | bit[j]);
                dp[ni] = min(dp[ni], dp[i] + d[j]);
            }
        }
       
        int res = INF;
        for (int i = 0; i < (1<<K); i++) {
            int d[MAX_N][MAX_H];
            for (int j = 0; j < N; j++) {
                for (int k = 0; k <= H; k++) {
                    d[j][k] = INF;
                }
            }

            d[S][H] = 0;
            
            priority_queue<State> Q;
            Q.push(State(0, S, H));
            
            while (!Q.empty()) {
                State s = Q.top(); Q.pop();
                int v = s.v, h = s.h;
                int cost = s.c;
                
                if (v == T) {
                    res = min(res, cost + dp[i]);
                    break;
                }

                for (int j = 0; j < (int)G[v].size(); j++) {
                    Edge &e = G[v][j];
                    int nh = h - e.h;
                    if (nh < 0) continue;
                    
                    int ncost = cost;
                    if (!(i >> e.r & 1)) {
                        ncost += e.c;
                    } 
                    if (ncost < d[e.to][nh]) {
                        d[e.to][nh] = ncost;
                        Q.push(State(ncost, e.to, nh));
                    }
                }
            }            
        }
        cout << (res == INF ? -1 : res) << endl;
    }
    return 0;
}

Measured memory_bytes: 1324
# -*- coding: utf-8 -*-


def main():
    s_dash = input()
    t = input()
    s_count = len(s_dash)
    t_count = len(t)
    ans = list()

    for i in range(s_count - t_count + 1):
        si = s_dash[i:i + t_count]

        count = 0

        for sj, tj in zip(si, t):
            if sj == '?':
                count += 1
            elif sj == tj:
                count += 1

        if count == t_count:
            s = s_dash[:i] + t + s_dash[i + count:]
            s = s.replace('?', 'a')
            ans.append(s)

    if len(ans) > 0:
        print(sorted(ans)[0])
    else:
        print('UNRESTORABLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main()
{
  int N;
  cin >> N;
  set <string> gacha;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    gacha.insert(S);
  }
  cout << gacha.size() << endl;
  return 0;
}


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

int main(){
  int64_t a,b,k;
  cin >> a >> b >> k;
  if(a >= k){
    cout << a-k << " " << b << endl;
  }else if(b+a >= k){
    cout << "0" << " " << b-(k-a) << endl;
  }else{
    cout << "0 0" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i%2 == 0){
                        if(j%2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j%2 == 0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                    }
                }
            }
            System.out.print("\n");
        }
        System.out.print("\n");
    }
}
}


Measured memory_bytes: 36420
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  int A = input();
  int B = input();
  int C = input();

  if((A == C && B != C) || (A == B && A != C) || (B == C && A != C)){
    output("Yes");
  }
  else{
    output("No");
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int K;
vector<long long> A(100000);

long long winner(long long n) {
    if (n == 0) return 0;
    rep(i, K) {
        n = n / A[i] * A[i];
    }
    return n;
}

int main() {
    cin >> K;
    rep(i, K) cin >> A[i];
    
    long long left = 0;
    long long right = 1e15;
    while (right - left > 1) {
        long long mid = (right + left) / 2;
        if (winner(mid) < 2) left = mid;
        else right = mid;
    }
    if (winner(right) != 2) {
        cout << -1 << endl;
        return 0;
    }
    cout << right << " ";
    left = 0;
    right = 1e15;
    while (right - left > 1) {
        long long mid = (right + left) / 2;
        if (winner(mid) > 2) right = mid;
        else left = mid;
    }
    cout << left << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main() {
	int n; // 長さ
	int count = 0;
	std::cin >> n;
	int seq[n];
	for (int i = 0; i < n; i++) {
		std::cin >> seq[i];
	}

	for (int i = 0; i < n - 2; i++) {
		if ((seq[i] < seq[i + 1] && seq[i + 1] < seq[i + 2]) || (seq[i] > seq[i + 1] && seq[i + 1] > seq[i + 2])) {
			count++;
		}
	}

	std::cout << count;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int n,i,c=1;
	scanf("%d",&n);
	char s[n][11];
	for( i=0;i<n;i++){
		scanf("%s",s[i]);
	}

	qsort(s,n,11,strcmp);
	for( i=0;i<n-1;i++){
		if(strcmp(s[i],s[i+1])!=0)
			c++;
	}
	printf("%d\n",c);

}


Measured memory_bytes: 5736
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	vl a(n);
	map<ll, ll> cnt;
	for (auto& x : a)
	{
		cin >> x;
		cnt[x]++;

	}
	
	auto solve = [](map<ll, ll>& cnt)
	{
		ll res = 0;
		for (auto p : cnt)
		{
			if (p.second <= 1)
				continue;
			res += (p.second * (p.second - 1)) / 2LL;
		}
		return res;
	};
	ll res = solve(cnt);
	for (int i = 0; i < n; i++)
	{
		ll cr = res;
		ll cur = cnt[a[i]];
		if (cur >= 2)
		{
			cr -= (cur * (cur - 1)) / 2LL;
			cr += ((cur - 1) * (cur - 2)) / 2LL;
		}
		cout << cr << "\n";
		
	}
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,y,i;
    cin>>x>>y;
    if(x%y==0)
    {
        cout<<"-1"<<endl;
        return 0;
    }

    for(i=2;;i++)
    {
        if((x*i)%y!=0)
        {
            cout<<x*i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
#define deba(x) cerr << #x << endl; for (auto a : x) cerr << a << " "; cerr << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const int MOD = 1000000007;


int main() {
	fastio();
	int n, k;
	cin >> n >> k;
	int h[n];
	for(int i=0;i<n;i++)
		cin >> h[i];
	int dp[n];
	dp[0] = 0;
	/* int prev[n]; */
	/* prev[0]=-1; */
	for(int i=1;i<n;i++) {
		int minc=INT_MAX, mini=-1;
		for(int j=i-1;j>=max(0, i-k);j--) {
			if(minc > dp[j]+abs(h[i]-h[j])) {
				minc = dp[j]+abs(h[i]-h[j]);
				mini = j;
			}
			dp[i] = minc;
			/* prev[i] = mini; */
		}
	}
	cout << dp[n-1] << "\n";
	/* vector<int> ans; */
	/* for(int trav = n-1;trav != -1;trav = prev[trav]) */
	/* 	ans.push_back(trav); */
	/* reverse(ans.begin(), ans.end()); */
	/* for(auto i: ans) */
	/* 	cout << i+1 << " "; */
	/* cout << "\n"; */
	return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int L = sc.nextInt();
			int R = sc.nextInt();
			int d = sc.nextInt();
			
			int count = 0;
			for(int i=L;i<=R;i++) {
				if(i%d == 0) {
					count++;
				}
			}
			System.out.println(count);
		}	
	}
}

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

const int MAXN = 2e5 + 5;

int main()
{
	int n; scanf("%d", &n);
	static int a[MAXN];
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
		
	int cur;
	for (cur = n - 1; cur >= 0; cur -= 2)
		printf("%d ", a[cur]);
	for (cur = -1 - cur; cur < n; cur += 2)
		printf("%d ", a[cur]);
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, a[N];
ll dp[N][3];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i][0] = dp[i][1] = dp[i][2] = -inf;
	}

	dp[1][0] = a[1] / 2;
	if (a[1]) dp[1][1] = (a[1] - 1) / 2;
	if (a[1] >= 2) dp[1][2] = (a[1] - 2) / 2;

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= 2; j++) {
			for (int k = 0; k <= 2; k++) {
				for (int x = 0; x <= 2; x++) {
					if (k + x <= a[i] && !((a[i] - k - x) & 1))
						dp[i][k] = max(dp[i][k], dp[i - 1][j] + (a[i] - k - x) / 2 + min(j, x));
				}
			}
		}
	}

	cout << max({dp[n][0], dp[n][1], dp[n][2]});
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 2944
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;
fn count_elem<T>(v: &[T]) -> HashMap<&T, u64>
  where T: std::cmp::Eq + std::hash::Hash {
    let mut m = HashMap::new();
    for e in v {
        *m.entry(e).or_insert(0) += 1;
    }
    m
}

fn main() {
    input! {
        n: usize,
        vv: [u64;n]
    }
    let mut even = Vec::new();
    let mut odd = Vec::new();
    for (i,v) in vv.iter().enumerate() {
        if i % 2 == 0 {
            even.push(*v);
        } else {
            odd.push(*v);
        }
    }
    let meven = count_elem(&even);
    let modd = count_elem(&odd);
    if vv[0] == vv[1] && meven.len() == 1 && modd.len() == 1 {
        println!("{}", vv.len() / 2);
        return;
    }
    fn revsort(m: &HashMap<&u64,u64>) -> Vec<(u64,u64)> {
        let mut res: Vec<(u64,u64)> =
            m.into_iter().map(|(k,v)| (**k,*v)).collect();
        res.sort_by_key(|t| t.1);
        res.reverse();
        res
    }
    let even = revsort(&meven);
    let odd = revsort(&modd);
    if even[0].0 != odd[0].0 {
        let sum = (n as u64) - even[0].1 - odd[0].1;
        println!("{}", sum);
    } else {
        let sum1 = (n as u64) - even[0].1 - odd[1].1;
        let sum2 = (n as u64) - odd[0].1 - even[1].1;
        println!("{}", std::cmp::min(sum1,sum2));
    }
}


Measured memory_bytes: 14060
#include <bits/stdc++.h>
using namespace std;
int n, m, c, i, j, k, x, y, mo=1e9+7;
long long a[200005];
int cmp(int a, int b){
	return abs(a) < abs(b);
}
int main(){
	scanf("%d%d", &c, &k);
	for(i=1; i<=c; i++){
		scanf("%lld", &a[i]);
		if(a[i] < 0) x++;
		if(a[i] > 0) y++;
	}
	n = k;
	while(x >= 2 && n >= 2) x -= 2, n -= 2;
	if(y >= n){
		sort(a+1, a+c+1);
		n = c;
		if(k&1) m = a[n--], k--;
		else m = 1;
		for(i=1, j=n; k>0; k-=2){
			if(a[i]*a[i+1] > a[j]*a[j-1]){
				m = m * (a[i]*a[i+1]%mo) % mo;
				i += 2;
			}
			else{
				m = m * (a[j]*a[j-1]%mo) % mo;
				j -= 2;
			}
		}
		printf("%d\n", m);
	}
	else{
		sort(a+1, a+c+1, cmp);
		for(m=i=1; i<=k; i++){
			m = m * a[i] % mo;
		}
		printf("%d\n", (m+mo)%mo);
	}
	return 0;
}

Measured memory_bytes: 5348
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, x: "List[float]", u: "List[str]"):
    ret = 0
    for xx, uu in zip(x, u):
        ret += xx * {
            'JPY': 1.0,
            'BTC': 380000.0
        }[uu]
    return ret

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]" 
    u = [str()] * (N)  # type: "List[str]" 
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    result = solve(N, x, u)
    print(result)

if __name__ == '__main__':
    main()


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

using namespace std;

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

  string s;
  cin >> s;

  int res = 0;

  int tmp = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
      tmp += 1;
      res = max(res, tmp);
    } else {
      res = max(res, tmp);
      tmp = 0;
    }
  }

  cout << res << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string str,str2,tmp;
	int n;
	cin >> n;
	str = to_string(n);
	str2 = to_string(n);
	tmp = str.substr(0, 1);
	str.replace(0, 1, str.substr(0, 1));
	str.replace(2, 1, tmp);
	
	if (str == str2) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B;
  
  scanf("%d",&A);
  scanf("%d",&B);
  
  if(A==1){
    if(B==2){
      printf("3");
    }
    if(B==3){
      printf("2");
    }
  }
  if(A==2){
    if(B==3){
      printf("1");
    }
    if(B==1){
      printf("3");
    }
  }
  if(A==3){
    if(B==1){
      printf("2");
    }
    if(B==2){
      printf("1");
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int a; string s; cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    } else {
        cout << "red\n";
    }
    
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;

  map<char, char> hand_to_win;
  hand_to_win['r'] = 'P';
  hand_to_win['s'] = 'R';
  hand_to_win['p'] = 'S';

  map<char, int> scores;
  scores['R'] = R;
  scores['S'] = S;
  scores['P'] = P;
  
  string U;
  for (auto t : T) {
    char u = hand_to_win[t];
    U += u;
  }

  int total_score = 0;
  for (int i = 0; i < K; ++i) {
    int x = i;
    int streak = 1;
    while (x + K < N) {
      if (U[x + K] == U[x]) {
	++streak;
      } else {
	total_score += ((streak + 1) / 2) * scores[U[x]];
	streak = 1;
      }
      x += K;
    }
    total_score += ((streak + 1) / 2) * scores[U[x]];
  }

  cout << total_score << endl;
  
  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n = input()<<ap>>int
print(n*800-n//15*200)



Measured memory_bytes: 12528
#define _USE_MATH_DEFINES
#include <stdio.h>
#include<math.h>
 
int main(void)
{
    int a, b, C;
    double c;
    double S, L, h;
    double z;
    scanf("%d %d %d", &a, &b, &C);
     
    z=C*M_PI / 180;
    S = (a*b*sin(z))/2;
    c = (a*a) + (b*b) - 2 * a*b*cos(z);
    L = (double)a + (double)b + sqrt(c);
    h = 2 * S / a;
    printf("%f\n%f\n%f\n", S, L, h);
 
    return 0;
}

Measured memory_bytes: 636
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	a := getStdin()
	if 'a' <= a[0] && a[0] <= 'z' {
		fmt.Print("a")
	} else {
		fmt.Print("A")
	}
	fmt.Printf("\n")
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d==1)cout<<1<<endl;
    else cout<<0<<endl;
}

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

Measured memory_bytes: 256
N = int(input())
camdy_for_pair =  (1 + N)
num_of_pairs, amari = divmod((N),2)

if amari == 0:
    nesseary_candy = num_of_pairs * camdy_for_pair
else :
    nesseary_candy = num_of_pairs * camdy_for_pair + num_of_pairs + 1
    
print(nesseary_candy)


Measured memory_bytes: 2940
#include <atcoder/segtree>

#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define ll long long
#define endl '\n'
#define mod 998244353
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

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

const int dx8[] = { -1, 0, 1, 0,1,1,-1,-1 };
const int dy8[] = { 0, -1, 0, 1,1,-1,1,-1 };

int op(int a, int b)
{
    return max(a, b);
}

int e()
{
   return  0;
}

ll max(ll a, ll b)
{
    if (a > b) return a;
    return b;
}
ll min(ll a, ll b)
{
    if (a< b) return a;
    return b;
}
void solve()
{

    ll n, k; 
    cin >> n >> k;
    ll ans = 0;
    vector<int >arr(300001);
    segtree<int, op, e> seg(arr); 
    for (ll i = 0; i < n; ++i)
    {
        ll x; 
        cin >> x;
        ll l, r; 
        l = max(0, x - k);
        r = min(300000, x + k)+1;
        ll y = seg.prod(l, r); 
        seg.set(x, y+1); 
        ans = max(ans, y+1);
    }
    cout << ans << endl; 
}




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



Measured memory_bytes: 8452
#include<stdio.h>
#define max 100000

typedef long long int llint;
int n, k;
int w[max];

int check(llint p){
    int i = 0;

    for(int j=1; j<=k; j++){
        llint s = 0;
        while(s + w[i] <= p){
            s += w[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i=0; i<=n; i++) scanf("%d", &w[i]);

    //二分探索でPを決める
    llint left = 0, right = 100000*100000;
    while(left+1 < right){
        llint mid = (left + right) / 2;
        int v = check(mid);     //仮決めしたPでcheck

        if(v < n) left = mid;
        else right = mid;
    }

    printf("%lld\n", right);

    return 0;
}


Measured memory_bytes: 2236
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{a:i32,b:i32,h:i32};
    println!("{}", (a+b)*h/2);
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
using namespace std;

const long MOD = 1e9 + 7;
int main()
{
  long N, C;
  cin >> N >> C;

  vector<vector<long>> d(C, vector<long>(C, 0));//違和感


  vector<vector<long>> c(N, vector<long>(N, 0));//色 c to cのときの違和感がd

  for (int i = 0; i < C; ++i) {
    for (int j = 0; j < C; j++) {
      cin >> d[i][j];
    }
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; j++) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }




  //まず良くないマスを判定
  //次によくするための色の候補を出す
  //同じ色に塗る場合は候補1だから考慮なし


  //結局求めるのは、良いグリッドにする際に対象と違う色で塗る場合に塗る色のうちコストが最小になる塗り方

  // (i + j) %3 == (x + y) %3 →　ijとxyは同じ色で塗る
  // (i + j) %3 != (x + y) %3 →　ijとxyはちがう色で塗る

  //i+j%3==0のマスは
  //○○●○○
  //○●○○●
  //●○○●○
  //○○●○○
  //○●○○●
  //●マス同士は色一致

  //というか、マップで選べるのは3色しかないのでは？
  //色は30以下だから 30*29*28 = 4000*6くらい=2.4*10^4(bitDPでいける？)
  //それぞれで違和感を計算して最小の色をきめればOK
  //それぞれ500*500 = 2.5*10^4
  //合わせて10^8*5　→　厳しい
  //
  //最初に各あまりにおける色の数の集計をとっておく
  //配列30こ * 3
  //こうすれば2.4*10^4 * 30でいける？

  vector<vector<long>> cMap(3, vector<long>(C, 0));

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; j++) {
      cMap[(i + j) % 3][c[i][j]]++;
    }
  }

  long ans = 10000000000;

  for (int c1 = 0; c1 < C; ++c1) {//あまり0
    for (int c2 = 0; c2 < C; ++c2) {//あまり1
      if (c2 == c1)continue;
      for (int c3 = 0; c3 < C; ++c3) {//あまり2
        if (c3 == c1 || c3 == c2)continue;
        long count = 0;

        for (int col = 0; col < C; ++col) {
          count += d[col][c1] * cMap[0][col];
        }
        for (int col = 0; col < C; ++col) {
          count += d[col][c2] * cMap[1][col];
        }
        for (int col = 0; col < C; ++col) {
          count += d[col][c3] * cMap[2][col];
        }

        if (count < ans) {
          ans = count;
        }

      }
    }
  }



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

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

int N, M;
int a, b;
int road[55];

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    road[a]++;
    road[b]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << road[i] << endl;
  }
  return 0;
}


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


int main(){
    LL n,p,q;cin >> n >> p >> q;
    vector<LL> c(n);
    LL sum=0;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        sum+=c[i];
    }
    vector<LL> ss(n,0);
    for (int i = 0; i < n; i++) {
        ss[i] = p*i+c[i];
    }
    sort(ALL(ss));
    vector<LL> cum(n+1,0);
    for (int i = 0; i < n; i++) {
        cum[i+1] = cum[i]+ss[i];
    }
    LL ans=-LINF;
    for (int i = 0; i <= n; i++) {
        ans=max(sum+p*q*i+p*i*(i-1)-cum[i],ans);
    }
    cout << ans << endl;
    return 0;
}



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

int main(void) {
	int gp, i, len, score;
	char s[100010];
	scanf("%s", &s);
	len = strlen(s);

	gp = 1;
	score = 0;
	for (i=1;i<len;i++) {
		if (s[i] == 'g') {
			if (gp>0) { score++; gp--; }
			else { gp++; }
		} else {
			if (gp>0) { gp--; }
			else { score--; gp++; }
		}
	}

	printf("%d\n", score);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,a,b,c,d;
char s[SZ];
int aa=0;
bool ok(int l,int r)
{
	for(int i=l;i<r;++i)
		if(s[i]=='#'&&s[i+1]=='#')
			return 0;
	return 1;
}
void edt(int x,int y)
{
	aa+=(s[x]=='#'&&s[x+1]=='#')*y;
}
int main()
{
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1);
	if(ok(a,c)&&ok(b,d));
	else
	{
		puts("No");
		return 0;
	}
	if(c<d)
	{
		puts("Yes");
		return 0;
	}
	s[b]='#';
	for(int j=a-1;j>=1;--j) s[j]='.';
	for(int j=d+1;j<=n;++j) s[j]='.';
	for(int j=1;j<=n;++j) edt(j,1);
	if(!aa)
	{
		puts("Yes");
		return 0;
	}
	while(b!=d)
	{
		int c=1;
		if(s[b+1]=='#') ++c;
		{
			edt(b,-1);
			edt(b-1,-1);
			edt(b+1,-1);
			edt(b+2,-1);
			s[b]='.';
			s[b+c]='#';
			b+=c;
			edt(b,1);
			edt(b-1,1);
			edt(b+1,1);
			edt(b+2,1);
		}
	if(!aa)
	{
		puts("Yes");
		return 0;
	}
	}
	puts("No");
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
//static const int INFTY = (1<<20);


//ABC154_c
int main() {
	int N;
	cin >> N;
	map<int, int> mp;
	int64_t num;
	rep(i, N) {
		cin >> num;
		mp[num]++;
	}
	int mx = 0;
	for (auto el : mp) {
		mx = max(mx, el.second);
	}
	if (mx != 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 9600
def binary_search_int(ok, ng, test, k, A, B):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid, k, A, B):
            ok = mid
        else:
            ng = mid
    return ok

def get_cnt(x, A, B):
    """ a+b>=x となるようなAの要素とBの要素の組の数 (A, Bはソート済み)"""
    l, r = bisect_left(B, x-A[-1]), len(A)-2
    cnt = len(B) - l
    while l < len(B) and r>=0:
        if A[r]+B[l] < x:
            l += 1
        else:
            cnt += len(B) - l
            r -= 1
    return cnt

def test(x, k, A, B):
    return get_cnt(x, A, B) >= k

from bisect import *

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

P = []
for k in range(1,K+1):
    tmp = binary_search_int(0, 10**11,test, k, A, B)
    if tmp != 0:
        P.append(tmp)
Q = []
P.sort()
for k in range(1,K+1):
    Q.append(binary_search_int(1, 10**11,test, k, P, C))
print(*Q, sep="\n")


Measured memory_bytes: 77376
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    string s;
    string t;
     
    int main()
    {
    	cin >> s;
    	cin >> t;
    	int slen = s.length();
    	int tlen = t.length();
    	vector<string>v;
     
    	for (int i = slen - 1; i >= tlen - 1; i--) {
    		int ope = 0;
    		string ans = s;
    		for (int j = i; j >= i - tlen + 1; j--) {
    			if (s[j] != t[tlen - 1 - (i - j)] && s[j] != '?') {
    				ope++; break;
    			}
    		}
    		if (ope == 0) {
    			for (int j = i; j >= i - tlen + 1; j--) {
    				ans[j] = t[tlen - 1 - (i - j)];
    			}
    			for (int i = 0; i < slen; i++) {
    				if (ans[i] == '?')ans[i] = 'a';
    			}
    			v.push_back(ans);
    		}
    	}
    	/*
    	for (int i = 0; i < v.size(); i++) {
    		cout << v[i] << endl;
    	}
    	*/
    	if (v.empty()) {
    		cout << "UNRESTORABLE" << endl;
    		return 0;
    	}
    	sort(v.begin(), v.end());
     
    	cout << v[0] << endl;
     
    	return 0;
    }

Measured memory_bytes: 256
/* Simplicity and Goodness */

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

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, k;
    scn(n); scn(k);

    vi a(n);

    for(int& i : a)
        scn(i);

    vector<bool> dp(k+1, 0);
    // dp[i] = TRUE if first player wins when i stones are left.

    for(int stones = 0; stones <= k; stones ++) {
        for(int x : a) {
            if(stones >= x and !dp[stones - x])
                dp[stones] = 1;
        }
    }

    puts(dp[k]? "First": "Second");
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3708
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000

using namespace std;

class COneStrokePath {
public:
    int dfs(int now, vector<bool> visited) {
        if (visited[now]) return 0;
        visited[now] = true;
        if (count(visited.begin(), visited.end(), false) == 1) {
            return 1;
        }
        int ans = 0;
        for (int i = 0; i < to_vec[now].size(); ++i) {
            ans += dfs(to_vec[now][i], visited);
        }
        return ans;

    }

    void solve(std::istream &cin, std::ostream &cout) {
        int n, m;
        cin >> n >> m;
        to_vec.resize(n + 1);
        vector<bool> visited(n + 1);

        for (int i = 0; i < m; ++i) {
            visited[i] = false;
            int a, b;
            cin >> a >> b;
            to_vec[a].push_back(b);
            to_vec[b].push_back(a);
        }
        cout << dfs(1, visited) << endl;
    }

    vector<vector<int>> to_vec;
};


int main() {
    COneStrokePath solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main(void){
    int m = 10000;
    int i = 0;
    vector<int> A(m), B(m);
    while(1){
        cin >> A[i] >> B[i];
        if(A[i] > B[i]) swap(A[i], B[i]);
        if(A[i] == 0 && B[i] == 0)   break;
        i++;
    }
    
    for (int k = 0; k < i; k++){
        cout << A[k] << " " << B[k] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int64_t> memo(100000);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int64_t memo2 = i * i + j * j + k * k + k * i + i * j + j * k;
        memo.at(memo2)++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << memo.at(i) << endl;
  }
}

Measured memory_bytes: 3944
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;
	if (S == "Sunny")
		std::cout << "Cloudy\n";
	else if (S == "Cloudy")
		std::cout << "Rainy\n";
	else
		std::cout << "Sunny\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力の取得
S = input()


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    Tに右から文字を詰めていき、Sと比較
    """
    # 文字の定義
    dream = "dream"
    dreamer = "dreamer"
    erase = "erase"
    eraser = "eraser"

    T = ""
    t = -1
    result = True
    while True:
        s = S[t]
        if s == dream[-1]:
            # 次の文字が"m"のとき、dreamを挿入
            T = dream + T
        elif s == erase[-1]:
            # 次の文字が"e"のとき、eraseを挿入
            T = erase + T
        elif s == dreamer[-1]:
            # 次の文字が"r"のとき、右から3つ目の文字で場合分け
            s = S[t-2]
            if s == dreamer[-3]:
                # 3つ目の文字が"m"のとき、dreamerを挿入
                T = dreamer + T
            elif s == eraser[-3]:
                # 3つ目の文字が"s"のとき、eraserを挿入
                T = eraser + T
            else:
                result = False
                break
        else:
            result = False
            break

        if len(S) <= len(T):
            # 最終チェック
            result = (S == T)
            break
        t = -len(T) - 1  # 次の文字のインデックスを取得

    # 結果出力
    if result:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

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

    for (int i=0; i<(int)s.size(); i++) {
        if (s[i] != t[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n; cin >> n;
		vector<int> a(n + 1);
		vector<int> b(n + 1);
		rep (i, n) {
			cin >> a[i + 1];
		}
		for (int i = n; i >= 1; --i) {
			int sum = 0;
			//i以外の倍数について配置数の偶奇をチェックする
			for (int j = i + i; j <= n;  j += i) {
				sum ^= b[j];
			}
			//a[i]と偶奇が一致しない場合はボールを配置する
			//偶奇が一致する場合はa[i]より多い個数を配置してしまうのでボールを置かない
			b[i] = sum^a[i];
		}
		vector<int> ans;
		//ボールを配置した場所の数値を出力する
		repn (i, n) {
			if (b[i]) {
				ans.emplace_back(i);	
			}
		}
		cout << ans.size() << endl;
		rep (i, ans.size()) {
			cout << ans[i] << endl;
		}
    return;
}

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



Measured memory_bytes: 3064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

type item struct {
	v, l int
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, K := getInt(), getInt()
	s := getString()
	a := make([]item, 0)
	cnt := 1
	c := s[0]
	for i := 1; i < N; i++ {
		if s[i] != c {
			a = append(a, item{int(c - '0'), cnt})
			cnt = 0
			c = s[i]
		}
		cnt++
	}
	a = append(a, item{int(c - '0'), cnt})
	// out(a)
	ans := 0
	cnt = 0
	idx := 0
	flg := false
	pidx := 0
	for cnt != K {
		ans += a[idx].l
		if a[idx].v == 0 {
			cnt++
			if !flg {
				pidx = idx
				flg = true
			}
		}
		idx++
		if idx == len(a) {
			out(ans)
			return
		}
	}

	if idx != len(a)-1 {
		ans += a[idx].l
		idx++
	}

	prev := ans
	for idx < len(a) {
		x := prev - a[pidx].l
		if pidx != 0 {
			x -= a[pidx-1].l
		}
		// out(x)
		x += a[idx].l
		if idx+1 != len(a) {
			x += a[idx+1].l
		}
		// out(x)
		// out("idx", idx, "pidx", pidx, "x", x)
		prev = x
		ans = max(ans, x)
		pidx += 2
		idx += 2
	}

	out(ans)
}


Measured memory_bytes: 8448