akhauriyash/Code-Regression huggingface dataset:
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N,X;
    cin>>N>>X;
    int A=0;
    vector<int>M(N);
    for(int i=0;i<N;i++){
        cin>>M[i];
        A+=M[i];
    }
    sort(M.begin(),M.end());
    int B=X-A;
    int C=B/M[0];

    cout<<N+C<<endl;


}


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

using namespace std;

const int N = 200002;
set<int> g[N];
map<int, int> cntA;
map<int, int> cntB;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        char cu = s[u];
        char cv = s[v];
        if (u != v) {
            if (g[u].count(v) == 0) {
                g[u].insert(v);
                g[v].insert(u);
                if (cu == 'A') {
                    cntA[v]++;
                } else {
                    cntB[v]++;
                }
                if (cv == 'A') {
                    cntA[u]++;
                } else {
                    cntB[u]++;
                }
            }
        } else {
            if (cu == 'A') {
                cntA[u]++;
            } else {
                cntB[u]++;
            }
        }
    }

    vector<int> q;
    vector<int> done(n, 0);
    for (int i = 0; i < n; i++) {
        q.push_back(i);
    }
    while(!q.empty()) {
        int curr = q.back();
        q.pop_back();
        if (done[curr]) continue;
        if (cntA[curr] == 0 || cntB[curr] == 0) {
            for (int next: g[curr]) {
                if (next != curr) {
                    q.push_back(next);
                    done[next] = 0;
                    g[next].erase(curr);
                    if (s[curr] == 'A') {
                        cntA[next]--;
                    } else {
                        cntB[next]--;
                    }
                }
            }
            g[curr].clear();
        }
        done[curr] = 1;
    }

    for (int i = 0; i < n; i++) {
        if (!g[i].empty()) {
            /*for (int i = 0; i < n; i++) {
                for (int next : g[i]) {
                    cout << i << " " << next << endl;
                }
            }*/
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
    return 0;
}


Measured memory_bytes: 40652
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner Sc=new Scanner(System.in);
    int n=Sc.nextInt();
    int m=Sc.nextInt();
    int sum=0;
    for(int i=0;i<m;i++)
      sum=sum+Sc.nextInt();
   	if(n-sum>=0)
    	System.out.println(n-sum);
    else
    	System.out.println("-1");
  }
}


Measured memory_bytes: 46236
n, m = gets.chomp.split(" ").map(&:to_i)
a = []
b = []

m.times do 
  ai, bi = gets.chomp.split(" ").map(&:to_i)
  a << ai
  b << bi
end

class UnionFind
  def initialize(n)
    @n = n
    @par = Array.new(@n+1){|i| i}
    @rank = Array.new(@n+1, 0)   
    @c = Array.new(@n+1, 1) 
  end

  def find(x)
    if @par[x] == x
      return x
    else 
      @par[x] = find(@par[x])
      return @par[x]
    end
  end

  def unite(x, y)
    x = find(x)
    cx = @c[x]
    y = find(y)
    cy = @c[y]
    if @rank[x] < @rank[y]
      @par[x] = y
      @c[y] = cx + cy
    else
      @par[y] = x
      @c[x] = cx + cy
      if @rank[x] == @rank[y]
        @rank[x] += 1
      end
    end
    return cx * cy
  end

  def same(x, y)
    return find(x) == find(y)
  end
end


uf = UnionFind.new(n)

ans = Array.new(m+1)
ans[m] = n * (n - 1) / 2

(m-1).downto(0) do |i|
  ai = a[i]
  bi = b[i]
  if uf.same(ai, bi)
    ans[i] = ans[i + 1]
  else
    u = uf.unite(ai, bi)
    ans[i] = ans[i + 1] - u
  end
end

puts ans[1..m]


Measured memory_bytes: 7700
#include <cstdio>
#include <iostream>
 
struct xyz{int x; int y; int z;};
int N, Y;
 
xyz solve(struct xyz ans){
    int deff = N - (ans.x + ans.y + ans.z);
    if(Y%1000 || deff<0){
        ans.x = ans.y = ans.z = -1;
        return ans;
    }
 
    if(deff/9){
        for(int i=0; i<deff/9; i++){
            if(ans.x==0)break;
            ans.x--;
            ans.z += 10;
        }
    }
 
    deff = N - (ans.x + ans.y + ans.z);
    if(deff/5){
        for(int i=0; i<deff/5; i++){
            if(ans.x==0)break;
            ans.x--;
            ans.y++;
            ans.z += 5;
        }
    }
 
    deff = N - (ans.x + ans.y + ans.z);
    if(deff/4){
        for(int i=0; i<deff/4; i++){
            if(ans.y==0)break;
            ans.y--;
            ans.z += 5;
        }
    }
 
    deff = N - (ans.x + ans.y + ans.z);
    if(deff){
        for(int i=0; i<deff; i++){
            if(ans.x==0)break;
            ans.x--;
            ans.y += 2;
        }
    }
 
    deff = N - (ans.x + ans.y + ans.z);
    if(deff>0) ans.x = ans.y = ans.z = -1;
 
    return ans;
}
 
