akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static int getInt(){return Integer.parseInt(s.next());}
	static class Pair<T,U>{
		T l;U r;
		Pair(T L,U R){l=L;r=R;}
		T getL(){return l;}
		U getR(){return r;}
	}
	public static void main(String[]$){
		int n=getInt();
		int odd=0,_2=0,_4=0;
		for(int i=0;i<n;++i) {
			int in=getInt();
			if(in%4==0) {
				++_4;
			}else if(in%2==0) {
				++_2;
			}else {
				++odd;
			}
		}
		/*
		System.out.println(_4);
		System.out.println(_2);
		System.out.println(odd);
		 */
		int r=odd-1;
		if(_2>0)
			++r;
		System.out.println(r<=_4
				?"Yes":"No"
				);
	}
}

Measured memory_bytes: 44116
#include<stdio.h>
#define SENTINEL 2147483647
#define MAX 500000
int cnt;
int L[MAX],R[MAX];


void merge(int A[], int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i=0; i<n1; i++) L[i]=A[left+i];
    for (i=0; i<n2; i++) R[i]=A[mid+i];
    L[n1]=SENTINEL;
    R[n2]=SENTINEL;
    i = 0;
    j = 0;
    for (k=left; k<right; k++) {
        cnt++;
        if (L[i]<=R[j]) {
            A[k] = L[i];
            i+=1;
        } else {
            A[k] = R[j];
            j+=1;
        }
    }
}

void merge_sort(int A[], int left, int right) {
    if (left+1<right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int i, n;
    int S[500000];
    cnt = 0;

    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &S[i]);
    merge_sort(S, 0, n);
    for (i=0; i<n; i++) {
        if (i>0) printf(" %d", S[i]);
        else printf("%d", S[i]);
    }
    printf("\n");
    printf("%d\n", cnt);
    return 0;
}


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

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

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> a(N),b(N);
    vector<pair<ll,P>> sum;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        sum.push_back(make_pair(a[i]+b[i],make_pair(a[i],b[i])));
    }
    sort(sum.rbegin(),sum.rend());

    ll sumA = 0,sumB = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            sumA += sum[i].second.first;
        } else {
            sumB += sum[i].second.second;
        }
    }

    cout << sumA - sumB << endl;




    return 0;
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
rep(i,1000000)rep(j,n){
  if(a[j]>=n){
    ll te=a[j]/n;
    a[j]-=n*te;
    ans+=te;
    rep(k,n)if(j!=k)a[k]+=te;
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

/*構造体の定義*/
typedef struct {
	char suit;
	int value;
} Card ;


void swap_Card(Card *x, Card *y)
{
	Card temp = *x;
	*x = *y;
	*y = temp;
}


void BubbleSort(Card A[], int N) {
	int i, j;
	Card temp;

	for (i = 0; i < N; i++) {
		for (j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) {
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
			}
		}
	}
}


void SelectionSort(Card A[], int N) {
	int i, j;
	int minj;
	Card temp;

	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j].value < A[minj].value) {
				minj = j;
			}
		}
		temp = A[i];
		A[i] = A[minj];
		A[minj] = temp;
	}
}



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

	int i,j;
	Card BC[36];
	Card SC[36];

	for (i = 0; i < N; i++) {
		Card c;
		scanf("%c", &c.suit);
		scanf("%d ", &c.value);
		BC[i] = c;
		SC[i] = c;
	}
    
    BubbleSort(BC,N);
    SelectionSort(SC,N);
	
	/* Output */
	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", BC[i].suit, BC[i].value);
	}
	printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);
	puts("Stable");

	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", SC[i].suit, SC[i].value);
	}
	printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

	for (i = 0; i < N; i++) {
		if (BC[i].suit != SC[i].suit) {
			puts("Not stable");
			return 0;
		}
	}
	puts("Stable");

	return 0;
}


Measured memory_bytes: 2008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), m = in.ni(), c = in.ni();
            int[] b = in.na(m);
            int[][] a = new int[n][];
            for (int i = 0; i < n; i++) {
                a[i] = in.na(m);
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                long res = c;
                for (int j = 0; j < m; j++) {
                    res += a[i][j] * b[j];
                }
                if (res > 0)
                    ans++;
            }
            out.println(ans);

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

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

    }
}



Measured memory_bytes: 23380
#include "bits/stdc++.h"
using namespace std;

struct BIT {
	long long n;
	vector<long long> dat;

	void init(long long n_input) {
		n = n_input + 1;
		dat.resize(n + 1);
		for (int i = 0; i <= n; i++) dat[i] = 0;
	}

	long long sum(long long i) {
		long long s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}

