akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
vector<int> G[100100];
int root;

int calc2(vector<int>& c, int k) {
    int L = (int)c.size();
    int lb = -1, ub = L;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        int max_len = 0;
        int l = 0, r = L-1;
        while (true) {
            if (l == mid) l++;
            if (r == mid) r--;
            if (l >= r) break;
            max_len = max(max_len, c[l] + c[r]);
            l++;
            r--;
        }
        if (max_len <= k) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return (ub == L ? inf : c[ub]+1); 
}

int calc(int v, int p, int k) {
    vector<int> c;
    for (int i = 0; i < (int)G[v].size(); i++) {
        int u = G[v][i];
        if (u != p) {
            c.push_back(calc(u, v, k));
        }
    }
    int L = (int)c.size();
    if (L == 0) return 1;
    sort(ALL(c));
    if (L % 2 == 0) {
        int max_len = 0;
        for (int i = 0; i < L / 2; i++) {
            max_len = max(max_len, c[i] + c[L-i-1]);
        }
        if (max_len <= k) return 1;
        if (c[L-1] > k) return inf;
        c.pop_back();
        return calc2(c, k);
    } else {
        return calc2(c, k);
    }
}

bool check(int k) {
    return calc(root, -1, k) <= k+1;
}

void solve() {
    int num_odd;
    root = -1;
    for (int i = 0; i < n; i++) {
        int d = (int)G[i].size();
        if (d % 2 == 1) {
            num_odd++;
            if (root < 0 && d == 1) root = i;
        }
    }

    int lb = 0, ub = n;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (check(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    cout << num_odd / 2 << " " << ub << endl;
}

void input() {
    cin >> n;
    int a, b;
    for (int i = 0; i < n-1; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 18176
a, b = list(map(int, input().split()))
g1 = [["#" for i in range(100)] for i in range(20)]
g2 = [["." for i in range(100)] for i in range(20)]

a, b = a-1, b-1
j = 0
while a!=0:
  for i in range(0, 100, 2):
    g1[j][i] = "."
    a -= 1
    if a==0:
      break
  j += 2

j = 1
while b!=0:
  for i in range(0, 100, 2):
    g2[j][i] = "#"
    b -= 1
    if b==0:
      break
  j += 2

g1.extend(g2)
print(40, 100)
for ele in g1:
  print("".join(ele))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s[12]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
  string t[5]={"","7","M7","m","m7"};
  string r[11]={"","-9","9","+9","-11","11","+11","","-13","13","+13"};
  int d[5][4]={{0,4,7,0},{0,4,7,10},{0,4,7,11},{0,3,7,0},{0,3,7,10}};
  int T;
  cin >> T;
  while(T--) {
    int n;
    cin >> n;
    vector<int> a(12,0);
    for(int i=0; i<n; i++) {
      string e;
      cin >> e;
      for(int j=0; j<12; j++) {
        if(s[j]==e) a[j]=1;
      }
    }
    vector<string> ans;
    for(int i=0; i<12; i++) {
      for(int j=0; j<5; j++) {
        vector<int> b(12,0);
        for(int k=0; k<4; k++) b[(i+d[j][k])%12]=1;
        if(a==b) {
          ans.push_back(s[i]+t[j]);
          continue;
        }
        for(int k=1; k<11; k++) {
          if(k==7) continue;
          int x=b[(i+k)%12];
          b[(i+k)%12]=1;
          if(a==b) ans.push_back(s[i]+t[j]+"("+r[k]+")");
          b[(i+k)%12]=x;
        }
        b[(i+7)%12]=0;b[(i+6)%12]=1;
        if(a==b) ans.push_back(s[i]+t[j]+"(-5)");
        b[(i+6)%12]=0;b[(i+8)%12]=1;
        if(a==b) ans.push_back(s[i]+t[j]+"(+5)");
      }
    }
    if(ans.size()) {
      for(int i=0; i<ans.size(); i++) {
        if(i) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    } else cout << "UNKNOWN" << endl;
  }
  return 0;
}


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

int main() {
    int A, B; cin >> A >> B;
    cout << (A * B % 2 == 1 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ac = 0, wa = 0, tle = 0, re = 0;
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (s.equals("AC")) ac++;
			if (s.equals("WA")) wa++;
			if (s.equals("TLE")) tle++;
			if (s.equals("RE")) re++;
		}
		System.out.format("AC x %d\n", ac);
		System.out.format("WA x %d\n", wa);
		System.out.format("TLE x %d\n", tle);
		System.out.format("RE x %d\n", re);
	}

}



Measured memory_bytes: 58012
use std::io;
fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> u32 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn main() {
    let N: u32 = to_i( &read_line() );

    let mut lines: Vec<String> = Vec::new();
    for i in 0..N {
        let line = read_line();
        let l = line.trim().to_string();
        lines.push(l);
    }
    for i in 1..N {

        let i0 = (i-1) as usize;
        let i1 = (i  ) as usize;
        let l0 = lines[i0].to_string();
        let l1 = lines[i1].to_string();
        let v0: Vec<char> = l0.chars().collect();
        let v1: Vec<char> = l1.chars().collect();
        let c0 = v0[v0.len()-1];
        let c1 = v1[0];
        //println!("{} {:?} {:?} {:?} {:?}", i, c0, c1, v0, v1);
        if (c0!=c1) {
            print!("No");
            return;
        }
        let mut j = i-1;
        while j>=0 {
            
            let l2 = lines[j as usize].to_string();
            if l2 == l1 {
                print!("No");
                return;
            }
            
            if j==0 {
                break;
            }
            j-=1;
        }
    }
    print!("Yes");
    

}   

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    ll ans = 0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans += __gcd(a,__gcd(b,c));
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3652
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, A, B;
	cin >> N >> A >> B;

	vector<lint> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	sort(h.begin(), h.end());

	auto biSearch = [&](auto f) {
		int ng = -1;
		int ok = h.back();

		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;

			if (f(mid)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	auto judge = [&](int idx) {

		lint ex = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] - B * idx > 0) ex += (h[i] - B * idx - 1) / (A - B) + 1;
			DMP(ex);
		}

		DMP(idx, ex);
		return ex <= idx;

	};

	cout << biSearch(judge) << "\n";

	return 0;
}

Measured memory_bytes: 1024
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math
import heapq

from scipy.sparse.csgraph import floyd_warshall

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

ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if i == N-1:
        break
    else:
        if A[i] + 1 == A[i+1]:
            ans += C[A[i]-1]

print(ans)


Measured memory_bytes: 25608
N,K=map(int,input().split())
x=[]

if N==1:
    a,b=map(int,input().split())
    print(a)
    exit()

for i in range(N):
    x.append(list(map(int,input().split())))

x.sort()
sum=0
for i in range(N):
    sum+=x[i][1]
    if sum>=K:
        print(x[i][0])
        exit()


Measured memory_bytes: 27872
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class ProblemA
	{
		private const int mask = (1 << 10) - 1;

		public static void Main(string[] args)
		{
			string[] line = Console.ReadLine().Split(' ');
			int h = int.Parse(line[0]);
			int w = int.Parse(line[1]);

			Queue<int> queue = new Queue<int>();
			int[,] panel = new int[h, w];

			for (int i = 0; i < h; i++)
			{
				string s = Console.ReadLine();
				for (int j = 0; j < w; j++)
				{
					if (s[j] == '.')
						panel[i, j] = 999;
					else
					{
						panel[i, j] = 0;
						queue.Enqueue(i + (j << 10));
					}
				}
			}

			int[] arrayX = new int[] { -1, 0, 1, 0 };
			int[] arrayY = new int[] { 0, -1, 0, 1 };

			int max = 0;

			while (queue.Count > 0)
			{
				int tmp = queue.Dequeue();
				int curX = (tmp >> 10) & mask;
				int curY = tmp & mask;
				int cur = panel[curY, curX];

				for (int i = 0; i < 4; i++)
				{
					int nextX = curX + arrayX[i];
					int nextY = curY + arrayY[i];
					if (nextX >= 0 && nextY >= 0 && nextX < w && nextY < h && panel[nextY, nextX] == 999)
					{
						panel[nextY, nextX] = cur + 1;
						max = Math.Max(cur + 1, max);
						queue.Enqueue(nextY + (nextX << 10));
					}
				}
			}

			Console.WriteLine(max);
		}
	}
}
 