int main(void){
    scanf("%d%d", &N, &Y);
 
    xyz ans;
    ans.x = Y/10000;
    ans.y = (Y%10000)/5000;
    ans.z = (Y%5000)/1000;
 
    ans = solve(ans);
 
    printf("%d %d %d\n", ans.x, ans.y, ans.z);
    return 0;
}

Measured memory_bytes: 256
s = str(input())
z = 'Yes'
for i in range(len(s)):
    if i%2 == 0:
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
            z = 'No'
            break
    else:
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            z = 'No'
            break
print(z)

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

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  int d[100];
  int idx=0;
  for(int i=100;i>0;i--){
    if(a%i==0&&b%i==0){
      d[idx]=i;
      idx++;
    }
  }
  cout<<d[k-1]<<endl;
  }


Measured memory_bytes: 256
<?php

$N = trim(fgets(STDIN));

$equal_count = 0;
for ($i = 0; $i < $N; $i++) {
    $in = trim(fgets(STDIN));
    $item = explode(' ', $in);

    if ($item[0] == $item[1]) {
        $equal_count++;
        if($equal_count == 3){
            echo 'Yes';
            return;
        }
    }else{
        $equal_count = 0;
    }

}
echo 'No';

Measured memory_bytes: 16276
def slove():
    import sys
    input = sys.stdin.readline
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    t = 0
    for i in range(1, len(a)):
        t += abs(a[i] - a[i-1])
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int K;
    cin >> K;
    
    if(K%2==1){
        cout << (K/2) * (K/2+1) << endl;
    }else{
        cout << (K/2) * (K/2) << endl;
    }

    return 0;

}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    s=chomp(readline())*"あ"
    cnt=0
    for i in 1:n
        if s[i]!=s[i+1]
            cnt+=1
        end
    end
    println(cnt)
end
main()

Measured memory_bytes: 108552
N = int(input())
L = [0] * (10 ** 4 + 1)

for a in range(1, 10 ** 2):
    for b in range(1, 10 ** 2):
        for c in range(1, 10 ** 2):
            num = a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a
            if num <= 10 ** 4:
                L[a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a] += 1

for i in range(1, N+1):
    print(L[i])

Measured memory_bytes: 9296
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	string s;
	cin>>s;
	int mi=INT_MAX;
	for(int i=0;i<=s.size()-3;i++){
		int a=s[i]-'0',b=s[i+1]-'0',c=s[i+2]-'0';
		int nu=a*100+b*10+c;
		mi=min(mi,abs(753-nu));
	}
	cout<<mi<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

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

	Int N, a, b, c;
	cin >> N >> a >> b >> c;

	vector<Int> l(N);
	for (Int i = 0; i < N; i++) {
		cin >> l[i];
	}

	Int mpa = 0;
	Int mpb = 0;
	Int mpc = 0;
	Int lena = 0;
	Int lenb = 0;
	Int lenc = 0;
	Int tempa = 0;
	Int tempb = 0;
	Int tempc = 0;
	Int ans = INF;
	for (Int bita = 1; bita< (1LL<<N); bita++) {
		mpa = 0;
		lena = 0;
		for (Int i = 0; i < N; i++){
				if (bita & (1LL<<i)) {
					mpa += 10;
					lena += l[i];
				}
		}
		mpa -= 10;

		for (Int bitb = 1; bitb < (1LL<<N); bitb++) {
			if (bita & bitb)continue;
			mpb = 0;
			lenb = 0;
			for (Int i = 0; i < N; i++) {
				if (bitb & (1LL << i)) {
					mpb += 10;
					lenb += l[i];
				}
			}
			mpb -= 10;

			for (Int bitc = 1; bitc < (1LL<<N); bitc++) {
				if (bita & bitc)continue;
				if (bitb & bitc)continue;
				mpc = 0;
				lenc = 0;
				for (Int i = 0; i < N; i++) {
					if (bitc & (1LL << i)) {
						mpc += 10;
						lenc += l[i];
					}
				}
				mpc -= 10;
				
				vector<Int> len = { lena,lenb,lenc };
				
				for (Int i = 0; i < 3; i++) {
					for (Int j = 0; j < 3; j++) {
						if (i == j)continue;
						for (Int k = 0; k < 3; k++) {
							if (k == i)continue;
							if (k == j)continue;
							tempa = mpa;
							tempb = mpb;
							tempc = mpc;

							tempa += abs(a - len[i]);
							tempb += abs(b - len[j]);
							tempc += abs(c - len[k]);

							ans = min(ans, tempa + tempb + tempc);
						}
					}
				}
			}
		}
	}
	cout << ans << endl;

}

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

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    set<string> sub;
    int len = 0;
    while (s.size() >= len && len <= 5) {
        for (int i = 0; i <= s.size() - len; i++) {
        string s_ = s.substr(i, len);
        sub.insert(s_);
        }
        len++;
    }
    set<string>::iterator it = sub.begin();
    while (K > 0) {
        it++; K--;
    }
        cout << *it << '\n';
}



