akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

alias Edge = Tuple!(int, "to", int, "cost");

void main() {
    int N, x, y;
    scan(N, x, y);
    x--, y--;

    auto adj = new Edge[][](N, 0);
    foreach (i ; 0 .. N - 1) {
        adj[i] ~= Edge(i + 1, 1);
        adj[i + 1] ~= Edge(i, 1);
    }
    adj[x] ~= Edge(y, 1);
    adj[y] ~= Edge(x, 1);

    auto cnt = new int[](N);
    foreach (s ; 0 .. N) {
        auto d = dijkstra(adj, s);
        foreach (di ; d) {
            cnt[di.to!int]++;
        }
    }

    cnt[] /= 2;

    foreach (i ; 1 .. N) {
        writeln(cnt[i]);
    }
}


auto dijkstra(Edge[][] adj, int s) {
    alias Pair = Tuple!(int, "num", long, "dist");

    int N = adj.length.to!int;

    auto dist = new long[](N);
    dist[] = infl;
    dist[s] = 0;

    auto q = BinaryHeap!(Array!Pair, "a.dist > b.dist")();
    q.insert(Pair(s, 0));

    int rep = N - 1;

    while (!q.empty && rep) {
        auto v = q.front;
        q.popFront();

        if (dist[v.num] < v.dist) continue;

        rep--;

        foreach (e ; adj[v.num]) {
            if (dist[e.to] > dist[v.num] + e.cost) {
                dist[e.to] = dist[v.num] + e.cost;
                q.insert(Pair(e.to, dist[e.to]));
            }
        }
    }

    return dist;
}


