akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

char c[55][55];

int main() {
    int h, w;

    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    cin >> h >> w;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }

  bool flag = false;
  int ans = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char now = c[i][j]; 
            flag= false;
                if(now == '#'){
                    for(int k = 0; k < 4; k++){
                        int nx = i + dx[k];
                        int ny = j + dy[k];
                        if(nx < 0 || ny < 0 || nx >= h || ny >= w){
                            continue;
                        }
                        if(flag) continue;
                        if(c[nx][ny] == now ){
                            flag = true;
//                            cout << i << j << endl;
//                            cout << nx << ny << endl;
                        }
                    }
                    if(!flag){
//                        cout << i << j << endl;
                       ans++;
                    }
                }          
        }

    }

    if(ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int deg[11451];
int U[11451];
int V[11451];
set<int> es[11451];
int ans[11451];

struct Compare {
  bool operator()(int a, int b) const {
    if (deg[a] != deg[b]) return deg[a] < deg[b];
    return a < b;
  }
};

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  rep(i, N-1) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    es[u].insert(v);
    es[v].insert(u);
    U[i] = u;
    V[i] = v;
    deg[u]++;
    deg[v]++;
  }

  set<int, Compare> st;
  priority_queue<int, vector<int>, greater<int>> cs;
  rep(i, N) {
    int c;
    cin >> c;
    cs.push(c);
    st.insert(i);
  }

  while (!cs.empty()) {
    int v = *st.begin();
    st.erase(v);

    ans[v] = cs.top(); cs.pop();
    for (int u : es[v]) {
      es[u].erase(v);
      st.erase(u);
      deg[u]--;
      st.insert(u);
    }
    deg[v] = 0;
    es[v].clear();
  }

  int tot = 0;
  rep(i, N-1) {
    int u = U[i];
    int v = V[i];
    tot += min(ans[u], ans[v]);
  }
  cout << tot << endl;
  rep(i, N) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m;
    cin>>n>>m;
    if(n>=m/2)
    {
        cout<<m/2<<endl;
        return 0;
    }
    cout<<(n+(m/2))/2<<endl;
    return 0;
}


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

namespace ConsoleApp93 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var t = new int[N];
            var x = new int[N];
            var y = new int[N];

            for (int i = 0; i < N; i++) {
                var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
                t[i] = st[0];
                x[i] = st[1];
                y[i] = st[2];
            }

            bool flg = true;

            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    if ((x[0] + y[0]) <= t[0] && ((x[0] + y[0]) - t[0]) % 2 == 0) {

                    } else {
                        flg = false;
                        break;
                    }
                    continue;
                }

                if ((Math.Abs(x[i] - x[i - 1]) + Math.Abs(y[i] - y[i - 1])) <= t[i] - t[i - 1] && (Math.Abs(x[i] - x[i - 1]) + Math.Abs(y[i] - y[i - 1]) - (t[i] - t[i - 1])) % 2 == 0) {

                } else {
                    flg = false;
                    break;
                }

            }

            Console.WriteLine(flg? "Yes" : "No");

        }
    }
}


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

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      char[] suit = new char[5];
      suit[1] = 'S';
      suit[2] = 'H';
      suit[3] = 'C';
      suit[4] = 'D';
      int n = in.nextInt();
      
      int[][] card = new int[5][14];
      for (int i = 1; i <= n; i++) {
        char tmpsuit = in.next().charAt(0);
        int num = in.nextInt();
        
        switch (tmpsuit) {
          case 'S':
            card[1][num] = 1;
            break;
          case 'H':
            card[2][num] = 1;
            break;
          case 'C':
            card[3][num] = 1;
            break;
          case 'D':
            card[4][num] = 1;
            break;
        }
        
      }
      
      for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= 13; j++) {
          if (card[i][j] != 1) {
            out.println(suit[i]+" "+j);
          }
        }
      }
//    End solve()
    }
//    End Solution
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

     
  }

}