	void add(long long i, long long x) {
		while (i <= n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
};

int main() {
	int i;
	int N;
	cin >> N;
	vector<int> A(N), sortedA(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sortedA[i] = A[i];
	}
	sort(sortedA.begin(), sortedA.end());
	int ub = N;
	int lb = 0;
	BIT bit;

	long long border = (((long long)N * (N + 1) / 2) + 1) / 2;
	while (ub - lb > 1) {
		int mid = (ub + lb) / 2;
		int midn = sortedA[mid];
		bit.init(2 * N + 1);
		int sum = 0;
		bit.add(sum + N, 1);
		long long result = 0;
		for (i = 0; i < N; i++) {
			sum += A[i] >= midn ? 1 : -1;
			result += bit.sum(sum + N);
			bit.add(sum + N, 1);
		}
		if (result >= border) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}
	cout << sortedA[lb] << endl;
	return 0;
}


Measured memory_bytes: 5612
n,h = gets.chomp.split(" ").map(&:to_i)
a = n.times.map{gets.chomp.split(" ").map(&:to_i)}.transpose
c = a[0].max
d = a[1].select{|num|num>=c}.sort
for i in 0..d.size-1
  h -= d[-i-1]
  if h <= 0
    puts i+1
    exit
  end
end
puts d.size + (h + c - 1)/c

Measured memory_bytes: 13448
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    ll n;
    ll buff;
    cin >> n;
    ll cnt = 0;
    while(n > 0){
        buff = n;
        n -= (ll)((cnt+6)*8*6*pow(10,cnt)) - 5;
        cnt++;
    }
    if(buff <= cnt*8+35){
        ll fr = pow(10,cnt)-9;
        string ss;
        ll cnt3 = 0;
        ll id = 0;
        while(cnt3 < buff + 20){
            if((fr+id) % 3 == 0){
                string hoge = "Fizz";
                ss += hoge;
                cnt3 += 4;
            }
            if((fr+id) % 5 == 0){
                string hoge = "Buzz";
                ss += hoge;
                cnt3 += 4;
            }
            if((fr+id) % 5 != 0 && (fr+id) % 3 != 0){
                string hoge;
                ll hoge2 = fr+id;
                while(hoge2 != 0){
                    hoge += (char)('0' + (hoge2 % 10));
                    cnt3++;
                    hoge2 /= 10;
                }
                reverse(hoge.begin(),hoge.end());
                ss += hoge;
            }
            id++;
        }
        cout << ss.substr(buff-1,20) << "\n";
    }else{
        buff -= cnt*8+35;
        ll buff2 = buff % (8*(cnt+5));
        ll cnt2 = buff / (8*(cnt+5));
        ll fr = (ll)(pow(10,cnt) + 6) + (ll)(cnt2*15LL);
        string ss;
        ll cnt3 = 0;
        ll id = 0;
        while(cnt3 < buff2 + 20){
            if((fr+id) % 3 == 0){
                string hoge = "Fizz";
                ss += hoge;
                cnt3 += 4;
            }
            if((fr+id) % 5 == 0){
                string hoge = "Buzz";
                ss += hoge;
                cnt3 += 4;
            }
            if((fr+id) % 5 != 0 && (fr+id) % 3 != 0){
                string hoge;
                ll hoge2 = fr+id;
                while(hoge2 != 0){
                    hoge += (char)('0' + (hoge2 % 10));
                    cnt3++;
                    hoge2 /= 10;
                }
                reverse(hoge.begin(),hoge.end());
                ss += hoge;
            }
            id++;
        }
        cout << ss.substr(buff2-1,20) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3292
from collections import deque

class Graph(): #directed
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0]-1].append(e[1]-1)
            self.deg[e[1]-1] += 1
    def topological_sort(self):
        res = [i for i in range(self.n) if self.deg[i]==0]
        queue = deque(res)
        used = [False for _ in range(self.n)]
        while queue:
            node = queue.popleft()
            for adj in self.graph[node]:
                self.deg[adj] -= 1
                if self.deg[adj] == 0:
                    queue.append(adj)
                    res.append(adj)
        return res

import sys
input = sys.stdin.readline

V,E = map(int,input().split())
edge = [tuple(map(lambda x:int(x)+1,input().split())) for _ in range(E)]

g = Graph(V,edge)
A = g.topological_sort()

print(0 if len(A)==V else 1)


Measured memory_bytes: 6060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  ll ans=0;
  cin >> n;
  vector<int> b(n);
  rep(i,n-1){
    cin >> b[i];
  }