Measured memory_bytes: 1664
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    copy_n(istream_iterator<string>(cin), h, s.begin());
    for(int i = 1; i < h - 1; i++){
        for(int j = 1; j < w - 1; j++){
            if(s[i][j] == '.')
                continue;
            bool can = false;
            if(s[i - 1][j] == '#')
                can = true;
            if(s[i + 1][j] == '#')
                can = true;
            if(s[i][j + 1] == '#')
                can = true;
            if(s[i][j - 1] == '#')
                can = true;
            if(!can){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    /*
    for(int i = 1; i < h; i++){
        if(s[i - 1][j] != s[i][j])
    }
    */
    cout << "Yes" << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    string S;
    cin >> S ;
    int N;
    N =S.size();
    rep2(i,N){
        if((i%2)==0){
            if(S[i-1]=='R'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i-1]=='L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
    

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int n,m;
int p[11],c[11];

int main()
{
    while (scanf("%d%d",&n,&m)!=EOF)
    {
        m=m/100;
        for (int i=1;i<=n;i++)
        {
            scanf("%d%d",&p[i],&c[i]);
            c[i]/=100;
        }
        int ans=1e8;
        for (int i=0;i<(1<<n);i++)
        {
            int num=0,tot=0;
            for (int j=0;j<n;j++)
                if (i&(1<<j)) 
                    num+=p[j+1],tot+=c[j+1]+p[j+1]*(j+1);

            if (tot<m)
            {
                for (int j=n-1;j>=0;j--)
                {
                    if (!(i&(1<<j)))
                    {
                        int k=(m-tot)/(j+1);
                        if ((m-tot)%(j+1)!=0) k++;
                        if (k>p[j+1])
                            num+=p[j+1],tot+=c[j+1]+p[j+1]*(j+1);
                        else
                            num+=k,tot+=c[j+1]*k*(j+1);
                    }
                    if (tot>=m) break;
                }
            }
            ans=min(ans,num);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll A[100100],B[100100],C[100100];
    ll cnt[100100];
    Fill(cnt, 0);
    ll S = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        S += A[i];
        cnt[A[i]]++;
    }
    ll Q; cin >> Q;
    for(int i=0;i<Q;i++){
        cin >> B[i] >> C[i];
    }
    for(int i=0;i<Q;i++){
        S += cnt[B[i]] * (C[i] - B[i]);
        cnt[C[i]] += cnt[B[i]];
        cnt[B[i]] = 0;
        cout << S << "\n";
    }
    return 0;
}

Measured memory_bytes: 6764
#include<string>
#include<stdio.h>
#include<iostream>
using namespace std;
int n, m;
int a[105];
int sum;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		for(int j=i+1;j<n;j++)
		sum += a[i] * a[j];
	};
	cout <<sum << endl;
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


#define BOOST        ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define AZ(x)        x.begin(),x.end()
#define fi           first
#define se           second
#define pb           push_back
#define emp          emplace_back
#define mp           make_pair
#define mt           make_tuple
#define debug(x)     cerr << #x << " : " << x << endl;
#define For(i,a,n)   for(auto i = a; i < n; i++)


template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;

typedef long long ll;
typedef long double ld;


template<typename T>
// for super_map add a parameter Y above and replace "null_type" with "Y"

// set with two additional super powers
    // find_by_order(int k) - returns k'th smallest element (0-indexed)
    // order_of_key(int k) - returns number of elements strictly smaller than k.
using super_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


const int mod = 1e9+7, N = 1e5+5;
const ll INF = 1e18;



ll power(ll a,ll b)
{
    a = a%mod;
    ll result = 1;

    while(b)
    {
        if(b&1)
            result = (result*a)%mod;
        b >>= 1, a = (a*a)%mod;
    }
    return result;
}

ll super_rand(ll n) // Random number from set [0,n-1]
{
    uniform_int_distribution<ll> uid(0, n - 1);
    return uid(rng);
}



/*



1. Make sure you're taking all the inputs.
2. In case of nested loops, remember to use different variables.
3. If in doubt, do int -> ll
4. Don't fight the question, try solving the next one.
5. ffs (positon of first set bit), clz (leading 0s, max->32), ctz (trailing 0s), popcount (set bits). Don't use any of these on 0;



*/



// Don't code anything above this //

ll n,fen[2*N];

void update(ll h, ll b)
{
    for(; h <= n; h += (h & (-h)))
        fen[h] = max(fen[h], b); 
}

ll query(ll h)
{
    ll ans = 0;
    for(; h >= 1; h -= (h & (-h)))
        ans = max(ans,fen[h]);
    return ans;
}

int main()
{
    BOOST   

    cin >> n;

    ll h[n+1],a[n+1];

    for(int i = 1; i <= n; i++)
        cin >> h[i];

    for(int i = 1; i <=n; i++ )
        cin >> a[i];

    ll dp[n+1] = {};       // dp[i] : max beauty till ith flower

    for(int i = 1; i <= n; i++)
    {
        dp[i] = a[i];
        if(h[i] > 1)
            dp[i] += query(h[i]-1);
        update(h[i],dp[i]);
    }

    for(int i = 1; i <= n; i++)
        dp[0] = max(dp[0],dp[i]);
    cout << dp[0] << "\n";
    // cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

    

Measured memory_bytes: 6528
#include <iostream>
#include <cstring>

using namespace std;


int dp[20][20];

int main() {

  int a,b;
  int n;
  
  int x,y;
  bool con[20][20];


  while(cin >> a >> b,a || b) {

    cin >> n;

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

      for(int j=0;j<b;j++) {

	con[j][i]=false;

      }

    }

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

      cin >> x >> y;

      con[y-1][x-1]=true;

    } 

    memset(dp,0,sizeof(dp));

    dp[0][0]=1;

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

      for(int j=0;j<b;j++) {

	if(i!=0 && con[j][i-1]==false) dp[i][j]+=dp[i-1][j];

	if(j!=0 && con[j-1][i]==false) dp[i][j]+=dp[i][j-1];

      }

    }

    cout << dp[a-1][b-1] << endl;

  }

  return 0;

}

  

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;

string s,t;
cin>>s;
cin>>t;

rep(i,N){
    cout<<s[i]<<t[i];
}

return 0;

}
/*
2
ip cc

icpc
*/


Measured memory_bytes: 256
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>

class UnionFind {

public:
	using size_type = std::uint_fast32_t;

private:
	std::vector<std::pair<bool, size_type>> tree;

public:
	UnionFind(const size_type size) : tree(size, std::make_pair(1, 1)) {}
	size_type find(const size_type x) {
		assert(x < size());
		if (tree[x].first)
			return x;
		return tree[x].second = find(tree[x].second);
	}
	bool unite(size_type x, size_type y) {
		assert(x < size());
		assert(y < size());
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x].second < tree[y].second)
			std::swap(x, y);
		tree[x].second += tree[y].second;
		tree[y] = std::make_pair(0, x);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return tree[find(x)].second;
	}
	size_type size() const noexcept { return tree.size(); }
	bool empty() const noexcept { return tree.empty(); }
};