Measured memory_bytes: 24520
object Main extends App{
  import scala.io.StdIn._
  var A=readLine().split(" ").map(_.toInt)
  var B=readLine().split(" ").map(_.toInt)
  var C=readLine().split(" ").map(_.toInt)
  var N=readInt()
  var ans="No"
  for{i <- (0 until N )}{
    var s=readInt()
    for {j <- (0 until 3 )}{
      if(A(j)==s) {
        A(j) = -1
      }else if(B(j)==s){
        B(j) = -1
      }else if(C(j)==s){
        C(j)= -1
      }
      if(A(j)+B(j)+C(j) == -3) ans="Yes"
    }
  }
  if(A.sum== -3 || B.sum== -3 || C.sum== -3) ans="Yes"
  if(A(0)+B(1)+C(2)== -3 || C(0)+B(1)+A(2)== -3) ans="Yes"
  println(ans)
}

Measured memory_bytes: 25668
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


long r, D, x;
int main(){
cin >> r >> D >> x;
erep(i, 10){
    x = x*r-D;
    show(x);
}


return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		long ans = (long) ((1900 * M + ((N-M) * 100)) * Math.pow(2, M));
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main() { int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for(int i=0;i<n;i++)
		cin >> p[i];
	
	vector<bool> stream(n,false);
	int bef=-1;
	int scnt=0;
	for(int i=n-1;i>=0;i--)
	{
		if(bef<p[i])scnt=0;
		else scnt++;
		if(scnt>=k-1)
			stream[i]=true;
		bef=p[i];
		//cerr << (stream[i] ? "y":"n") << endl;
	}


	set<int> now;
	queue<int> que;

	for(int i=0;i<k;i++)
	{
		now.insert(p[i]);
		que.push(p[i]);
	}
	
	bool notsort=false;
	bool bef_head=true;
	bool now_tail=false;

	int cnt=0;
	for(int i=0;i<n-k+1;i++)
	{
		now.insert(p[i+k-1]);
		if(stream[i])
		{
			if(!notsort)
				cnt++;
			notsort=true;
			bef_head=false;
		}
		else
		{
			auto itr=now.end();
			itr--;
			int settail=*itr;
			//cerr << i << " " << settail << " : " <<  p[i+k-1] <<  endl;
			if(settail!=p[i+k-1] or bef_head)
			{
				cnt++;
				//cerr << i << " cnt : " << cnt << endl;
			}

			itr=now.begin();
			int sethead=*itr;
			if(sethead!=p[i])
				bef_head=true;
			else
				bef_head=false;
		}
		now.erase(p[i]);
	}
		

	cout << cnt << endl;





}


Measured memory_bytes: 11264
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;
const int intINF = 1e9 * 2 + 3;
//--------------------------------------------------

ulli gcd(ulli a, ulli b) {return (b <= 0) ? a : gcd(b, a % b);}
ulli lcm(ulli a, ulli b) {return a * b / gcd(a, b);}

bool isPrime(int n)
{
	if (n <= 3)return n > 1;
	if (n % 2 == 0)return false;
	if (n % 3 == 0)return false;
	for (int i = 5; i * i < n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0) { return false; }
	}
	return true;
}
//---------------------------------------------------