  rep(i,n-1){
    ans+=min(b[i],b[i+1]);
  }
  ans+=(b[0]+b[n-2]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
  int A,B,C;
  std::cin>>A>>B>>C;
  int coin_count=0,day=0;
  while(coin_count<C){
    day++;
    coin_count+=A;
    if(day%7==0){
      coin_count+=B;
    }
    if(coin_count>=C)break;
  }
  std::cout<<day<<std::endl;
  return 0;
}



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

class UnionFind {
 private:
  vector<int> _parent;

 public:
  // n要素で生成
  UnionFind(int N) {
    _parent = vector<int>(N, -1);
  }

  // 木の根を求める
  int find(int x) {
    if (_parent[x] < 0) return x;
    return _parent[x] = find(_parent[x]);
  }

  // xとyの属する集合を併合する
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }

    if (size(x) < size(y)) swap(x, y);
    _parent[x] += _parent[y];
    _parent[y] = x;

    return true;
  }

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

  int size(int x) {
    return -_parent[find(x)];
  }

  // 全体の個数を求める
  int size() {
    return _parent.size();
  }
};

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

  UnionFind uni(N);

  vector<long long> ans(M);
  ans[M - 1] = (long long) N * (N - 1) / 2;

  for (int i{M - 1}; i >= 1; --i) {
    ans[i - 1] = ans[i];
    if (uni.find(A[i]) != uni.find(B[i])) {
      ans[i - 1] -= (long long) uni.size(A[i]) * uni.size(B[i]);
      uni.unite(A[i], B[i]);
    }
  }

  for (int i{}; i < M; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
import queue
K=int(input())
q = queue.Queue()
for i in range(10):
    q.put(i)
q.get()
X=0
while X<=K:
    X+=1
    A=q.get()
    if X==K:
        print(A)
    if A%10!=0:
        q.put(A*10+A%10-1)
    q.put(A*10+A%10)
    if A%10!=9:
        q.put(A*10+A%10+1)
        









Measured memory_bytes: 12452
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    vector<int> W(N);

    rep(i, N) cin >> W[i];

    int p=0, q=0, wa=0;

    rep(i, N) wa += W[i];

    q = wa;

    int sa = abs(wa);

    for (int i = 0; i < N; ++i) {
        p += W[i];
        q -= W[i];
        sa = min(sa, abs(p - q));
    }

    cout << sa << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//データの読み込み
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		//結果の計算
		int area = a * b;
		int length = (2 * a) + (2 * b);
		
		//結果を出力
		System.out.println(area + " " + length);
	}
}


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

using namespace std;

