akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define neko 110
#define qwq return printf("Possible"),0
#define orz return printf("Impossible"),0
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int a[neko],book[neko],n,maxn,mid;
int cmin(int a,int b){return a<b?a:b;}
int cmax(int a,int b){return a>b?a:b;}
int main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",&a[i]),++book[a[i]],maxn=cmax(maxn,a[i]);
	if(maxn&1)
	{
		mid=(maxn+1)>>1;
		if(book[mid]^2)orz;
		f(i,1,mid-1)if(book[i])orz;
		f(i,mid+1,maxn)if(book[i]<2)orz;
		qwq;

	}
	else
	{
		mid=maxn>>1;
		if(book[mid]^1)orz;
		f(i,1,mid-1)if(book[i])orz;
		f(i,mid+1,maxn)if(book[i]<2)orz;
		qwq;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int c,q,i,j,z=0,k=1,o=0,m[1001][1001]={0};
int a[1001]={0},b[1001]={0},w[1001]={0},e[6][2]={0};
for(i=0;i<6;i++){
cin>>q>>c;
if(q>c)m[q][c]++;
else m[c][q]++;
}
for(i=0;i<1001;i++){
for(j=0;j<1001;j++){
if(m[i][j]){
if(m[i][j]==4){e[z][0]=i;e[z++][1]=j;e[z][0]=i;e[z++][1]=j;}
else if(m[i][j]==6){e[z][0]=i;e[z++][1]=j;e[z][0]=i;e[z++][1]=j;e[z][0]=i;e[z++][1]=j;}
else{ e[z][0]=i;e[z++][1]=j;}
}
}
}
if(e[0][0]!=e[2][1]||e[1][0]!=e[2][0]||e[0][1]!=e[1][1])k=0;
if(k)cout<<"yes"<<endl;
else cout<<"no"<<endl;
return 0;
}

Measured memory_bytes: 7020
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = int(n**0.5)+1
    res = 10**20
    for i in range(1, a):
        if n%i==0:
            res = min(res, i+n//i)
    print(res-2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

const int maxn = 512;

int n;
char input[maxn][maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", input[i]);
    }
    int full_col = 0;
    vector<bool> any_in_col;
    for (int j = 0; j < n; j++) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (input[i][j] == '#')
                cnt ++;
        }
        if (cnt == n)
            full_col ++;
        any_in_col.push_back(cnt > 0);
    }
    int ans = -1;
    for (int i = 0; i < n; i++) {
        int empty_cnt = 0;
        for (int j = 0; j < n; j++) {
            if (input[i][j] == '.') {
                empty_cnt ++;
            }
        }
        int now = empty_cnt + (n - full_col);
        if (empty_cnt > 0 && !any_in_col[i]) {
            if (empty_cnt < n)
                now ++;
            else
                continue;

        }
        if (ans < 0 || ans > now)
            ans = now;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var ar = new[] { Input.ar, Input.ar };
        var res = new[] { 0L, 0L };
        for (var j = 0; j < 2; j++)
            for (var i = 0; i < nm[j]; i++)
                res[j] = (res[j] + ((long)(i + 1) * 2 - 1 - nm[j]) * ar[j][i]%Input.MOD) % Input.MOD;
        WriteLine(res[0] * res[1] % Input.MOD);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static string[] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static Tuple<int, int, long> MakeEdge(int num1, int num2, long weight=Inf)
        => new Tuple<int, int, long>(num1, num2, weight);
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

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

int main(){
	int a[1000],b[1000];
	int i=0,j=0;
	
	while(scanf("%d",&a[i])!=EOF){
		if(a[i]==0){
			printf("%d\n",a[i-1]);
			i--;
			j++;
		}else{
			i++;
		}
	}
	return 0;
}

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

using namespace std;

bool is_odd(int v){
  int num = 0;
  while(v > 0){
    v = v / 10;
    num++;
  }

  if (num % 2 == 0){
    return false;
  }
  else{
    return true;
  }
}

int main(){
  int n;
  cin >> n;
  int result = 0;
  for(int i = 1; i <= n; ++i){
    if (is_odd(i)){
      result++;
    }
  }

  cout << result << endl;
  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;

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

class ACandyDistributionAgain {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, x; in >> n >> x;
		int arr[n];
        f(i, n) in >> arr[i];
        sort(arr, arr + n);
        int res = 0;
        f(i, n-1) if(x >= arr[i]) ++res, x -= arr[i];
        if(x==arr[n-1]) ++res;
        out << res;
	}
};


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ACandyDistributionAgain 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;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a <<" "<< b <<" "<< c;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int N;
int A[501];
int K;
long long sum = 0;
std::vector<int> d;

bool check(int n) {
	int *m = new int[N];
	for (int i = 0; i < N; i++) {
		m[i] = A[i] % n;
	}
	std::sort(m, m + N);
	int f = 0, e = N - 1;
	int cf = 0, ce = 0;
	while (1) {
		if (cf <= ce) {
			cf += m[f];
			f++;
		}
		else {
			ce += n - m[e];
			e--;
		}
		if (e == f - 1) {
			delete[]m;
			return cf <= K;
		}
	}
}

int main() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)scanf("%d", A + i);
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}
	for (int i = 1; i < sum; i++) {
		if (sum%i == 0) {
			d.push_back(i);
			d.push_back(sum / i);
		}
		if (i >= sum / i)break;
	}
	std::sort(d.begin(), d.end());
	/*
	int r = 0;
	for (int i = 20; i >= 0; i--) {
		int c = r | (1 << i);
		if (c >= d.size())continue;
		if (check(d[c]))r = c;
	}*/
	int r = 0;
	for (int i = 0; i < d.size(); i++) {
		if (check(d[i]))r = i;
	}
	printf("%d", d[r]);
	return 0;
}

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