#include <cstddef>
#include <functional>
#include <utility>
#include <vector>

template <class GraphContainer, class UnionFindDataStructure>
std::vector<typename GraphContainer::size_type> TarjansOfflineLCA(
	const GraphContainer &graph, const typename GraphContainer::size_type root,
	const std::vector<std::pair<typename GraphContainer::size_type,
	typename GraphContainer::size_type>> &queries) {
	using size_type = typename GraphContainer::size_type;
	const size_type size_ = graph.size();
	UnionFindDataStructure uft(size_);
	std::vector<size_type> ret(queries.size(), size_), anc(size_);
	std::vector<std::vector<std::size_t>> qset(size_);

	for (std::size_t i = 0; i < queries.size(); ++i) {
		qset[queries[i].first].emplace_back(i);
		qset[queries[i].second].emplace_back(i);
	}

	std::function<void(const size_type, const size_type)> dfs =
		[&](const size_type v, const size_type prev) {
		anc[v] = v;
		for (const auto &e : graph[v]) {
			if (e.to != prev) {
				dfs(e.to, v);
				uft.unite(v, e.to);
				anc[uft.find(v)] = v;
			}
		}
		for (const auto e : qset[v])
			if (ret[e] == size_)
				ret[e] = v;
			else
				ret[e] = anc[uft.find(ret[e])];
	};
	dfs(root, size_);
	return ret;
}