int main()
{
    int n , x , y , s = 0 , k , p;
    cin >> n >> x >> y;
    while(n--)
    {
        cin >> k >> p;
        s += (k >= x && p >= y);
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>

#define MIN(x, y) ((x) <= (y) ? (x) : (y))
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void *partition(int *first, int *last) {
    int pivot = *(last - 1);
    int *p = first - 1;
    for(int *it = first; it != last - 1; ++it) {
        if(*it <= pivot) {
            p++;
            int tmp = *p;
            *p = *it;
            *it = tmp;
        }
    }
    int tmp = *++p;
    *p = pivot;
    *(last - 1) = tmp;
    return p;
}
void quick_sort(void *first, void *last, size_t N) {
    if(last - first <= N) return;
    void *mid = partition(first, last);
    quick_sort(first, mid, N);
    quick_sort(mid, last, N);
}
int mincost_sort(const int *a, const int N, const int minw) {
    int cnt = 0;
    // b[]: sorted arr of b
    int b[N];
    memcpy(b, a, N * sizeof(int));
    quick_sort(b, b + N, sizeof(int));
    // pos[i]: index of i in b
    int pos[10001];
    for(int i = 0; i < N; ++i) pos[b[i]] = i;
    // flag[i]: is pos[i] checked
    int flag[1001] = {};
    for(int i = 0; i < N; ++i) {
        if(flag[i]) continue;
        int cur = i;
        int sum = 0;
        int num = 0;
        int mina = 1 << 29;
        while(!flag[cur]) {
            flag[cur] = 1;
            num++;
            sum += a[cur];
            mina = MIN(mina, a[cur]);
            cur = pos[a[cur]];
        }
        // [ sum + (num-2)*mina + 2(mina+minw) - (num-1)*(mina-minw) ] -> [ sum + mina + (n+1)*minw ]
        cnt += MIN(sum + (num - 2) * mina, sum + mina + (num + 1) * minw);
    }
    return cnt;
}
int main(int argc, char **argv) {
    int n = get_uint();
    int w[n];
    int minw = 1 << 29;
    for(int i = 0; i < n; ++i) {
        w[i] = get_uint();
        minw = MIN(minw, w[i]);
    }
    put_uint(mincost_sort(w, n, minw));
    putchar_unlocked('\n');
    return 0;
}



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

int main() {
    int a;
    vector<int> q(4,0);
    for (int i=0;i<6;i++){cin >> a;q[a-1]++;}
    auto mq = max_element(q.begin(),q.end());
    cout << ((*mq==3) ? "NO" : "YES") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <cfloat>
#include <cmath>
#include <functional>
#include <forward_list>
#include <list>


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

#define MAX_N 

using namespace std;


class Main {
public:
	ll getAns(vector<ll> ws, vector<ll> vs, ll maxW) {
		vector<vector<ll> > vss(4, vector<ll>());

		rep(i, vs.size()) {
			vss[ws[i] - ws[0]].push_back(vs[i]);
		}

		rep(i, vss.size()) {
			vss[i].push_back(0);
			sort(vss[i].begin(), vss[i].end(), greater<ll>());
		}

		vector<vector<vector<vector<ll> > > > dp(vss[0].size()+1,
			vector<vector<vector<ll> > >(vss[1].size()+1,
				vector<vector<ll> >(vss[2].size()+1,
					vector<ll>(vss[3].size()+1))));
		dp[0][0][0][0] = 0;
		rep(i0, vss[0].size()) {
			rep(i1, vss[1].size()) {
				rep(i2, vss[2].size()) {
					rep(i3, vss[3].size()) {
						ll w = i0 * ws[0] + i1 * (ws[0] + 1) + i2 * (ws[0] + 2) + i3 * (ws[0] + 3);
						ll a = dp[i0][i1][i2][i3];
						if (w + ws[0] <= maxW) {
							dp[i0 + 1][i1][i2][i3] = max(dp[i0 + 1][i1][i2][i3], dp[i0][i1][i2][i3] + vss[0][i0]);
						}

						if (w + ws[0] + 1 <= maxW) {
							dp[i0][i1 + 1][i2][i3] = max(dp[i0][i1 + 1][i2][i3], dp[i0][i1][i2][i3] + vss[1][i1]);
						}

						if (w + ws[0] + 2 <= maxW) {
							dp[i0][i1][i2 + 1][i3] = max(dp[i0][i1][i2 + 1][i3], dp[i0][i1][i2][i3] + vss[2][i2]);
						}

						if (w + ws[0] + 3 <= maxW) {
							dp[i0][i1][i2][i3 + 1] = max(dp[i0][i1][i2][i3 + 1], dp[i0][i1][i2][i3] + vss[3][i3]);
						}
					}
				}
			}
		}

		ll maxDp = 0;
		rep(i0, vss[0].size() + 1) {
			rep(i1, vss[1].size() + 1) {
				rep(i2, vss[2].size() + 1) {
					rep(i3, vss[3].size() + 1) {
						maxDp = max(maxDp, dp[i0][i1][i2][i3]);
					}
				}
			}
		}

		return maxDp;

	}
};

int main(void) {
	Main main;
	vector<ll> ws;
	vector<ll> vs;
	ll n,maxW;

	cin >> n >> maxW;
	rep(i, n) {
		ll inpW;
		ll inpV;
		cin >> inpW >> inpV;
		ws.push_back(inpW);
		vs.push_back(inpV);
	}

	cout << main.getAns(ws, vs, maxW) << endl;

	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <cstdlib>
#define MAXN 100005
#define ll long long
using namespace std;
ll a[MAXN], b[MAXN], c[MAXN];
ll n;
template <typename T> inline void read(T &x) {
    char c; bool flag = 0; x = 0;
    c=getchar();
    while(c > '9' || c < '0') {if(c=='-') flag = 1; c = getchar();}
    while(c <= '9' && c >= '0'){x = x*10+c-48; c = getchar();}
    if(flag) x = x*(-1);    
}

inline void init() {
    read(n);
    for(int i = 1; i <= n; i++) read(a[i]);
    for(int i = 1; i <= n; i++) read(b[i]);
    for(int i = 1; i <= n; i++) read(c[i]);
}

inline ll searcha(ll x) {
    if(x <= a[1]) return 0;
    ll l = 1, r = n, mid;
    while(l <= r) {
        mid = (l+r) >> 1;
        if(a[mid] >= x) r = mid - 1;
        else l = mid + 1;
    }
    if(r < 0) r = 0;
    return r;
}
inline ll searchc(ll x) {
    if(x >= c[n]) return 0;
    ll l = 1, r = n, mid;
    while(l <= r) {
        mid = (l+r) >> 1;
        if(c[mid] > x) r = mid - 1;
        else l = mid + 1;
    }
    l --;
    return n-l;
}
int main() {
    long long ans = 0;
    ll loc1, loc2;
    init();
    sort(a+1, a+1+n);
    sort(c+1, c+1+n);
    for(int i = 1; i <= n; i++) {
        loc1 = searcha(b[i]);
        loc2 = searchc(b[i]);
        ans += loc1*loc2;
    }
    cout << ans << "\n";
    // system("pause");
    return 0;
}

Measured memory_bytes: 2560
n,d=map(int,input().split())
X=[]
for _ in range(n):
    X.append(list(map(int,input().split())))

f=0
for i in range(n-1):
  for j in range(i+1,n):
    l=0
    for a in range(d):
      l+=(X[i][a]-X[j][a])**2
    if int(l**(1/2))==l**(1/2):
        f+=1
print(f)

Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll l[n+10]={};
 l[0]=2;l[1]=1;
 rep(i,2,n+1)l[i]=l[i-1]+l[i-2];
 pr(l[n]);
return 0;}


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

ll modpow(ll a, ll n){

ll ret = 1;
  while(n){
    if(n & 1) ret=ret*a % mod;
    a = a*a % mod;

    n >>= 1;
  }

  return ret;
}

int main(){
  ll N,K;
  cin>>N>>K;

  ll d[K+1];

  for(ll i=1;i<=K;i++){
    d[i] = modpow(K/i,N);
  }

  for(ll i= K; i>=1; i--){
    for(ll j = 2*i; j <= K; j+=i){
      d[i] -= d[j];
    }
  }

  ll ans=0;
  for(ll i=1;i<=K;i++){
    ans += (d[i]*i )% mod;
  }

  cout<<ans % mod;
}


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

int main()
{
  long long int N;
  cin >> N;
  if (N % 2 != 0)
    cout << 0 << endl;
  else
  {
    long long ans = 0;
    long long int now = 10;
    while (N / now > 0)
    {
      ans += N / now;
      now *= 5;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
const int MAXN = 1e7 + 5;
const int MAXD = 2e7 + 5;
const int mod = 1e9 + 7;

inline ll pw(ll a,ll b)
{
	ll res = 1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

ll fac[MAXN], inv[MAXN];
inline ll c(int n,int m)
{
	if(n<0||m<0||n<m) return 0;
	return fac[n] * inv[m] %mod * inv[n-m] %mod;
}

ll pw25[MAXN], pw26[MAXN];

char s[MAXN];

int main(void)
{
	fac[0] = 1;
	for(int i=1; i<MAXN; ++i) fac[i] = fac[i-1] * i %mod;
	inv[MAXN-1] = pw(fac[MAXN-1], mod-2);
	for(int i=MAXN-2; i>=0; --i) inv[i] = inv[i+1] * (i+1) %mod;
	
	int d;
	scanf("%d%s",&d,s+1);
	int n = strlen(s+1);
	
	pw25[0] = pw26[0] = 1;
	for(int i=1; i<MAXN; ++i)
		pw25[i] = pw25[i-1] * 25 %mod,
		pw26[i] = pw26[i-1] * 26 %mod;
	
	ll ans = 0;
	for(int i=0; i<=d; ++i)
		ans = (ans + pw25[i] * c(i+n-1,n-1) %mod * pw26[d-i]) %mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 317244
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
    int a[3][3],i,j,b[1000],k,n;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin >> a[i][j];
        }
    }
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> b[i];
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
           for(k=0;k<n;k++)
           {
                if(b[k]==a[i][j])
                a[i][j]=1000;
           }
        }
    }
    if((a[0][0]==1000 && a[0][1]==1000 && a[0][2]==1000)||(a[1][0]==1000 && a[1][1]==1000 && a[1][2]==1000)||
    (a[2][0]==1000 && a[2][1]==1000 && a[2][2]==1000)||(a[0][0]==1000 && a[1][0]==1000 && a[2][0]==1000)||
    (a[0][1]==1000 && a[1][1]==1000 && a[2][1]==1000)||(a[0][2]==1000 && a[1][2]==1000 && a[2][2]==1000)||
    (a[2][0]==1000 && a[1][1]==1000 && a[0][2]==1000)||(a[0][0]==1000 && a[1][1]==1000 && a[2][2]==1000))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    


}


Measured memory_bytes: 3592
#include <iostream>
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1000000000
#define MOD 1000000007
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define fori(i, a, b) for(i=a; i<b; i++)
#define ford(i, a, b) for(i=a; i>b; i--)
using namespace std;
const ll N = 500043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n - k], fact[k]));
}