void Main()
{
	int n, mina = intINF;
	cin >> n;
	vi x(n);
	rep(i, n) cin >> x[i];
	sort(x.begin(), x.end());
	for (int i = x[0]; i <= x[n - 1]; i++) {
		int sum = 0;
		for (auto a : x) {
			sum += (a - i) * (a - i);
		}
		mina = min(sum, mina);
	}
	cout << mina << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll N;
    cin>>N;
    string s,t;
    cin>>s>>t;
    rep(i,0,N){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

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

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

signed main(void)
{
  string s;
  cin >> s;
  char pre = 'A';
  int ret = 0;
  REP(i, s.size()) {
    if(s[i] <= pre) ret++;
    pre = s[i];
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<vector>

using namespace std;

vector<char> t, d;
int N, Q;
string s;

int check(int m) {
    for(int i = 0; i < Q; i++)
    {
        if (s[m] == t[i]) {
            m += (d[i] == 'R') ? 1 : -1;
        }
        if (0 > m){
            return -1;
        }else if (m > N - 1){
            return 1;
        }  
    }
    return 0;
}

int bin_search_left() {
    int l, r;
    l = 0;
    r = N - 1;

    while(r >= l){
        int m = (l + r) / 2;
        if (check(m) == -1){
            l = m + 1;
        } else
        {
            r = m - 1;
        }
    }
    return l;
}

int bin_search_right()
{
    int l, r;
    l = 0;
    r = N - 1;

    while (r >= l)
    {
        int m = (l + r) / 2;
        if (check(m) == 1)
        {
            r = m - 1;
        }
        else
        {
            l = m + 1;
        }
    }
    return r;
}

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

    t.resize(Q);
    d.resize(Q);
    for(int i = 0; i < Q; i++) cin >> t[i] >> d[i];
    
    int left = bin_search_left();
    int right = bin_search_right();

    int ans = right - (left - 1);

    cout << ans << endl;
}

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


int main(){
	cout<<fixed<<setprecision(12);
	int n,t;
	cin>>n>>t;
	int a[200000]={};
	for(int i=0;i<n;i++){
		int x,h;
		cin>>x>>h;
		a[x]=h;
	}
	double h=0;
	for(int i=1;i<=t;i++){
		h=max(h,(double)t*a[i]/i);
	}
	cout<<h<<endl;


	return 0;
}



Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[n+5];
	for(int i=0;i<n;i++)
	cin>>a[i];
	long long mx=a[0];
	long long ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<mx)
		ans+=(mx-a[i]);
		else
		mx=a[i];
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;

int main(){
  vector<int> A(5);
  vector<int> B(5);
  for (int i = 0; i < 5; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < 5; i++) {
    B.at(i) = A.at(i);
  }
  for (int i = 0; i < 5; i++) {
    if (B.at(i)%10!=0){
      while (B.at(i)%10!=0) {
        B.at(i)++;
      }
    }
  }
  int ans = 10000;
  for (int i = 0; i < 5; i++) {
    int cnt = accumulate(B.begin(), B.end(), 0) - B.at(i) + A.at(i);
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int m, n;

    m=0;
    scanf("%d", &n);
    m += n*1;
    scanf("%d", &n);
    m += n*5;
    scanf("%d", &n);
    m += n*10;
    scanf("%d", &n);
    m += n*50;
    scanf("%d", &n);
    m += n*100;
    scanf("%d", &n);
    m += n*500;
    printf("%d\n", m>=1000?1:0);
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF = 1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int par[5002],r[5002];
void init(){
	rep(i,5002){
		par[i] = i;
		r[i] = 0;
	}
}
int find(int x){
	if(x == par[x])return x;
	return par[x] = find(par[x]);
}
bool same(int x,int y){
	return find(x) == find(y);
}
void unit(int x,int y){
	if(same(x,y))return;
	x = find(x);
	y = find(y);
	if(r[x] < r[y]){
		par[x] = y;
	}
	else {
		par[y] = x;
		if(r[x] == r[y]){
			r[x] ++;
		}
	}
}

int main(){
	int n,m,x[5002];
	string a[5002],s[1002],t[1002];
	
	cin >> n;
	rep(i,n){
		cin >> a[i] >> x[i];
	}
	cin >> m;
	rep(i,m){
		cin >> s[i] >> t[i];
	}
	
	vector<string> Z;
	rep(i,n){
		Z.pb(a[i]);
	}
	sor(Z); uniq(Z);
	
	init();
	rep(i,m){
		unit(lb(Z,s[i])-Z.begin(),lb(Z,t[i])-Z.begin());
	}
	
	int cost[5002];
	rep(i,5002)cost[i] = INF;
	
	rep(i,n){
		cost[find(lb(Z,a[i])-Z.begin())] = min ( cost[find(lb(Z,a[i])-Z.begin())] , x[i] );
	}
	
	int ret = 0;
	rep(i,n){
		ret += cost[find(lb(Z,a[i])-Z.begin())];
	}
	
	cout << ret << endl;
}

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

int main(){
  int N;
  cin >>N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i,0,N) cin >> A[i];
  rep(i,0,N) cin >> B[i];
  rep(i,0,N-1) cin >> C[i];
  
  int ans = 0;
  int a = 100;
  rep(i,0,N){
    ans += B[A[i]-1];
    if((a+1)==A[i]) ans += C[A[i-1]-1];
    a = A[i];
  }
 
  cout <<ans<< 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() {
  int n; cin >> n;
  string str; cin >> str;
  
  int ans = 0;
  int rI = 0;
  for(int i = str.size() -1 ; i > 0; i--) {
    char temp = str.at(i);
    if(temp == 'R') {
        for(int j = rI; j < i; j++) {
           if(str.at(j) == 'W') {
           	 str.at(i) = 'W';
             str.at(j) = 'R';
             ans++;
             break;
           } else {
             rI = j;
           }
 		}
    }
  }
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3680
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	string S(500000, '0');
	string str;
	cin >> str;
	int len = str.size();
	S.replace(200001, len, str);

	int Left = 200000;
	int Right = Left + len + 1;

	int Q;
	cin >> Q;
	bool rev = false;
	string C;
	for(int i=0;i<Q;++i){
		int pat;
		cin >> pat;
		if (pat == 1) {
			rev = !rev;
		}
		else {
			int F;
			cin >> F >> C;
			if (F == 1) {
				if (rev == false) {
					S[Left] = C[0];
					Left--;
				}
				else {
					S[Right] = C[0];
					Right++;
				}
			}
			else {
				if (rev == false) {
					S[Right] = C[0];
					Right++;
				}
				else {
					S[Left] = C[0];
					Left--;
				}
			}
		}
	}
	if (rev == false) {
		cout << S.substr(Left+1,Right-1-Left) << endl;
	}
	else {
		for (int i = 0; i < Right - Left -1; ++i) {
			cout << S[Right - 1 - i];
		}
		cout << endl;
	}
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  vector <ll> v;
  set <ll> s;
  ll n,i,j,x;
  scanf("%lld", &n);
  for(i=1; i<=n; i++){
    scanf("%lld", &x);
    v.push_back(x);
    s.insert(x);
  }
  ll size_1 = v.size();
  ll size_2 = s.size();
  if(size_1==size_2){
    printf("YES\n");
  }
  else{
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
#define MAX 1050
#define INF 1<<28
int main(){
  int n,m,i,j,k;cin>>n>>m;
  int c[n],d[m],ans=INF;
  for(i=0;i<n;i++) cin>>c[i];
  for(i=0;i<m;i++) cin>>d[i];
  int dp[MAX][MAX];
  fill(dp[0],dp[MAX-1]+MAX,INF);
  dp[0][0]=0;
  for(i=0;i<m;i++)
    for(j=0;j<n;j++)
      dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+c[j]*d[i]),
	dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
  for(i=0;i<=m;i++) ans=min(ans,dp[i][n]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7380
#include <cassert>
#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>
*/

// 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 <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>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  if(n%2==0) cout<<n<<endl;
  else cout<<n*2<<endl;

}

int main(){
  solve();
  return 0;
}


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


int main(){
	string picture[100];
	int H,W;
	cin >> H >> W;
	
	for(int i=0;i<H;i++){
		cin >> picture[i];
	}
	for(int i=0;i<H;i++){
		cout << picture[i] << endl << picture[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  int cntb=0;
  while(B<=A){
    cntb++;
    B*=2;
  }
  int cntc=0;
  while(C<=B){
    cntc++;
    C*=2;
  }
  if(cntb+cntc<=K){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	Rep(i, n) cin >> A[i];
	int q;
	cin >> q;
	Rep(i, q) {
		int b, e, t;
		cin >> b >> e >> t;
		Rep(i, e - b) {
			swap(A[b + i], A[t + i]);
		}
	}
	Rep(i, n) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int[] l = new int[n];
        int[] r = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            sum += r[i] - l[i] + 1;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 25044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
ll a[200000];
int main()
{
	
	ll w;
	long double m,n;
	cin>>n>>m;
	 w=n*m;
    printf("%lld",w);
	 
 } 

Measured memory_bytes: 3800
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;
 
int main() {
    int n = 0, m = 0;
    ll l = 0;
    cin >> n >> m >> l;
    vector<vector<ll>> dis(n, vector<ll>(n, 1e10));
    for (int i=0; i<n; i++) {
        dis.at(i).at(i) = 0;
    }
    int a = 0, b = 0;
    ll c = 0;
    for (int i=0; i<m; i++) {
        cin >> a >> b >> c;
        if (c > l) continue;
        dis.at(a-1).at(b-1) = c;
        dis.at(b-1).at(a-1) = c;
    }

    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                if (dis.at(i).at(k) + dis.at(k).at(j) < dis.at(i).at(j)) {
                    dis.at(i).at(j) = dis.at(i).at(k) + dis.at(k).at(j);
                }
            }
        }
    }
 
    vector<vector<ll>> cnt(n, vector<ll>(n, 1e10));
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (i == j) {
                cnt.at(i).at(j) = 0;
            }
            else if (dis.at(i).at(j) <= l) {
                cnt.at(i).at(j) = 1;
            }
        }
    }
    for (int k=0; k<n; k++) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                if (cnt.at(i).at(k) + cnt.at(k).at(j) < cnt.at(i).at(j)) {
                    cnt.at(i).at(j) = cnt.at(i).at(k) + cnt.at(k).at(j);
                }
            }
        }
    }

    int q = 0;
    cin >> q;
    int s = 0, t = 0;
    vector<ll> ans(q);
    for (int i=0; i<q; i++) {
        cin >> s >> t;
        s--; t--;
        if (cnt.at(s).at(t) == 1e10) {
            ans.at(i) = -1;
        }
        else {
            ans.at(i) = cnt.at(s).at(t) - 1;
        }
    }
    for (ll x : ans) cout << x << endl;
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int> v;
	int n,a[10005],cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i-1]);
		v.push_back(a[i-1]);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(i%2==0)
		{
			cnt+=v[v.size()-1-i];
		}else
		{
			cnt-=v[v.size()-1-i];
		}
	}
	printf("%d",cnt);
}

Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  const int n = getInt();
  const int m = getInt();
  const int k = getInt();
  vector<vector<pair<int, int> > > g(n);
  vector<int> dp(n, -1);

  REP(i,m){
    const int a = getInt() - 1;
    const int b = getInt() - 1;
    const int c = getInt();

    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }

  typedef pair<int, int> data;
  priority_queue<data, vector<data>, greater<data> > pq;

  REP(i,k){
    int s = getInt() - 1;
    pq.push(make_pair(0, s));
  }

  while(pq.size()){
    data d = pq.top(); pq.pop();
    int cost = d.first;
    int pos  = d.second;

    if(dp[pos] != -1) continue;
    dp[pos] = cost;

    REP(i,g[pos].size()){
      int pp = g[pos][i].first;
      int cc = cost + g[pos][i].second;
      if(dp[pp] == -1) pq.push(make_pair(cc, pp));
    }
  }

  const int mx = *max_element(dp.begin(), dp.end());

  double ans = mx;
  REP(pp,n){
    REP(j,g[pp].size()){
      const int qq = g[pp][j].first;
      const int dd = g[pp][j].second;
      // dp[pp] + x == dp[qq] + (dd - x)
      // x = (dp[qq] - dp[pp] + dd) / 2.0
      const double x = (dp[qq] + dd - dp[pp]) / 2.0;
      if(0.0 < x && x < dd){
        ans = max(ans, dp[pp] + x);
      }
    }
  }

  printf("%d\n", (int)floor(ans + 0.5 + 1e-10));

  return 0;
}

