akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn gcd(mut x: i64, mut y: i64) -> i64 {
    while y != 0 {
        let r = x % y;
        x = y; y = r;
    }
    x
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, m: i64,
        a: [i64; n],
    }
    let a: Vec<i64> = a.into_iter().map(|x| x / 2).collect();
    let mut lcm = 1;
    for i in 0..n {
        let g = gcd(lcm, a[i]);
        lcm /= g;
        lcm *= a[i];
        if lcm > m {
            puts!("0\n");
            return;
        }
    }
    for i in 0..n {
        if (lcm / a[i]) % 2 == 0 {
            puts!("0\n");
            return;
        }
    }
    let q = m / lcm;
    puts!("{}\n", (q + 1) / 2);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 10620
import itertools as it
import math

a = int(input())
b = []
for i in range(a):
  var0 = input().split()
  var0 = [int(i) for i in var0]
  b.append(var0)
li = list(it.permutations(b))
result = []
for i in li:
  re = []
  for j in range(a - 1):
    re.append(math.sqrt((i[j + 1][0] - i[j][0]) * (i[j + 1][0] - i[j][0]) + (i[j + 1][1] - i[j][1]) * (i[j + 1][1] - i[j][1])))
  result.append(sum(re))
print(sum(result) / len(result))

Measured memory_bytes: 9252
// B - Palace
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	double T,A; cin>>T>>A;
	double mini = 1e9;
	int ans = 0;
	for(int i=0; i<N; ++i){
		double hi; cin>>hi;
		double a = abs(T - hi*.006 - A);
		if(mini>a){
			mini = a;
			ans = i + 1;
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>


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

    int A[N];
    int A_sum[N];

    for(int j=0;j<N;j++){
        A_sum[j]=0;
    }

    for(int i=1;i<N;i++){
        scanf("%d", &A[i]);

        A_sum[A[i]-1]++;
    }

    for(int i=0;i<N;i++){
        printf("%d\n",A_sum[i]);
    }

    return 0;
}

Measured memory_bytes: 3296
#define Link "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0348"

#include <iostream>
#include <cstdio>

#define TASK "Sevens"

using namespace std;

void OpenFile()
{
    freopen(TASK".INP","r",stdin);
    freopen(TASK".OUT","w",stdout);
}

bool b[14];

void Enter()
{
    fill(b+1,b+13+1,0);
    for (int i=1;i<=6;++i) {
        int x;
        cin >> x;
        b[x] = 1;
    }
}

void Init()
{

}

bool BT(int l, int r, bool p)
{
    if (l == 1 && r == 13)
        return p;
    if ((l == 1 || b[l-1] != p) && (r == 13 || b[r+1] != p))
        return BT(l,r,p^1);
    if (1 < l && b[l-1] == p && BT(l-1,r,p^1) == p)
        return p;
    if (r < 13 && b[r+1] == p && BT(l,r+1,p^1) == p)
        return p;
    return p ^ 1;
}

void Solve()
{
    if (BT(7,7,1))
        cout << "yes";
    else
        cout << "no";
    cout << '\n';
}

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

    //OpenFile();

    int T;
    for (cin>>T;T>0;--T) {
        Enter();
        Init();
        Solve();
    }
}



Measured memory_bytes: 3148
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int n = IO.INT();
        int[] m = IO.INT(n);
        int min = m[0];
        int max = int.MinValue;
        for (int i = 1; i < n; i++)
        {
            max = Math.Max(max, m[i] - min);
            min = Math.Min(min, m[i]);
        }
        IO.WRITE(max);
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

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

double dp[3005][3005];//当前概率[当前硬币数][向上硬币数] 
double p[3005];

