akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];

  ll INF = 1e18;
  vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, INF));
  vector<vector<ll>> cost(N + 1, vector<ll>(N + 1, 0));
  for (ll i = 0; i < N; i++) {
    dp[i][i] = 0;
    dp[i][i + 1] = A[i];
  }
  dp[N][N] = 0;

  for (ll len = 2; len <= N; len++) {
    for (ll l = 0; l < N; l++) {
      ll r = l + len;
      if (r > N) break;

      cost[l][r] = INF;
      for (ll m = l; m < r; m++) {
        if (cost[l][r] > cost[l][m] + cost[m][r] + dp[l][m] + dp[m][r]) {
          cost[l][r] = cost[l][m] + cost[m][r] + dp[l][m] + dp[m][r];
          dp[l][r] = dp[l][m] + dp[m][r];
        }
      }
    }
  }

  cout << cost[0][N] << '\n';
  return 0;
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"

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

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];

	double ans = 0;
	rep(i, N)ans += (double)1 / A[i];
	cout << fixed << setprecision(15) << 1/ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
typedef long long ll;
int n,m,V,E,cnt[3],col[N];
bool vis[N],vise[N*2],colored;
ll ans;
struct node{
    int u,v,w,nxt;
}edge[N*2];
int head[N],mcnt=1;
void add_edge(int u,int v,int w){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].w=w;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
void dfs(int u)
{
	V++; vis[u]=true;
	cnt[col[u]]++;
	for(int i=head[u];i;i=edge[i].nxt){
        if(vise[i|1])
            continue ;
        vise[i|1]=1,E++;
        int v=edge[i].v,w=edge[i].w;
        if(!vis[v]){
            col[v]=(col[u]+w+3)%3;
            dfs(v);
        }
		else if((col[u]+w+3)%3!=col[v])
            colored=true;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add_edge(x,y,1);
		add_edge(y,x,-1);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			V=E=cnt[0]=cnt[1]=cnt[2]=colored=0;
			dfs(i);
			if(colored)
                ans+=1ll*V*V;
			else
                if(!cnt[0]||!cnt[1]||!cnt[2])
                    ans+=1ll*E;
			else
			ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[0]*cnt[2];
		}
	printf("%lld\n",ans);
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if((i+1) % 2 == 1){
            if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D'){
                Yes(0);
                exit(0);
            }
        } else {
            if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D'){
                Yes(0);
                exit(0);
            }
        }
    }
    Yes(1);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C,D;
cin >> A >> B >> C >> D;
if((A + B) > (C + D)){
cout << "Left" << endl;
}
if((A + B ) < ( C + D )){
cout << "Right" <<endl;
}
if((A+B) == (C + D)){
cout << "Balanced" <<endl;
}

}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define int long long
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 3e5 + 233;
struct Q {
  int l, r, id;
}a[N], b[N];
int n, ban[N];
inline bool cmp_l(Q a, Q b) {return a.l > b.l;}
inline bool cmp_r(Q a, Q b) {return a.r < b.r;}

inline int cal(int fff) {
  memset(ban, 0, sizeof ban);
  if(fff == 1) {
    for(int i = 1; i <= n; i ++) {
      a[i].l *= -1, a[i].r *= -1; swap(a[i].l, a[i].r);
      b[i].l *= -1, b[i].r *= -1; swap(b[i].l, b[i].r);
    }
  }
  sort(a + 1, a + n + 1, cmp_l);
  sort(b + 1, b + n + 1, cmp_r);
  int pos = 0, ans = 0;
  for(int i = 1, j = 1; i <= n && j <= n;) {
    while(ban[a[i].id]) ++ i;
    while(ban[b[j].id]) ++ j;
    if(b[j].r < pos) {
      ans += pos - b[j].r;
      pos = b[j].r;
      ban[b[j].id] = 1;
    }
    else if(a[i].l > pos) {
      ans += a[i].l - pos;
      pos = a[i].l;
      ban[a[i].id] = 1;
    }
    else break;
  }
  ans += abs(pos);
  return ans;
}