int solve()
{
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if(x1==0)
        return 1;
    if(x2==0)
        return 2;
    if(x3==0)
        return 3;
    if(x4==0)
        return 4;
    if(x5==0)
        return 5;
}

int main()
{
    io
    int t;
    t=1;
    // cin >> t;
    while(t--)
        cout << solve() << endl;
        // solve();
    return 0;
}

Measured memory_bytes: 3612
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut dp = vec![vec![0; N + 1]; N + 1];
    for i in (1..N).rev() {
        for j in (0..i).rev() {
            dp[j][i] = if S[j] == S[i] {
                std::cmp::min(i - j, dp[j + 1][i + 1] + 1)
            } else {
                0
            };
        }
    }
    let ans = (0..(N - 1))
        .map(|i| ((i + 1)..N).map(|j| dp[i][j]).max().unwrap())
        .max()
        .unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 231804
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;
 
typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>=(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
 
int main(){
    int K,S; cin>>K>>S;
    int ans = 0;
    
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if((S-i-j <= K) && (S-i-j >= 0)) ans++;
        }
    }
    
    put(ans);
    
}

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

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

using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;

//fixed << setprecision(10)

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

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

	if (s == "SUN")cout << 7 << endl;
	if (s == "MON")cout << 6 << endl;
	if (s == "TUE")cout << 5 << endl;
	if (s == "WED")cout << 4 << endl;
	if (s == "THU")cout << 3 << endl;
	if (s == "FRI")cout << 2 << endl;
	if (s == "SAT")cout << 1 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,sum=0;;
	cin>>a>>b>>c;
	if(a==b){
		sum++;
	}if(a==c){
		sum++;
	} if(b==c){
		sum++;	
	}
	if(sum==1){
		cout<<"Yes";
	}else{
		cout<<"No"; 
	}
	return 0;
} 

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