signed main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	cin>>p[i];
	
	dp[1][0]=1-p[1],dp[1][1]=p[1];
	for(int i=2;i<=n;i++)
		for(int j=0;j<=n;j++){
			if(j==0)dp[i][0]=dp[i-1][0]*(1-p[i]);
			dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
		}
	
	double ans=0;
	for(int i=1;i<=n;i++){
		if(i>n-i)ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 74184
#include<cstdio>
#include<algorithm>
#include<vector>
#define MAXN 100006
#define INF 2100000000
using namespace std;
vector<pair<int,long long> > road[MAXN];
int sum[MAXN],a[MAXN],n,ans[MAXN],cnt,u,v;
long long ret,len,minone=INF;
void DFS(int x,int fa)
{
	sum[x]=1;
	for(int i=0;i<(int)road[x].size();i++)
	{
		int nex=road[x][i].first;
		if(nex==fa) continue;
		DFS(nex,x);
		sum[x]+=sum[nex];
		a[x]=max(a[x],sum[nex]);
	}
	a[x]=max(a[x],n-sum[x]);
	if(a[x]==a[ans[cnt]]) ans[++cnt]=x;
	if(cnt==0||a[x]<a[ans[cnt]])
	{
		cnt=1;
		ans[cnt]=x;
	}
}
void DFSS(int x,int fa)
{
	sum[x]=1;
	for(int i=0;i<(int)road[x].size();i++)
	{
		int nex=road[x][i].first;
		if(x==ans[1]&&nex==ans[2]) continue;
		if(x==ans[2]&&nex==ans[1]) continue;
		if(nex==fa) continue;
		DFSS(nex,x);
		sum[x]+=sum[nex];
		ret+=road[x][i].second*sum[nex];
		if(x==ans[1]) minone=min(minone,road[x][i].second);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d%lld",&u,&v,&len);
		road[u].push_back({v,len});
		road[v].push_back({u,len});
	}
	DFS(1,0);
	if(cnt==1)
	{
		ans[2]=0;
		DFSS(ans[1],0);
		printf("%lld",ret*2-minone);
	}
	else
	{
		long long v=0;
		for(int i=0;i<(int)road[ans[1]].size();i++)
		{
			int nex=road[ans[1]][i].first;
			if(nex==ans[2])
			{
				v=road[ans[1]][i].second;
				break;
			}
		}
		DFSS(ans[1],0);
		DFSS(ans[2],0);
		printf("%lld",ret*2+v*(n-1));
	}
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    rep(i, S.size()) {
        int string_code = S[i] - 'A' + N;
        // cout << "sc: " << string_code;
        if (string_code >= 26) {
            string_code -= 26;
        }
        cout << (char) (string_code + 'A');
    }
    cout << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

struct node
{
    int x, y;
    bool operator < (const node &o) const
    {
        return y > o.y;
    }
}a[100005];

int n, k, cot = 0;
bool vis[100005];

stack <int> s;

int main()
{
    ll ans = 0, res = 0, type = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    	cin >> a[i].x >> a[i].y;
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
    {
        if (cot < k)
        {
            if (!vis[a[i].x])
            {
                vis[a[i].x] = 1;
                type++;
            }
            else 
				s.push(a[i].y);
            res += a[i].y;
            cot++;
            ans = max(ans, res + type * type);
        }
        else
        {
            if (s.empty()) break;
            if (vis[a[i].x]) continue;
            vis[a[i].x] = 1;
            type++;
            res += a[i].y;
            res -= s.top();
			s.pop();
            ans = max(ans, res + type*type);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
def insertionSort arr, n, g
	for i in g ... n
		v = arr[i]
		j = i - g
		while j >= 0 && arr[j] > v
			arr[j + g] = arr[j]
			j -= g
			@count += 1
		end
		arr[j + g] = v
	end
end

def shellSort arr, n
	@count = 0

	interval = n / 2
	g = [interval]
	while interval > 1
		interval /= 2
		g << interval
	end	
	m = g.length

	for i in 0 ... m
		insertionSort(arr, n, g[i])
	end

	puts m
	puts g.join(" ")
	puts @count
end

n = gets.to_i
arr = Array.new(n)
n.times{|i| arr[i] = gets.to_i}
shellSort(arr, n)
puts arr

Measured memory_bytes: 16520
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
struct Edge {
	int from, to, cost;
	Edge(int from, int to, int cost)
		: from(from), to(to), cost(cost) {};
};

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
	ll n;
	ll res = 0;
	cin >> n;
	vector<ll> L(2*n);

	rep(i, 2*n)
	{
		cin >> L[i];
	}

	sort(L.begin(), L.end(), greater<ll>());

	rep(i, 2 * n)
	{
		res += min(L[i], L[i + 1]);
		i++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int K;
    cin >> K;
    cout << ((K / 2) * ((K + 1) / 2)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin, (x).end
#define sz(x) (int)(x).size()
#define rep1(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define get4(_1, _2, _3, _4, ...) _4
#define rep(...) get4(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<pair<ll, ll>> cand;
  for (ll i = 1; i * i <= n; i++) {
    if (i * (n / i) == n) cand.pb({i, n / i});
  }
  for (int i = sz(cand) - 1; ~i; i--) {
    cout << cand[i].first + cand[i].second - 2 << '\n';
    break;
  }
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
#define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
#define sortV(v) sort(v.begin(),v.end())
#define revV(v) reverse(v.begin(),v.end())
#define FOR(i,n) for(int i=0;i<n;i++)
    
    ll a,b,c,d,e,f,g,n,m,k,t,p,x,h,w,q;
    ll curr = 1;
    ll mod = 998244353;


    void solve(){
       cin >> a >> b >> c;
       swap(a,b);
       swap(a,c);
       cout << a << " "<< b<< " " << c;
    }
  
   
    int main(){
    ios_base::sync_with_stdio(false);
  
    int cases = 1;
    //cin >> cases;
  
    while(cases--){ 
        solve();
    }

    return 0;

    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll n;
	cin >> n;

	for (int a = 1; a <= n; a++)
	{
		ll ans = 0;
		for (ll x = 1; x * x <= a; x++)
		{
			for (ll y = 1; y * y <= a - x * x; y++)
			{
				for (ll z = 1; z * z+z*x+z*y <= a - x * x - y * y-x*y; z++)
				{
					if (x * x + y * y + z * z + z * x + z * y + x * y == a)
					{
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3564
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, s;
    for(;;){
      n = sc.nextInt(); if(n == 0)break;
      s = 1;
      for(i = 2;i * i <= n;i++)if(n % i == 0)s += i + n / i;
      if(--i * i == n)s -= i;
      if(s < n)out.println("deficient number");
      else if(s > n)out.println("abundant number");
      else out.println("perfect number");
    }
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

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

int main()
{
    int x, y, ac, bc, cc;
    cin >> x >> y >> ac >> bc >> cc;
    vector<int> a(ac), b(bc), c(cc);
    rep(i, ac) cin >> a[i];
    rep(i, bc) cin >> b[i];
    rep(i, cc) cin >> c[i];
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());
    sort(c.begin(), c.end(), greater<int>());

    ll ans = 0;
    int ci = 0, ai = 0, bi = 0;
    rep(i, x + y)
    {
        if (bi >= y || a[ai] > b[bi] && ai < x)
        {
            if (ci < cc && c[ci] > a[ai])
            {
                ans += c[ci];
                ci++;
            }
            else
            {
                ans += a[ai];
                ai++;
            }
        }
        else
        {
            if (ci < cc && c[ci] > b[bi])
            {
                ans += c[ci];
                ci++;
            }
            else
            {
                ans += b[bi];
                bi++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))

ans = "APPROVED"
for i in a:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            ans = "DENIED"
    else:
        pass
print(ans)

Measured memory_bytes: 2940
N, K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = max(C)
for i in range(N):
    check = {i}
    loop_score =[]
    k = i
    while True:
        loop_score.append(C[k])
        k = P[k]-1
        t = len(check)
        check.add(k)
        if len(check)==t:
            break
    cum_score = 0
    cum_scores = []
    for j in loop_score:
        cum_score+=j
        cum_scores.append(cum_score)
    loop = cum_scores[-1]
    compare = min(0,max(cum_scores))
    loops = K//len(cum_scores)
    plus = K%len(cum_scores)
    if loop > 0:
        compare = 0
        compare+=loops*loop
    final = cum_scores[:plus]
    if plus != 0:
        compare+=max(final)
        
    if loop > 0:
        compare2 = max(cum_scores) + (loops-1)*loop
        if compare2 > compare:
            compare = compare2

    if K < len(cum_scores):
        cum_scores = cum_scores[:K]
    if max(cum_scores)>compare:
        compare = max(cum_scores)
    if compare>ans and compare!=0:
        ans = compare
print(ans)

Measured memory_bytes: 209000
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	if( s == "SUN" ) cout << 7 << endl;
	if( s == "MON" ) cout << 6 << endl;
	if( s == "TUE" ) cout << 5 << endl;
	if( s == "WED" ) cout << 4 << endl;
	if( s == "THU" ) cout << 3 << endl;
	if( s == "FRI" ) cout << 2 << endl;
	if( s == "SAT" ) cout << 1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
num = int(input())
num_list = [int(i) for i in input().split()]

#大きい順に並び変える
num_list.sort(reverse = True)

senkou = 0
koukou = 0
for i in range(num):
    if i % 2 == 0:
        senkou += num_list[i]
    else:
        koukou += num_list[i]

result = senkou - koukou
print(result)


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
 
public class Main {
    static ArrayList<ArrayList<Point>> map;
    static long[] dist;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        map = new ArrayList<ArrayList<Point>>();
        for(int i = 0; i < n; i++){
            map.add(new ArrayList<Point>());
        }
        for(int i = 0; i < n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            int c = sc.nextInt();
            map.get(a).add(new Point(b,c));
            map.get(b).add(new Point(a,c));
        }
        int q = sc.nextInt();
        int s = sc.nextInt()-1;
        dist = new long[n];
        Arrays.fill(dist,Long.MAX_VALUE);
        dist[s] = 0;
        boolean[] arr = new boolean[n];
        arr[s] = true;
        dfs(s,0,arr);
        for(int i = 0; i < q; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            pw.println(dist[a] + dist[b]);
        }
        pw.flush();
    }
    
    public static void dfs(int s, long dd, boolean[] a){
        for(Point p : map.get(s)){
            if(!a[p.x]){
                dist[p.x] = dd+p.d;
                a[p.x] = true;
                dfs(p.x,dd+p.d,a);
                a[p.x] = false;
            }
        }
        return;
    }
    
}

class Point{
    int x;
    long d;
    public Point(int x, long d){
        this.x = x;
        this.d = d;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 102764
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef pair <int,int> pii;
#define X first
#define Y second

int main(){
  char m[501];
  scanf("%s",m);
  int len=strlen(m);
  int lev=0;
  int flag=0;

  stack <char> s;
  rep(i,len){
    s.push(m[i]);
    lev++;
    char t1=s.top();
    s.pop();
    if(s.empty()){
      s.push(t1);
      continue;
    }

    char t2=s.top();
    s.pop();
    if(s.empty()){
      s.push(t2);
      s.push(t1);
      continue;
    }

    char t3=s.top();
    s.pop();
    
    if(t1=='w' && t2=='e' && t3=='m'){
      lev-=3;
      if(lev==0)
	flag++;
      continue;
    }
    
    s.push(t3);
    s.push(t2);
    s.push(t1);
  }
  printf("%s\n",(s.empty()&&flag==1)?"Cat":"Rabbit");
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//45C

ll plusNum(string s) {
	if (s.length() == 1) return (ll)stoll(s);
	else {
		ll ret = stoll(s);
		rep(1, s.length()) {
			string sub1 = s.substr(0, i), sub2 = s.substr(i,s.length() - i);
			ret += pow(2, sub2.length() - 1) * stoll(sub1) +  plusNum(sub2);
		}
		return ret;
	}
}

int main(void) {
	string s;
	cin >> s;
	ll ans = 0;
	ans += plusNum(s);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        int[] b = new int[5];
        for (int i = 0 ; i < 5 ; i++) {
            a[i] = sc.nextInt();
            b[i] = a[i] % 10;
        }
        int min = 123345;
        for (int i = 0 ; i < 5 ; i++) {
            int sum = 0;
            for (int j = 0 ; j < 5 ; j++) {
                if (i == j) {
                    sum += a[j];
                } else {
                    int d = (a[j] + 9) / 10;
                    sum += d * 10;
                }
            }
            min = Math.min(min, sum);
        }

        System.out.println(min);
    }

}

Measured memory_bytes: 21712
n, m = gets.split.map(&:to_i)
ks = []
m.times do
  ks.push gets.split.map(&:to_i)
end
p = gets.split.map(&:to_i)
c = []
ks.each_index do |i|
  k = ks[i][0]
  s = ks[i][1..-1]
  b = 0
  s.each do |f|
    b += (1 << (f - 1))
  end
  c.push [b, p[i]]
end
def bitcount(n)
  c = 0
  while n > 0
    c += 1 if (n & 1) == 1
    n /= 2
  end
  c
end
count = 0
0.upto(2**n - 1) do |b|
  flag = false
  0.upto(m - 1) do |i|
    if bitcount(c[i].first & b) % 2 != c[i].last
      flag = true
      break
    end
  end
  next if flag

  count += 1
end
puts count


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

using namespace std;

int main() {
    char a[10];

    scanf("%s", a);

    if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) printf("Bad\n");
    else printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e7;
const long long N = 5e5 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

long long cnt, n, m , x , k , z , mn = 1e9 , mn1 = 1e9;
long long a , b , c;
string s;
int main(){
    TIME
    cin >> n >> m >> k;
    ll arr[n] , b1[m];
    for( int i = 0;i < n;i ++ )
        cin >> arr[i] , mn1 = min( mn1 , arr[i] );
    for( int i = 0;i < m;i ++ )
        cin >> b1[i] , mn = min( mn , b1[i] );
        mn1+=mn;
    for( int i = 0; i < k;i ++ ){
        cin >> a >> b >> c;
        mn1 = min( mn1 , arr[a - 1] + b1[b - 1] - c );
    }
    cout << mn1;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
 
int main(){
    
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    char s2=s[1].front();

    cout << "A" << s2 << "C" << endl;

    
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int x, n; cin >> x >> n;
    vi no(105);
    FOR(i, 1, n) {
        int p; cin >> p;
        no[p] = 1;
    }
    int ans = 0, dif = 200;
    FOR(i, 0, 101) {
        if (!no[i] && abs(x - i) < dif)
            dif = abs(x - i), ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    cin >> A >> B >> C;
    for (int i = 0; i <= B; ++i) {
        if ((A*i) % B == C) {
cout << "YES" << endl; return 0;
        }
    }
cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int r;
	cin >> r;
	if (r<1200) {
		cout << "ABC" << endl;
	}
	else if (r>=1200&&r<2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
#define maxn 233333
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int a,b,c;
int main()
{
	a=read(),b=read(),c=read();
	int res=a-b;
	if(c>=res) cout<<c-res;
	else cout<<0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h1=0,h2=0,h3=0,h;
  for(int i;i<10;++i){
    cin >> h;
    if(h>h1){
      h3=h2;
      h2=h1;
      h1=h;
    }else if(h>h2){
      h3=h2;
      h2=h;
    }else if(h>h3){
      h3=h;
    }
  }
  cout<<h1<<endl<<h2<<endl<<h3<<endl;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar();}
	return f * x;
}

int n, m, l[2500003], ans, len, ns[2500003], s[2500003], num, num1;
char a[500003];
struct Node
{
	int x, y, p, b;
} q[2500003];
struct Code
{
	int o;
	char v;
} c[2500003];

inline bool cmp(Node a, Node b)
{
	return s[a.x]^s[b.x]? s[a.x]<s[b.x]:s[a.y]^s[b.y] ? s[a.y]<s[b.y]:a.p<b.p;
} 

inline void add(int xx)
{
	if (++l[xx] == 1) ++ans;
}

inline void shan(int xx)
{
	if (--l[xx] == 0) --ans;
}

inline void modify(int now, int xx)
{
	if (c[now].o >= q[xx].x && c[now].o <= q[xx].y)
	{
		if (--l[(int)a[c[now].o]] == 0) --ans;
		if (++l[(int)c[now].v] == 1) ++ans;
	}
	swap(c[now].v, a[c[now].o]);
}

inline void solve()
{
	int L = 0, r = 0, no = 0;
	for (int i = 1; i <= num; i++)
	{
		while (L < q[i].x) shan(a[L++]);
		while (L > q[i].x) add(a[--L]);
		while (r < q[i].y) add(a[++r]);
		while (r > q[i].y) shan(a[r--]);
		while (no < q[i].p) modify(++no, i);
		while (no > q[i].p) modify(no--, i);
		ns[q[i].b] = ans;
	}
}

int main()
{
	n = gi();
	scanf("%s", a + 1);
	int tn = 0;
	m = gi();
	while (m--)
	{
		int h = gi();
		if (h == 2)
		{
			q[++num].x = gi(), q[num].y = gi();
			q[num].p = num1, q[num].b = num;
		}
		else 
		{
		    ++tn;
			c[++num1].o = gi();
			scanf("%c", &c[num1].v);
		}
	}
	len = pow(n, 2.0/3.0);
	for (int i = 1; i <= n; i+=1) s[i] = (i - 1) / len + 1;
	sort(q + 1, q + num + 1, cmp);
	solve();
	for (int i = 1; i <= num; i++) printf("%d\n", ns[i]);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int root[425252], depth[425252];

// xの根を求める
int find(int x){
	if(root[x]==x){
		return x;
	}
	else{
		return root[x]=find(root[x]);
	}
}

// xとyが属する集合を併合
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y){
		return;
	}
	if(depth[x]<depth[y]){
		root[x]=y;
	}
	else{
		root[y]=x;
		if(depth[x]==depth[y]){
			++depth[x];
		}
	}
	return;
}

// xとyが同じ集合に属するか判定
bool same(int x, int y){
	return find(x)==find(y);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, l, p, q, r, s;
	cin>>n>>k>>l;
	// 初期化
	REP(i, n*2){
		root[i]=i;
		depth[i]=0;
	}
	REP(i, k){
		cin>>p>>q;
		--p;
		--q;
		unite(p, q);
	}
	REP(i, l){
		cin>>r>>s;
		--r;
		--s;
		unite(r+n, s+n);
	}
	pii pqrs1[252525], pqrs2[252525];
	REP(i, n){
		pqrs1[i]=pqrs2[i]=pii(find(i), find(i+n));
	}
	sort(pqrs1, pqrs1+n);
	REP(i, n){
		cout<<upper_bound(pqrs1, pqrs1+n, pqrs2[i])-lower_bound(pqrs1, pqrs1+n, pqrs2[i])<<' ';
	}
	return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n, k;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &k);

  ans = 0LL;

  for (ll i = 1LL; i <= n; ++i) {
    ll block = (n + 1LL) / i;
    ll remain = (n + 1LL) % i;

    ll commit_block = max(i - k, 0LL);
    ll commit_remain = max(remain - k, 0LL);

    ans += commit_block * block + commit_remain - ((k == 0LL) ? 1LL : 0LL);
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> A(b);
  int count = 0;
  for(int i=0;i<b;i++)
    cin >> A.at(i);
  for(int i = 0;i<a;i++){
    int sum = 0;
    for(int j = 0;j<b;j++){
      int d;
      cin >> d;
      sum += A.at(j)*d;
    }
    sum += c;
    if(sum > 0)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

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

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

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	string s;
	LL k;
	cin>>s>>k;
	VLL cnt;
	char cur=s.at(0);
	LL c=0;
	for(LL i=0;i<s.size();i++){
		if(cur==s.at(i)){
			c++;
		}else{
			cnt.push_back(c);
			cur=s.at(i);
			c=1;
		}
	}
	cnt.push_back(c);
	LL ans=0;
/*
	for(LL i=0;i<cnt.size();i++){
		ans+=cnt.at(i)/2;
	}
	ans*=k;
	if(s.at(0)==s.at(s.size()-1)){
		if(cnt.at(0)%2 == 1 and cnt.at(cnt.size()-1)%2 == 1){
			if(cnt.at(0) ==1 or cnt.at(cnt.size()-1)==1
			ans+= k-1;
		}
		if(cnt.at(0)==1 and cnt.at(cnt.size()-1)==1){
			ans+=k-1;
		}else if(cnt.at(0)==1 or cnt.at(cnt.size()-1)==1){
			ans+=k-1;
		}else{
			ans
	}
	cout<<ans<<endl;
*/
	if(cnt.size()==1){
		ans = cnt.at(0) * k / 2;
		cout<<ans<<endl;
		return 0;
	}
	if(s.at(0)==s.at(s.size()-1)){
		ans+=cnt.at(0)/2+cnt.at(cnt.size()-1)/2;
		for(int i=1;i<cnt.size()-1;i++){
			ans+=cnt.at(i)/2 * k;
		}
		ans+=(cnt.at(0)+cnt.at(cnt.size()-1))/2 * (k-1);
	}else{
		for(int i=0;i<cnt.size();i++){
			ans+=cnt.at(i)/2*k;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
from itertools import product


def main():
    h, w, k = map(int, input().split())
    grid = np.full((h, w), False, dtype=bool)
    for i in range(h):
        line = input()
        for j in range(w):
            if line[j] == '#':
                grid[i][j] = True
    ans = 0
    for e in product((True, False), repeat=h + w):
        grid_copy = np.copy(grid)
        for i in range(h):
            if e[i]:
                grid_copy[i, :] = False
        for j in range(w):
            if e[h + j]:
                grid_copy[:, j] = False
        if np.sum(grid_copy) == k:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27280
import random
import time

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


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

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

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

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 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) and c[j] != 0:
                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 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        last_d = [0 for i in range(26)]
        score2 = 0  
        tmp1 = 0
        tmp2 = 1
        tmp3 = 2
        if random.randint(0,1):           
            d1 = random.randint(0,D-15) 
            d2 = random.randint(d1+1,d1+7)
            d3 = random.randint(d2+1,d2+7) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            ans[d1] = tmp2
            ans[d2] = tmp1
            ans[d3] = tmp3
                  
        else:
            d1 = random.randint(0,D-15) 
            d2 = random.randint(d1+1,d1+7)
            d3 = random.randint(d2+1,d2+7) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp1
            ans[d2] = tmp2
            ans[d3] = tmp3
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


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

int main() {
  int N,M,ans=0;
  double check,count=0;
  cin >> N >> M;
  vector<double> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
    count+=vec.at(i);
  }
  
  check=(count/(4*M));
  for(int i=0;i<N;i++){
    if(vec.at(i) >= check) ans++;
  }
  if(M<=ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String p = in.next();
		String s2 = s + s;
		System.out.println(s2.contains(p) ? "Yes" : "No");
	}
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long a=0,b=0,c=0,d=0,m=0,n=0,p=0,q=0;

cin >> a >> b >> c;

while(a>0)
{
a-=b;
n++;
}

cout << n*c;

}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n[4];
    cin >> n[0] >> n[1] >> n[2] >> n[3];
    sort(n, n+4);
    do {
        if ( n[0] == 1 && n[1] == 9 && n[2] == 7 && n[3] == 4 ) {
            cout << "YES" << endl;
            return 0;
        }
    } while( next_permutation(n, n+4) );
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
int abc[300000];
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int X = 0, Y = 0, A = 0, B = 0, C = 0;
	while ((ct = getchar_unlocked()) >= '0') X = X * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') Y = Y * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') A = A * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') B = B * 10 + ct - '0';
	while ((ct = getchar_unlocked()) >= '0') C = C * 10 + ct - '0';

	auto a = abc;
	auto b = abc + A;
	auto c = abc + A + B;

	int k = 0;
	int M = A + B + C;
	while (k < M) {
		int yoyuu = (cm - (ci - cn)) / 11;
		chmin(yoyuu, M - k);
		if (yoyuu > 10) {
			rep(i, yoyuu) {
				int aa = 0;
				while ((ct = *ci++) >= '0') aa = aa * 10 + ct - '0';
				abc[k++] = aa;
			}
		}
		else {
			auto tmp = ci;
			while (k < M) {
				abc[k++] = getint();
				if (tmp - ci < 0) break;
				tmp = ci;
			}
		}
	}

	nth_element(a, b - X, b);
	nth_element(b, c - Y, c);
	if (X + Y > B) memcpy(b, b - X, (B - Y) * sizeof(int));
	else memcpy(c - X - Y, b - X, X * sizeof(int));
	nth_element(c - X - Y, c + C - X - Y, c + C);

	ll kotae = accumulate(c + C - X - Y, c + C, 0ll);
	//for (auto kari = c + C - X - Y; kari < c + C; kari++) kotae += *kari;
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libmod {{{*/
struct ModCalc(N) if (isIntegral!N) {
 public:
  N mod(N n) const {
    const x = n%m;
    return x < 0? x+m: x;
  }
  N inv(N a) const {
    N b = m, u = 1, v = 0;
    while (b) {
      const t = a / b;
      a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return mod(u);
  }

  N add(N l, N r) const {
    return mod(mod(l) + mod(r));
  }
  N sub(N l, N r) const {
    return mod(mod(l) - mod(r));
  }
  N mul(N l, N r) const {
    return mod(mod(l) * mod(r));
  }
  N div(N l, N r) const {
    assert(r != 0);
    return mod(mod(l) * inv(mod(r)));
  }

  N m = 1000000007;
}
/*}}}*/

/+---test
5 3
---+/
/+---test
2000 3
---+/

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);

  long[4000] facts;
  facts[0] = 1;

  const ModCalc!long M;

  foreach (i; 1..4000) {
    facts[i] = M.mul(facts[i-1], i);
  }

  long f(long x) {
    return x >= 0? facts[x]: 0;
  }

  foreach (i; 1..K+1) {
    const num1 = M.div(f(N-K+1), f(N-K+1-i));
    const den1 = f(i);

    const num2 = M.div(f(K-1), f(K-1-(i-1)));
    const den2 = f(i-1);

    M.mul(M.div(num1, den1), M.div(num2, den2)).writeln;
  }
}


Measured memory_bytes: 380
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;

struct Card {
    int num;
    char suit;
};

int main(){

    int n;
    cin >> n;

    vector<Card> cards(n); //バブルソート
    vector<Card> cards1(n); //選択ソート
    for(int i=0;i<n;i++){
        cin >> cards[i].suit;
        cin >> cards[i].num;
        cards1[i].suit = cards[i].suit;
        cards1[i].num = cards[i].num;
    }

    // バブルソート
    for(int i=0;i<n-1;i++){
        for(int j=n-1;j>i;j--){
            if(cards[j].num < cards[j-1].num) {
                swap(cards[j], cards[j-1]);
            }
        }
    }

    // 選択ソート
    int min;
    int idx = 0;;
    for(int i=0;i<n-1;i++){
        min = cards1[i].num;
        idx = i;
        for(int j=i+1;j<n;j++){
            if(cards1[j].num < min){
                min = cards1[j].num;
                idx = j;
            }
        }
        swap(cards1[idx], cards1[i]);
    }

    for(int i=0;i<n;i++){
        if(i > 0) cout << " ";
        cout << cards[i].suit << cards[i].num;
    }
    cout << endl;
    cout << "Stable" << endl;

    bool isStable = true;
    for(int i=0;i<n;i++){
        if(i > 0) cout << " ";
        cout << cards1[i].suit << cards1[i].num;
    }
    cout << endl;
    for(int i=0;i<n;i++){
        if(cards[i].suit != cards1[i].suit){
            isStable = false;
            break;
        }
    }
    if(isStable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}


Measured memory_bytes: 3096