main(void) {
  read(n);
  for(int i = 1; i <= n; i ++) {
    int l, r; read(l); read(r);
    a[i] = b[i] = (Q) {l, r, i};
  }
  int t1 = cal(0);
  int t2 = cal(1);
  cout << max(t1, t2) << "\n";
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, m; cin >> n >> m;
  vector<vvll> dp(n+1, vvll(n+2, vll(m+1, 0)));
  dp[0][0][0] = 1;
  for(int i=0;i<n;++i) {
    for(int j=0;j<=n;++j) {
      for(int k=0;k<=m;++k) {
        int tmpk = k + 2 * j;
        if(0 <= tmpk && tmpk <= m) {
          dp[i+1][j][tmpk] += dp[i][j][k];
          dp[i+1][j][tmpk] %= MOD;
          dp[i+1][j+1][tmpk] += dp[i][j][k];
          dp[i+1][j+1][tmpk] %= MOD;
          dp[i+1][j][tmpk] += j * dp[i][j][k] % MOD;
          dp[i+1][j][tmpk] %= MOD;
          if(j > 0) dp[i+1][j-1][tmpk] += j * j % MOD * dp[i][j][k] % MOD;
          if(j > 0) dp[i+1][j-1][tmpk] %= MOD;
          dp[i+1][j][tmpk] += j * dp[i][j][k] % MOD;
          dp[i+1][j][tmpk] %= MOD;
        }
      }
    }
  }
  cout << dp[n][0][m] << endl;
}


Measured memory_bytes: 53120
# seishin.py
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

*S, = map(sum, P)
if any((S[0] - S[i]) % 2 for i in range(N)):
    print("-1")
    exit(0)

M = 31
A = 2**M-1
d = (S[0] & 1) ^ 1

U = []
if d:
    U.append(1)
    print(M+1)
else:
    print(M)
b = 1
for i in range(M):
    U.append(b)
    b <<= 1
print(*U)

C = "LDUR".__getitem__
for x, y in P:
    x -= d
    u = (x + y + A) >> 1
    v = (x - y + A) >> 1

    R = []
    if d:
        R.append("R")
    b = 1
    for k in range(M):
        R.append(C(2*(u & b > 0)+(v & b > 0)))
        b <<= 1
    print(*R, sep='')

Measured memory_bytes: 4692
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] rec = new int[N+1];
        for(int i=0;i<M;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            rec[a]++;
            rec[b]++;
        }
        for(int i=1;i<=N;i++){
            System.out.println(rec[i]);
        }
    }
}
 

Measured memory_bytes: 21844
import sys
from itertools import permutations

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def do_dp(N, Adj):
    univ = 2**N - 1
    dp = [[0]*N for i in range(univ + 1)]
    dp[1][0] = 1

    for S in range(2, univ + 1):
        for v in range(N):
            S2 = S & (univ ^ (1 << v))
            for u in range(N):
                if ((1 << u) & S2) and Adj[u][v]:
                    dp[S][v] += dp[S2][u]

    # debug(dp, locals())
    ans = sum(dp[univ][u] for u in range(1, N))

    return ans

def solve():
    N, M = map(int, input().split())
    Adj = [[0]*N for i in range(N)]

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

    ans = do_dp(N, Adj)

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main
{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = 2*r*pi;
        System.out.printf("%f %f",area,length);
        if(sc!=null){
            sc.close();
        }
    }
}


Measured memory_bytes: 28272
def solve():
    h, k = read()
    result = think(h, k)
    write(result)