int main() {
  string S; cin >> S;
  int D = S.size();
  int N[D];
  for (int d = 0; d < D; d++)
    N[d] = stoi(S.substr(d, 1));
  int carry[D+1], no_carry[D+1];
  carry[0] = 1; no_carry[0] = 0;
  for (int d = 0; d < D; d++) {
    if (N[d]+1<5) carry[d+1] = no_carry[d] + (N[d]+1);
    else if (N[d]+1>5) carry[d+1] = carry[d] + (9-N[d]);
    else carry[d+1] = min(carry[d], no_carry[d]) + 5;
    if (N[d]<5) no_carry[d+1] = no_carry[d] + N[d];
    else if (N[d]>5) no_carry[d+1] = carry[d] + (10-N[d]);
    else no_carry[d+1] = min(carry[d], no_carry[d]) + 5;
  }
  cout << no_carry[D] << endl;
}

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

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

  vector<int> a(m);
  vector<int> b(m);
  rep(i, m) cin >> a.at(i) >> b.at(i);

  vector<int> roads(n);
  rep(i, m) {
    roads.at(a.at(i) - 1)++;
    roads.at(b.at(i) - 1)++;
  }

  rep(i, n) {
    cout << roads.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

int D;

int main(){
	scanf("%d",&D);
	switch(D){
		case 25:
			printf("Christmas");
			break;
		case 24:
			printf("Christmas Eve");
			break;
		case 23:
			printf("Christmas Eve Eve");
			break;
		case 22:
			printf("Christmas Eve Eve Eve");
			break;
	}
	return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n,1);
    vector<bool>ok(n,false);
    ok[0]=true;
    rep(i,m){
        int x,y; cin>>x>>y;
        x--; y--;
        a[x]--; a[y]++;
        if(ok[x]){
            ok[y]=true;
        }
        if(a[x]==0)ok[x]=false;
    }
    int ans=0;
    rep(i,n)if(ok[i])ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	int A,B,C;
	cin >> A >> B >> C;
	if(A == B){
		cout << C << endl;
	}else if(B == C){
		cout << A << endl;
	}else{
		cout << B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
    int n; cin>>n;
    string s; cin>>s;
    vi a(n+1,0);
    rep(i,n){
        if(s[i]=='W'){
            a[i+1]++;
            a[n]--;
        }else{
            a[0]++;
            a[i]--;
        }
    }
    partial_sum(all(a),a.begin());
    cout<<*min_element(a.begin(),a.end()-1)<<endl;
	return 0;
}


Measured memory_bytes: 1796
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  if b == 1
    then putStrLn "0"
    else print $ (b+a-3) `quot` (a-1)


Measured memory_bytes: 380
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll n;
  double t,x,ans;
  cin>>t>>x;
  ans=t/x;
  cout<<ans<<endl;
}


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

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	const ll oo = 1e15;
	
	int n;
	cin >> n;
	
	vector<ll> v(n + 1);
	
	ll sum = 0, cur = 0;
	for(int i = 1; i <= n; i++){
		cin >> v[i];
		sum += v[i];
	}
	
	ll ans = oo;
	for(int i = 1; i < n; i++){
		cur += v[i];
		ans = min(ans, abs(cur - (sum - cur)));
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	max := 0
	vote := map[string]int{}
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s", &s)
		vote[s] = vote[s] + 1
		if vote[s] > max {
			max = vote[s]
		}
	}

	tops := []string{}
	for s, n := range vote {
		if n == max {
			tops = append(tops, s)
		}
	}

	sort.Strings(tops)
	for _, s := range tops {
		fmt.Println(s)
	}
}