Measured memory_bytes: 42476
import math

Q=int(input())
AB=[sorted(list(map(int,input().split()))) for i in range(Q)]

for A,B in AB:
    x=math.sqrt(A*B)
    y=int(x)
    if x!=y:
        y=int(x)
        if y*(y+1)<A*B:
            print(y*2-1)
        else:
            print(y*2-2)
    else:
        if A==B:
            print(y*2-2)
        else:
            print(y*2-3)

Measured memory_bytes: 3064
Q,H,S,D=map(int,input().split())
o=Q*8;h=H*4;s=S*2;d=D
N=int(input())*100
A=[0]*4;p=0;q=N
 
A=[[25,Q,o],[50,H,h],[100,S,s],[200,D,d]]
A.sort(key=lambda x: x[2])
 
#print(A)
 
i=0
while  q>0:
  if q%A[i][0]==0:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    break
  else:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    i=i+1
 
print(int(p))

Measured memory_bytes: 3064
house = []
4.times{house << Array.new(30, 0)}

n = gets.to_i

n.times do
    b, f, w, v = gets.split.map(&:to_i)
    house[b-1][10 * (f-1) + w-1] += v
end

i = 0
j = 0
house.each do |build|
    build.each do |floor|
        print " ", floor
        i += 1
        if i == 10
            puts
            i = 0
        end
    end
    puts "#"*20 if j < 3
    j += 1