void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
using namespace std;
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define N 100005
int main()
{
	lld a,b,c;
	cin>>a>>b>>c;
	lld tmp=(a*100 + b*10 + c);
	cout<<(tmp%4 ? "NO":"YES")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    for (int i = 0; ; ++i) {
        if (i % 2 == 0) {
            C -= B;
        } else {
            A -= D;
        }
        if (A <= 0 || C <= 0) {
            break;
        }
    }
    if (A <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>

int main(int argc, const char *argv[]) {
    int n;
    std::cin >> n;
    int a, b, c, a2, b2, c2;
    for (int i = 0; i < n && std::cin >> a >> b >> c; i++) {
        a2 = a * a;
        b2 = b * b;
        c2 = c * c;
        if (a2 == b2 + c2 || b2 == c2 + a2 || c2 == a2 + b2) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n;
    vector<pair<int,int> > p;
    for(int i=0;i<n;i++){
        cin>>a;
        p.pb(make_pair(a,i));
    }
    int num=1,ans=1;
    sort(be(p));
    for(int i=1;i<n;i++){
        if(p[i-1].second<p[i].second){
            num++;
            ans=max(ans,num);
        }
        else{
            num=1;
        }
    }
    cout <<n-ans<<"\n";
    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
int main(void)
{
	int s[5],s1,s2,i,temp,max,x;
	while(1){
		max=0;
		scanf("%d %d",&s1,&s2);
		if(s1==0&&s2==0)break;
		s[0]=s1+s2;
		for(i=1;i<=4;i++){
			scanf("%d %d",&s1,&s2);
			s[i]=s1+s2;
		}
		for(i=0;i<5;i++){
			if(max<s[i]){
				max=s[i];
				x=i;
			}
		}
		if(x==0){
			printf("A %d\n",max);
		}
		if(x==1){
			printf("B %d\n",max);
		}
		if(x==2){
			printf("C %d\n",max);
		}
		if(x==3){
			printf("D %d\n",max);
		}
		if(x==4){
			printf("E %d\n",max);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();
    int c = sc.nextInt();
    int[] b = new int[m];
    int ans = 0;

    for (int i = 0; i < m; i++) {
      b[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j < m; j++) {
        sum += sc.nextInt() * b[j];
      }
      if (sum > (-1 * c)) {
        ans++;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 36504
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);
const int MAX = INT_MAX;

int main(){
	int n;
	cin >> n;
	int a[n], b[n], c[n], dpa[n], dpb[n], dpc[n];
	
	for(int i = 0; i<n; i++)
		cin >> a[i] >> b[i] >> c[i];
	
	dpa[0] = a[0], dpb[0] = b[0], dpc[0] = c[0];
	
	for(int i = 1; i<n; i++){
		dpa[i] = a[i] + max(dpb[i-1], dpc[i-1]);
		dpb[i] = b[i] + max(dpc[i-1], dpa[i-1]);
		dpc[i] = c[i] + max(dpa[i-1], dpb[i-1]);
		
		//cout << dpa[i] << " " << dpb[i] << " " << dpc[i] << endl;
	}
	
	cout << max(dpa[n-1], max(dpb[n-1], dpc[n-1])) << endl;
	return 0;
}

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

using namespace std;

const int INF = 1e9;

int n,m,i,j,k,lv[30005],iter[30005],fst,fed;
char s[105][105];
pair <int, int> st, ed;

struct dat{
	int to, cap, rev;
};

vector <dat> edge[30005];

void add(int u, int v, int cap){
	edge[u].push_back({v, cap, edge[v].size()});
	edge[v].push_back({u, 0, edge[u].size() - 1});
}

int in(int u, int v){
	return u * m + v;
}

int out(int u, int v){
	if(s[u][v] == 'S' || s[u][v] == 'T')
	return u * m + v;
	return u * m + v + n * m;
}

bool bfs(){
	memset(iter, 0, sizeof(iter));
	for(i = 0; i < 2 * n * m; i++)
	lv[i] = -1;
	lv[fst] = 0;
	queue <int> now;
	now.push(fst);
	
	while(now.size()){
		int cur = now.front();
		now.pop();
		
		for(int k = 0; k < edge[cur].size(); k++){
			int to = edge[cur][k].to;
			int cap = edge[cur][k].cap;
			
			if(lv[to] == -1 && cap){
				lv[to] = lv[cur] + 1;
				now.push(to);
			}
		}
	}
	
	
	return (lv[fed] >= 0);
}

int dfs(int id, int mn){
	if(id == fed) return mn;
	
	int flow;
	
	for(int k = iter[id]; k < edge[id].size(); k++){
		iter[id] = k;
		
		int to = edge[id][k].to;
		int cap = edge[id][k].cap;
		int rev = edge[id][k].rev;
		
		if(lv[to] == lv[id] + 1 && cap && (flow = dfs(to, min(mn, cap)))){
			edge[id][k].cap -= flow;
			edge[to][rev].cap += flow;
			return flow;
		}
	}
	
	return 0;
}

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < n; i++)
	scanf("%s", s[i]);
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			if(s[i][j] != 'S' && s[i][j] != 'T')
			add(in(i, j), out(i, j), 1);
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			if(s[i][j] == '.') continue;
			for(k = 0; k < j; k++){
				if(s[i][k] == '.') continue;
				add(out(i, j), in(i, k), INF);
				add(out(i, k), in(i, j), INF);
			}
			
			if(s[i][j] == 'S')
			st = {i, j};
			
			if(s[i][j] == 'T')
			ed = {i, j};
		}
	}
	
	if(st.first == ed.first || st.second == ed.second) return 0 * printf("-1\n");
	
	for(i = 0; i < m; i++){
		for(j = 0; j < n; j++){
			if(s[j][i] == '.') continue;
			for(k = 0; k < j; k++){
				if(s[k][i] == '.') continue;
				add(out(j, i), in(k, i), INF);
				add(out(k, i), in(j, i), INF);
			}
		}
	}
	
	fst = st.first * m + st.second;
	fed = ed.first * m + ed.second;
	int res = 0;
	
	while(bfs()){
		int flow;
		while(flow = dfs(fst, INF))
		res += flow;
	}	
	
	printf("%d\n", res);
}


Measured memory_bytes: 61824
N = $stdin.gets.chomp.to_i
sum = 0
same = 0
cand = Float::INFINITY
N.times do |_|
    a, b = $stdin.gets.chomp.split(' ').map(&:to_i)
    sum += a
    same += 1 if a == b
    if a > b
        cand = b if b < cand
    end
end

print same == N ? 0 : sum - cand

Measured memory_bytes: 1788
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	fmt.Println(min(a, b) + min(c, d))
}

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

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
// #define int             long long int
#define pb              push_back
#define se              second
#define mp              make_pair
#define fi              first
#define del(a,vec)      vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v)   binary_search(f,l,v)
#define iter(a,b)       vector<int>::iterator a,b
#define lower(v,num)    lower_bound (v.begin(), v.end(), num);
#define upper(v,num)    upper_bound (v.begin(), v.end(), num); 
#define removecopy(a)   unique(a.begin(), a.end()); 
#define vi              vector<int> 
#define pi              pair<int,int>    
#define vpi             vector<pi>      
#define mlbb            ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)    
int mod =1000000007;
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    int pow (int x, int n,int mod) {//calculate x^n
    if (n == 0) return 1;
 
    int res = pow (x, n / 2,mod);
 
    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;
 
    return res;
    }
    int _gcd(int a,int b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int main()
{
    mlbb;
    long long int n,a,b;
    cin>>n>>a>>b;
    
    
    
   
        if((b-a)%2==1) {
            if(a==1 || b==n)
            {
                long long int ans= 1+ (b-a)/2;
                
                cout<<ans<<endl;
            }
            else
            {
                long long int ans= min(n-a, b-1) ;
                
                
                long long int ans2 ;
                long long int val1 = n- b;
                long long int a1 =a + n -b ;
                ans2 = val1 + ( n- a1)/2 +1;
                
                
                long long int ans3 ;
                long long int val2 = a- 1;
                long long int b1 =b - val2 ;
                ans3 = val2 + ( b1-1)/2 +1;
                
                ans = min(ans ,  min(ans2,ans3));
                cout<<ans<<endl;
            }
            
        }
        else{
            long long int ans= (b-a)/2;
            cout<<ans<<endl;}
    // }
    
}


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;
using P = pair<int,int>;

int main(){
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> nh(h+1), nw(w+1);
    map<P,int> f;
    int mh = 0, mw = 0;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        nh[a]++; nw[b]++;
        f[P(a,b)]++;
    }
    rep(i,h+1) mh = max(nh[i], mh);
    rep(i,w+1) mw = max(nw[i], mw);
    
    vector<int> x, y;
    
    for(int i = h; i >= 0; i--){
        if(mh == nh[i]) x.push_back(i);
    }
    for(int i = w; i >= 0; i--){
        if(mw == nw[i]) y.push_back(i);
    }

    int ans = mh + mw;
    rep(i,(int)x.size()){
        rep(j,(int)y.size()){
            if(f[P(x[i],y[j])] == 0){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 28528
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

int n;
vll t;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  t.resize(n);
  cin >> t;
  ll ans = 1;
  rep(i, 0, n) {
    ans = lcm(ans, t[i]);
  }
  cout << ans << endl;
  return 0;
}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

long long fac[MAX], facinv[MAX], inv[MAX];
void facinit(){
    fac[0] = fac[1] = 1;
    facinv[0] = facinv[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;
        facinv[i] = facinv[i - 1] * inv[i] % MOD;
    }   
}

int main(){
    facinit();

    int n; cin >> n; n *= 2;
    string s; cin >> s;
    vector<int> t(n); t[0] = 0;
    rep(i, n - 1){
        if(s[i] == s[i+1]) t[i+1] = t[i] ^ 1;
        else t[i+1] = t[i];
    }

    vector<int> v(n), w(n);
    v[0] = 1; w[0] = 0;
    rep(i, n - 1){
        v[i+1] = v[i]; w[i+1] = w[i];
        if(t[i+1] == 0) v[i+1]++;
        else w[i+1]++;
    }

    if(s[0] == 'W' || s[n-1] == 'W' || v[n-1] != w[n-1]){
        out(0); return 0;
    }

    lint ans = 1;
    rep(i, n){
        if(t[i] == 1){
            ans *= v[i] - w[i] + 1;
            ans %= MOD;
        }
    }
    ans *= fac[n/2]; ans %= MOD;
    out(ans);
}


Measured memory_bytes: 7556
#include <iostream>
#include <cstdio>
using namespace std;
int n,k;
int ans;
int main()
{
	ans = 1;
	cin >> n >> k;
	for (int i = 1;i <= n;i++)
	{
		ans += min (ans,k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	string a;
	bool flag=true;
	cin>>a;
	int len=a.length();
	for(int i=0;i<=len/2-1;i++){
		if(a[i]!=a[len/2-1-i])flag=false;
	}
	for(int i=len/2+1;i<=len-1;i++){
		if(a[i]!=a[len-1-i])flag=false;
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

    #define ll long long

        int mat[3][3];
    bool test(int A[],int B[])
    {
        for(int i=0; i<3; i++)
        {
            for(int j=0; j<3; j++)
            {
                if(A[i]+B[j]!=mat[i][j])
                    return 0;
            }
        }
        return 1;
    }
    int main()
    {

        for(int i=0; i<3; i++)
        {
            for(int j=0; j<3; j++)
                cin>>mat[i][j];
        }
        int x=mat[0][0],y=mat[1][1],z=mat[2][2];
        for(int a1=0,b1=x; a1<=x; a1++,b1--)
        {
            for(int a2=0,b2=y; a2<=y; a2++,b2--)
            {
                for(int a3=0,b3=z; a3<=z; a3++,b3--)
                {
                    int A[3],B[3];
                    A[0]=a1;
                    A[1]=a2;
                    A[2]=a3;
                    B[0]=b1;
                    B[1]=b2;
                    B[2]=b3;
                    if(test(A,B))
                    {
                        cout<<"Yes"<<endl;
                        return 0;
                    }

                }
            }
        }
        cout<<"No"<<endl;
        return 0;
    }


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

using namespace std;

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

int main() {
	int n, cnt = 0;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];

	for (int i = 1; i < n - 1; ++i) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) {
			++cnt;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

bool check(int x)
{
	int a[5], i=0, j, flag=0;
	while(x)
	{
		a[i++]=x%10;
		x/=10;
	}
	for(j=0; j<i; j++)
		if(a[j]!=a[i-j-1])
		{
			flag=1;
			break;
		}
	if(flag==1) return 0;
	return 1;
}

int main()
{
	int i, a, b, cnt=0;
	scanf("%d%d", &a, &b);
	for(i=a; i<=b; i++)
		if(check(i)) cnt++;
	printf("%d", cnt);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(){
  int N,s[30];
  long int ans=1;
  for(int i=0; i<30; ++i) s[i]=1;
  cin>>N;
  char a[N+1];
  for(int i=1; i<=N; ++i){
    cin>>a[i];
    if(a[i]=='q') s[1]+=1;
    if(a[i]=='w') s[2]+=1;
    if(a[i]=='e') s[3]+=1;
    if(a[i]=='r') s[4]+=1;
    if(a[i]=='t') s[5]+=1;
    
    if(a[i]=='y') s[6]+=1;
    if(a[i]=='u') s[7]+=1;
    if(a[i]=='i') s[8]+=1;
    if(a[i]=='o') s[9]+=1;
    if(a[i]=='p') s[10]+=1;
    
    if(a[i]=='a') s[11]+=1;
    if(a[i]=='s') s[12]+=1;
    if(a[i]=='d') s[13]+=1;
    if(a[i]=='f') s[14]+=1;
    if(a[i]=='g') s[15]+=1;
    
    if(a[i]=='h') s[16]+=1;
    if(a[i]=='j') s[17]+=1;
    if(a[i]=='k') s[18]+=1;
    if(a[i]=='l') s[19]+=1;
    if(a[i]=='z') s[20]+=1;
    
    if(a[i]=='x') s[21]+=1;
    if(a[i]=='c') s[22]+=1;
    if(a[i]=='v') s[23]+=1;
    if(a[i]=='b') s[24]+=1;
    if(a[i]=='n') s[25]+=1;
    if(a[i]=='m') s[26]+=1;
  }
  for(int i=1; i<30; ++i){
    ans *= s[i];
    ans %= 1000000007;
  }
  cout<<ans-1<<endl;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<Integer> h = new ArrayList<Integer>();
		for (int i = 0; i < 10; ++i) {
			h.add(s.nextInt());
		}
		Collections.sort(h);
		Collections.reverse(h);
		for (int i = 0; i < 3; ++i) {
			System.out.println(h.get(i));
		}
	}
}

Measured memory_bytes: 17304
#!/usr/bin/env python3
import sys
import math
import random


def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義

def solve(N, A):
    left = [A[0]]
    right = [A[N-1]]
    for i in range(1, N):
        left.append(gcd(left[i-1], A[i]))
    for i,j in zip(range(1,N),range(N-2, -1, -1)):
        right.append(gcd(right[i-1], A[j]))

    result = -1
    max_value = -1

    for i in range(N):
        if i == 0:
            current_value = right[N-2]
        elif i == N-1:
            current_value = left[N-2]
        else:
            current_value = gcd(left[i-1], right[N-i-2])
        if current_value > max_value:
            max_value = current_value
    print(max_value)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18164
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ft first
#define sd second
using namespace std;
 

inline void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int power(int a, ll b, ll m = MOD) {
    ll res = 1;
    while(b) {
        if(b & 1) {
            res = 1LL * res * a % m;
        }
        a = 1LL * a * a % m;
        b /= 2;
    }
    return (int) res;
}


const int N = 2000 + 9;
int a[N];

signed main() {
 
    // freopen("out1.txt","w",stdout); 
    ios::sync_with_stdio(false); cin.tie(0);
    
    int n; cin >> n;
    bitset<N * N> bs = 0;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        bs |= 1;
        sum += a[i];
        bs |= (bs << a[i]);
    }

    for(int i = (sum + 1) / 2; ; i++) {
        if(bs[i]) {
            cout << i << endl;
            return 0;
        }
    }

    assert(0);

    
    return 0; 
    
}

Measured memory_bytes: 1792
#include <cstdio>

using namespace std;

int main(){
  int a, b;
  for(int i=0; i<10000; i++) {
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) break;
    if(a > b) {
      printf("%d %d\n", b, a);
    } else {
      printf("%d %d\n", a, b);
    }
  }
  
  return 0;
}



Measured memory_bytes: 2588
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < S.size()/2; i++) {
        if (S.at(i) != S.at(S.size() - 1 - i)) cnt++;
    }
    cout << cnt << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	reverse(A,A+N);
	int S=0;
	FOR(i,N) {
		if(i%2==0) S+=A[i];
		else S-=A[i];
		
	}
	cout<<S<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

long long gcd(long long a, long long b) {
    long long r = a % b;

    while(r > 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int coprime(long long n) {
    long long l = 2;
    long long r = 1;
    int cnt = 0;
    long long first = n;
    while(first >= l*l) {
        if(n % l == 0) {
            if(l != r) {
                cnt++;
                r = l;
            }
            n /= l;
        }else {
            l++;
        }
    }
    if(n == 1) cnt++;
    else cnt += 2;

    return cnt;
}

int main() {
    cin >> a >> b;
    if(a > b) swap(a, b);
    long long g = gcd(a, b);

    int ans = coprime(g);

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int ans = 0;
            
            if (n == 0 && x == 0) {
                break;
            }
            
            for (int i = 1; i <= n - 2; i++) {
                for (int j = i + 1; j <= n - 1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) {
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
        
    }
}


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

int main(){
  string s1,s2,s3;
   cin>>s1>>s2>>s3;
  
  string A,B,C;
   A=s1[0]-32;
   B=s2[0]-32;
   C=s3[0]-32;
  cout<<A<<B<<C<<endl;
}         // 文字には番号が割り振られており、ASCII文字コード表より、
          // 小文字から32を引くと大文字に変換される


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

using namespace std;

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

	if (B < A) {
		swap(A, B);
	}

	if ((B - A) % 2 != 0) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << A + (B - A) / 2 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

long gcd(long a, long b) {
	while (b != 0) {
		long a_tmp = a;
		a = b;
		b = a_tmp % b;
	}
	return a;
}
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}

void solve() {
	long a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}

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


Measured memory_bytes: 256
def root(x):
    if x == p[x]:
        return x
    p[x] = y = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
    else:
        p[px] = py
    return 1


while 1:
    N = int(input())
    if N == 0:
        break
    *p, = range(N)
    M = int(input())
    E = []
    for i in range(M):
        a, b, d = map(int, input().split(','))
        E.append((d, a, b))
    E.sort()
    ans = 0
    for c, a, b in E:
        if unite(a, b):
            ans += (c - 100) // 100
    print(ans)



Measured memory_bytes: 5984
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d=min (b,c);
	int e=b+c-a;
	if (e<=0)
	  printf ("%d %d\n",d,0);
	else
	  printf ("%d %d\n",d,e);
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int x,y;cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
/*
参考
ブログ
https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
コード
https://github.com/key-moon/Library/blob/master/src/Algorithm/String/rolling%20hash.csx
verify;
https://atcoder.jp/contests/abc141/tasks/abc141_e
*/

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define bit(n,k) ( (n>>k)&1 )

//+++++++++++++++++++++++++++++

struct RollingHash{
    using u64=uint_fast64_t;
    const u64 MASK30=((u64)1<<30)-1;
    const u64 MASK31=((u64)1<<31)-1;
    const u64 MOD=((u64)1<<61)-1ul;
    const u64 POSITIVIZER=MOD*7;
    const u64 base=307;

    vector<u64> hash,power;

    RollingHash(const string &s){
        int sz=(int)s.size();
        hash.assign(sz+1,0);
        power.assign(sz+1,0);
        power[0]=1;
        ll t=1;
        for(int i=1;i<=sz;i++){
            power[i]=calc_mod( mul(power[i-1],base) );
            hash[i]=calc_mod( mul(hash[i-1],base)+s[i-1] );
        }
    }

    inline u64 get(int begin,int len){
        return calc_mod(hash[begin+len]+POSITIVIZER-mul(hash[begin],power[len]));
    }

    inline u64 mul(u64 l,u64 r){
        u64 lu=l>>31;
        u64 ld=l&MASK31;
        u64 ru=r>>31;
        u64 rd=r&MASK31;
        u64 middle=ld*ru+lu*rd;
        return ((lu*ru)<<1)+ld*rd+((middle&MASK30)<<31)+(middle>>30);
    }

    inline u64 calc_mod(u64 x){
        x=(x&MOD)+(x>>61);
        if(x>=MOD) x-=MOD;
        return x;
    }
};

//+++++++++++++++++++++++++++++++++++

bool check(int mid,string &s,RollingHash &x){
    for(int i=0;i<s.size();i++){
        for(int j=i+mid;j<s.size();j++){
            if(x.get(i,mid)==x.get(j,mid)){
                return true;
            }
        }
    }
    return false;
}

signed main(){
    int N;
    string S;
    cin>>N>>S;
    int ng=N+1,ok=0;
    RollingHash r(S);
    while(ng-ok!=1){
        int mid=(ng+ok)/2;
        if(check(mid,S,r)) ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    sx, sy, tx, ty = map(int, input().split())
    ans = []

    for i in range(ty-sy):
        ans.append("U")
    for i in range(tx-sx):
        ans.append("R")
    for i in range(abs(sy-ty)):
        ans.append("D")
    for i in range(abs(sx-tx)):
        ans.append("L")
    
    ans.append("L")
    for i in range(ty-sy+1):
        ans.append("U")
    for i in range(tx-sx+1):
        ans.append("R")
    ans.append("D")
    ans.append("R")
    for i in range(abs(sy-ty)+1):
        ans.append("D")
    for i in range(abs(sx-tx)+1):
        ans.append("L")
    ans.append("U")

    print("".join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int N,M;
	boolean[] first,second;

	public void solve() {

		N = nextInt();
		M = nextInt();

		first = new boolean[N];
		second = new boolean[N];

		for(int i = 0;i < M;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;

			if(a == 0){
				first[b] = true;
			}

			if(b == N-1){
				second[a] = true;
			}
		}

		for(int i = 1;i < N - 1;i++){
			if(first[i] && second[i]){
				out.println("POSSIBLE");
				return;
			}
		}

		out.println("IMPOSSIBLE");
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 45312
#include<bits/stdc++.h>
using namespace std;
char str[105];
int main(void){
	int n; scanf("%d",&n);
	scanf("%s",str);
	int r = 0, b = 0;
	for(int i=0;i<n;i++){
		if(str[i]=='R') r++;
		else b++;
	}
	if(r>b) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
R,G,B,N = map(int,input().split())
lis = [R,G,B]
lis = sorted(lis)
ans = 0
if min(lis) <= N:
    while N >= 0:
        i = 0
        while N - i*lis[1] >= 0:
            if (N-i*lis[1])%lis[0]==0:
                ans += 1
            i += 1
        N -= lis[2]
print(ans)


Measured memory_bytes: 40556
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define jkl int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7


int main(){
    ll n, m;
    ll N = 1, M = 1;
    cin >> n >> m;
    rep(i, 1, n + 1)N = (N * i) % mod;
    rep(i, 1, m + 1)M = (M * i) % mod;
    ll ans = 0;
    if(abs(n - m) > 1){ans = 0;}
    else if(abs(n - m) == 1) (ans = N * M % mod);
    else ans = (N * M % mod) * 2 % mod;
    print(ans);
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int dp[maxn],f[70000010];
char x[maxn];

void solve()
{
    scanf("%s",x+1);

    int len = strlen(x+1);
    int sum = 0;
    
    memset(f,0x3f,sizeof(f));
    f[0] = 0;
    repp(i,1,len)
    {
        int y = (1<<(int)(x[i]-'a'));
        sum ^= y;
        dp[i] = INF;
        //DE(dp[i])
        dp[i] = min(dp[i],f[sum]+1);
        rep(j,0,26)
        {
              dp[i] = min(dp[i],f[sum^(1<<j)]+1);
        }
        f[sum] = min(f[sum],dp[i]);
        // DE(i)
        // DE(dp[i])
    }
    printf("%d\n", dp[len]);
}

int main()
{
    solve();
    // system("pause");
    return 0;
}

Measured memory_bytes: 274688
#pragma target("avx")
#pragma optimize("O3")
#include<stdio.h>
int main(){
	int n, k, x=1;
	scanf("%d%d", &n, &k);
	while(n--){
		if(x<k) x += x;
		else x += k;
	}
	printf("%d", x);
	return 0;
}



Measured memory_bytes: 128
#include <iostream>

using namespace std;

#define EPS 1e-9

int main()
{
	int a,b,c,d,e,f;
	double x,y,dx,dy;
	while( cin >> a >> b >>c >>d >> e >> f ) {
		x = (c*e-b*f)/(double)(a*e-b*d);
		y = (c*d-a*f)/(double)(b*d-a*e);
		

		printf("%.3f %.3f\n",x+EPS,y+EPS);
	}



	return 0;
}

Measured memory_bytes: 0
main = do
  _ <- getLine
  xs <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
  print . (`div` 2) . length $ filter (`elem` [x^2 | x <- [1..127]]) [sum . fmap (\(y, z) -> (y - z)^2) $ zip ys zs | ys <- xs, zs <- xs, ys /= zs]


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF =ll(1e18) +5;
vector<vector<pair<ll,ll>>> tree;
vector<ll> pos;

void dfs(int t){
    // cerr << "t=" <<t <<"pos=" << pos[t]<< endl;
    for(auto P:tree[t]){
        if(pos[P.first] == -INF){
            pos[P.first] = pos[t] - P.second;
            dfs(P.first);
            continue;
        }
    }
}

int main() {
    ll N,M;
    cin >> N>>M;
    tree.resize(N);
    pos.resize(N,-INF);

    vector<ll> A(M),B(M),C(M);

    for(int i=0;i<M;i++){
        ll L,R,D;
        cin >> L >>R >>D;
        --L;--R;
        A[i] = L;B[i] =R;C[i] =D;
        tree[L].emplace_back(R,-D);
        tree[R].emplace_back(L,D);
    }
    for(int i=0;i<N;i++){
        if(pos[i] != -INF){
            continue;
        }
        pos[i] =0;
        dfs(i);
    }
    for(int i=0;i<M;i++){
        if(pos[A[i]] +C[i] != pos[B[i]]){
            cout <<"No" << endl;
            return 0;
        }
    }
    cout <<"Yes" << endl; 

    return 0;
}

Measured memory_bytes: 21120
#include <iostream>

int main(){
   int K, N;
   std::cin >> K >> N;
   int A, A_prev, A_0;
   int max = 0;
   int d;
   std::cin >> A_0;
   A_prev = A_0;
   for(int i=1; i<N; ++i){
      std::cin >> A;
      d = A - A_prev;
      max = std::max(max, d);
      A_prev = A;
   }
   d = K - A + A_0;
   max = std::max(max, d);

   std::cout << K - max << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-9
#define mod 1000000007
#define pi 3.14159265359
#define inf 1e18

using namespace std;

typedef long long ll;
typedef long double ld;

string s;
ll k, t, x;
set<pair<ll, ll>, greater<> > S;

int main()
{
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>k>>t;
    for (ll i=1; i<=t; i++)
    {
        cin>>x;
        S.insert({x, i});
    }

    ll last = 0;
    while (!S.empty())
    {
        ll count = S.begin()->first;
        ll idx = S.begin()->second;
        S.erase(S.begin());

        if (idx == last)
        {
            if (S.empty())
            {
                cout<<count;
                return 0;
            }
            ll cnt = S.begin()->first;
            ll i = S.begin()->second;
            S.erase(S.begin());

            cnt--;
            last = i;
            if (cnt > 0)
                S.insert({cnt, i});
            S.insert({count, idx});
        }
        else
        {
            count--;
            last = idx;
            if (count > 0)
                S.insert({count, idx});
        }
    }
    cout<<0;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl a(n);cin>>a;
    vl dp0(n+1, -LINF);
    vl dp1(n+1, -LINF);
    vl dp2(n+1, -LINF);
    dp0[0]=0;
    rep(i,n){
        dp0[i+1]=dp0[i];
        dp1[i+1]=dp1[i];
        dp2[i+1]=dp2[i];
        if(i%2==0){
            chmax(dp1[i+1],dp0[i+1]);
            dp0[i+1]+=a[i];
            dp2[i+1]+=a[i];
        }else{
            chmax(dp2[i+1], dp1[i+1]);
            dp1[i+1]+=a[i];
        }
    }
    if(n%2==0)puta(max(dp0[n], dp1[n]));
    else puta(max(dp2[n], dp1[n]));
    return 0;
}

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    int A, B;
    cin>>A>>B;
    string S;
    cin>>S;
    bool flag = true;
    for (int i = 0; i < A; i++) if (!('0' <= S[i] && S[i] <= '9')) flag = false;
    if (S[A] != '-') flag = false;
    for (int i = 0; i < B; i++) if (!('0' <= S[A+1+i] && S[A+1+i] <= '9')) flag = false;
    cout<<(flag ? "Yes" : "No")<<endl;

    return 0;
}

Measured memory_bytes: 256
(let ((i (make-array 11)))
    (incf (aref i (read)))
    (incf (aref i (read)))
    (incf (aref i (read)))
    (if (and (= (aref i 5) 2) (= (aref i 7) 1))
        (princ "YES")
        (princ "NO")
    )
)

Measured memory_bytes: 24012
from sys import exit

S = input()
K = int(input())

if K < 4:
    t = bytearray(S * K, 'us-ascii')
    for i in range(1, len(t)):
        if t[i - 1] == t[i]:
            t[i] = 0
    print(t.count(0))
    exit()

t = bytearray(S * 3, 'us-ascii')
for i in range(1, len(t)):
    if t[i - 1] == t[i]:
        t[i] = 0
b0 = t[:len(S)].count(0)
b1 = t[len(S):len(S)*2].count(0)
b2 = t[len(S)*2:len(S)*3].count(0)
print(b0 + b1 * (K // 2) + b2 * ((K - 1) // 2))


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

int main(){
    int N, K;
    cin >> N >> K;
    int h[100001];
    rep(i, N ) cin >> h[i];

    sort(h, h+N);

    // rep(i, N) cout << h[i] << endl;

    unsigned int  minV = 0;
    // cout << minV << endl;
    minV--;

    // cout << minV << endl;
    rep(i, N-K+1) {
        // cout << i << endl;
        int tmp = 0;
        tmp = abs(h[i] - h[i+K-1]);
        if(tmp < minV) minV =tmp;
        // cout << i <<  " " << tmp << " " << h[i] << " " << h[i+K]<<endl;
     }

    cout << minV << endl;


    return 0;
}

Measured memory_bytes: 640