akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var L = F;
		var V = 1;
		while ((1 << V) <= L) V++;
		var es = new List<Edge>[V];
		for (var i = 0; i < V; i++) es[i] = new List<Edge>();
		for (var i = 0; i < V - 1; i++)
		{
			es[i].Add(new Edge(i + 1, 0));
			es[i].Add(new Edge(i + 1, 1 << i));
		}
		for (var i = 0; i < V - 1; i++)
		{
			if ((L & (1 << i)) != 0)
			{
				var tmp = (1 << 30) - 1;
				tmp ^= (1 << (i + 1)) - 1;
				es[i].Add(new Edge(V - 1, L & tmp));
			}
		}
		var E = 0;
		foreach (var e in es) E += e.Count;
		WriteLine($"{V} {E}");
		for (var i = 0; i < V; i++)
			foreach (var e in es[i])
				WriteLine($"{i + 1} {e.To + 1} {e.Cost}");
		var res = new List<Edge>[V];
		for (var i = 0; i < V; i++) res[i] = new List<Edge>();
		for (var i = 0; i < V; i++)
			foreach (var e in es[i])
				res[e.To].Add(new Edge(i, e.Cost));
	}
}
struct Edge
{
	public readonly int To, Cost;
	public Edge(int t, int c) { To = t; Cost = c; }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<algorithm>
#include<string.h>
#include<utility>
#include<vector>
using namespace std;

#define pb push_back
#define mp make_pair
#define ld long double
#define int long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

const int N=4e5;
// ll A[N];

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


	string S;
	cin>>S;
	int count=0;
	for(int i=1;i<S.size();i++)
	{
		if(S[i] == S[i-1])
		{
			count++;
			S[i] = char((S[i-1]-'0'+1)%2+'0');
			// cout<<i<<" "<<S<<"\n";
		}
	}
	cout<<count<<"\n";
	
	return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())

s = []
for i in range(n):
    a,b = map(int,input().split())
    temp = (a,b)
    s.append(temp)
s.sort()

temp = 0
ans = 0
i = 0
while temp < m:
    p = min(s[i][1],m-temp)
    temp += p
    ans += (s[i][0])*p
    i += 1

print(ans)

Measured memory_bytes: 16892
using System;

namespace AOJ0025
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 4; //number of data
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] Ast = input.Split(' ');
                input = Console.ReadLine();
                string[] Bst = input.Split(' ');

                int[] A = new int[N];
                int[] B = new int[N];

                int hit = 0;
                int blow = 0;

                for (int i = 0; i < N; i++)
                {
                    A[i] = int.Parse(Ast[i]); B[i] = int.Parse(Bst[i]);
                }

                for (int i = 0; i < N; i++)
                {
                    for (int j = 0; j < N; j++)
                    {
                        if (i == j)
                        {
                            if (A[i] == B[j])
                            {
                                hit++;
                            }
                        } else
                        {
                            if (A[i] == B[j])
                            {
                                blow++;
                            }
                        }
                    }
                }

                Console.WriteLine(hit + " " + blow);
            }
        }
    }
}

Measured memory_bytes: 9160
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

#define COMPARE(left , right)   (left == right ? "YES" : "NO")
#define SQUARE(value)			(value * value)
#define SIZE	3