end


Measured memory_bytes: 6888
#include <iostream>
#include <cstring>
#include <stack>

using namespace std;

int main()
{
    int n,m,p[1000],a,b,chart[100][100],temp,ans=0;
    memset(p,0,sizeof(p));
    memset(chart,0,sizeof(chart));
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++)
        {
            scanf("%d%d",&a,&b);
            p[a]++;p[b]++;
            chart[a][b]=chart[b][a]=1;
        }

    stack<int>s;

    for (int i=1;i<=n;i++) if (p[i]==1) s.push(i);
    while (!s.empty())
        {
            temp=s.top();
            s.pop();
            if (p[temp]==1)
                {
                    for (int i=1;i<=n;i++)
                        if (chart[temp][i]==1 && p[i]>0) { p[temp]--;p[i]--;if (p[i]==1) s.push(i);ans++;}

                }
        }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
from math import sqrt 


n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
d = []
for i in range(n):
    for j in range(i):
        dis = (l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2
        d.append(sqrt(dis))
print(sum(d)/n*2)
        



Measured memory_bytes: 3064
from itertools import combinations_with_replacement
import copy

def main(lst, K):
    original = copy.copy(lst)
    # 要するにC>B>Aになればおけ．
    comb = combinations_with_replacement([0, 1, 2], K)
    for c in comb:
        lst = copy.copy(original)
        for i in c:
            lst[i] *= 2
            if lst[0] < lst[1] and lst[1] < lst[2]:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    lst = list(map(int, input().split()))
    K = int(input())
    main(lst, K)

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#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 trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
int n,m;
vector<int> edges[100001];
vector<int> ans;

void bfs(int sv){
    vector<bool> visited(n,false);

    visited[sv]=true;
    queue<pair<int,int>> q;
    q.push({sv,0});

    while(!q.empty()){
        pii front=q.front();
        q.pop();

        ans[front.ff]=front.ss;

        for(auto ed: edges[front.ff]){
            if(!visited[ed]){
                visited[ed]=true;
                q.push({ed,front.ff});
            }
        }
    }
}
void solve()
{ 
    cin>>n>>m;

    forn(i,m){
        int idx1,idx2;
        cin>>idx1>>idx2;
        idx1--;
        idx2--;

        edges[idx1].pb(idx2);
        edges[idx2].pb(idx1);
    }
    ans.assign(n,-1);
    bfs(0);
    bool ans1=true;
    for(int i=1;i<n;i++){
        if(ans[i]==-1){
            ans1=false;
        }
    }

    if(!ans1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        for(int i=1;i<n;i++){
            cout<<ans[i]+1<<endl;
        }
        return;
    }
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 10476
def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    # print(exp_sum(n, k, P))
    mx = 0
    for i in range(k):
        mx += (P[i] + 1) / 2
    tmp = mx
    for i in range(k, n):
        tmp += (P[i] - P[i - k]) / 2
        mx = max(mx, tmp)
    print(mx)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24804
#include<bits/stdc++.h>
using namespace std;
int h[100005];
int ab(int a) {
    return a<0? -a : a;
}
int dp[100005];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) {
        cin >> h[i];
        dp[i] = 2e9;
    }
    dp[1]=0;
    for(int i=1;i<=n;i++) {
        dp[i+1]=min(dp[i+1],dp[i]+ab(h[i+1]-h[i]));
        dp[i+2]=min(dp[i+2],dp[i]+ab(h[i+2]-h[i]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;
int n,a[200005],mx,mxx;double mm=1e18;
int main(){
	scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]),mx=max(mx,a[i]);
	double t=mx/2.0;for(int i=1;i<=n;i++)if(a[i]!=mx&&fabs(a[i]-t)<mm)mm=fabs(a[i]-t),mxx=a[i];printf("%d %d\n",mx,mxx);

	return 0;
}


Measured memory_bytes: 768
#!/usr/bin/env python
# coding: utf-8


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def main():
    n = int(input())
    la = list(map(int, input().split()))
    la.sort()
    m = la[0]
    ans = pow(10, 9) + 1
    for a in la[1:]:
        g = gcd(a, m)
        if g < ans:
            ans = g
        if ans == 1:
            break
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 14228
#include <iostream>
long long N,M,a,i,m=1e9+7;long long f(int A){a=1;for(i=1;++i<=A;a=a*i%m);return a;}main(){std::cin>>N>>M;std::cout<<(M^N?M>N+1||M<N-1?0:1:2)*f(N)*f(M)%m;}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B,C,D=get_i
s1=A*B
s2=C*D
puts [s1,s2].max

Measured memory_bytes: 1788
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
ll a[maxn];
ll c[maxn];
int n, k;
struct node{
    ll v;
	int t;
    int id;
}d[maxn];

bool cmp(node f, node g){
    return f.v < g.v;
}

bool cmp1(node f, node g){
    return f.id < g.id;
}

int lowbit(int x){
    return x & (-x);
}

void add(int x, ll value){
    while(x < maxn){
        c[x] += value;
        x = x + lowbit(x);
    }
}

ll sum(int x){
    ll ans = 0;
    while(x > 0){
        ans += c[x];
        x = x - lowbit(x);
    }
    return ans;
}

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

    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        a[i] = a[i] - k;

    }
    for(int i = 1; i <= n; i++){
        d[i].v = d[i - 1].v + a[i];
        d[i].id = i;
    }
    d[0].v = 0;
    d[0].id = 0;
    sort(d, d + n + 1, cmp);
    int cnt = 0;
    for(int i = 0; i <= n; i++){
        if(i == 0 || d[i].v != d[i - 1].v){
            cnt++;
            d[i].t = cnt;
        }else d[i].t = d[i - 1].t;
    }
    sort(d, d + n + 1, cmp1);
    ll ans = 0;


    for(int i = 0; i <= n; i++){

       ans += sum(d[i].t);
       add(d[i].t, 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6528
import itertools

h, w, k = map(int, input().split())

kuro = []

for i in range(h):
    tmp = input()
    a = []
    for j in tmp:
        if j == '#':
            a.append(True)
        else:
            a.append(False)
        
    kuro.append(a)

ans=0
for i in range(h+1):
  for j in range(w+1):
    for n in itertools.combinations(list(range(h)),i):
      for m in itertools.combinations(list(range(w)),j):
        count = 0
        for a in n:
          for b in m:
            if(kuro[a][b]):count+=1
        if(count == k):
          ans += 1
print(ans)

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

int main() {
  int K, X;
  cin >> K >> X;
  
  int min = X - K + 1;
  int max = X + K - 1;

  if (min < -1000000) { min = -1000000; }
  if (1000000 < max) { max = 1000000; }

  for (int i = min; i <= max; i++) {
    cout << i;
    if (i != max) {
      cout << " ";
    }
    else {
      cout << endl;;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>

typedef long long int64;

int main(void) {
  int n, r;
  std::cin >> n >> r;

  if (n >= 10) {
    std::cout << r << std::endl;
  }
  else {
    std::cout << r + 100 * (10 - n) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=Number(r[1]),o=Number(r[2]),u=Number(r[3]),i=Number(r[4]),f=[t,n,o,u,i],l=0,c=0,a=0;a<5;a++){var d=(10-f[a]%10)%10;c+=d,d>l&&(l=d)}var p=t+n+o+u+i+c-l;console.log(p)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7372
#include<stdio.h>
int main()
{
int a,b,i,f=0;
scanf("%d",&a);
for(i=1;i<10;i++){
b=a/i;
if(b<10 && (b*i)==a){
f=1;
}
}
if(f==1){
printf("Yes\n");
} else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int x1,x2,x3,x4,x5;
    scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);

    if(x1==0){
        printf("1");
    }
    else if(x2==0){
        printf("2");
    }
    else if(x3==0){
        printf("3");
    }
    else if(x4==0){
        printf("4");
    }
    else{
        printf("5");
    }

    return 0;
}

Measured memory_bytes: 1608
#include<iostream>

using namespace std;

int main()
{
	int N;
	
	cin >> N;
	
	for(int n = 0;n < N;n++)
	{
		int tubeB = 0, tubeC = 0;
		bool ans = true;
		
		for(int i = 0;i < 10;i++)
		{
			int ball;
			cin >> ball;
			
			if(tubeB < ball) tubeB = ball;
			else if(tubeC < ball) tubeC = ball;
			else ans = false;
		}
		
		if(ans) cout << "YES\n";
		else cout << "NO\n";
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t[i];
  int ans = 0;
  rep(i,n) {
    int score = 0;
    rep(j,n) {
      if (s[i] == s[j]) score++;
    }
    rep(j,m) {
      if (s[i] == t[j]) score--;
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;
int main(){
  string s;
  cin>>s;
  int n=(int)(s.length());
  int even=0;
  int odd=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='L') odd++;
    }
    else{
      if(s[i]=='R') even++;
    }
  }
  if(odd==0 && even==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int ordena(const void *a, const void *b){
  return (*(int *)a)- (*(int *)b);
}

int vezes[224690];  //vezes que cada numero de a[i] apareceu;

int main (){

  int n,k,c=0,a;

  scanf("%d%d", &n,&k);

  for (int i = 0; i < n; i++){
    scanf("%d", &a);
    vezes[a-1]++;
  }

  qsort(vezes,n,sizeof(int), ordena);

  for(int i=0; i<n-k; i++)
    c+=vezes[i];

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


  return 0;
}


Measured memory_bytes: 1788
#include<cstdio>

int n,k,p;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&k,&p);
		int res=k%p;
		if(res==0)res=p;
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return abs(gcd(b,a%b));
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int k,x;cin>>k>>x;
    if(k*500>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
        


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll n;
  cin>>n;
  ll a[n];
  FOR(i,0,n-1){
    cin>>a[i];
  }

  sort(a,a+n);
  ll ans1 = a[n-1];
  ll ans2;
  ll min=99999999999;
  FOR(i,0,n-1){
    ll tmp = abs(ans1 -a[i]*2);
    if(tmp<min){
      min=tmp;
      ans2=a[i];
    }
  }

  cout<<ans1<<" "<<ans2<<endl;

  return 0;
}
 


Measured memory_bytes: 1024
x1, y1, x2, y2 = map(int,input().split())

a = x1 - x2
b = y1 - y2
x3 = x2 + b
y3 = y2 - a
x4 = x1 + b
y4 = y1 - a
print('{}  {}  {}  {}'.format(x3,y3,x4,y4))

Measured memory_bytes: 3060
N = int(input())
As = list(map(int,input().split()))
zoka = 0
before = As[0]
c = 1
for i in range(1,N):
    if before < As[i]:
        if zoka == 0 or zoka == 1:
            zoka = 1
        else:
            c+=1
            zoka = 0
        before = As[i]
    elif before > As[i]:
        if zoka == 0 or zoka == 2:
            zoka = 2
        else:
            c+=1
            zoka = 0
        before = As[i]
print(c)


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

int mod = 998244353;

int expo(int num, int p) {
    if(num == 0) {
        if(p == 0) return 1;
        return 0;
    }
    num = num % mod;
    int ret = 1;
    while(p) {
        if(p & 1) ret = (ret * num) % mod;
        num = (num * num) % mod;
        p /= 2;
    }
    return ret;
}

signed main() {
    IOS;
    int fact[200005], inv[200005];
    fact[0] = 1;
    for(int i = 1; i < 200005; ++i) fact[i] = (fact[i - 1] * i) % mod;
    for(int i = 0; i < 200005; ++i) inv[i] = expo(fact[i], mod - 2);
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    for(int i = 0; i <= k; ++i) {
        int cur = (m * expo(m - 1, n - i - 1)) % mod;
        cur = (cur * fact[n - 1]) % mod;
        cur = (cur * inv[i]) % mod;
        cur = (cur * inv[n - i - 1]) % mod;
        ans = (ans + cur) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6776
#include <stdio.h>

int main(){
    int k,i,j,a[1000],v,n;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
            for(k=0;k<n;k++){
            printf("%d",a[k]);
            if(k==n-1){printf("\n");}
            else{printf(" ");}
        } 
    for(i=1;i<n;i++){
        v=a[i];
        j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for(k=0;k<n;k++){
            printf("%d",a[k]);
            if(k==n-1){printf("\n");}
            else{printf(" ");}
        } 
    }
}





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

int main() {
	int a, b; cin >> a >> b; a--; b--;
	cout << "100 100" << endl;
	
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++) {
			if (a > 0 && i % 2 == 0 && j % 2 == 1) { cout << '.'; a--; }
			else cout << '#';
		}
		cout << endl;
	}
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++) {
			if (b > 0 && i % 2 == 1 && j % 2 == 1) { cout << '#'; b--; }
			else cout << '.';
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
const int maxn=200005;
int L[maxn],U[maxn];
int main(){
	int n,q,up,le;long long cnt;
	read(n),read(q);up=le=n;
	cnt=1ll*(n-2)*(n-2);
	for(int i=1;i<=q;++i){
		int a,b;read(a),read(b);
		if(a==1){
			if(b>le)
				cnt-=U[b]-2;
			else{
				cnt-=up-2;
				for(int j=le-1;j>b;--j)
					U[j]=up;
				le=b;
			}
		}
		else{
			if(b>up)
				cnt-=L[b]-2;
			else{
				cnt-=le-2;
				for(int j=up-1;j>b;--j)
					L[j]=le;
				up=b;
			}
		}
	}
	write(cnt),pc('\n');
	return 0;
}


Measured memory_bytes: 5144
s = int(input())
a = []
i = 1

while True:
	
	if i == 1:
		a.append(s)
	
	else:

		if a[-1] % 2 == 0:
			a.append(int(a[-1]/2))
		else:
			a.append(3 * a[-1] + 1)

	
	if a.count(a[-1]) >= 2:
		print(max([i for i, x in enumerate(a) if x == a[-1]]) + 1)
		exit()

	i += 1



Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
typedef greater<ll> g;

const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, c, k;
vector<ll> t;
priority_queue<ll, vector<ll>, g> que;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> c >> k;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        t.push_back(temp);
    }
    sort(ALL(t));
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        que.push(t[i] + k);
        if (!que.empty())
        {
            while (que.top() <= t[i])
            {
                int temp = que.top();
                ans++;
                for (int j = 0; j < c; j++)
                {
                    if (!que.empty() && que.top() - k <= temp)
                        que.pop();
                }
            }
        }
    }
    while (que.size() >= c)
    {
        ans++;
        for (int j = 0; j < c; j++)
        {
            que.pop();
        }
    }
    if (!que.empty())
        ans++;
    cout << ans << "\n";
}

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

			using ll = long long;
			using ld = long double;
			#define rep(i, a, n) for(ll i = (a); i < (n); i++)
			#define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
			#define F first
			#define S second
			#define endl "\n"
			#define all(x) begin(x),end(x)
			#define maxx(a, b) a = max(a, b)
			#define minn(a, b) a = min(a, b)
			#define db(x) cerr<<#x<<" = "<<x<<endl
			#define N 1111111
			#define mod 1000000007
			#define rt return
			#define inf 1234567891123456789ll

			using namespace std;
//			random_device rd;
//			mt19937 mt(rd());
//			using namespace __gnu_pbds;
//
//			typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

			#define error(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

			void err(istream_iterator<string> it) {}
			template<typename T, typename... Args>
			void err(istream_iterator<string> it, T a, Args... args)
			{
				cerr<<*it<<" = "<<a<<endl;
				err(++it, args...);
			}

			ll modlaber(ll a, ll m = mod)
			{
				rt ((a+m)%m+m)%m;
			}

			int main()
			{
				ios_base::sync_with_stdio(0);
				cin.tie(0);
				cout.tie(0);
				
				rep(i,1,6)
				{
					int j; cin>>j;
					if(j == 0)
						cout<<i;
				}

				rt 0;
			}





















Measured memory_bytes: 3652
s = input()
n = len(s)
for i in range(int((n-1)*0.5)):
    if s[i] != s[int((n-3)*0.5) - i] or s[i] != s[n-1 - i] or s[i] != s[int((n+1)*0.5) + i]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 const ll N = 200005;
 set<pll> s;
 vll adj[N];
bool done[N];
ll sum=0,mx=0;
void dfs(ll x){
    done[x] = 1;
    sum ++ ;
    for(auto y : adj[x]){
        if(!done[y]) dfs(y);
    }
}
int32_t main(){
    IOS;
    ll i,j,k,n,m,x,y;
    cin >> n >> m;
    fori(m){
        cin >> x >> y;
        s.insert({min(x,y),max(x,y)});
    }
    for(auto p : s){
        adj[p.F].pb(p.S);
        adj[p.S].pb(p.F);
    }
    fori2(n){
        if(!done[i]){
            sum = 0;
            dfs(i);
            mx = max(mx,sum);
        }
    }

    cout << mx <<"\n";
} 

Measured memory_bytes: 33592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n, w, h;
	cin >> n >> w >> h;
	vector<pii> v;
	REP(i, n)
	{
		int x, y; char d;
		cin >> x >> y >> d;
		if (d == 'W')
		{
			int rh = x;
			int r = y + rh;
			int l = y - rh;
			v.emplace_back(r, l);
		}
		if (d == 'N')
		{
			int rh = h - y;
			int r = h + x + rh;
			int l = h + x - rh;
			v.emplace_back(r, l);
		}
		if (d == 'E')
		{
			int rh = w - x;
			int r = h + w + (h - y) + rh;
			int l = h + w + (h - y) - rh;
			v.emplace_back(r, l);
		}
		if (d == 'S')
		{
			int rh = y;
			int r = h * 2 + w + (w - x) + rh;
			int l = h * 2 + w + (w - x) - rh;
			v.emplace_back(r, l);
		}
	}
	sort(ALL(v));
	int len = (h + w) * 2;
	int ans = INF;
	REP(i, n)
	{
		auto tv = v;
		REP(j, n)
		{
			if (tv[j].first < v[i].first)
			{
				tv[j].first += len;
				tv[j].second += len;
			}
		}
		sort(ALL(tv));
		int tmp = tv[0].first;
		int cnt = 1;
		REP(j, n)
		{
			if (tv[j].second > tmp)
			{
				tmp = tv[j].first;
				cnt++;
			}
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int t; cin >> t;
  while(t--){
    long long n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n,m,a,b) << endl;  
  }
  return 0;
}

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

int main()
{
    int b1[3][10] = {0}, b2[3][10] = {0}, b3[3][10] = {0}, b4[3][10] = {0};
    int n, b, f, r, v;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>b>>f>>r>>v;
        if(b==1)
        {
            b1[f-1][r-1]+=v;
        }
        else if(b==2)
        {
            b2[f-1][r-1]+=v;
        }
        else if(b==3)
        {
            b3[f-1][r-1]+=v;
        }
        else
        {
            b4[f-1][r-1]+=v;
        }
        
    }
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<10;j++)
        {
            cout<<' '<<b1[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<10;j++)
        {
            cout<<' '<<b2[i][j];
        }
        cout<<endl;
    }       
    cout<<"####################"<<endl;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<10;j++)
        {
            cout<<' '<<b3[i][j];
        }
        cout<<endl;
    }     
    cout<<"####################"<<endl;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<10;j++)
        {
            cout<<' '<<b4[i][j];
        }
        cout<<endl;
    }    
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int a[3][3];
  rep(i,3) rep(j,3){
    cin >> a[i][j];
  }
  int N; cin >> N;
  int b[N];
  bool bingo[3][3];
  rep(i,3){
    rep(j,3){
      bingo[i][j] = false;
    }
  }
  rep(i,N){
    cin >> b[i];
    rep(j,3){
      rep(k,3){
        if(a[j][k] == b[i]) bingo[j][k] = true;
      }
    }
  }
  rep(i,3){
    if(bingo[i][0] && bingo[i][1] && bingo[i][2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  rep(i,3){
    if(bingo[0][i] && bingo[1][i] && bingo[2][i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(bingo[0][0] && bingo[1][1] && bingo[2][2]){
    cout << "Yes" << endl;
    return 0;
  }
  if(bingo[2][0] && bingo[1][1] && bingo[0][2]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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


#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
 
deque<int> next_good(deque<int> s) {
    int p = sz(s) - 1;
    while (p >= 0 && s[p] == 9) {
        s[p] = 0;
        p--;
    }
    if (p == -1) {
        s.push_front(1);
    } else {
        s[p]++;
    }
    while (true) {
        int b = -1;
        rep(i, 0, sz(s) - 1) {
            if (abs(s[i] - s[i + 1]) > 1) {
                b = i;
                break;
            }
        }
        if (b == -1) {
            break;
        }
        if (s[b + 1] > s[b]) {
            s[b]++;
        }
        int lll = max(s[b] - 1, 0);
        rep(i, b + 1, sz(s)) {
            s[i] = lll;
            lll = max(lll - 1, 0);
        }
    }
    return s;
}
 
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;

    int k;
    cin >> k;
    deque<int> ans = {0};
    rep(i, 0, k) {
        ans = next_good(ans);
    }
    for (int i : ans) {
        cout << i;
    }
    cout << "\n";
    return 0;
}
 

Measured memory_bytes: 256
object Main {
    def main(args: Array[String]) = {
        val inf = Int.MaxValue-10000
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt)).toList
        val Array(v, _, r) = in.head
        val g = Array.fill(v)(inf).updated(r, 0)
        var flag = true
        while(flag) {
            var prev = g.clone
            for (b <- in.tail) if (g(b(0)) + b(2) < g(b(1))) g.update(b(1), g(b(0)) + b(2))
            flag = !(g sameElements prev)
        }
        g.foreach(n => if (n == inf) println("INF") else println(n))
    }
}

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

int main() {

    string c1,c2;

    cin >> c1 >> c2;

    if (c1[2] == c2[0] && c1[1] == c2[1] && c1[0] == c2[2]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

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

vector <long long> v[200005];
long long asd[200005];
long long asddd[200005];
bool e1[200005];
bool e2[200005];

void rt(int p, int o){
	for(int j = 0; j < v[p].size(); j++){
		asd[v[p][j]] += o;
		rt(v[p][j], asd[v[p][j]]);
	}
}

int main(){
	
	int n, q; 
	cin >> n >> q;
	for(int i = 0; i < n-1; i++){
		int f, g;
		cin >> f >> g;
		v[f].push_back(g);
		e1[f] = true;
		e2[g] = true;
	}
	int root = 1;
	while(root <= n){
		if(e1[root] && !e2[root]) break;
	}
	for(int i = 0; i < q; i++){
		int f;
		long long g;
		cin >> f >> g;
		asd[f] += g;
	}
	
	for(int j = 0; j < v[root].size(); j++){
		asd[v[root][j]] += asd[root];
		rt(v[root][j], asd[v[root][j]]);
	}
		
	for(int i = 1; i <= n; i++){
		printf("%lld ", asd[i]);
	}
	

	return 0;
}


Measured memory_bytes: 24704