Measured memory_bytes: 4472
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = Number(xs[0].split(' ')[0]);
   let K = Number(xs[0].split(' ')[1]);
   let l = [];
   for(let i=0; i<N; i++){
   l.push(xs[1].split(' ')[i]);
   }
   const compare = (b, a)=>{ //関数名は何でもOK
   return a - b;  //a - b 昇順 b - a 降順
   }
   l.sort(compare);
   
   let ans = 0;
   for(let i=0; i<K; i++){
     ans += Number(l[i]);
   }  
   console.log(ans);

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

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int SZ=1<<18;
int D[200000], D2[200000], tree[2*SZ];

int get_max(int s, int e)
{
	int ret=0;
	for(s+=SZ,e+=SZ;s<=e;s>>=1,e>>=1) {
		if(s&1) ret=max(ret,tree[s++]);
		if(~e&1) ret=max(ret,tree[e--]);
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K, C;
	string s;
	cin>>N>>K>>C>>s; ++C;
	for(int i=0;i<N;i++) {
		if(i) D[i]=D[i-1];
		if(s[i]=='o') D[i]=max(D[i],(i>=C ? D[i-C]:0)+1);
	}
	for(int i=N-1;i>=0;i--) {
		if(i+1<N) D2[i]=D2[i+1];
		if(s[i]=='o') D2[i]=max(D2[i],(i+C<N ? D2[i+C]:0)+1);
	}
	for(int i=0;i-C+1<N;i++) tree[SZ+i]=(i>=C ? D[i-C]:0)+(i+1<N ? D2[i+1]:0);
	for(int i=SZ;--i;) tree[i]=max(tree[2*i],tree[2*i+1]);
	for(int i=0;i<N;i++) if(s[i]=='o' && get_max(i,i+C-1)<K && (i>=C ? D[i-C]:0)+(i+C<N ? D2[i+C]:0)+1==K) cout<<i+1<<'\n';
	return 0;
}

Measured memory_bytes: 5268
#pragma GCC optimize("O3")

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

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll s=abs(v-w);
    if(v>w && s*t>=abs(a-b))
        cout << "YES\n";
    else
        cout << "NO\n";
    
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int P, Q, R; cin >> P >> Q >> R;
	cout << P + Q + R - max(P, max(Q, R)) << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

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

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

int main() {

    int n,m;
    cin >> n >> m;
    vector <int>data(n+m);
  
  	if(n == 0 & m == 0){
      cout << "0" << endl;
      return 0;
    }

    for(int i = 0; i < n; i++){
        data.at(i) = (i+1)*2;
    }
	
  	int index = 0;
    for(int i = n; i < n+m; i++){
        data.at(i) = index*2+1;
    }

    int counter = 0;
    rep(i,n+m){
    	for(int j = i; j < n+m; j++){
            if(i != j & (data.at(i) + data.at(j) ) % 2 == 0) counter++;
        }
      
      //cout << data.at(i) << endl;
    }

    cout << counter << endl;
}

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

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

    std::vector<int> V(N);
    std::vector<int> C(N);

    for (int i = 0; i < N; i++) {
        std::cin >> V[i];
    }

    for (int i = 0; i < N; i++) {
        std::cin >> C[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] > C[i]) ans += (V[i]-C[i]);
    }

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

    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