#include <cstddef>
#include <vector>

struct edge {
	using cost_type = int;
	using size_type = std::size_t;

	std::size_t to;
	edge(size_type t):to(t){}
};

template <class Edge> using Graph = std::vector<std::vector<Edge>>;

#include<cstdio>
int main() {
	using uint = unsigned int;
	uint n;
	scanf("%u", &n);
	Graph<edge> g(n);
	for (uint i = 0;i < n;++i) {
		uint k, c;
		scanf("%u", &k);
		while (k--) {
			scanf("%u", &c);
			g[i].emplace_back(c);
		}
	}
	uint q;
	scanf("%u", &q);
	using S = typename Graph<edge>::size_type;
	std::vector<std::pair<S, S>> Q;
	Q.reserve(q);
	while (q--) {
		uint u, v;
		scanf("%u%u", &u, &v);
		Q.emplace_back(u, v);
	}
	const auto &&ans=TarjansOfflineLCA<Graph<edge>, UnionFind>(g, 0, Q);
	for (const auto e : ans)
		printf("%u\n", e);
	return 0;
}


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

int64_t gcd(int64_t a, int64_t b) {
    return b ? gcd(b, a % b) : a;
}

int64_t lcm(int64_t a, int64_t b) {
    return a / gcd(a, b) * b;
}

int main() {

    int64_t A, B;
    int64_t C, D;
    std::cin >> A >> B >> C >> D;

    int64_t a = (A - 1) / C + (A - 1) / D - (A - 1) / lcm(C, D);
    int64_t b = B / C + B / D - B / lcm(C, D);
    int64_t ans = (B - A + 1) - (b - a);
    std::cout << ans << std::endl;

}

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

const ll INF = pow(10, 9) + 7;

int main() {
  ll a,b;
  cin >> a >> b;
  if(a>b) swap(a,b);
  vector<ll> aa;
  for(ll i = 1;i*i<=a;i++){
    if(a%i==0){
      aa.push_back(i);
      aa.push_back(a/i);
    }
  } 
  ll g = 1;
  rep(i,aa.size()){
    if(b%aa[i]==0) g=max(g,aa[i]);
  }
  //cout << g << endl;
  cout << a*b/g << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        bool ok = 1;
        for(int i = 0; i < s.size() / 2; i++){
            if(s[i] != s[s.size() - i - 1]){
                ok = 0;
                break;
            }
        }
        cnt += ok;
    }
    cout << cnt;
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	for(int i=0;i*4<=n;++i){
		if((n-i*4)%7==0){
			cout<<"Yes\n"s;
			return 0;
		}
	}
	cout<<"No\n"s;
}


Measured memory_bytes: 3632
package main

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

func main() {
	scan_init()
	n := scanInt()
	k := scanInt()
	a := make([]int, n)
	aFlags := make([]bool, n)
	costA := make([]int,n)
	for i:= 0; i<n; i++ {
		a[i] = scanInt()-1
	}
	queue := []int{0}
	cost := 0
	start := 0 // startIndex
	end := 0
	aFlags[0] = true
	for len(queue)>0{
		var take int
		take, queue = shift(queue)
		costA[take] = cost
		cost ++
		next := a[take]
		if !aFlags[next] {
			aFlags[next] = true
			queue = append(queue,next)
		} else {
			end = take
			start = next
		}
	}
	length := costA[end] - (costA[start]) +1
	// amari := int(uint64(k)%length64)
	// fmt.Println(amari)
	// fmt.Println(costA, start, end, length, k)
	if a[0] == 1 {
		fmt.Println(1)
	}else if k<1000000 || length == 0 {
		take := 0
		// fmt.Println(length)
		for i:=0;i<k; i++ {
			take = a[take]
		}
		fmt.Println(take+1)
	} else {
		amari := int(uint64(k-costA[start])%uint64(length))
		take := start
		for i:=0; i<amari;i++{
			take =a[take]
		}
		fmt.Println(take+1)
	}

}
var sc = bufio.NewScanner(os.Stdin)
func scan_init () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
func scan () string{
 sc.Scan()
	return sc.Text()
}
func pop(slice []int) (int, []int) {
	n := len(slice)
	value := slice[n-1]
	popSlice := slice[0:n-1]
	return value, popSlice
}
func shift(slice []int) (int, []int){
	n := len(slice)
	value := slice[0]
	popSlice := slice[1:n]
	return value, popSlice
}