int main(void)
{
	int ansArray[SIZE] = {0};
	int n;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < SIZE; j++)
		{
			cin >> ansArray[j];
		}

		sort(ansArray , ansArray + SIZE);

		cout << COMPARE(SQUARE(ansArray[0]) +SQUARE( ansArray[1]) , SQUARE(ansArray[2])) << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a==b+c) {
			System.out.println("Yes");
		}else if(a+b==c) {
			System.out.println("Yes");
		}else if(a+c==b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string S;
    long long K;
	cin >> S >> K;
    //文字列𝑆において、1文字目から𝐾文字目まで全て‘1’であれば、答えは‘1’
    //そうでなければ、答えは𝑆中に初めて出現する‘2’以上の文字
	for (int i = 0; i < min((long long)S.size(), K); i++) {
		if (S[i] >= '2'){
          cout << S[i] << endl;
          return 0;
        }
	}
	cout << '1' << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
x=sorted([int(input()) for i in range(n)])

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

y=groupby(x)
c=0
for i in y:
    if i[1]%2==1:
        c+=1
print(c)


Measured memory_bytes: 17384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

struct UnionFind {
  vector<int> par; // par[i]が親を表す
  vector<int> _size; // _size[i]でそのノードの属しているサイズを返す

  // コンストラクタ
  UnionFind(int n) {
    _size = vector<int>(n);
    par = vector<int>(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      _size[i] = 1;
    }
  }

  // データxの根を求める
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]); // 木構造の縮約を行っている
  }

  // xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
  void merge(int x, int y) {
    int rootx = root(x);
    int rooty = root(y);
    if (rootx == rooty)
      return;
    par[rooty] = rootx;
    int s = _size[rooty] + _size[rootx];
    _size[rooty] = s;
    _size[rootx] = s;
  }

  // xの属している集団のサイズ
  int size(int x) { return _size[x]; }

  // 同じグループに属しているか
  bool isSame(int x, int y) { return root(x) == root(y); }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n + m);
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int l;
      cin >> l;
      uf.merge(i, n + l - 1);
    }
  }

  int root = uf.root(0);
  REP(i, n) {
    if (uf.root(i) != root) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


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

from collections import deque

N,C = map(int,input().split())
H = [int(x) for x in input().split()]

dp = [0] * N
funcs = deque() # ax + b

def add(i):
    h = H[i]
    a3,b3 = -2*h,h*h+dp[i]
    while len(funcs) >= 2:
        a1,b1 = funcs[-2]
        a2,b2 = funcs[-1]
        if (a2-a1)*(b3-b2) < (b2-b1)*(a3-a2):
            break
        funcs.pop()
    funcs.append((a3,b3))

def get_min(x):
    a,b = funcs[0]
    y = a*x+b
    while len(funcs) >= 2:
        a2,b2 = funcs[1]
        y2 = a2*x+b2
        if y < y2:
            break
        y = y2
        funcs.popleft()
    return y

add(0)
for i,h in enumerate(H[1:],1):
    dp[i] = get_min(h) + h*h + C
    add(i)

dp

answer = dp[-1]
print(answer)

Measured memory_bytes: 41612
#include <stdio.h>
#include <stdint.h>

int main() {
	uint32_t dataNum, data;

	scanf("%d", &dataNum);
	scanf("%d", &data);

	uint32_t min = data;
	int32_t result = -1000000000;

	for (uint32_t i = 1; i < dataNum; i++) {
		scanf("%d", &data);

		int32_t diff = data - min;
		result = (result < diff) ? diff : result;
		min = (min > data) ? data : min;
	}
	printf("%d\n", result);
	return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define big 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define mem0(a) memset(a,0,sizeof(a))
    #define memf(a) memset(a,false,sizeof(a))
    #define mem1(a) memset(a,1,sizeof(a))
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
	{ 
    	if (y == 0) 
        	return 1; 
    	int p = power(x, y/2, m) % m; 
    	p = (p * p) % m; 
  
 	   return (y%2 == 0)? p : (x * p) % m; 
	} 
	int modInverse(int a, int m) 
	{   
    	return power(a, m-2, m);
	}
    signed main()
    {
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	ll t=1;
    	// cin >> t;
    	/*SAARE INPUTS LENA*/
    	/*VARIABLES KI RANGE DEKHLENA*/
    	while(t-->0)
    	{
    		ll a=0,b=0,h=0,m=0;
    		cin>>a>>b>>h>>m;
    		double theta=abs((60*h+m)/(2.0)-6*m)*(pi/180);
    		cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(theta));

    	}
    	return 0;
    }

Measured memory_bytes: 4152
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

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

#define pb push_back
#define F first
#define S second

#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5+5, LG = 17, MOD = 998244353;
const int SQ = 390;
const long double EPS = 1e-7;
int n, x[N], L;
int tb[N][17];
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE
  cin >> n;
  f(i,0,n){
    cin >> x[i];
  }
  cin >> L;
  for(int i = 0, j = 0; i < n; i++){
    while(j<n&&x[j]-x[i]<=L)j++;
    tb[i][0] = j - 1;
  }

  f(k,1,17)
    for(int i = 0; i <n; i++)
      tb[i][k] = tb[tb[i][k-1]][k-1];

  int q; cin >> q;
  while(q--){
    int x, y; cin >> x >> y;  --x,--y;
    if(x>y)swap(x,y);
    int ans = 0;
    for(int k = 16; k >= 0; --k)
    if(tb[x][k] < y){
      x = tb[x][k];
      ans += (1 << k);
    }
    cout <<ans+1<<'\n';
  }

  return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

int32_t main()
{
    fast;
    int n,m,c,val,ans,cnt=0;
    cin>>n>>m>>c;
    vi b;
    rep(i,m)
    {
        cin>>val;
        b.pb(val);
    }
    rep(i,n)
    {
        ans=0;
        rep(j,m)
        {
            cin>>val;
            ans+=(b[j]*val);
        }
        ans+=c;
        if(ans>0)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,1,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)
#define pb push_back

template<typename T> 
void chmax(T &a,T b){ a = max(a, b);};
template<typename T> 
void chmin(T &a,T b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int n,a;
bool b;
void solve(){
	if(b)
		cout<<"first"<<endl;
	else
		cout<<"second"<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	rep(i,n) {
		cin>>a;
		if(a%2==1) b=true;
	}
		solve();
	return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    string t;
    cin >> t;
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Iterator;

class Graph2 {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph2() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}

		for(i = 0; i < totalVertex; i ++) {
			for(j = 0; j < totalVertex; j ++) {
				int val = in.nextInt();
				if (val != -1) {
					adjMatrix[i][j] = 1;
					adjWeight[i][j] = val;
				}
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	
	public boolean allVisited() {
		for (int i = 0; i < ifSettled.length; i++) {
			if (ifSettled[i] == false) return false;
		}
		return true;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		int[] dist = new int[totalVertex];
		Arrays.fill(dist, Integer.MAX_VALUE);		
		dist[s] = 0;
		
		int curr = s;	
		while (!allVisited()) {
			ifSettled[curr] = true;
			LinkedList<Integer> neighbours = getUnsettledNeighbors(curr);
			Iterator<Integer> itr = neighbours.iterator();
			
			while (itr.hasNext()) {
				int next = itr.next();
				int cost = getWeight(curr, next);
				if (dist[next] > cost) dist[next] = cost;
			}
			
			curr = getUnsettledNearest(dist);
		}
		
		
		return dist;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph2 g = new Graph2();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		int ans = 0;
		
		for (int i =0; i < dist.length; i++) {
			ans += dist[i];
		}
		
		System.out.println(ans);
	}
}



Measured memory_bytes: 41488
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
inline int read(){
	int x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

const int N = 105;

int n,s,t;
struct node{
	int x,y;
}a[N],b[N];
int head[N],link[N],to[N*2],nxt[N*2],w[N*2],cnt = -1;
bool mp[N][N];
bool vis[N];
inline void insert(int x,int y){
	to[++cnt] = y; nxt[cnt] = head[x]; head[x] = cnt;
}

bool can(int x){
	for(int i = 1;i <= n;++i){
		if(!vis[i] && mp[x][i]){
			vis[i] = true;
			if(link[i] == -1 || can(link[i])){
				link[i] = x;
				return true;
			}
		}
	}
	return false;
}

inline void dinic(){
	int ans = 0;
	for(int i = 1;i <= n;++i){
		memset(vis,false,sizeof vis);
		if(can(i)) ++ans;
	}
	printf("%d\n", ans);
}

int main(){
	n = read(); s = 0; t = 2*n+1;
	for(int i = 1;i <= n;++i){
		a[i].x = read(); a[i].y = read();
	}
	for(int i = 1;i <= n;++i){
		b[i].x = read(); b[i].y = read();
	}
	memset(head,-1,sizeof head);
	memset(link,-1,sizeof link);
	for(int i = 1;i <= n;++i)
		for(int j = 1;j <= n;++j){
			if(a[i].x < b[j].x && a[i].y < b[j].y){
				mp[i][j] = 1;
				// insert(j+n,i);
			}
		}
	dinic();
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;


template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

typedef long long ll;
typedef pair<ll, ll> Pa;

typedef modint<MOD> m;
m func[100000];
void funcinit(int N){
    func[0] = 1;
    for(int i=1;i<=N;i++){
        func[i] = func[i-1]*i;
    }
}

modint<MOD> comb(modint<MOD> n, modint<MOD> r) {
    if(n.a <= 0 || n.a < r.a) {
        return 0;
    }    
    return func[n.a]/(func[r.a]*func[(n-r).a]);
}
 
ll a[100000];
m arr[100000];
int main() {
    m _sum;
    _sum.a = 0;
    cin >> N >> K;
    rep(i, N){
        cin >> a[i];
    }    
    sort(a, a+N);
    funcinit(N);
    rep(i, N){
        arr[i].a = a[i];
    }
    for(int i=0;i<N;i++){
        _sum -= arr[i]*comb(N-i-1, K-1);
        _sum += arr[i]*comb(i, K-1);
    }
    cout << _sum.a;
}


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

int main() {
	int N;
	cin >> N;
	int ans = 0, count = -1, height;
	rep(i, N) {
		int H;
		cin >> H;
		if (count == -1) {
			count = 0;
			height = H;
		}
		else if (H <= height) {
			count++;
			height = H;
		}
		else {
			ans = max(ans, count);
			count = 0;
			height = H;
		}
	}
	ans = max(ans, count);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
r=lambda x:p[x]>=0and r(p[x])or x
(n,m,k),*t=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
s=[-1]*-~n
for a,b in t:
 x,y=sorted((r(a),r(b)))
 if(x!=y)*m>0:p[x]+=p[y];p[y]=x
 if(x==y)+(m>0):s[a]-=1;s[b]-=1
 m-=1
print(*[s[i+1]-p[r(i+1)]for i in range(n)])

Measured memory_bytes: 98772
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
s = S()

left_List = [0]
left = 0
flag = ""
cnt = 0
j = 0
ans = 0
for i in range(N):
  if i != 0:
    if flag == 0:
      if s[i] == "1":
        left_List.append(i)
        cnt += 1
    else:
      if cnt >= K:
        if s[i] == "0":
          ans = max(ans, i-left_List[j])
          j += 1

  if s[i] == "0":
    flag = 0
  else:
    flag = 1

else:
  ans = max(ans, N-left_List[j])

print(ans)

Measured memory_bytes: 14556
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=55;
int a[N],w[N];
void no(){cout<<"-1\n";exit(0);}
int pos=1,n,k;
void kek(int i){
    int v=max(0ll,k+1-a[i]);
    while(v--){
        w[pos]=i;
        pos+=2;
        if(pos>k)pos=2;
    }
}
int32_t main(){
    cin>>n>>k;
    if(n==1){
        cout<<"1\n1\n";
        return 0;
    }
    int s=0;
    memset(w,-1,sizeof w);
    int mx=-1,wx=-1;
    forn(i,n){
        cin>>a[i];
        int v=max(0ll,k+1-a[i]);
        if(v>(k+1)/2)no();
        s+=v;
        if(v>mx)mx=v,wx=i;
    }
    if(s>k)no();
    kek(wx);
    forn(i,n)if(i^wx)kek(i);
    for(int j=1;j<=k;++j){
        if(w[j]==-1){
            forn(x,n){
                if(w[j-1]!=x&&w[j+1]!=x){
                    w[j]=x;
                    break;
                }
            }
        }
    }
    cout<<n+k*(n-1)<<'\n';
    forn(i,k+1){
        if(w[i]!=-1)cout<<w[i]+1<<' ';
        forn(j,n)if(j!=w[i]&&j!=w[i+1])cout<<j+1<<' ';
    }
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

int main()
{
    ll n;
    cin >> n;

    cout << n*n*n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<functional>
#include<queue>
using namespace std;
int n;
int main() {
	cin >> n;
	if (n % 10 == 9 || n / 10 == 9)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define BIG 10000000000
typedef long long int ll;
int main(){
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll> > s[n+1];
  ll p,y;
  for(int i=0;i<m;i++){
    cin>>p>>y;
    s[p].push_back(make_pair(y,i));
  }
  for(int i=0;i<n;i++){
    sort(s[i+1].begin(),s[i+1].end());
  }
  vector<ll> ans(m);
  for(int i=1;i<n+1;i++){
    for(int j=0;j<s[i].size();j++){
      ans[s[i][j].second]=i*(ll)1000000+j+(ll)1;
    }
    }
  for(int i=0;i<m;i++){
    printf("%012lld\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int n;
	ll k;
	cin >> n >> k;
	int now = 1;
	vector<int>to(n + 1);
	vector<int>roop;
	int roopc = 0;
	vector<bool> unused(n + 1, true);
	for (int i = 1; i <= n; i++) {
		cin >> to[i];
	}

	while (unused[now] && k > 0) {
		//printf("%d->", now);
		roop.emplace_back(now);
		unused[now] = false;
		now = to[now];
		k--;
	}

	if (k > 0LL) {
		int size = roop.size();
		for (int i = 0; i < size; i++) {
			if (roop[i] == now) {
				//printf("[%d,%d]\n", i, size);
				roopc = size - i;
			}
		}
		//printf("roopsize = %d\n", roopc);
		k %= roopc;
		//printf("[k%%%d,now] = [%lld,%d]\n", roopc, k, now);
		for (int i = 0; i < k; i++) {
			now = to[now];
		}
	}
	printf("%d", now);
	return 0;
}



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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  sort(s.begin(),s.end());
  int cnt=0;
  rep(i,n){
    if(s[i]!=s[i+1]) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 9608
#include <iostream>
#include <vector>
#include <cmath>

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

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

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;
    std::vector<long long> T(N);
    for(int i = 0; i < N; i++){
        std::cin >> T.at(i);
    }
    long long ans = 1;
    for(int i = 0; i < N; i++){
        ans = lcm(ans, T.at(i));
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    int a=0,b=0;
    if(x==2||y==2){
        cout<<"No"<<endl;
        return 0;
    }
    
    if(x == 1||x==3||x==5||x==7||x==8||x==10||x==12){
        a = 1;
    }
    
    else{
        a = 2;
    }
    
    if(y == 1||y==3||y==5||y==7||y==8||y==10||y==12){
        b = 1;
    }
    
    else{
        b = 2;
    }
    
    if(a == b){
        cout<<"Yes"<<endl;
    }
    
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */

int main()
{
    fio;
    int t,n,i,a;
    cin >> a;
    cout << a + (a*a) + (a*a*a) << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int ans = 0;
    for(int i = s.length()-2; i > 0; i-=2) {
        ans += 2;
        if(s.substr(0, i/2) == s.substr(i/2, i/2)) {
            cout << s.length() - ans;
            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 rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  ll x,y;
  cin >> x >> y;
  int ans = 0;
  if(x*y==0){
    if(x<y) ans = y-x;
    if(y<x) ans = x-y+1;
  }
  if(x*y>0){
    if(x<y) ans = y-x;
    if(y<x) ans = x-y+2;
  }
  if(x*y<0){
    ans = abs(abs(y)-abs(x))+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
from itertools import accumulate

def equalfind(A):#配列中の等しい要素の組をカウント　オーダーはO(NlogN)
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2


N,M=map(int,input().split())
A=list(map(int,input().split()))
A=list(accumulate(A))
X=[A[i]%M for i in range(0,N)]
X.append(0)
print(equalfind(X))

Measured memory_bytes: 14180
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   int a,b;
   cin>>a>>b;
   string s;
   cin>>s;
   
   bool can=true;
   rep(i,0,a)if(!('0'<=s[i]&&s[i]<='9'))can=false;
   if(s[a]!='-')can=false;
   rep(i,a+1,b+a+1)if(!('0'<=s[i]&&s[i]<='9'))can=false;
   if(can) cout<<"Yes"<<endl;
   else cout<<"No"<< endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

    map<int,int> m;
    rep(i,n){
        int a;
        cin >> a;
        range(j,-1,2) m[a + j]++;
    }

    int ans = 0;
    for(auto it : m){
        ans = max(ans, it.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) {
        int d;
        cin >> d;
        a[i] = d;
        b[i] = d + 1;
        c[i] = d - 1;
    }

    map<int, int> cnt;
    rep(i, n) {
        cnt[a[i]]++;
        cnt[b[i]]++;
        cnt[c[i]]++;
    }

    int ans = 0;
    for (auto e: cnt) {
        ans = max(ans, e.second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
int main() {
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-2*b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define crap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    crap;
  	int n, k;
  	cin >> n >> k;
  	int arr[n];
  	for(int i = 0;  i < n;  i++)
      	cin >> arr[i];
 	int dp[n];
  	dp[0] = 0;
  	for(int i = 1;  i < n;  i++){
  	    dp[i] = INT_MAX;
  	    int k1 = k;
  	    for(int j = i-1;  j >= 0  &&  k1 > 0;  j--){
      	    dp[i] = min(dp[i], dp[j]+abs(arr[i]-arr[j]));
      	    k1--;
  	    }
  	}
  	cout << dp[n-1] << endl;
	return 0;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N,K;
  cin>>K>>N;
  vector<int> a(N+1),b(N);
  int i,j;
  rep(i,N){
    cin>>a[i];
  }
  rep(i,N-1){
    b[i]=a[i+1]-a[i];
  }
  b[N-1]=K-a[N-1]+a[0];
  sort(b.begin(),b.end());
  cout<<K-b[N-1];  
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define pb push_back
typedef vector<int> vec;
typedef vector<vec> mat;

int N,K;
const int MAX_N=2010;

mat path,farNodes;

int a[20][MAX_N],h[MAX_N];
int chk[MAX_N];

int tree[4*MAX_N],treeV[4*MAX_N],sz;

void init(){
	for(sz=1;sz<N;sz<<=1);
	sz--;
	for(int i=1;i<=N;i++)treeV[i+sz]=i;
}

void update(int x,int c){
	x+=sz;
	tree[x]+=c;
	x>>=1;
	while(x){
		tree[x]=tree[x*2+1];
		treeV[x]=treeV[x*2+1];
		if(tree[x]<tree[x*2]){
			tree[x]=tree[x*2];
			treeV[x]=treeV[x*2];
		}
		x>>=1;
	}
}

int query(){
	return treeV[1];
}

void bfs(){
	queue<int> Q;
	Q.push(1);
	h[1]=1;
	a[0][1]=1;
	while(!Q.empty()){
		int v=Q.front();Q.pop();
		for(auto& u:path[v]){
			if(h[u])continue;
			Q.push(u);
			h[u]=h[v]+1;
			a[0][u]=v;
		}
	}
	for(int i=1;i<20;i++){
		for(int j=1;j<=N;j++){
			a[i][j]=a[i-1][a[i-1][j]];
		}
	}
}

int dist(int x,int y){
	if(h[x]<h[y])swap(x,y);
	int dif=h[x]-h[y];
	int ret=0;
	for(int i=0;i<20;i++){
		if(dif>>i&1){
			x=a[i][x];
			ret+=1<<i;
		}
	}
	for(int i=19;i>=0;i--){
		if(a[i][x]!=a[i][y]){
			x=a[i][x];
			y=a[i][y];
			ret+=2<<i;
		}
	}

	if(x==y)return ret;
	return ret+2;
}

int main(){
	scanf("%d%d",&N,&K);
	path.assign(N+1,vec());
	farNodes.assign(N+1,vec());

	for(int i=0,x,y;i<N-1;i++){
		scanf("%d%d",&x,&y);
		path[x].pb(y);
		path[y].pb(x);
	}

	bfs();
	init();

	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			if(dist(i,j)>K){
				farNodes[i].pb(j);
				farNodes[j].pb(i);
				chk[i]++;
				chk[j]++;
			}
		}
	}

	for(int i=1;i<=N;i++){
		update(i,chk[i]);
	}

	int ans=0;
	while(chk[query()]>0){
		int v = query();ans++;
		update(v,-chk[v]);
		chk[v]=0;
		for(auto& u:farNodes[v]){
			if(chk[u]>0){
				update(u,-1);
				chk[u]--;
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 17792
from __future__ import print_function
from collections import deque

q = deque()
n = 0
d = 0
r = {}
mind = 0
maxd = 0

for x, c in enumerate(raw_input()):
    if c == "\\":
        d += 1
        maxd = max(maxd, d)
        q.append(x)
        n += 1
    elif c == "/":
        d -= 1
        mind = min(mind, d)
        if n == 0:
            continue
        x0 = q.pop()
        n -= 1
        s = x - x0
        if (d + 1) in r:
            while r[d + 1] and r[d + 1][-1][0] > x0:
                s += r[d + 1].pop()[1]
        if d not in r:
            r[d] = deque()
        r[d].append((x, s))

a = 0
k = 0
l = []
for d in xrange(mind, maxd):
    if d in r:
        for x, s in r[d]:
            a += s
            k += 1
            l.append((x, s))
l.sort()

print(a)
print(k, *(s for x, s in l))

Measured memory_bytes: 9032
# Node
class Node
  attr_accessor :id, :edges, :visited, :cost

  def initialize(id, edges = [], visited = false, cost = nil)
    @id, @edges, @visited, @cost = id, edges, visited, cost
  end
end

# Edge
class Edge
  attr_accessor :to

  def initialize(to)
    @to = to
  end
end

# Graph
class Graph
  attr_accessor :nodes

  def initialize(data)
    @nodes = data.each_with_object({}) do |(id, edges), hash|
      edges.map! { |edge| Edge.new(*edge) }
      hash[id] = Node.new(id, edges)
    end
  end

  def bfs(start)
    @nodes.each do |id, node|
      node.visited = false
      node.cost = (id == start) ? 0 : -1
    end

    queue = [@nodes[start]]

    while queue.any?
      node = queue.shift
      node.visited = true
      node.edges.each do |edge|
        id = edge.to
        visited_node = @nodes[id]
        unless visited_node.visited
          visited_node.cost = node.cost + 1 if visited_node.cost == -1
          queue << visited_node
        end
      end
    end
  end
end

n = gets.chop.to_i

data = {}

n.times do
  u, k, *v = gets.chop.split.map(&:to_i)
  data[u] = v
end

g = Graph.new data
g.bfs(1)

g.nodes.each do |id, node|
  puts "#{id} #{(node.visited) ? node.cost : -1}"
end

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


void solve(long long H, long long W, long long h, long long w){
    cout << (H - h) * (W - w) << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int H,W;

  cin>>H>>W;

  rep(i,W+2){
    cout<<'#';
  }
  cout<<"\n";

  rep(i,H){
    cout<<'#';
    rep(i,W){
      char c;
      cin>>c;
      cout<<c;
    }
    cout<<'#'<<"\n";;
  }

  rep(i,W+2){
    cout<<'#';
  }
  cout<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
if N==1:
  print(0)
  exit()
ans=0
for i in range(1,N):
  if L[i-1]>L[i]:
    ans+=L[i-1]-L[i]
    L[i]=L[i-1]
print(ans)

Measured memory_bytes: 32248
#include <stdio.h>


int main(void) {

	// 1_2-C Sorting Three Numbers
	int num[3];
	int i,j,wk;
	scanf("%d %d %d",&num[0],&num[1],&num[2]);

	for(i=2; 0<=i; i--){
		for(j=0; j<i; j++){
			if(num[j] > num[j+1]){
				wk = num[j];
				num[j] = num[j+1];
				num[j+1] = wk;
			}
		}
	}
	printf("%d %d %d\n",num[0],num[1],num[2]);
        return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size())
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int n,l,r;
   string s;
   cin>>s;
   n=s.size();
   l=0;
   r=n-1;
   for(int i=l;i<n/2;i++)
   {
     if(s[i]!=s[r])
     {
        cout<<"No"<<endl;
        return 0;
     }
     r--;
   }
   l=0;
   r=((n-1)/2)-1;
   for(int i=l;i<r;i++)
   {
     if(s[i]!=s[r])
     {
        cout<<"No"<<endl;
        return 0;
     }
     r--;
   }
   l=((n+3)/2)-1;
   r=n-1;
   for(int i=l;i<r;i++)
   {
     if(s[i]!=s[r])
     {
        cout<<"No"<<endl;
        return 0;
     }
     r--;
   }
   cout<<"Yes"<<endl;
   return 0;
}



Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll a;
	double b;
	cin >> a >> b;
	b = round(b*100.0); //100倍して小数第1位で四捨五入
	ll c = b; // long long int に格納
	cout << (ll)(c*a/100) << endl; //Aとの積を100で割って出力
}

Measured memory_bytes: 3780
import itertools

n = int(input())
pl = list(map(int, input().split()))
ql = list(map(int, input().split()))

count = 0
a, b = 0, 0

for v in itertools.permutations(range(1, n+1)):
    count += 1
    if pl == list(v):
        a = count
    if ql == list(v):
        b = count

print(abs(a-b))


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m;
void solve() {
    cin >> n >> m;

    if (n == m) cout << "Yes" << endn;
    else cout << "No" << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;

int main() {
  long long n,k;
  cin >> n >> k;
  vector<long long> A(n+1);
  for (int i=1; i<n+1; i++) {
    cin >> A.at(i);
  }

  if ( n >= k) {
    long long now=1;
    for (int i=0; i<k; i++) {
      now = A.at(now);
    }
    cout << now << endl;
    return 0;
  }

  vector<long long> isAlready(n+1,-1);

  long long order=0;
  long long now=1;
  while (isAlready.at(now) < 0) {
    isAlready.at(now) = order;
    now = A.at(now);
    order++;
  }
  long long loopNum = order - isAlready.at(now);
  long long p=1;
  while (p!=now) {
    p = A.at(p);
    // cout << p << endl;
    k--;
  }
  // cout << " " <<  loopNum << endl;
  k = k%loopNum;

  int ans=p;
  for (int i=1; i<=k; i++) {
    ans = A.at(ans);
    // cout << ans << endl;
  }

  cout << ans << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i < 2 * b; i++) {
		if (a * i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3604
M, N = map(int, input().split())
COST, STOCK = range(2)
energy_drinks = sorted((tuple(map(int, input().split())) for _ in range(M)), key=lambda tuple_: tuple_[COST])

cost = 0
for energy_drink in energy_drinks:
    buy = min(energy_drink[STOCK], N)
    N -= buy
    cost += buy * energy_drink[COST]
print(cost)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 056 D / Link: http://abc056.contest.atcoder.jp/tasks/abc056_d  ----- */

struct Cumusum {
	vector<LL>csum;
	Cumusum(vector<LL>&a) {
		csum.assign((int)a.size() + 1, 0);
		for (int i = 0; i < (int)a.size(); i++) {
			csum[i + 1] = csum[i] + a[i];
		}
	}
	LL query(int l, int r) {
		return csum[r] - csum[l];
	}
};

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

	LL N, K; cin >> N >> K;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	// prebuild back dp
	VVL dpB(N + 1, VL(K + 1, 0));
	dpB[N][0] = 1;
	FORR(i, N, 0) {
		int A = a[i - 1];
		FOR(k, 0, K + 1 - A) {
			dpB[i - 1][k + A] |= dpB[i][k];
		}
		FOR(k, 0, K + 1) {
			dpB[i - 1][k] |= dpB[i][k];
		}
	}


	VL dp(K + 1, 0);
	dp[0] = 1;
	LL ans = N;
	FOR(i, 0, N) {

		// build back dp cumsum
		Cumusum asum(dpB[i+1]);


		// query [K-a[i]-s,K-s) is exist
		bool exist = 0;
		FOR(s, 0, K+1) {
			if (dp[s]) {
				int L = max(0LL, K - s - a[i]);
				int R = max(0LL, K - s);
				exist |= asum.query(L, R) > 0;
			}
		}
		// if(exist)need.
		ans -= exist;

		// front dp
		FORR(k, K - a[i], 0 - 1) {
			dp[a[i] + k] |= dp[k];
		}
	}

	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 195968
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 2020;
const int mod = 1e9 + 7;

LL f[N][N][2], s[N];

LL qpow(LL a, LL b)
{
	LL ret = 1, base = a;
	while (b) {
		if (b & 1) ret = ret * base % mod;
		base = base * base % mod, b >>= 1;
	}
	return ret;
}

void upd(LL &a, LL b) { a = (a + b) % mod;}

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	f[n + 1][0][0] = 1;
	for (int i = n + 1; i >= 2; i --) {
		for (int j = n - i + 1; j >= 0; j --) s[j] = s[j + 1], upd(s[j], f[i][j][0]);
		
		for (int j = n - i + 1; j >= 0; j --) {

			upd(f[i - 1][j + 1][1], s[j] + f[i][j][1]);
			upd(f[i - 1][j][0], s[j] + f[i][j][1]);
		}
	}
	
	if (n == k) printf("%lld\n", f[1][n - k][0]);
	else printf("%lld\n", f[1][n - k][0] * qpow(2, n - k - 1) % mod);
	
	return 0;
}

Measured memory_bytes: 63616