// [Related]: monoid
template <class Monoid>
struct SegmentTree {
    using T = typename Monoid::T;

    int n;
    vector<T> data;

    SegmentTree() {}

    SegmentTree(int size, T initial_value = Monoid::unit()) {
        n = 1;
        while (n < size) n <<= 1;
        data.assign(2 * n - 1, initial_value);

        if (initial_value != Monoid::unit()) {
            for (int i = n - 2; i >= 0; i--) data[i] = Monoid::merge(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    SegmentTree(const vector<T>& v) {
        int size = v.size();
        n = 1;
        while (n < size) n <<= 1;
        data.assign(2 * n - 1, Monoid::unit());

        for (int i = 0; i < size; i++) data[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) data[i] = Monoid::merge(data[i * 2 + 1], data[i * 2 + 2]);
    }

    T getLeaf(int k) {
        return data[k + n - 1];
    }

    void update(int k, T x) {
        k += n - 1; //葉の節点
        Monoid::update(data[k], x);
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = Monoid::merge(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    //区間[a, b)に対するクエリに答える
    //k:節点番号, [l, r):節点に対応する区間
    T query(int a, int b, int k, int l, int r) {
        //[a, b)と[l, r)が交差しない場合
        if (r <= a || b <= l) return Monoid::unit();
        //[a, b)が[l, r)を含む場合、節点の値
        if (a <= l && r <= b) return data[k];
        else {
            //二つの子をマージ
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return Monoid::merge(vl, vr);
        }
    }

    //外から呼ぶ用
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    //非再帰版: バグってるかもしれないので定数倍高速化する時以外使わないで
    //区間[a, b)に対するクエリに答える
    T query_fast(int a, int b) {
        T vl = Monoid::unit(), vr = Monoid::unit();
        for (int l = a + n, r = b + n; l != r; l >>= 1, r >>= 1) {
            if (l & 1) vl = Monoid::merge(vl, data[l++ - 1]);
            if (r & 1) vr = Monoid::merge(data[--r - 1], vr);
        }
        return Monoid::merge(vl, vr);
    }
};

template <class U = ll>
struct RangeMax {
    using T = U;
    static T merge(const T& x, const T& y) { return max(x, y); }
    static void update(T& target, const T& x) { target = x; }
    static constexpr T unit() { return 0; }
};

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

    int n, K;
    cin >> n >> K;

    SegmentTree< RangeMax<int> > st(300001);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        st.update(a, st.query(max(a - K, 0), min(a + K, 300000) + 1) + 1);
    }
    cout << st.query(0, 300001) << newl;

    return 0;
}

Measured memory_bytes: 7424
#include <cstdio>
#include <queue>

using namespace std;

int main() {
    int N, M, A;
    priority_queue<int> que;
    scanf("%d%d", &N, &M);
    for(int i=0; i<N; ++i) {
        scanf("%d", &A);
        que.push(A);
    }
    for(int i=0; i<M; ++i) {
        A = que.top();
        que.pop();
        que.push(A>>1);
    }
    long long sum = 0;
    while(!que.empty()) {
        sum += que.top();
        que.pop();
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 892
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)%2)
typedef long long ll;
typedef long double ld;
const ll oo=2*1000*1000*1000;
const int _cnt=1000*1000;
const int _p=1000*1000*1000+7;
int o(int x) { return x%_p; }
int gcd(int a,int b) { return (b)?gcd(b,a%b):a; }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
using namespace std;

void file_put(){
	freopen("filename.in","r",stdin);
	freopen("filename.out","w",stdout);
}

int n,m;
ll ans=0,a[200005],b[200005];

ll _get(ll a[],int n){
	ll ans=0,sum=0;
	for (int i=1; i<=n; i++) {
		sum=(sum+a[i])%_p;
		ans=(ans+i*a[i])%_p;
	}
	ans=(ans*2%_p-(ll)(n+1)*sum%_p)%_p;
	return ans;
}

int main(){
	//file_put();
	
	scanf("%d%d",&n,&m);
	for (int i=1; i<=n; i++) scanf("%lld",&a[i]);
	for (int i=1; i<=m; i++) scanf("%lld",&b[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	ans=(ll)(_get(a,n)%_p)*(_get(b,m)%_p)%_p;
	ans=(ans+_p)%_p;
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 1920
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	c := nextInt()

	colors := make(map[int]int)
	colors[a]++
	colors[b]++
	colors[c]++

	fmt.Println(len(colors))
}


Measured memory_bytes: 640
s = input()
for _ in range(int(input())):
    code=input().split()
    if code[0]=='print'  :
        print(s[int(code[1]):int(code[2])+1])
    elif code[0]=='reverse':
        s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:]
    elif code[0]=='replace':
        s = s[:int(code[1])] + code[3] + s[int(code[2])+1:]


Measured memory_bytes: 5616
function Main(input){

input=input.split(" ");
inA=parseInt(input[0]);
inB=parseInt(input[1]);

answerY = "Yay!";
answerN = ":(";

answer = answerY;
if (inA > 8 || inB > 8 ) {
    answer = answerN;
}

console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22332
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n, m;
vector<pair<int,int>> edges;
int cnt = 0;
void dfs(int now, vector<int> &visited, vector<vector<int>> &g){
    cnt++;
    for(int i = 0; i < g[now].size(); i++){
        int next = g[now][i];
        if(visited[next]) continue;
        visited[next] = 1;
        dfs(next, visited, g);
    }
}
int main(void){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges.push_back(make_pair(a, b));
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        vector<vector<int>> g(n);
        for(int j = 0; j < m; j++){
            if(j == i) continue;
            int a = edges[j].first;
            int b = edges[j].second;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        cnt = 0;
        vector<int> visited(n, 0);
        visited[0] = 1;
        dfs(0, visited, g);
        if(cnt != n) ans++;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
cityx = [[0,i]for i in range(N)]
cityy = [[0,i]for i in range(N)]
for i in range(N):
    x,y = map(int,input().split())
    cityx[i][0] = x
    cityy[i][0] = y

cityx.sort()
cityy.sort()
side = []
for i in range(N-1):
    side.append([cityx[i+1][0]-cityx[i][0], cityx[i+1][1], cityx[i][1]])
    side.append([cityy[i+1][0]-cityy[i][0], cityy[i+1][1], cityy[i][1]])
side.sort()
ans = 0
per = [i for i in range(N)]
rank = [0]*N
def find(x):
    if per[x] == x:
        return x
    else:
        per[x] = find(per[x])
        return per[x]

ans = 0

for cost,x,y in side:
    x = find(x)
    y = find(y)
    if x != y:
        ans += cost
        if rank[x] < rank[y]:
            per[x] = y
        else:
            per[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

print(ans)


Measured memory_bytes: 107644
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char s[51];
    int i = 0, count = 0, n;
    scanf("%d",&n);
    getchar();
    gets(s);
    while(s[i] != '\0')
    {
        if(s[i] == 'A'){
            if(s[i+1] == 'B'){
               if(s[i+2] == 'C') count++;}}
        i++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N, K;
    cin >> N >> K;
    int cnt = 0;
    REP(i, N) {
        int h;
        cin >> h;
        if(K <= h) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int p,t=0,ans=0;
    fr(i,3){
        cin>>p;
        t=max(t,p);
        ans+=p;
    }
    cout<<ans-t<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int N;
int a[100000];
int r[100000];
int rr[100000];

int main() {
	cin >> N;
	rep(i, N) cin >> a[i];

	rep(i, N) r[i] = 0;
	rep(i, N) {
		int ab = abs(i - (N-1-i));
		r[ab]++;
	}

	rep(i, N) rr[i] = 0;
	rep(i, N){rr[a[i]]++;}

	bool flg = true;
	rep(i, N){
		if(r[i] != rr[i]) flg = false;
	}

	if(flg){
		ll ret = 1;
		rep(i, N){
			ret *= max(r[i], 1);
			ret %= 1000000007;
		}
		cout << ret << endl;
	}
	else{
		cout << 0 << endl;
	}


}

Measured memory_bytes: 1408
// D.cpp
#include <bits/stdc++.h>
#define ll long long
#define pr pair<ll, ll>
using namespace std;
const int MAX_N = 10100;
ll seqA[MAX_N], seqB[MAX_N], seqC[MAX_N], x, y, z, k, current_seq[MAX_N << 2], tmp[MAX_N << 2];
struct node
{
    ll val, ptr1, ptr2;
    bool operator<(const node &nd) const { return val < nd.val; }
};
priority_queue<node> pq;
bool cmp(ll a, ll b) { return a > b; }
void solve(ll *seq)
{
    pq.push(node{current_seq[1] + seq[1], 1, 1});
    memset(tmp, 0, sizeof(tmp));
    for (int i = 1; i <= k && (!pq.empty()); i++)
    {
        node curt = pq.top();
        tmp[i] = curt.val, pq.pop();
        if (curt.ptr2 == 1 && current_seq[curt.ptr1 + 1] != 0)
            pq.push(node{current_seq[curt.ptr1 + 1] + seq[curt.ptr2], curt.ptr1 + 1, curt.ptr2});
        if (seq[curt.ptr2 + 1] != 0)
            pq.push(node{current_seq[curt.ptr1] + seq[curt.ptr2 + 1], curt.ptr1, curt.ptr2 + 1});
    }
    memcpy(current_seq, tmp, sizeof(tmp));
    while (!pq.empty())
        pq.pop();
}
int main()
{
    scanf("%d%d%d%d", &x, &y, &z, &k);
    for (int i = 1; i <= x; i++)
        scanf("%lld", &seqA[i]);
    for (int i = 1; i <= y; i++)
        scanf("%lld", &seqB[i]);
    for (int i = 1; i <= z; i++)
        scanf("%lld", &seqC[i]);
    sort(seqA + 1, seqA + 1 + x, cmp), sort(seqB + 1, seqB + 1 + y, cmp), sort(seqC + 1, seqC + 1 + z, cmp);
    for (int i = 1; i <= k; i++)
        current_seq[i] = seqA[i];
    solve(seqB), solve(seqC);
    for (int i = 1; i <= k; i++)
        printf("%lld\n", current_seq[i]);
    return 0;
}

Measured memory_bytes: 1152