Measured memory_bytes: 7692
n, m, x, y = map(int, input().split())
l_X = list(map(int, input().split()))
l_y = list(map(int, input().split()))

l = []

for i in range(x+1, y+1):
    l.append(i)
    
for i in l:
    if max(l_X) < i:
        if min(l_y) >= i:
            print('No War')
            exit()
            
print('War')

Measured memory_bytes: 63628
#include <stdio.h>


int main(){
	long int x;
	long int a=100;
	long int cnt=0;
	
	scanf("%ld",&x);
	
	while(a<x){
		a=a+a/100;
		cnt++;
	}
	printf("%ld\n",cnt);
	
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans;
    if(s==t)
        ans = n;
        else{
            for (int i = 0; i <= n;i++){
                if(s.substr(i)==t.substr(0,n-i)){
                    ans = n + i;
                    break;
                }
            }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int k=0;k<10;k++){
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					WF[i][j] = Math.Min(WF[i][j],WF[i][k] + WF[k][j]);
				}
			}
		}
		
		long tot = 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(A[i][j] != -1)tot += WF[A[i][j]][1];
			}
		}
		Console.WriteLine(tot);
		
	}
	int H,W;
	long[][] WF;
	long[][] A;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		WF = new long[10][];
		for(int i=0;i<10;i++) WF[i] = rla();
		A = new long[H][];
		for(int i=0;i<H;i++) A[i] = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
nxy = list(map(int, input().rsplit()))
N= nxy[0]
X= nxy[1]
Y= nxy[2]
x = [0]*N
for i in range(1, N):
	for j in range(i +1, N+1):
		x[min(
			abs(i-j), 
			abs(X-j) + abs(Y-i) +1,
			abs(X-i) + abs(Y-j) +1)]+=1
for i in x[1:]:
	print(i)

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

public class Hello{
    
    public static int taro=0;
    public static int hanako=0;
    
    public static void keisan(string a,string b)
    {
        string [] str=new string [2]{a,b};
        Array.Sort(str);
        if(a==b)
        {
            taro+=1;
            hanako+=1;
        }
        else if(str[0]==a)hanako+=3;
        else taro+=3;
    }
    
    public static void Main(){
        string[] str=null;
        
        int kaisu=int.Parse(Console.ReadLine());
        for(int i=0;i<kaisu;i++)
        {
            str=Console.ReadLine().Split(' ');
            keisan(str[0],str[1]);
        }
        Console.WriteLine(taro+" "+hanako);
    }
}




Measured memory_bytes: 18752
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main()
{
  ll k = 0;
  ll ans = -1;

  cin >> k;

  vector <ll> vec;

  vec.emplace_back(7 % k);

  for (ll i = 1; i < k ;i++) {

    vec.emplace_back((vec[i - 1] * 10 + 7) % k);

  }

  for (ll i = 0; i < k; i++) {

    if (vec[i] == 0) {

      ans = i + 1;
      break;
      
    }
  }


  cout << ans << endl;

}

Measured memory_bytes: 11664
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(a<=5)cout << 0 << endl;
    else if(a<=12)cout << b/2 << endl;
    else cout <<b << endl;
}

Measured memory_bytes: 256
w=input()
l=[]
for i in range(4):
  if w[i] in l:
    pass
  else:
    l.append(w[i])
if len(l)!=2:
  print("No")
else:
  count=0
  for i in range(4):
    if w[i]==l[0]:
      count+=1
  if count==2:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064
import math
x1, y1, x2, y2 = map(float, input().split())
def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d
c = get_distance(x1, y1, x2, y2)
print(c)