Measured memory_bytes: 34816
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var t = cin.nextInt();
            var a = cin.nextInt();
            var h = cin.ArrayLong(n);

            var ta = h.Select(i =>Math.Abs(a- (t - (0.006 * i)))).Min();

            var ans = 0;
            foreach (var item in h)
            {
                ans++;
                if(ta == (Math.Abs(a - (t - (0.006 * item)))))
                {
                    Console.WriteLine(ans);
                    return;
                }
            }            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13324
#include <iostream>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define print(x) for(auto& i:x) cout<<i<<" "; cout<<'\n';
#define scan(x) for(auto& i:x) cin>>i;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define pii pair<int, int>
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define d4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define d5(a,b,c,d,e) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
ll mod=1e9+7;

void solve(){
	int n,x,t; cin>>n>>x>>t;
	int ans=n/x;
	if(n%x) ans++;
	cout<<ans*t<<endl;
}


int main() {
	//freopen("test.txt", "r", stdin);
	FAST; int T=1;
	//cin>>T;
	while(T--) solve();
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
    cin>>arr[i];
    int temp=1;
    for(i=0;i<n;i++){
        if(arr[i]%2==0 && !(arr[i]%3==0 || arr[i]%5==0)){
            temp=0;
            break;
        }
    }
    if(temp)
    cout<<"APPROVED";
    else
    cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 3636
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>

using namespace std;
typedef vector <int> vi;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound

#define SZ(x) (int)x.size()
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define RSZ resize
#define INS insert
#define REP(i,a,b) for (int i = (a); i <= (b); i++)
#define PER(i,a,b) for (int i = (b); i >= (a); i--)
#define TRAV(a,x) for (auto& a : x)

int nxt(){int x;cin>>x;return x;}
ll nxtll(){ll x;cin>>x;return x;}


signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n=nxtll();
    ll ans=1e18;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,(i-1)+(n/i-1));
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
def main(a, b)
  cakes = Array.new(18)
  [[:A, a], [:B, b]].each do |user, peace|
    peace.times do
      x = (1..16).find{|i| cakes[i].nil? && cakes[i - 1] != user && cakes[i + 1] != user}
      return ":(" if x.nil?
      cakes[x] = user
    end
  end
  return "Yay!"
end

a, b = gets.split.map(&:to_i)
puts main(a, b)

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line="";
		while((line = br.readLine())!=null){
			int d = Integer.parseInt(line);
			int menseki = 0;
			for(int i = d; i <= 600-d;i+=d){
				menseki += i*i*d;
			}
			System.out.println(menseki);
		}

	}

}

Measured memory_bytes: 23840
#include<iostream>
using namespace std;
char a[100010];
int main()
{
	long long int n=0;
	while(~scanf("%c",&a[n]))
	{
		n++;
	}
	for(int i=0;i<n;i=i+2)
		{
			cout<<a[i];
		}
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 62
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (int i = 0; i < m; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  int n, k;
  cin >> n >> k;
  ll a[n];
  REP(i, n) cin >> a[i];
  ll ps[n+1], s[n+1];
  s[0] = 0;
  ps[0] = 0;
  ll psum = 0, sum = 0;
  REP(i, n){
    ps[i+1] = ps[i] + (a[i] > 0 ? a[i] : 0);
    psum = psum + (a[i] > 0 ? a[i] : 0);
    sum += a[i];
    s[i+1] = s[i] + a[i];
  }
  ll ans = 0;
  REP(i, n-k+1){
    ll tmp = (s[i+k] > s[i] ? s[i+k] - s[i] : 0) + psum - ps[i+k] + ps[i];
    if(ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {

    static int mod = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d  = new int[n];
        boolean zeroStart = false;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            d[x]++;
            if(i == 0 && x == 0) zeroStart = true;
            if(max < x) max = x;
        }
        long ans = zeroStart && d[0] == 1 ? 1L : 0L;
        for (int i = 1; i <= max; i++) {
            ans = ans * modPow((long)d[i-1], d[i]) %mod;
        }
        System.out.println(ans);
        sc.close();

    }
    public static long modPow(long base, int exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}


Measured memory_bytes: 60236
#include <stdio.h>

int main(int argc, char const *argv[]) {

    int a,b,c,tmp;

    scanf("%d%d%d",&a,&b,&c);

    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }

    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }

    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }

    printf("%d %d %d\n",a,b,c);


    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main(){
    int a[100],n,b,sum=0,c,dem=1;
    cin>>n>>b>>c;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0) continue;
        if(a[i]>=1) sum++;
        while(dem*a[i]+1<=b){
            sum++;
            dem++;
        }
        dem=1;
    }
    // }
    // for(int i=0;i<n;i++){
    //     sum=a[n-i-1]-a[n-i-2];
    //   // cout<<sum<<endl;
    // }
    cout<<sum+c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