def read():
    n, k = read_int(2)
    return read_int(n), k


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(h, k):
    cost = [0 for x in range(len(h))]
    for dst in range(1, len(h)):
        start_point = max(0, dst - k)
        cost[dst] = min([cost[src] + abs(h[src] - h[dst]) for src in range(start_point, dst)])
    return cost[len(h) - 1]


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 13928
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  string str;

  while(getline(cin,str)){
    int i, N = str.size();

    while(1){
      rep(i,N) if('a' <= str[i] && str[i] <= 'z'){
        str[i]--;
        if(str[i] < 'a') str[i] = 'z';
      }
      if(str.find("this") != -1 || str.find("the") != -1 || str.find("that") != -1){
        cout << str << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define Nmax 100
int main(){
  int p[2][25]={{}},N,i,j,k,id;
  int ans=0,br;
  scanf("%d",&N);
  for(i=2;i<=N;i++){
    id=i;
    for(j=2;j<i;j++){
      while(id%j==0){
        id/=j;
        for(k=0;k<25;k++){
          if(j==p[0][k]) p[1][k]++;
          if(j==p[0][k]) break;
        }
      }
      if(id==1)break;
    }
    if(id==i){
      br=0;
      for(j=0;j<25;j++){
        if(p[0][j]==0){
          br=1;
          p[0][j]=id;
          p[1][j]=1;
        }
        if(br)break;
      }
    }
  }
  for(i=0;i<25;i++){
    if(p[1][i]>=74) ans++;
    else break;
  }
  for(i=0;i<25;i++){
    if(p[1][i]>=24){
      for(j=0;j<25;j++){
        if(i==j)ans+=0;
        else if(p[1][j]>=2)ans++;
        else break;
      }
    }
    else break;
  }
  for(i=0;i<25;i++){
    if(p[1][i]>=14){
      for(j=0;j<25;j++){
        if(i==j)ans+=0;
        else if(p[1][j]>=4)ans++;
        else break;
      }
    }
    else break;
  }
  for(i=0;i<25;i++){
    if(p[1][i]>=4){
      for(j=i+1;j<25;j++){
        if(p[1][j]>=4){
          for(k=0;k<25;k++){
            if(k==i)ans+=0;
            else if(k==j)ans+=0;
            else if(p[1][k]>=2)ans++;
            else break;
          }
        }
        else break;
      }
    }
    else break; 
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b){return (0==b)?a:gcd(b,a%b);}
int main(void)
{
  ll T = 0;
  ll Ti = 0;
  ll ans = 0;
  scanf("%d", &T);
  scanf("%lld", &Ti);
  ans = Ti;
  while(--T)
  {
    scanf("%lld", &Ti);
    ll g = gcd(ans,Ti);
    ans = ans/g*Ti;
  }
  printf("%lld\n", ans);
  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL t,n,d,nn[3],c[3];
map <LL,LL> mp;
multiset <pii> q;
/*
LL dfs(LL x)
{
	if(x==0) return 0;
	if(x==1) return d;
	if(mp[x]>0) return mp[x];
	//if(vis[x]) return 1e18;
	vis[x]=1;
	//cout<<x<<' '<<mp.size()<<endl;
	LL ret=5e18;
	rep(ii,3)
	{
		LL i=nn[ii],tmp=x-x%i;
		if(!vis[tmp/i]) ret=min(ret,dfs(tmp/i)+min(c[ii]+x%i*d,abs(tmp/i-x)*d));
		if(x%i>0)
		{
			tmp=x-x%i+i;
			if(!vis[tmp/i]) ret=min(ret,dfs(tmp/i)+min(c[ii]+(i-x%i)*d,abs(tmp/i-x)*d));
		}
	}
	//cout<<x<<' '<<ret<<endl;
	//if(ret>=5e18) cout<<x<<endl;
	vis[x]=0;
	return mp[x]=ret;
}
*/
int main()
{
	nn[0]=2;
	nn[1]=3;
	nn[2]=5;
	cin>>t;
	while(t--)
	{
		cin>>n>>c[0]>>c[1]>>c[2]>>d;
		mp.clear();
		q.clear();
		mp[n]=0;
		q.insert(mpr(0,n));
		while(!q.empty())
		{
			LL x=q.begin()->se,y=q.begin()->fi;
			//cout<<x<<' '<<y<<endl;
			q.erase(q.begin());
			rep(ii,3)
			{
				LL i=nn[ii],tmp=x-x%i,tmp2=y+min(c[ii]+x%i*d,abs(tmp/i-x)<(LL)2e18/d ? abs(tmp/i-x)*d:(LL)2e18);
				if(tmp/i!=n&&(mp[tmp/i]==0||mp[tmp/i]>tmp2))
				{
					mp[tmp/i]=tmp2;
					q.insert(mpr(tmp2,tmp/i));
				}
				if(x%i>0)
				{
					tmp=x-x%i+i;
					tmp2=y+min(c[ii]+(i-x%i)*d,abs(tmp/i-x)<(LL)2e18/d ? abs(tmp/i-x)*d:(LL)2e18);
					if(tmp/i!=n&&(mp[tmp/i]==0||mp[tmp/i]>tmp2))
					{
						mp[tmp/i]=tmp2;
						q.insert(mpr(tmp2,tmp/i));
					}
				}
			}
			if(x==0) break;
		}
		//cout<<(int)(mp.find(0)==mp.end())<<endl;
		cout<<mp[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4404
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define v_in(v) for(auto&& i : v) cin >> i
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;


int main(void){
    FAST_IO
    ll x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll x_sabun = x2-x1;
    ll y_sabun = y2-y1;

    ll x3 = x2 - y_sabun;
    ll y3 = y2 + x_sabun;

    ll x4 = x3 - x_sabun;
    ll y4 = y3 - y_sabun;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 3164
require 'matrix'
loop do
  s = gets.chomp.chop
  break if s == ''

  #lookahead(?!  )
  s.gsub!(/([A-Z\)])(?![a-z\d])/, '\11')
  s.gsub!(/([A-Z][a-z])(?!\d)/, '\11')
  s.gsub!(/\((.+?)\)(\d*)/){
    as, n = $1, $2
    as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * n.to_i}"}
  }

  atoms = s.scan(/[A-Z][a-z]?/).uniq
  molecules = s.split('->').map{|ms| ms.split('+')}
  l = molecules[0].size
  molecules.flatten!
  m = molecules.size - 1
  n = atoms.size

  a = Matrix.build(n, m){|y, x|
    molecules[x].scan(/#{atoms[y]}(\d+)/).reduce(0){ |sum, a|
      x < l ? sum + a[0].to_i : sum - a[0].to_i
    }.to_r
  }.to_a

  b = [0] * n
  atoms.each do |atom|
    molecules[-1].scan(/(#{atom})(\d+)/).each{ |a, k|
      b[atoms.index(a)] = k.to_r
    }
  end

  # Gauss-Jordan elimination
  (0...[n,m].min).each do |i|
    pv = (i...n).max{|k| a[k][i].abs}
    a[i], a[pv] = a[pv], a[i]
    b[i], b[pv] = b[pv], b[i]
    (0...n).each do |j|
      next if i == j
      r = a[j][i] / a[i][i]
      (i...m).each do |k|
        a[j][k] -= r * a[i][k]
      end
      b[j] -= r * b[i]
    end
  end

  ans = (Matrix[*a[0,m]].inv * Vector[*b[0,m]]).to_a + [1.to_r]
  lcm = ans.map(&:denominator).reduce(&:lcm)
  puts ans.map{|x| (x * lcm).to_i} * ' '
end

Measured memory_bytes: 9924
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

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

        Arrays.sort(a);

        int half = n / 2;
        System.out.println(a[half] - a[half-1]);
    }
}

Measured memory_bytes: 52748
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def sub(a,b,c,d):
    x1 = a - (a - (c+1))//b * b
    if d<b:
        ans = "No"
    elif a<b:
        ans = "No"
    elif d%b==0:
        if x1>=b:
            ans = "Yes"
        else:
            ans = "No"
    else:
        k = gcd(d,b)
        x2 = x1 - (x1 - (c+1))//k * k
        if x2>=b:
            ans = "Yes"
        else:
            ans = "No"
    return ans

t = int(input())
ans = []
for i in range(t):
    a,b,c,d = map(int, input().split())
    ans.append(sub(a,b,c,d))
write("\n".join(ans))

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int count1 = count(s.begin(), s.end(), '1');
    cout << count1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;
#define total 10


int main (void){

	int height[total];
	for(int i=0;i<total;i++){
		cin>>height[i];
		while(height[i]<0||height[i]>10000){
			cin>>height[i];
		}
	}
	int temp=0;
	for(int i=0;i<total;i++){
		for(int j=i+1;j<total;j++){
			if(height[i]<height[j]){
				temp=height[i];
				height[i]=height[j];
				height[j]=temp;
			}
		}
	}
	cout<<height[0]<<endl<<
		height[1]<<endl<<
		height[2]<<endl;
}

Measured memory_bytes: 1160
n,m = map(int,input().split())
L = [[] for i in range(n)]
ans = [None]*m
l = [list(map(int,input().split())) for i in range(m)]

for i in range(len(l)):
  L[l[i][0]-1].append([l[i][1],i+1])
  
for ind,lis in enumerate(L):
  lis.sort()
  for j in range(len(lis)):
    ans[lis[j][1] - 1] = str(ind+1).zfill(6) + str(j+1).zfill(6)
    
print(*ans,sep = '\n')

Measured memory_bytes: 118928
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    char S[4];
    bool A = false, B = false, C = false;
    scanf("%s", S);
    for(char ch : S){
        if(ch == 'a') A = true;
        if(ch == 'b') B = true;
        if(ch == 'c') C = true;
    }
    if(A && B && C) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



// // 二分探索(最小値を出す問題は疑う)
// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < N; ++i){
// 		res += max(0ll, A[i]-x/F[i]);
//     }
//     return res <= K;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int len = S.length();
  int x= 0, y = 0;

  REP(i, len){
    if(S.at(i) == 'a' && x < A + B){
      x++;
      yes;
    }else if(S.at(i) == 'b' && x < A + B && y < B){
      x++;
      y++;
      yes;
    }else{
      no;
    }
  }


}


Measured memory_bytes: 896
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int N;
	sci(N);
	map<ll,ll> sum;
	map<ll,ll> sub;
	vi dat(N);
	for (int i = 0; i < N; ++i) {
		sci(dat[i]);
		++sum[i+dat[i]];
		++sub[i-dat[i]];
	}
	ll ans = 0;
	for (auto &it : sum) {
		ans += it.se * sub[it.fi];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 38216
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
    int n;
    int s = 8;
    cin >> n;
    for (int i = 4; i < 20; i += 2)
    {
        if (i * 100 <= n && n < (i + 2) * 100)
        {
            s = 8-(i - 4) / 2;
             printf("%d", s);
        }
    }
}


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

using namespace std;

const int md = 1e9 + 7;
using ll = long long;

ll solve(string &s, vector<vector<ll>> &memo, int offset = 0,
         bool is_less = false) {
  if (s.size() == offset) {
    return 1;
  }

  if (memo[offset][is_less] < 0) {
    char ch = s[offset];
    ll ans = 0;
    ans = (ans + solve(s, memo, offset + 1, is_less || ch == '1')) % md;
    if (ch == '1' || is_less) {
      ll res = (solve(s, memo, offset + 1, is_less) * 2) % md;
      ans = (ans + res) % md;
    }

    memo[offset][is_less] = ans % md;
  }

  return memo[offset][is_less];
}

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  vector<vector<ll>> memo(s.size(), vector<ll>(2, -1));
  cout << solve(s, memo) << '\n';
  return 0;
}

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

using namespace std;

typedef long long ll;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	char x, y;
	cin>>x>>y;
	if(x==y){
		cout<<'='<<'\n';
		return 0;
	}
	x<y ? cout<<'<'<<'\n' : cout<<'>'<<'\n';
	return 0;
}


Measured memory_bytes: 256
from collections import deque
def bfs(cur):
    q=deque()
    q.append(cur)
    while q:
        cur=q.popleft()
        for nx,e_dist in G[cur]:
            if ans[nx]!=-1:continue
            ans[nx]=(ans[cur]+e_dist)%2
            q.append(nx)

n=int(input())
G=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,w])
ans=[-1]*n
bfs(0)
print(*ans,sep='\n')

Measured memory_bytes: 46892
/****************************
 * ×÷Õß£ºzxf
 * ÈÕÆÚ£º
 * ±êÌâ£º
 * ÌâºÅ£º
 * ×öÌâ·½·¨£º
 * ½á¹û£º
 * Time used£º
 * Memory used£º
 ****************************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,k,a,b;
vector<int> nei[2007];
queue<int> q;
int juli[2007];

void bfs()
{
	while(!q.empty())
	{
		int v=q.front();
		int w=juli[v]+2;
		q.pop();
		for(int i=0;i<SZ(nei[v]);i++)
		{
			if(juli[nei[v][i]]<=w)continue;
			juli[nei[v][i]]=w;
			q.push(nei[v][i]);
		}
	}
}

int solvevertex(int what)
{
	FOR(i,n)
		juli[i]=Inf;
	juli[what]=0;
	q.push(what);
	bfs();
	int cnt=0;
	FOR(i,n)
		if(juli[i]>k)
			cnt++;
	return cnt;
}

int solveedge(int what1,int what2)
{
	FOR(i,n)
		juli[i]=Inf;
	juli[what1]=juli[what2]=1;
	q.push(what1);
	q.push(what2);
	bfs();
	int cnt=0;
	FOR(i,n)
		if(juli[i]>k)
			cnt++;
	return cnt;
}

int minn=Inf;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&a,&b);
		a--,b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	for(int v=0;v<n;v++)
		minn=min(minn,solvevertex(v));
	for(int v=0;v<n;v++)
		for(int u=0;u<SZ(nei[v]);u++)
			minn=min(minn,solveedge(v,nei[v][u]));
	printf("%d\n",minn);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int WW = Integer.parseInt(sc.next());
    int[] v = new int[N+1];
    int[] w = new int[N+1];
    for(int i=1; i<N+1; i++){
      v[i] = Integer.parseInt(sc.next());
      w[i] = Integer.parseInt(sc.next());
    }

    int[][] dp = new int[N+1][WW+1];
    for(int i=1; i<N+1; i++){
        dp[i][0] = 0;
    }
  
    for (int i=1; i<=N; i++) {
      for (int W=1; W<=WW; W++) {
        if(W>=w[i]){
            dp[i][W] = Math.max(dp[i-1][W], dp[i-1][W-w[i]] + v[i]);
        }else{
          dp[i][W] = dp[i-1][W];
        }
      
      }
    }
    System.out.println(dp[N][WW]);
  }
}

Measured memory_bytes: 30852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll n = (ll)s.length();
    if(n==1){
        cout << k / 2 << endl;
        return 0;
    }
    ll ans=0;
    bool same = true;
    rep(i, n - 1)
    {
        
        if(s[i]==s[i+1]){
            ans++;
            i++;
        }
    }
    rep(i, n)
    {
        if(s[i]!=s[0]){
            same = false;
            break;
        }
    }

    if(same){
        cout << n * k/2 << endl;
    }
    else if(s[0]!=s[n-1]){
        cout << ans * k << endl;
    }
    else{
        ll a=0;
        ll b = 0;
        rep(i,n){
            if(s[i]==s[0])
                a++;
            else
                break;
        }
        for (int i = n - 1; i >= 0;i--){
            if(s[i]==s[n-1])
                b++;
            else
                break;
        }
        if(a%2==1&&b%2==1){
            cout << ans * k+((a+b)/2-a/2-b/2)*(k-1) << endl;
        }
        else{
            cout << ans * k << endl;
        }
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int N;
string A,B,C;

// 文字a,b,cを等しくするのにかかる回数
int equate_char(char a, char b, char c)
{
  if (a == b && b == c) return 0;
  // 2つが同じ
  if (a == b && b != c) return 1;
  if (b == c && a != c) return 1;
  if (c == a && a != b) return 1;
  // 全て異なる
  return 2;
}

int main()
{
  cin >> N >> A >> B >> C;

  int ans = 0;
  REP(i,0,N) {
    ans += equate_char(A[i], B[i], C[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;
int a,b;
signed main(){
	 cin>>a>>b;
	 for(int i=1;i<111111;i++){
	 	int s=i*8/100;
	 	int t=i*10/100;
	 	if(s==a && t==b){
	 		cout<<i<<endl;
	 		return 0;
	 	}
	 }
	 cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 2048
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a;
        String s;
        a=scan.nextInt();
        s=scan.next();
        if(a<3200) System.out.println("red");
        else System.out.println(s);
    }
}

Measured memory_bytes: 21712
#define _GLIBCXX_DEBUG

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

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

template<typename T>
std::vector<T> slice(std::vector<T> const &v, int m, int n)
{
    auto first = v.cbegin() + m;
    auto last = v.cbegin() + n + 1;

    std::vector<T> vec(first, last);
    return vec;
}

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
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 (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

void Main() {
    //code here
    double r = gi;
    print(2*r * 3.1415926535);
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


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

"""
参考：https://pitsbuffersolution.com/compro/atcoder/arc089d.php
　　　http://tutuz.hateblo.jp/entry/2018/06/20/212752
　　　https://paiza.hatenablog.com/entry/2014/05/28/%E3%82%82%E3%81%97%E5%A5%B3%E5%AD%90%E5%A4%A7%E7%94%9F%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AB%E3%80%8E%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0%E3%80%8F%E3%82%92%E5%9B%B3
　　　http://www.learning-algorithms.com/entry/2018/01/31/144519
　　　https://img.atcoder.jp/arc089/editorial.pdf
・2次元累積和
・0-indexedのまま行くか1-indexedにするか人によって色々で、
　それぞれに考慮する点があると思った。
・とりあえず理解重視で、処理を分けて実装したから、このままだと多分pypyでもTLEかと。
"""

import sys
def input(): return sys.stdin.readline().strip()

N, K = map(int, input().split())

# K*2の正方形を右下まで動かすので、K*4まで作っておく
B = [[0] * (K*4+1) for i in range(K*4+1)]
for i in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    # 白に塗る条件はxかyにKずらして黒の条件にする(これで2色考えなくていい)
    if c == 'W':
        y += K
    # 循環するのでmod K*2でやる
    # 累積和でひとつ前を見に行くので、1-indexedにする
    B[x%(K*2)+1][y%(K*2)+1] += 1

for i in range(1, K*4+1):
    for j in range(1, K*4+1):
        # K*2からはみ出る範囲も正しく累積和を出すため、K*2までの値を循環させる
        # 1-indexedにしているため、ここの加減がややこしい
        B[i][j] = B[(i-1)%(K*2)+1][(j-1)%(K*2)+1]

# 2次元累積和を取る
# 1-indexedなので、気にせず1からループすればいい
for i in range(1, K*4+1):
    for j in range(1, K*4+1):
        B[i][j] += B[i][j-1]
for i in range(1, K*4+1):
    for j in range(1, K*4+1):
        B[i][j] += B[i-1][j]

# 2次元累積和に必要な4点の加減を行う
def get_sum(x1, y1, x2, y2, sm):
    # 1-indexedなので、x, yがマイナスの値になる考慮は必要ない
    res = sm[x2][y2] - sm[x1-1][y2] - sm[x2][y1-1] + sm[x1-1][y1-1]
    return res

ans = 0
for i in range(1, K*2+1):
    for j in range(1, K*2+1):
        # 1つ目の黒い正方形
        tmp = get_sum(i, j, i+K-1, j+K-1, B)
        # 2つ目の黒い正方形
        tmp += get_sum(i+K, j+K, i+K*2-1, j+K*2-1, B)
        ans = max(tmp, ans)
print(ans)


Measured memory_bytes: 166876
#include <bits/stdc++.h>
using namespace std;
 
int division(int n) {
  int count = 0;
  
  while (true) {
    if (n % 2 == 0) {
      n /= 2;
      count ++;
    } else {
      break;
    }
  }
  
  return count;
}
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  int ans = 0;
  
  for (int i : a) ans += division(i);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    vector<int> A(N);
    
    for(int i=0;i<N;i++)    cin >> A.at(i);
    
    sort(A.begin(),A.end());
    
    cout << A.at(N-1) - A.at(0) << endl;
}


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

#define TEST 0

using ll = long long;

#if TEST
static const ll N = ll(1e9) - 1;
#endif

bool cmp(ll a, ll b) {
	return (a <= b) == (to_string(a) <= to_string(b));
}

bool query(ll v) {
	assert(1 <= v && v <= ll(1e18));
	cout << "?" << ' ' << v << '\n' << flush;
	char c;
#if TEST
	c = "NY"[cmp(v, N)];
	cerr << c << '\n' << flush;
#else
	cin >> c;
#endif
	assert(c == 'Y' || c == 'N');
	return c == 'Y';
}

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

	ll mi = ll(1e8) - 1;
	ll ma = ll(1e9) - 1;
	while (ma - mi > 1) {
		ll md = (mi + ma) / 2;
		if (query(md * 10)) {
			ma = md;
		} else {
			mi = md;
		}
	}
	// it's a prefix of ma
	if (ma == ll(1e8)) {
		ma *= 10;
	}
	string s = to_string(ma);
	if (s[0] == '1') {
		s[0]++;
		mi = 0;
		ma = int(s.size());
		while (ma - mi > 1) {
			ll md = (mi + ma) / 2;
			if (query(stoll(s.substr(0, md)))) {
				ma = md;
			} else {
				mi = md;
			}
		}
		s[0]--;
		s = s.substr(0, ma);
	} else {
		s[0]--;
		mi = 1;
		ma = int(s.size())+1;
		while (ma - mi > 1) {
			ll md = (mi + ma) / 2;
			if (query(stoll(s.substr(0, md)))) {
				mi = md;
			} else {
				ma = md;
			}
		}
		s[0]++;
		s = s.substr(0, mi);
	}
	ll ans = stoll(s);
	cout << "!" << ' ' << ans << '\n';
#if TEST
	assert(ans == N);
#endif

	return 0;
}


Measured memory_bytes: 596
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        out.println((a-c)*(b-d));
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32944
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp
{
	bool operator() (pii a, pii b) {
		return (a.l < b.l);
	}
};

int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}



signed main()
{

// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	haha
	int x;
	cin >> x;
	cout << (x ^ 1);





}

Measured memory_bytes: 3628
from collections import deque

n, m = map(int, input().split())
plst = list(map(int, input().split()))
edges = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    edges[x].append(y)
    edges[y].append(x)
    
check = [False for _ in range(n)]
uni = [0 for _ in range(n)]
pos = 0
queue = deque()
for i in range(n):
    if check[i]:
        continue
    pos += 1
    queue.append(i)
    check[i] = True
    while queue:
        now = queue.popleft()
        uni[now] += pos
        uni[plst[now] - 1] -= pos
        for aft in edges[now]:
            if check[aft]:
                continue
            check[aft] = True
            queue.append(aft)
print(uni.count(0))

Measured memory_bytes: 33768
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n;
    long long an;
    long long a[100005];
    
    cin >> n;
    for (int i = 1;i <= n;i++){
        cin >> an;
        a[i] = 2*an;
    }
    
    long long res = 0;
    for (int i = 1;i <= n-1;i++){
        if (i%2 == 1){
            res += a[i];
        }
        else {
            res -= a[i];
        }
    }
    
    long long t[n+1];
    t[1] = (res+a[n])/2;
    cout << t[1] << " ";
    for (int i = 1;i < n;i++){
        t[i+1] = a[i] - t[i];
        cout << t[i+1] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2816