Measured memory_bytes: 5656
#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 ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,a[200000];
	cin>>n;
	map<ll,lii> mp1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(ll i=n-1;i>=0;i--)
	{
		mp1[a[i]].ff=i;
		mp1[a[i]].ss++;
	}
	ll pos=n;
	lvi ans(n+2,0);
	ll ct=0;
	mp1[0]={-1,0};
	for(auto it=mp1.crbegin();it!=mp1.crend();it++)
	{
		pos=min(pos,it->ss.ff);
		if(pos==-1) break;
		ct+=it->ss.ss;
		ll value=it->ff;
		it++;
		ll next=it->ff;
		ll dif=value-next;
		ans[pos]+=(dif*ct);
		it--;
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 8960
#include<stdio.h>
#include<iostream>
using namespace std;
#define QUEUE_SIZE 500000
#define QUEUE_NEXT(i) (((i) + 1) % QUEUE_SIZE)

typedef struct pp{
    char name[100];
    int t;
}P;

struct Queue{
    Queue(){
        queue = new P[QUEUE_SIZE];
        head = tail = 0;
    }

    ~Queue(){
		delete[] queue;
	};

    int isEmpty(){
        return head == tail;
    }

    int isFull(){
        return QUEUE_NEXT(tail) == head;
    }

    int Size(){
        return (tail >= head) ? (tail - head) : 
			(QUEUE_SIZE - (head - tail));
    }

    void enqueue(P x){
        if (!isFull()){
            queue[tail] = x;
            tail = QUEUE_NEXT(tail);
        }

    };

    P dequeue(){
        P data;
        if (!isEmpty()){
            data = queue[head];
            head = QUEUE_NEXT(head);
            return data;
        }
    }

    private:
    P *queue;
    int head;
    int tail;
};


int main(){
    int n, q, elaps =0,c;
    cin >> n >> q;
    Queue Q;
    for(int i=0; i<n; i++){
        P* p = new P;
        cin >> p->name >> p->t;
        Q.enqueue(*p); 
    }
 


    while(!Q.isEmpty()){
        P u;
        u = Q.dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if ( u.t > 0 ){
            Q.enqueue(u);
        }else {
            printf("%s %d\n",u.name, elaps);
        }
    }
}


Measured memory_bytes: 27652
#include"bits/stdc++.h"
using namespace std;
 
int main() {
    long long N, Z, W;
    cin >> N >> Z >> W;
    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
 
    if (N == 1) {
        cout << abs(a[0] - W) << endl;
    } else {
        cout << max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
    long long ans=1;
int N,a=0,b=0;
cin >>N;
vector <int>T(N);
vector <int>A(N);
vector <int>TT(N);
vector <int>AA(N);
vector <int>AT(N);
for(int i=0;i<N;i++){
    cin >>T[i];
  
}
for(int i=0;i<N;i++){
    cin >>A[i];
  
}
reverse(A.begin(), A.end());
for(int i=0;i<N;i++){
   if(i==0){TT[i]=1;
    if(T[i]>A[N-i-1])ans=0;
   }
   else if(T[i-1]<T[i]){TT[i]=1;
   if(T[i]>A[N-i-1])ans=0;
   }
   else TT[i]=T[i];
}
for(int i=0;i<N;i++){
   if(i==0){AA[i]=1;
    if(T[i]>A[N-i-1])ans=0;
   }
   else if(A[i-1]<A[i]){AA[i]=1;
 if(A[i]>T[N-i-1])ans=0;
   }
   else AA[i]=A[i];
}
reverse(AA.begin(), AA.end());
for(int i=0;i<N;i++){
    AT[i]=min(TT[i],AA[i]);
}
for(int i=0;i<N;i++){
    ans*=AT[i];
    ans%=1000000007;
}

cout <<ans;
}



Measured memory_bytes: 2176
#include <stdio.h>
void main(){
  int a,b,c,d;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  while(a>0){
    c=c-b;
    if(c<=0)
      break;
    a=a-d;
  }
  if(c<=0)
    printf("Yes\n");
  else
    printf("No\n");
  
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> V(M);
    rep(i,0,M)cin >> V[i];
    int cnt = 0;
    rep(i,0,N){
        int sum = 0;
        rep(j,0,M){
            int a;
            cin >> a;
            sum += a * V[j];
        }
        if(sum + C > 0)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

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

struct node_t{
    int value;
    struct node_t* left;
    struct node_t* right;
};

struct node_t* mallocNode(int adds) {
    struct node_t* add;

    add = (struct node_t*)malloc(sizeof(struct node_t));
    if (add == NULL) {
        return NULL;
    }

    add->left = NULL;
    add->right = NULL;
    add->value =  adds;

    return add;
}

int addNode(struct node_t* root, int tmps) {
    struct node_t* node;
    if (root == NULL) {
        root = mallocNode(tmps);
        return 0;
    }

    node = root;
    while (1) {
        if (tmps < node->value) {
            if (node->left == NULL) {
                node->left = mallocNode(tmps);
                return 0;
            }
            node = node->left;
        }
        else if (tmps > node->value) {
            if (node->right == NULL) {
                node->right = mallocNode(tmps);
                return 0;
            }
            node = node->right;
        }
        else {
            return 1; // 重複のときのみ1を返す
        }
    }

}


int main() {
    int i,j;
    int n;
    int a,b,c;
    int k;
    int sum = 0;

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

    if(a<k){
        sum += a;
        k -= a;
    }else{
        sum += k;
        k = 0;
    }

    if(b<k){
        k -= b;
    }else{
        k = 0;
    }

    sum-=k;
    printf("%d", sum);
    return 0;

}

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

int main() {
    ll N;
    cin >> N;
    
    ll minval = 1000000000000;
    for(ll a = 1;(a*a)<=N;a++){
        ll b = N/a;
        if((a * b) == N){
            // cout << a << " " << b << endl;
            minval = min(minval, a+b-2);
        }
    }
    cout << minval << endl;

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<long long, long long>>P1(N);
	vector<pair<long long, long long>>P2(N);
	for (int i = 0; i < N; ++i) {
		long long x, y;
		cin >> x >> y;
		P1[i] = { x + y,x - y };
		P2[i] = { x - y,x + y };
	}
	sort(P1.begin(), P1.end());
	sort(P2.begin(), P2.end());
	long long ans0 = P1[N - 1].first - P1[0].first;
	long long ans1 = P2[N - 1].first - P2[0].first;
	cout << max(ans0, ans1) << endl;
	return 0;
}

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

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

	if ((A % 2 == 1) && (B % 2 == 1)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, D, res; cin >> N >> D;
    int X[N][D];
    res = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> X[i][j];
        }
    }
    
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            int A = 0;
            int B = 0;
            for (int k = 0; k < D; k++)
            {
                A += (int)pow((double)abs(X[i][k]-X[j][k]), 2.0);
            }
            B = (int)sqrt(A);
            if ((int)pow((double)B,2.0) == A)
            {
                res++;
            }
        }
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (y - r >= 0 && y + r <= H&&x - r >= 0 && x + r <= W){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double d = (60 * h + m) * 0.5 - 6 * m;

    double c = 0;
    c = sqrt(a*a + b*b - 2*a*b*cos(d * 3.141592653589793 / 180));

    printf("%.10lf\n", c);
}

Measured memory_bytes: 4148
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
    long long int n,m,sum=0;
    cin>>n;
    vector<long long int>t(1000);
    vector<long long int>a(1000);
    vector<long long int>b(1000);
    for(long long int i=0;i<n;i++){
        cin>>t[i];
        sum+=t[i];
    }
    cin>>m;
    for(long long int i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    for(long long int i=0;i<m;i++){
        cout<<sum-t[a[i]-1]+b[i]<<endl;
    }
    return 0;
}


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

int main() {
	// your code goes here
int l;
cin>>l;
int a[200000];
for(int i=0;i<l;i++)
{
    scanf("%d",&a[i]);
}
int br=0;
int tr_no=1;
for(int i=0;i<l;i++)
{
    if(a[i]==tr_no)
    {
        tr_no++;
    }
    else
    {
        br++;
    }
}
    if(br>l-1)
    {
        cout<<"-1";
        return 0;
    }
    cout<<br;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>

int n;
int t;

std::map<int, int> m;

int main() {
    std::cin >> n;
    for (int i = 0; i < n - 1; i++) {
        std::cin >> t;
        m[t]++;
    }
    for (int i = 1; i <= n; i++) {
        std::cout << m[i] << std::endl;
    }
}

Measured memory_bytes: 13012
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 5e4+5;;
const int MOD = 1e9+7;




int main(){

    FIO
    
    string s; cin>>s;
    cout<<s.substr(0,3)<<endl;


} 


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  string S;cin>>S;
  int begin=0,end=S.size()-1,ans=0;
  while(begin<end){
    if(S.at(begin)!=S.at(end))ans++;
    begin++;end--;
  }
  print(ans)
}


Measured memory_bytes: 256
'use strict'

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);


function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let a = temp[1].split(' ').map((v)=>parseInt(v));

	let min = INF;
	let sum = 0;
	let count = 0;
	let v;
	for(let i=0;i<n;i++){
		if(a[i]<0){
			count++;
		}
		v = Math.abs(a[i]);
		min = Math.min(min,v);
		sum += v;
	}
	if( (count%2) === 1 ){
		sum -= min*2;
	}
	//回答出力
	console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29900
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,R;
    cin >> N >> R;
    cout << R+100*(max(0ll,10-N)) << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    ll a, b, n; cin>>a>>b>>n;

    ll x = min(b - 1, n);

    cout << a * x / b - a * (x / b) << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n, k;
	cin >> n >> k;
	vector<bool> ok(n, 0);
	while(k--) {
		int t;
		cin >> t;
		while(t--) {
			int x;
			cin >> x;
			ok[x - 1] = 1;
		}
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(!ok[i]) {
			cnt++;
		}
	}
	cout << cnt << "\n";




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3608