using namespace std;
int main(){
  int N,a,b,c=0;
  cin>>N;
  for(int i=1;i<N+1;i++){
    for(int j=1;j<N+1;j++){
      for(int k=1;k<N+1;k++){
        a=gcd(i,j);
        b=gcd(a,k);
        c+=b;
      }
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// ll mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t,c,i,j,k,temp,temp2,n,m;
    cin >> t >> n >> m;
    vector <ll> sum(t-1);
    ll dis;
    for(i=1;i<t;i++){
        for(j=i+1;j<=t;j++){
            if(j>=m&&i<=n){
                dis = j-i-(m-n)+1;
            }
            else if(i>=m||j<=n) dis = j-i;
            else if(i<=m&&j>=n){
                dis = min(j-i,abs(m-j)+abs(i-n)+1);
            }
            else dis=j-1;
            sum[dis-1]++;
           // cout <<  i << " "<< j << " " << dis << endl;
        }
    }
    for(i=0;i<t-1;i++){
        cout << sum[i] << endl;
    }
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; int M; cin >> N >> M;
  // M = G * (a_1 / G + ... a_N / G)
  // M = G * (1 + 1 + ... + 1 + c_N)
  bool is_prime = 1;
  for (int i = 2; (ll)i * i <= M; i++) {
    if (M % i == 0) {
      is_prime = 0;
      break;
    }
  }
  if (is_prime) {
    cout << 1 << "\n";
    return 0;
  }
  for (int c_N = 1; ; c_N++) {
    if (M % (N - 1 + c_N) == 0) {
      auto G = M / (N - 1 + c_N);
      cout << G << "\n";
      return 0;
    }
  }
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ya = [0] * 1000001
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            l = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ya[l] += 1
for i in range(1,n+1):
    print(ya[i])


Measured memory_bytes: 87088
# 問題数と提出数
input_data = input().split()
n, m = map(int, input_data)

# 正解状況のリスト
col_list = [0 for i in range(n)]
penal_list = [0 for i in range(n)]

# 正解回数
col = 0
# 不正解数
penal = 0

# 提出数分取得
for i in range(m):
  input_data = input().split()
  
  # チェックする問題
  chk_index = int(input_data[0]) - 1
  
  # 正解済みのため、チェックしない
  if(col_list[chk_index] == 1):
    continue
  if(input_data[1] == "AC"):
    col_list[chk_index] = 1
  else:
    penal_list[chk_index] += 1

# 正解,不正解
for i,v in enumerate(col_list):
  if(v == 1):
    col += 1
    penal += penal_list[i]
# 出力
print(str(col) + " " + str(penal))

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    bool b = true;
    rep(i,n-1){
        if(a[i] == a[i+1]){
            b = false;
            break;
        }
    }
    if(b) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for(int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
  int n;
  cin >> n;
  vec<int> a(n);
  rep(i, n) cin >> a[i];
  map<int, int> mp;
  ll ans = 0;
  rep(i, n) {
    int sa = i - a[i];
    ans += mp[sa];
    int wa = a[i] + i;
    mp[wa]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21156
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll H, W, N;
ll ans[10];
int a[100000];
int b[100000];
set<P> s;

int find(int i, int x, int y) {
	int sum = 1;
	for(int yy = 0; yy < 3; yy++) {
		for(int xx = 0; xx < 3; xx++) {
			if(y == yy && x == xx) continue;
			int dx = xx - x, dy = yy - y;
			int na = a[i] + dy, nb = b[i] + dx;
			if(na < 0 || H <= na || nb < 0 || W <= nb) return -1;
			if(s.find(P(na, nb)) != s.end()) sum++;
		}
	}
	return sum;
}

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

	cin >> H >> W >> N;

	for(int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		s.insert(P(a[i], b[i]));
	}

	for(int i = 0; i < N; i++) {
		for(int y = 0; y < 3; y++) {
			for(int x = 0; x < 3; x++) {
				int res = find(i, x, y);
				if(res != -1) ans[res]++;
			}
		}
	}

	ll s = (W - 2) * (H - 2);
	for(int i = 1; i <= 9; i++) {
		ans[i] /= i;
		s -= ans[i];
	}
	ans[0] = s;
	for(int i = 0; i <= 9; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 5760
let N = Int(readLine()!)!
let ball: [(Int, Int)] = (0..<N).map { _ in
	let input = readLine()!.characters.split(" ").map{Int(String($0))!}
	return (input[0], input[1])
}
var dic = [String : Int]()
for i in ball {
	for j in ball {
		if i != j {
			let key = "\(i.0 - j.0),\(i.1 - j.1)"
			dic[key] = (dic[key] ?? 0) + 1
		}
	}
}
print(N - (dic.values.maxElement() ?? 0))

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   ll a,b,x;cin>>a>>b>>x;
   ll ans=0;
   if(a==0){
      ans++;
      a++;
   }
    ans+=b/x-(a-1)/x;

   cout<<ans<<endl;
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int H, W, X, Y;;
    cin >> H >> W >> X >> Y;

    if ((H * W) % 2 == 1 && (X + Y) % 2 == 1) {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}












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

int main(void){
  long long n, a, b;
  cin >> n >> a >> b;
  long long num = b - a + 1;
  long long z = 0;
  if(n > 2){
    cout << max(z, (a + b * (n - 1)) - (b + a * (n - 1)) + 1) << endl;
  }
  else if(n == 1){
    if(a == b) cout << 1 << endl;
    else cout << 0 << endl;
  }
  else{
    if(a > b) cout << 0 << endl;
    else cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int s[10];

int n;
int ans = 0;
void dfs(int i, int sum, int now) {
	if (i == n - 1) {
		ans += sum + now;
	}
	else {
		dfs(i + 1, sum + now, s[i + 1]);
		dfs(i + 1, sum, now * 10 + s[i + 1]);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str; cin >> str;
	n = str.size();
	rep(i, str.size()) {
		s[i] = str.at(i) - '0';
	}
	dfs(0, 0, s[0]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
char in[1005][1005];
ll dp[1005][1005];
int main(){
	int h,w;
	while(~scanf("%d%d",&h,&w)){
		for(int i=0;i<h;i++) scanf("%s",in[i]);
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) dp[i][j]=0;
		dp[0][0]=1;
		for(int i=1;i<w;i++){
			if(dp[0][i-1]==0||in[0][i]=='#') dp[0][i]=0;
			else dp[0][i]=1;
		}
		for(int i=1;i<h;i++){
			if(dp[i-1][0]==0||in[i][0]=='#') dp[i][0]=0;
			else dp[i][0]=1;
		}
		for(int i=1;i<h;i++) for(int j=1;j<w;j++) if(in[i][j]=='.')  dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		printf("%lld\n",dp[h-1][w-1]);
	}
}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
 
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==5 && B==5 && C==7 || A==5 && B==7 && C==5 || A==7 && B==5 && C==5){
    cout << "YES" << endl;}
  else{
       cout << "NO" << endl;}
     }

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    int cnt_AB = 0;
    int cnt_A = 0;
    int cnt_B = 0;
    int cnt_both = 0;
    
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        
        int m = (int)s.size();
        
        for(int j = 0; j < m - 1; j++){
            if(s[j] == 'A' && s[j+1] == 'B') cnt_AB++;
        }
        
        if(s.size() == 2 && s[0] == 'A' && s[1] == 'B');
        else if(s[0] == 'B' && s[m - 1] == 'A') cnt_both++;
        else if(s[0] == 'B') cnt_B++;
        else if(s[m - 1] == 'A') cnt_A++;
        
        
    }

    int ans = 0;
    
    if(cnt_both == 0) ans = min(cnt_A,cnt_B);
    else if(cnt_both != 0 and cnt_A + cnt_B > 0) ans = cnt_both + min(cnt_A,cnt_B);
    else if(cnt_both != 0 and cnt_A == 0 and cnt_B == 0) ans = cnt_both - 1;
    
    ans += cnt_AB;
    
    cout << ans << endl;
    
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int a[MAXN], b[MAXN], c[MAXN], aa[MAXN], bb[MAXN];

void solve(){
	int A, B, M;
	scanf("%d%d%d", &A, &B, &M);
	REP(i, 0, A) {
		scanf("%d", &a[i]);
	}
	REP(i, 0, B) {
		scanf("%d", &b[i]);
	}
	REP(i, 0, M) {
		scanf("%d%d%d", &aa[i], &bb[i], &c[i]);
		aa[i]--, bb[i]--;
	}
	int ans = a[0] + b[0];
	REP(i, 0, M) {
		ans = min(ans, a[aa[i]] + b[bb[i]] - c[i]);
	}
	int mna = a[0], mnb = b[0];
	REP(i, 0, A) {
		mna = min(mna, a[i]);
	}
	REP(i, 0, B) {
		mnb = min(mnb, b[i]);
	}
	ans = min(ans, mna + mnb);
	printf("%d\n", ans);
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
 
}

int dp[1000][1000];


int go(int last,int sz){
  if(sz==0)return 1;
  int &x = dp[last][sz];
  if(x!=-1)return x;
  x=0;
  for(int i=max(0LL,last-1);i<=min(9LL,last+1);i++){
    x+=go(i,sz-1);
  }
  return x;
}

string s="";

void find(int last,int sz,int k){
  if(sz==0)return;
  for(int i=max(0LL,last-1);i<=min(9LL,last+1);i++){
    
    if(k-go(i,sz-1)<=0){
      s+='0'+i;
      find(i,sz-1,k);
      return;
    }else{
      k-=go(i,sz-1);
    }

  }
}

int32_t main(){
  memset(dp,-1,sizeof(dp));
  fastio;
  int k;
  cin>>k;
  int tot=0;
  if(k<10){
    cout<<k<<endl;
    return 0;
  }
  tot=9;
  for(int dig=2;;dig++){
    for(int i=1;i<=9;i++){
      if(tot+go(i,dig-1) < k){
        tot+=go(i,dig-1);
      }else{
        s+='0'+i;
       find(i,dig-1,k-tot);
       cout<<s<<endl;
       return 0;
      }

    }
  }
  // Math -> gcd it all // chack MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 8064
def palindrome(s,n)
  (n/2).times do |i|
    if s[i]!=s[-1-i]
      puts "No"
      exit
    end
  end
end

s=gets.chomp
n=s.size
s1=s[0..(n-1)/2-1]
s2=s[(n+3)/2-1..-1]
palindrome(s,n)
palindrome(s1,s1.size)
palindrome(s2,s2.size)
puts "Yes"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 累乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
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;
}
 
int dx[4] = {1, 0, 0, -1}, dy[4] = {0, 1, -1 ,0};
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main(){
    double L;
    cin >> L;
    double ans = (L * L * L) / 27;
    prints(ans);
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=5005,mod=1e9+7;
const ll mod2=(ll)mod*mod;
vector<int> v[N];
ll dp[N][N],zs[N],f[N];
int sz[N];
void dfs(int p,int fa){
	dp[p][1]=sz[p]=1;	
	for(auto i:v[p])if(i!=fa){
		dfs(i,p);
		For(j,1,sz[i]+sz[p])zs[j]=0;
		For(j,1,sz[p]){
			For(k,0,sz[i]){
				zs[j+k]=(zs[j+k]+dp[p][j]*dp[i][k])%mod;
			}
		}
		sz[p]+=sz[i];
		For(j,1,sz[p])dp[p][j]=zs[j];
	}
	For(j,1,sz[p])dp[p][0]=(dp[p][0]+mod2-dp[p][j]*f[j])%mod;
	//For(j,0,sz[p])wri(dp[p][j]); puts("");
}
int main(){
	int n=read();
	f[0]=1; for(int i=2;i<=n;i+=2)f[i]=f[i-2]*(i-1)%mod;
	For(i,1,n-1){
		int s=read(),t=read();
		v[s].pb(t); v[t].pb(s);
	}
	dfs(1,0);
	cout<<(mod-dp[1][0])%mod<<endl;
}

Measured memory_bytes: 195200
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, x = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A)
for i in range(1, N):
    if A[i] + A[i - 1] > x:
        d = sum(A[i - 1:i + 1]) - x
        for j in range(2):
            if d <= 0:
                break
            A[i - j], d = A[i - j] - min(A[i - j], d), d - min(A[i - j], d)

print(s - sum(A))

Measured memory_bytes: 14952
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
int i,N,a;
long long ans;
string S;
string T;
cin >> N >> S >> T;;
	if(N==1){
	cout << 3 << endl;
	}else if(N==2){
	cout << 6 << endl;
	}else{
	if(S[0] == T[0]){
		ans = 3;
		a = 1;
		i = 1;
	while(i!=N){
		if(S[i] == T[i]){
			i += 1;
			if(a==1){
				ans = 2*ans;
				a = 1;
			}else{
				ans = ans;
				a = 1;
		}
		}else{
			i += 2;
			if(a==1){
				ans = 2*ans;
				a = 0;
			}else{
				ans = 3*ans;
				a = 0;
			}
			}
		}
	}else{
		ans = 6;
		a = 0;
		i = 2;
	while(i!=N){
		if(S[i] == T[i]){
			i +=1;
			if(a==1){
				ans = 2*ans;
				a = 1;
			}else{
				ans = ans;
				a = 1;
		}
		}else{
			i +=2;
			if(a==1){
				ans = 2*ans;
				a = 0;
			}else{
				ans = 3*ans;
				a = 0;
			}
			}
		}
	}
cout << ans%1000000007 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=2e5;
int n, m;
ll k, a[mxN+1], b[mxN+1];
 
int main() {
	cin >> n >> m >> k;
	for(int i=0; i<n; ++i) {
		cin >> a[i+1];
		a[i+1]+=a[i];
	}
	for(int i=0; i<m; ++i) {
		cin >> b[i+1];
		b[i+1]+=b[i];
	}
	int ans=0;
	for(int i=0, j=m; i<=n; ++i) {
		if(a[i]>k)
			break;
		while(a[i]+b[j]>k)
			--j;
		ans=max(i+j, ans);
	}
	cout << ans;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int w, a, b; cin >> w >> a >> b;
   int ans = max(a,b) - min(a,b) - w;
   if(ans < 0)
      cout << 0;
   else
      cout << ans << nl;
   return 0;

}


Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;


int main(void)
{
	int r, g, b;
	int m;
	cin >> r >> g >> b;

	m = 100 * r + 10 * g + b;

	if (m % 4 == 0) {
		cout << "YES" << endl;

	}
	else {
		cout << "NO" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int h,w;
  cin >> h >> w;
  
  vector<vector<char>>mass(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mass[i][j];
    }
  }
  
  bool can = true;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mass[i][j] == '#'){
        for(int k=i + 1;k<h;k++){
          for(int l=0;l<j;l++){
            if(mass[k][l] == '#'){
              can = false;
            }
          }
        }
      }
    }
  }
  
  if(can)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  
  return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
ac = [0]*n
wa = [0]*n
ans = 0

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and ac[p] == 0:
        ac[p] = 1
        ans += wa[p]
    wa[p] += 1
print(sum(ac), ans)


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

int main(){
  int a,b,c,d,l,r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  
  if(l == r){
    cout << "Balanced" << endl;
  }
  else if (l < r){
    cout << "Right" << endl;
  }
  else{
    cout << "Left" << endl;
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
char line[8]="IVXLCDM";
int calc(char mozi){
    int i;
    for(i=0;i<8;i++){
        if(mozi==line[i])
            break;
    }
    if(i==0)
        return 1;
    if(i==1)
        return 5;
    if(i==2)
        return 10;
    if(i==3)
        return 50;
    if(i==4)
        return 100;
    if(i==5)
        return 500;
    if(i==6)
        return 1000;
    return 0;
}
int main(void){
    char line1[101];
    int len,i,sum;
    for(;i=0,sum=0,scanf("%s",line1)!=EOF;){
        while(line1[i]){
            if(i!=0 && calc(line1[i])>calc(line1[i-1]))
                sum+=calc(line1[i])-calc(line1[i-1])*2;
            else
                sum+=calc(line1[i]);
            i++;
        }
        printf("%d\n",sum);
    }
    return 0;
} 

Measured memory_bytes: 540