using namespace std;

#define endl '\n'

int main()
{
#ifdef jcg
	assert(freopen("input.in", "r", stdin));
	// assert(freopen("output.out", "w", stdout));
#else
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		if (i) a[i] += a[i - 1];
	}

	vector<int> b(N);
	for (int i = 0; i < N; ++i)
		cin >> b[i];
	for (int i = N - 2; i >= 0; --i)
		b[i] += b[i + 1];

	int ans = 0;

	for (int i = 0; i < N; ++i)
		ans = max(ans, a[i] + b[i]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,m,pa[12],pb[12];
string a[12],b[12];
void dfs1(int x,bool free){
	if(x==m) cout<<"YES"<<endl,exit(0);
	else if(pb[x]!=-1) dfs1(x+1,free);
	else{
		for(int y=x+1;y<m;y++){
			if(pb[y]!=-1) continue;
			int ok=1;
			for(int z=0;z<n;z++) if(a[z][x]!=a[pa[z]][y]){ok=0;break;}
			if(ok) pb[x]=y,pb[y]=x,dfs1(x+1,free),pb[x]=pb[y]=-1;
		}
		if(free){
			int ok=1;
			for(int z=0;z<n;z++) if(a[z][x]!=a[pa[z]][x]){ok=0;break;}
			if(ok) pb[x]=x,dfs1(x+1,0),pb[x]=-1;
		}
	}
}
void dfs2(int x,bool free){
	if(x==n) dfs1(0,m%2);
	else if(pa[x]!=-1) dfs2(x+1,free);
	else{
		for(int y=x+1;y<n;y++) if(pa[y]==-1&&b[x]==b[y])
			pa[x]=y,pa[y]=x,dfs2(x+1,free),pa[x]=pa[y]=-1;
		if(free)
			pa[x]=x,dfs2(x+1,0),pa[x]=-1;
	}
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++)
		b[i]=a[i],sort(b[i].begin(),b[i].end());
	memset(pa,-1,sizeof(pa));
	memset(pb,-1,sizeof(pb));
	dfs2(0,n%2);
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  character(100000) :: s
  integer :: n, i, np
  read(*, *) s
  n = len(trim(s))
  np = 0
  do i = 1, n
    if (s(i:i) == "p") np = np + 1
  end do
  write(*, "(i0)") n / 2 - np
end program main


Measured memory_bytes: 700
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${5PL2iRE5WFMthv^{+v?dBYMx`G~IoQTdEE$80tEzo{*Wd=yz1W_eo!MP$KlHFh$m0~eaaTywkAn~BRX?eaXF3w(ceoAiIC9UeRrXFAJ$F}?NJ*tL!#zJq?ldEsaY5&q?34ywFR!N<Eyg@se2S5wsu`99o-vspHRyuKWw{o@D&8p{Vek@exEg!TGf)_f@xoiY;dF*q;nO?tB{k#CUu}GqOCr%Cvhi>XJp*SD42B^v$UK`TDGs}C*Bu!4#M$?xq6ZH{RcR9i70yjHb(#A5S4gsZk?i@}6i0<R!D5BQ2BrZyo*IZGydC<T4$*EBF#_rEM<_aqM<}|56`JK<nptm)igr=^x*4nBl9fZ%puYE4jTaZ2k!MJv&(Aztem}0@!_f*P&GQQng{I2")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9900
#import math

def main():
    H1, M1, H2, M2, K = tuple(int(c) for c in input().split(' '))

    dh = (H2 - H1) * 60
    dm = M2 - M1
    delta = dh + dm

    print(delta - K)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using T = tuple<ll,ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  while(K>0&&A>=B){
    B*=2;
    K--;
  }
  while(K>0&&B>=C){
    C*=2;
    K--;
  }
  if(B>A&&C>B){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
    

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

int main(void) {
    string S1, S2;
    cin >> S1 >> S2;

    if(S1.length()+1 != S2.length()) {
        cout << "No" << endl;
    } else if(S2.substr(0, S1.length()) == S1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
s = int(input())
MOD = 10**9 + 7
dp = [1 for _ in range(2005)]
dp[0] = dp[1] = dp[2] = 0
for i in range(6, s+1):
    dp[i] += sum(dp[3:i-2])
    dp[i] %= MOD
print(dp[s]%MOD)

Measured memory_bytes: 9196
n, k = map(int, input().split())
h = []
d = [0 for _ in range(n)]
ans = float('inf')

for _ in range(n):
    h.append(int(input()))
h = sorted(h)

for i in range(1, n):
    d[i] = d[i - 1] + h[i] - h[i - 1]

for i in range(n - k + 1):
    diff = d[i + k - 1] - d[i]
    ans = min(ans, diff)

print(ans)


Measured memory_bytes: 11060
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/




#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n, d; cin >> n >> d;
    vector<vector<int>> a(n, vector<int>(d, 0));
    rep(i, n) rep(j, d) cin >> a[i][j];

    int ans = 0;
    rep(i, n) {
        for(int j = i + 1; j < n; j++) {
            double tmp = 0;
            rep(k, d) {
                tmp += pow(abs(a[i][k] - a[j][k]), 2);
            }
            if(ceil(sqrt(tmp)) == sqrt(tmp)) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
H = [int(h) for h in input().split()]

dp = [0]*N
dp[1] = abs(H[0]-H[1])
for i in range(2, N):
    dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))
    
print(dp[-1])

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

int main()
{
  int N,T,A;
  cin >> N >> T >> A;
  
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }
  
  double maxhei = 999999;
  int place = 0;
  for(int i = 0; i < N; i++){
    double hei = A - (T - (h.at(i) * 0.006));
    if(hei > 0){
      if(hei < maxhei){
        maxhei = hei;
        place = i;
      }
    }else{
      hei = -hei;
      if(hei < maxhei){
        maxhei = hei;
        place = i;
      }
    }
  }
  
  cout << place+1 << endl;
  
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;

    ll a,b,c,n,x,y,z,cnt=0,sum=0;
        string str;
        cin>>n;
        if(n>=1 && n<=1000)cout<<1000-n;
        else if(n>1000 &&n<=2000)cout<<2000-n;
         else if(n>2000&&n<=3000)cout<<3000-n;
          else if(n>3000&&n<=4000)cout<<4000-n;
          else if(n>4000&&n<=5000)cout<<5000-n;
           else if(n>5000&&n<=6000)cout<<6000-n;
            else if(n>6000&&n<=7000)cout<<7000-n;
            else if(n>7000&&n<=8000)cout<<8000-n;
            else if(n>8000&&n<=9000)cout<<9000-n;
            else if(n>9000&&n<=10000)cout<<10000-n;


}




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

int main() {
  int a,b;
  cin >> a >> b;
  int ans = 0;
  
  if(a > b){
  	ans = a - 1;
  }else{
  	ans = a;
  }
cout << ans << endl;  
return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

which = s[0]
init_sum = 0
for i in range(1, n):
  if s[i] == which:
    init_sum += 1
  else:
    which = s[i]
    
print(min(init_sum + 2*k, n-1))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


const int maxn = 1e5 ;
vector<vector<int>>g(maxn+1);
vector<unordered_map<int,int>>dp(maxn+1);
vector<int>cnt(maxn+1);
vector<int>ans(maxn+1);
int n,M;
void dfs1(int u=1,int p=0)
{
	cnt[u]=1;
	vector<int>temp;
    vector<int>chil;
	for(auto v:g[u])
	{
		if(v!=p)
		{
			dfs1(v,u);
			temp.push_back(cnt[v]+1);
			chil.push_back(v);
		}
	}
	
	
	if( temp.size() )
	{
		vector<int>fdp=temp;
		vector<int>bdp=temp;
		int p;
		p=1;
		
		for(size_t i=0;i<temp.size();i++)
		{
			p*=temp[i];
			p%=M;
			fdp[i]=p;
		}
		p=1;
		for(int i=temp.size()-1;i>=0;i--)
		{
			p*=temp[i];
			p%=M;
			bdp[i]=p;
		}
		
		for(size_t i=0;i<temp.size();i++)
		{
			int p1 = ( i ? fdp[i-1] : 1);
			int p2 = ( i+1!=temp.size() ? bdp[i+1] : 1 );
			dp[u][ chil[i] ]=(p1*p2)%M;
		}
		cnt[u]*=bdp[0];
		cnt[u]%=M;
	}
	
}

void dfs2(int u=1,int p=0)
{
	//unordered_map<int,int>udp;
	//unordered_map<int,int>pdp;
	//int ucnt;
	//int pcnt;
	if( p )
	{
		// make yourself root
		
		//udp = dp[u];
		//pdp = dp[p];
		
		//ucnt = cnt[u];
		//pcnt = cnt[p];
		
		cnt[u] *= ( dp[p][u] + 1);
		cnt[u] %= M;
		for(auto &it:dp[u])
		{
			it.second *=  (dp[p][u]+1);
			it.second %=  M;
		}
		//dp[u][p]=ucnt;
		
		
	}
	// update yourself as root
	ans[u]=cnt[u];
	for(auto v:g[u])
	{
		if(v!=p)
		{
			dfs2(v,u);
		}
	}
	if( p )
	{
		// reform yourself
		//dp[u]=udp;
		//dp[p]=pdp;
		//cnt[u]=ucnt;
		//cnt[p]=pcnt;
	}
}
	
			
	
int32_t main()
{
	IOS
	cin >> n >> M;
	for(int i=1;i<n;i++)
	{
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	dfs1();
	//cout << dp[1][2] <<" "<< dp[1][3] <<" "<< dp[1][4] << endl;
	//cout << dp[3][2] << endl;
	dfs2();
	
	for(int i=1;i<=n;i++)
	cout << ans[i] << " ";
	cout<< endl;
}


Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
int ans[11111];
int main(void){
	for(int e=1;e<=100;e++){
		for(int p=1;p<=100;p++){
			for(int q=1;q<=100;q++){
				int rr = e*e+p*p+q*q+e*p+e*q+p*q;
				if(rr<11111) ans[rr]++;
			}
		}
	}
	int n;
	scanf("%d",&n);
	for(int e=1;e<=n;e++) printf("%d\n",ans[e]);
	return 0;
}


Measured memory_bytes: 3800
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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; }
int dp[110000][3]; int a[110000], b[110000], c[110000];
int main() {
    int N; cin >> N;
    rep(i,N) {
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i, N) {
        rep(j, 3) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] += a[0], dp[0][1] += b[0]; dp[0][2]+=c[0];
    rep(i, N) {
        if (i != 0) {
            chmax(dp[i][0], max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]));
            chmax(dp[i][1], max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]));
            chmax(dp[i][2], max(dp[i - 1][1] + c[i], dp[i - 1][0] + c[i]));
        }      
    }
   
    ll ans = max((ll)dp[N - 1][0], (ll)dp[N - 1][1]);
 
    ans = max(ans, (ll)dp[N - 1][2]);
    cout << ans << endl;
   
    
}





























































































































































































































































































































Measured memory_bytes: 2560
N, M, K = map(int, input().split())
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    F[a].append(b)
    F[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    B[c].append(d)
    B[d].append(c)


class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根(最初は全て根)
        self.par = [i for i in range(n)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * n
        # 人間の数
        self.size = [1] * n

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら、親の要素で再検索
        else:
            # 走査していく過程で親を書き換える(return xが代入される)
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)


UF = UnionFind(N)
for iam in range(N):
    for friend in F[iam]: 
        UF.union(iam, friend) # 自分と自分の友達を併合

ans = [UF.size[UF.find(iam)] - 1 for iam in range(N)] # 同じ集合に属する人の数

for iam in range(N):
    ans[iam] -= len(F[iam]) # すでに友達関係にある人達を引く

for iam in range(N):
    for block in B[iam]:
        if UF.same(iam, block): # ブロック関係にあったら引く
            ans[iam] -= 1

print(*ans, sep=' ')


Measured memory_bytes: 48448