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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

const int MAX = 510000;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(long long H, long long W, long long N, std::vector<long long> r, std::vector<long long> c) {
    r.push_back(H);
    c.push_back(W);

    vector<tuple<int, int, int>> vs;
    rep(i, N + 1) vs.emplace_back(r[i], c[i], i);
    sort(all(vs));

    COMinit();
    vi dp(3001, 0);
    rep(idx, N + 1) {
        int x, y, i;
        tie(x, y, i) = vs[idx];
        int ret = 0;
        rep(iidx, N + 1) {
            int x2, y2, j;
            tie(x2, y2, j) = vs[iidx];
            if (r[j] <= r[i] and c[j] <= c[i]) {
                int dr = r[i] - r[j];
                int dc = c[i] - c[j];
                ret += dp[j] * COM(dr + dc, dr);
                ret %= MOD;
            }
        }
        dp[i] = (COM(r[i] + c[i] - 2, r[i] - 1) - ret + MOD) % MOD;
    }

    cout << dp[N] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> r(N);
    std::vector<long long> c(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &r[i]);
        scanf("%lld", &c[i]);
    }
    solve(H, W, N, std::move(r), std::move(c));
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 1e5+5;
const int n = 4e5+5;
int maxa = 1e9+1;
int N;
int A[maxn];
int B[maxn];
int C[n];

//vector<int> vi;
//unordered_map<int,int> mp;

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

int sum(int x){
    int ret = 0;
    while(x > 0){
        ret += C[x];
        x -= lowbit(x);
    }

    return ret;
}

void add(int x,int d){
    while(x < n){
        C[x] += d;
        x += lowbit(x);
        //cout << x << endl;
    }
}

//[0,x)
LL shun(int x){
    LL ans = 0;
    _rep(i,0,x){
       int num = B[i];
       ans += sum(num);
       add(num,1);
       //cout << "ok" <<endl;
    }
    return ans;
}

bool valid(int m){
    memset(C,0,sizeof(C));
    B[0] = 0;
    int min_val = 0;

    _for(i,0,N){
        B[i+1] = B[i];
        if(A[i] >= m){
            B[i+1]++;
        }
        else{
            B[i+1]--;
        }
        min_val = min(min_val,B[i+1]);
    }


    int ad = -min_val + 1;
    _rep(i,0,N) B[i] += ad;


    LL ss = shun(N);
    //cout << ss <<endl;

    LL len = ((LL)N*(LL)(N+1))/2;
    return ss >= (1+len)/2;
}




int main()
{
    cin >> N;
    _for(i,0,N){
        scanf("%d",&A[i]);

    }
    int l = 1,r = maxa;
    while(l+1 < r){
        int m = (l+r)/2;
        //cout << l <<" "<<r<<endl;
        if(valid(m)){
            l = m;
        }
        else r = m;
    }

    cout << l <<endl;

    return 0;
}


Measured memory_bytes: 2560
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

/**
 * @author: pashka
 */


private fun solve() {
    var n = nextInt()
    var M = nextLong()
    var a = IntArray(n)
    for (i in 0 until n) {
        a[i] = nextInt()
    }
    a.sort()

    var l = 0
    var r = 3e5.toInt()
    while (r > l + 1) {
        var j = n
        var m = (l + r) / 2
        var cnt = 0L
        for (i in 0 until n) {
            // j = min : a[i] + a[j] >= m
            while (j > 0 && a[i] + a[j - 1] >= m) {
                j--
            }
            cnt += n - j
        }
        if (cnt >= M) {
            l = m
        } else {
            r = m
        }
    }

    var j = n
    var cnt = 0L
    var sum = 0L
    var sumR = 0L
    for (i in 0 until n) {
        while (j > 0 && a[i] + a[j - 1] >= l) {
            j--
            sumR += a[j]
        }
        cnt += n - j
        sum += (n - j) * a[i].toLong() + sumR
    }
    sum -= (cnt - M) * l

    println(sum)
}

fun main(args: Array<String>) {
    solve()
    out.close()
}

private var br = BufferedReader(InputStreamReader(System.`in`))
private var st: StringTokenizer? = null
private var out = PrintWriter(System.out)

@Throws(IOException::class)
private fun next(): String {
    while (st == null || !st!!.hasMoreTokens()) {
        st = StringTokenizer(br.readLine())
    }
    return st!!.nextToken()
}

@Throws(IOException::class)
private fun nextInt(): Int {
    return next().toInt()
}

@Throws(IOException::class)
private fun nextLong(): Long {
    return next().toLong()
}


Measured memory_bytes: 43928
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
int n,m;
ll x,sum,ans;
map<ll,int>mmp;
int main()
{
    scanf("%d%d",&n,&m);
    sum=0;
    ans=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&x);
        sum+=x;
        ans+=mmp[sum%m];
        if(sum%m==0) ans++;
        mmp[sum%m]++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
 
#define REP(i,n) for (int i=0;i<(n);++i)
 
using namespace std;
 
enum Result {
    STAY,
    FALL_RIGHT,
    FALL_LEFT,
};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<char> t(Q), d(Q);
    REP(i, Q) {
        cin >> t[i] >> d[i];
    }
 
    function<Result(int)> f = [&](int x) {
        REP(i, Q) {
            if (t[i] == s[x]) {
                if (d[i] == 'L') {
                    --x;
                    if (x == -1) {
                        return FALL_LEFT;
                    }
                } else if (d[i] == 'R') {
                    ++x;
                    if (x == N) {
                        return FALL_RIGHT;
                    }
                }
            }
        }
        return STAY;
    };
 
    int result = N;
 
    int low = 0;
    int high = N;
    while (low < high) {
        int step = (high - low) / 2;
        int x = low + step;
        if (f(x) == FALL_RIGHT) {
            high = x;
        } else {
            low = x + 1;
        }
    }
    result -= N - low;
 
    low = 0;
    high = N;
    while (low < high) {
        int step = (high - low) / 2;
        int x = low + step;
        if (f(x) == FALL_LEFT) {
            low = x + 1;
        } else {
            high = x;
        }
    }
    result -= low;
 
    cout << result << endl;
 
    return 0;
}

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

int h,w,m,hm[300050],wm[300050],p1,p2;
set<pair<int,int> > st;
vector<int> l,r;

int main()
{
	int x,y;
	cin>>h>>w>>m;
	
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		st.insert(make_pair(x,y));
		hm[x]++;
		wm[y]++;
		if(hm[x]>p1)
		{
			l.clear();
			p1=hm[x];
		}
		if(hm[x]==p1) l.push_back(x);
		if(wm[y]>p2)
		{
			r.clear();
			p2=wm[y];
		}
		if(wm[y]==p2) r.push_back(y);
	}
	
	for(int i=0;i<l.size();i++)
	   for(int j=0;j<r.size();j++)
	   {
	   	  if(st.find(make_pair(l[i],r[j]))==st.end())
	   	  {
	   	  	cout<<p1+p2;
	   	  	return 0;
		  }
	   }
	   
	cout<<p1+p2-1;
	
	return 0;
	
}

Measured memory_bytes: 21844
/*input
3
334 1000
334 1000
334 1000
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool comp(pii a , pii b){
	return a.s < b.s ; 
}
signed main() {
	IOS;
	int n;
	cin>>n;
	pii a[n];
	int start = 0 ; 
	for(int i=0;i<n;i++){
		cin>>a[i].f>>a[i].s;
	}
	sort(a,a+n,comp);
	for(int i=0;i<n;i++){
		if(start + a[i].f <= a[i].s){
			start = a[i].f + start ; 
		}
		else
		{
			return cout << "No",0;
		}
	}
	cout <<"Yes";
return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

const int INF=1e9;

//struct edge{int to,cost,time;};
struct edge{int cost,time;};

int main(){
	int n,m;
	while(cin >> n >> m, n || m){

		//vector<edge> es[n];
		edge es[m][m];
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++) es[i][j] = (edge){INF,INF};
		}

		int a,b,cost,time;
		for(int i=0;i<n;i++){
			cin >> a >> b >> cost >> time;
		//	es[a].emplace_back((edge){b,cost,time});
			es[a-1][b-1] = (edge){cost,time};
			es[b-1][a-1] = es[a-1][b-1];
		}

		int d_cost[m][m];
		int d_time[m][m];
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				d_cost[i][j] = es[i][j].cost;
				d_time[i][j] = es[i][j].time;
			}
		}

		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					d_cost[i][j] = min(d_cost[i][j],d_cost[i][k] + d_cost[k][j]);
					d_time[i][j] = min(d_time[i][j],d_time[i][k] + d_time[k][j]);
				}
			}
		}

		int k;
		cin >> k;
		for(int n=0;n<k;n++){
			int p,q,r;
			cin >> p >> q >> r;

			if(r==0) cout << d_cost[p-1][q-1] << "\n";
			else	cout << d_time[p-1][q-1] << "\n";
		}
	}

	return 0;
}



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

typedef struct
{
	int num;
	int value;
}replace;

int cmp1(const void *p,const void *q)
{
	return *(int *)p - *(int *)q;
}

int cmp2(const void *r,const void *s)//降順
{
	if(((replace*)s)->value==((replace*)r)->value)return ((replace*)s)->num - ((replace*)r)->num;
	return ((replace*)s)->value - ((replace*)r)->value;
}

int main()
{
	int n,m,b,c,i,j;
	int card[100010];
	//long long int cardsum[100010]={0};
	replace lst[100010];
	long long int din,max=0,ans=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&din);
		if(max<din)max=din;
		card[i]=din;
	}
	for(j=0;j<m;j++)
	{
		scanf("%d %d",&b,&c);
		lst[j].num=b;
		lst[j].value=c;
	}
	qsort(card,n,sizeof(int),cmp1);//カードのソート（昇順）
	qsort(lst,m,sizeof(replace),cmp2);//書き換え個数のソート（降順）
	
	
	//大きい書き換えを小さいものに反映させていけばいい
	
	int k,l=0;
	for(k=0;k<n;k++)
	{
		if(lst[l].num<=0)l++;
		if(lst[l].value>card[k])
		{
			card[k]=lst[l].value;
			lst[l].num--;
		}
		else break;
	}
	
	//cardsum[0]=card[0];
	for(i=0;i<n;i++)
	{
		//cardsum[i]=(cardsum[i-1]+card[i]);
		//printf("%d ",card[i]);
		ans+=(long long int)card[i];
	}
	printf("%lld",ans);
	
}


Measured memory_bytes: 2164
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------


int main() {

  int a, b, min;

  cin >> a >> b;

  min = a + b;
  min = max(min, a-b);
  min = max(min, a*b);

  cout << min << endl;



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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 long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int cnt[51] = { 0 };

int main()
{
	int N, M, a, b;

	cin >> N >> M;

	rep(i, M) {
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}

	repc(i, 1, N) cout << cnt[i] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const int maxn=105;
ll n,ans;
inline void init()
{
}
inline ll get(ll x)
{
	ll s=0;
	for(int i=1;i*i<=x;++i)
		if(x%i==0)
		{
			s+=2;
			if(i*i==x)
				--s;
		}
	return s;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	--n;
	for(int i=1;i<=n;++i)
		ans+=n/i;
	cout<<ans<<endl;
	return 0;
	for(ll c=1;c<=n-1;++c)
	{
		ll x=n-c;
		ans+=get(x);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
string s;

int main(){
	cin>>n>>s;
	if(n%2==0&&s.substr(0,n/2)==s.substr(n/2,n/2)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

using namespace std;

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> t(N, 0);
	for (int i = 0; i < M; ++i) {
		int A;
		cin >> A;
		t[A - 1] = 1;
	}
	int ans = min(accumulate(t.begin(), t.begin() + X, 0), accumulate(t.begin() + X, t.end(), 0));
	cout << ans << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

struct Rst {
  string s;
  int p, i;
  Rst() {}
  Rst(string _s, int _p, int _i): s(_s), p(_p), i(_i) {}

  bool operator<(const Rst &r) const {
    return s < r.s || (s == r.s && p > r.p);
  }
};

/* global variables */

Rst rs[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    char s[16];
    int p;
    scanf("%s%d", s, &p);
    rs[i] = Rst(string(s), p, i);
  }
  sort(rs, rs + n);

  for (int i = 0; i < n; i++) printf("%d\n", rs[i].i + 1);
  return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);

//-------------------------------------------


int main(){

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

    string s;
    cin >> s;
    bool flag = true;
    REP(i, s.size() ){

        char key = s[i];
        FOR(j, i+1, s.size()){
            if (key == s[j]){
                flag = false;
                break;
            }

        }
    }

    if(flag) { cout << "yes";}
    else{ cout << "no"; }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 5, mod = 1e9 + 7;

int a[N], tmam[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    for(int i = 0; i < n; i++){
        int x = a[i];
        mp[x]++;
        if(tmam[x] || mp[x] > 1) continue;
        for(int j = x + x; j < N; j+=x){
            tmam[j] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(mp[a[i]] > 1 || tmam[a[i]]) continue;
        ans++;
    }
    cout << ans;


    return 0;

}



Measured memory_bytes: 17616
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var ans = 1, up = 0, x = next();
  for(var i = 1; i < n; i++){
    var a = next();
    if(x === a)continue;
    if(up === 0){
      if(x > a)up = -1; else up = 1;
    }else if((x > a && up === 1) || (x < a && up === -1))ans++, up = 0;
    x = a;
  }
  return ans++;
}

Measured memory_bytes: 40744
#include<cstdio>
#include<iostream>
#define MAX (int)1e5
using namespace std;
int a[MAX+7],f[MAX+7];
int find(int x)
{
	if(f[x]!=x) f[x]=find(f[x]);
	return f[x];
}
int main()
{
	int n,m,i;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		f[i]=i;
		scanf("%d",&a[i]);
	}
	for(i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		int fx=find(x),fy=find(y);
		if(fx!=fy)
			f[fx]=fy;
	}
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(find(i)==find(a[i]))
			ans++;
	}
	cout<<ans<<endl;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == 'S') puts("Cloudy");
    if(s[0] == 'C') puts("Rainy");
    if(s[0] == 'R') puts("Sunny");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool tag[100];
int n;
int main(){
	for(int i=1;i<=9;i++)
	  for(int j=1;j<=9;j++) tag[i*j]=1;
	scanf("%d",&n);
	if(tag[n]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> mas(N+1, 0);
    rep(i, M) {
        int a;
        cin >> a;
        mas[a] = 1;
    }

    int res;
    int l=0, r=0;
    for(int i=0; i<X; i++) l+=mas[i];
    for(int i=X; i<N+1; i++) r+=mas[i];
    res = min(l, r);

    cout << res <<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b[ohara],d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[1500][6000];
V c[2000];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    rep(i,m){
        cin>>a[i]>>b[i];
        rep(j,b[i]){
            cin>>d;
            d--;
            c[i].p_b(d);
        }
    }
    rep(i,1200){
        rep(j,6000){
            dp[i][j]=LINF;
        }
    }
    dp[0][0]=0;
    rrep(i,1,m+1){
        tmp=0;
        rep(j,b[i-1]){
            tmp|=(1LL<<c[i-1][j]);
            //cout<<c[i-1][j]<<" ";
        }
        //cout<<tmp<<"\n";
        //cout<<"\n";
       
        rep(j,5000){
          dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if((j | tmp)>=5000)continue;
            dp[i][(j | tmp)]=min({dp[i-1][(j | tmp)],dp[i][(j | tmp)],dp[i-1][j]+a[i-1]});
        }
    }
    tmp=0;
    rrep(i,0,n)tmp|=(1LL<<i);
    if(dp[m][tmp]==LINF)Cout(-1);
    else Cout(dp[m][tmp]);
    return 0;
}


Measured memory_bytes: 61824
#include <stdio.h>
#include <string.h>
int main(){ 
char a[11],b[11],c[11];
scanf("%s%s%s",a,b,c);
    if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
    printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

vector<int> v;

int N;
int main(){
    cin >> N;
    int A,B;
    cin >> A >> B;
    int x=0,y=0,z=0;
    for(int i=0; i<N; i++) {
        int p;
        cin >> p;
        if( p <= A ) {
            x++;
        } else if( p <= B ) {
            y++;
        } else z++;
    }
    cout << min( x, min(y,z)) << endl;
    return 0;
}


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

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
//#define int ll //オーバーフローでWAのときコメントアウトする(非推奨)
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e15)
#pragma endregion


int main() {
	ll n, a, b; put n >> a >> b;
	ll h[100000];
	rep(i, n) {
		put h[i];
	}
	ll mid;
	ll low = 1;
	ll hi = 1000000000;
	while (hi > low + 1) {
		mid = ( hi + low ) / 2;
		dbg(mid);
		bool ok = false;
		ll count = mid;//魔法回数
		rep(i, n) {
			if (h[i] - b * mid <= 0)continue;
			else {
				count -=
					(( ( h[i] - b * mid ) % ( a - b ) == 0 ) ? 0 : 1)
					+ ( h[i] - b* mid ) / ( a - b );
			}
			dbg(count);
		}
		if (count > 0) {
			hi = mid;
		}
		else {
			low = mid;
		}
	}
	bool flag = false;
	ll cnt = low;//
	rep(i, n) {
		if (h[i] - b * low <= 0)continue;
		else {
			cnt -= 
				(((h[i] - b * low) % ( a-b) == 0)  ? 0:1)
			  + (h[i] - b* low) / ( a - b );
		}
		
	}
	dbg(cnt);
	if (cnt < 0) { putans(hi); }
	else { putans(low); }
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
int a;
int b;
int c;
int oppai;
scanf("%d%d%d",&a,&b,&c);
if(b<a)
{
oppai = a;
a = b;
b = oppai;
}
if(c<b)
{
oppai = b;
b = c;
c = oppai;
}
if (b<a)
{
oppai = a;
a = b;
b = oppai;
}

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

	return 0;
}




Measured memory_bytes: 2036
while True:
    n=int(input())
    if n==0:
        break
    else:
        i=0
        while True:
            if n==1:
                break
            else:
                i+=1
                if n%2==0:
                    n=n//2
                else:
                    n=3*n+1
        print(i)


Measured memory_bytes: 5588
N,M = list(map(int, input().split()))

LR = []
max_L = 0
min_R = N
for i in range(M):
    LR = list(map(int, input().split()))
    if max_L < LR[0]:
        max_L = LR[0]
    if min_R > LR[1]:
        min_R = LR[1]

if min_R-max_L >= 0:
    print(min_R-max_L+1)
else:
    print(0)

Measured memory_bytes: 3064
H, W = list(map(int, input().split()))

a = []
for i in range(H):
    a.append(list(map(int, input().split())))

re = []
for i in range(H):
    for j in range(W):
        # 奇数の場合
        if a[i][j] % 2 == 1:
            if i < H - 1:
                a[i][j] -= 1
                a[i+1][j] += 1
                re.append([i+1,j+1,i+2,j+1])
            elif j < W - 1:
                a[i][j] -= 1
                a[i][j+1] += 1
                re.append([i+1,j+1,i+1,j+2])
print(len(re))
for r in re:
    print(r[0], r[1], r[2], r[3])

Measured memory_bytes: 30236
#define _CRT_SECURE_NO_WARNINGS
 
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>
 
#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
 
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;
 
int main() {
	string s;
	cin >> s;
	bool ans = true;
	if (s[0] != 'A') ans = false;
 
	int ix = -1;
	REPS(i, 2, s.size() - 1) {
		if (s[i] == 'C') {
			ix = i;
			break;
		}
		if (i == s.size() - 2) ans = false;
	}
	if (ix >= 2) {
		REPS(i, 1, s.size()) {
			if (i != ix) {
				if (islower(s[i]) == 0) ans = false;
			}
		}
	}
	if (ans) cout << "AC";
	else cout << "WA";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
N,M = map(int, input().split())
H = list(map(int, input().split()))
goodTowerFlag = [True] * N

for _ in range(M):
	a,b = map(int, input().split())
	if H[a-1] <= H[b-1]:
		goodTowerFlag[a-1] = False
	if H[b-1] <= H[a-1]:
		goodTowerFlag[b-1] = False

print(goodTowerFlag.count(True))

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[5005];
bool dpL[5005][5005];
bool dpR[5005][5005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    memset(dpL, 0, sizeof(dpL));
    memset(dpR, 0, sizeof(dpR));
    dpL[0][0] = true;
    REP(i, N) {
        REP(j, K + 1) {
            dpL[i + 1][j] |= dpL[i][j];
            if (j + A[i] <= K)
                dpL[i + 1][std::min(K, j + A[i])] |= dpL[i][j];
        }
    }
    dpR[N][0] = true;
    for (ll i = N - 1; i >= 0; --i) {
        REP(j, K + 1) {
            dpR[i][j] |= dpR[i + 1][j];
            dpR[i][std::min(K, j + A[i])] |= dpR[i + 1][j];
        }
    }

    ll ans = 0;
    REP(i, N) {
        vector<ll> v(K + 5, 0);
        REP(j, K + 1) {
            if (dpR[i + 1][j])
                v[j]++;
            v[j + 1] += v[j];
        }

        bool e = false;
        REP(j, K) {
            if (!dpL[i][j])
                continue;
            //! K-A[i] -> K-1
            ll m = K - 1 - j;
            ll d = K - A[i] - j - 1;
            ll s = v[m];
            if (d >= 0)
                s -= v[d];
            if (s > 0) {
                e = true;
                break;
            }
        }
        if (!e)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;

#define endl '\n'
ll n;
ll arr[3005];
ll dp[3005][3005][2];
ll solve(ll i,ll j,ll s)
{

    if(i>j){
        return 0;
    }

    if(dp[i][j][s]==-1){

        if(s==0){
            dp[i][j][s] = max(arr[i]+solve(i+1,j,1),arr[j]+solve(i,j-1,1));
        }
        else{
            dp[i][j][s] = min(-arr[i]+solve(i+1,j,0),-arr[j]+solve(i,j-1,0));
        }
    }
    //cout<<i<<" "<<j<<" "<<s<<" "<<dp[i][j][s]<<endl;
    return dp[i][j][s];


}

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

    cout.tie(0);

    memset(dp,-1,sizeof(dp));
    cin>>n;

    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }

    cout<<solve(0,n-1,0)<<endl;






}


Measured memory_bytes: 141568
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
	int N, K, count = 0;
	

	cin >> N >> K;
	int h[N];
	for(int i=0;i<N;i++){
		cin >> h[i];
		if(h[i] >= K) count++;
	}

	cout << count << "\n";
}

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, a[max_n], b[max_n], sa[max_n];
pair<int, int> p[max_n];
map<int, int> pos;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &p[i].second);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &p[i].first);
    }
    sort(p, p + n);
    for (int i = 0; i < n; ++i) {
        a[i] = p[i].second;
        b[i] = p[i].first;
        sa[i] = a[i];
    }
    sort(sa, sa + n);
    for (int i = 0; i < n; ++i) {
        if (sa[i] > b[i]) {
            puts("No");
            return 0;
        }
    }
    for (int i = 0; i + 1 < n; ++i) {
        if (sa[i + 1] <= b[i]) {
            puts("Yes");
            return 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        pos[a[i]] = i;
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int p = pos[sa[i]];
        //cout << i << ": " << p << endl;
        if (p == i) {
            ++cnt;
        } else {
            int p1 = pos[a[p]], p2 = pos[a[i]];
            swap(pos[a[p]], pos[a[i]]);
            swap(a[p1], a[p2]);
        }
    }
    //cout << "$" << cnt << endl;
    if (cnt <= 1) {
        puts("No");
    } else {
        puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 8960
N = int(raw_input())
alist = raw_input().split()
a = {}
for i in range(len(alist)):
  a[i] = int(alist[i])

minv = -101
minsum = 99999999
for i in range(-100, 101):
  sums = 0
  for k in range(len(a)):
    sums += (a[k] - i) * (a[k] - i)
  if sums < minsum:
    minv = i
    minsum = sums

print minsum

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >> S;
    int ans=700;
    rep(i,3){
        if(S[i]=='o') ans+=100;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void wri(ll a){write(a); putchar(' ');}
inline void writeln(ll a){write(a); puts("");}
const int N=100005;
ll sz[N];
int f[N],ans[N],fa[N];
pair<int,pair<int,int> > e[N];
inline int gf(int x){
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
signed main(){
	int n=read(),m=read();
	for(int i=1;i<=n;i++)sz[fa[i]=i]=read();
	for(int i=1;i<=m;i++){
		int s=read(),t=read(),w=read();
		e[i]=mp(w,mp(s,t));
	}
	sort(&e[1],&e[m+1]);
	int cnt=0;
	for(int i=1;i<=m;i++){
		int s=e[i].second.first,t=e[i].second.second,w=e[i].first;
		int tx=gf(s),ty=gf(t);
		if(tx==ty){if(sz[tx]<w){f[tx]++;cnt++;} continue;}
		fa[tx]=ty; sz[ty]+=sz[tx]; f[ty]+=f[tx]; f[ty]++; cnt++; //cout<<sz[ty]<<" "<<cnt<<endl;
		if(sz[ty]>=w){cnt-=f[ty]; f[ty]=0;}
	}
	cout<<cnt<<endl;
}


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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i < K)
      ans += X;
    else
      ans += Y;
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    bool clear = false;
    
    for(int i = 1; i <=3; i++){
        if((A * B * i) % 2 == 1){
            clear = true;
        }
    }if(clear) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.length();++i){
    if(s[i]!=t[i]){
      ++ans;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int area = x * y;
        int length = 2 * (x+y);

        System.out.print(area);
        System.out.print(" ");
        System.out.println(length);
    }
}


Measured memory_bytes: 25964
#include<stdio.h>
#include <stdlib.h>
int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
int adjust_time(int input_time){
    if(input_time%10 == 0){
        return input_time;
    }
    input_time += (10 - (input_time % 10));
    return input_time;

}

int get_last_dish(int tmp_array[10]){
    int max_value = 0; //一番増える量の多いやつを選ぶ
    int max_index = 0;
    int tmp_value = 0;
    for (int i =0;i<5;i++){
        if(tmp_array[i]%10 == 0){
            continue;
        }
        tmp_value = 10 - (tmp_array[i] % 10);
        if(max_value < tmp_value){
            max_value = tmp_value;
            max_index = i;
        }
    }
    // printf("***%d***\n",min_index);
    return max_index;
}
int main()
{
    int a,b,c,d,e = 0;
    int el_time = 0;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);

    int tmp_array[5] = {a,b,c,d,e};
    int last_index = get_last_dish(tmp_array);
    for(int i=0;i<5;i++){
        if(!(i == last_index)){
            el_time+=adjust_time(tmp_array[i]);
        }
    }
    el_time += tmp_array[last_index];
    printf("%d", el_time);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//関数
const long MOD=1000000007;

int main(void){
    //入力
    long H,W;
    cin>>H>>W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin>>S.at(i);
    }
    
    //計算
    vector<vector<long>> yoko(H,vector<long>(W)), tate(H,vector<long>(W));
    
    for(int i=0;i<H;i++){
        long count=0;
        for(int j=0;j<W;j++){
            if(S.at(i).at(j)=='.') count++;
            else count=0;
            yoko.at(i).at(j)=count;
        }
        long hold=yoko.at(i).at(W-1);
        for(int j=W-1;j>=0;j--){
            if(yoko.at(i).at(j)>0){
                if(hold==0) hold=yoko.at(i).at(j);
                else yoko.at(i).at(j)=hold;
            } else{
                if(hold!=0) hold=0; 
            }
        }
    }
    
    for(int j=0;j<W;j++){
        long count=0;
        for(int i=0;i<H;i++){
            if(S.at(i).at(j)=='.') count++;
            else count=0;
            tate.at(i).at(j)=count;
        }
        long hold=tate.at(H-1).at(j);
        for(int i=H-1;i>=0;i--){
            if(tate.at(i).at(j)>0){
                if(hold==0) hold=tate.at(i).at(j);
                else tate.at(i).at(j)=hold;
            } else{
                if(hold!=0) hold=0; 
            }
        }
    }
    
    
    long ans=-1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans=max(ans,yoko.at(i).at(j)+tate.at(i).at(j)-1);
        }
    }
    
    //出力
    cout<<ans<<endl;
}

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

int main(){

  int a[5];
  for(int i = 0;i<5;i++){
    cin >> a[i];
  }

  int x=0,y=0;

  x = a[0]*a[4];
  if(a[4] < a[2]) y = a[1];
  else{
    y = a[1] + (a[4]-a[2])*a[3];
  }
  if(x>y) cout << y << endl;
  else  cout << x << endl;


}

Measured memory_bytes: 1160
d, g = map(int, input().split())
pc = [0] + [[int(i) for i in input().split()] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    n = min(g // (100 * i), pc[i][0])
    score = 100 * i * n
    if n == pc[i][0]:
        score += pc[i][1]
    if g > score:
        n += dfs(g - score, i - 1)
    return min(n, dfs(g , i - 1))

print(dfs(g, d))

Measured memory_bytes: 3064
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string result = "";
            var line = Console.ReadLine().Split(' ');
            foreach(var item in line)
            {
                int r;
                if(!int.TryParse(item,out r) || int.Parse(item) < -100 || int.Parse(item) > 100)
                {
                    result = "No";
                    break;
                }
            }

            if(result == "")
            {
                int a = int.Parse(line[0]);
                int b = int.Parse(line[1]);
                int c = int.Parse(line[2]);

                if(c >= a && c <= b)
                {
                    result = "Yes";
                }
                else
                {
                    result = "No";
                }
            }

            Console.WriteLine(result);

            //Console.ReadKey();
        }
    }
}


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

using namespace std;
typedef long long ll;

ll a[100001];
ll memo[100001];
ll memo1[100001];
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){
  int n;
  cin >> n;
  int tmp;
  rep(i,n){
    cin >> a[i];
    if(i==0){
      tmp=a[0];
    }
    tmp=gcd(a[i],tmp);
    memo[i]=tmp;
  }
  tmp=a[n-1];
  rep(i,n){
    tmp=gcd(a[n-i-1],tmp);
    memo1[n-i-1]=tmp;
  }
  int ans=0;
  rep(i,n){
    if(i==0){
      ans=memo1[i+1];
    }
    else if(i==n-1){
      if(ans<memo[i-1]){
        ans=memo[i-1];
      }
    }
    else{
      if(ans<gcd(memo[i-1],memo1[i+1])){
        ans=gcd(memo[i-1],memo1[i+1]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,q,era[1000],we[1000];
char nm[1000][20];


int main()
{
	while(scanf("%d%d",&n,&q),n)
	{
		rep(i,n)scanf("%s%d%d",nm+i,era+i,we+i);
		rep(i,q)
		{
			int y; scanf("%d",&y);
			rep(j,n)if(we[j]-era[j]<y&&y<=we[j])
			{
				printf("%s %d\n",nm[j],y-we[j]+era[j]);
				goto END;
			}
			puts("Unknown"); END:;
		}
	}
	return 0;
}

Measured memory_bytes: 916
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
xy1ma=-10**10
xy1mi=10**10
xy2ma=-10**10
xy2mi=10**10
for x,y in xy:
  xy1ma=max(xy1ma,x-y)
  xy1mi=min(xy1mi,x-y)
  xy2ma=max(xy2ma,x+y)
  xy2mi=min(xy2mi,x+y)
print(max(xy1ma-xy1mi,xy2ma-xy2mi))


Measured memory_bytes: 102476
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll dfs(ll a,ll b){
    ll res=0;
    return res+=(a%b?a/b*2*b+dfs(b,a%b):a/b*2*b-b);
}
int main(){
   ll n,x;cin>>n>>x;
   ll ans=0;
   ll tmp=n-x;
   if(tmp<x)swap(x,tmp);
   ans=dfs(tmp,x)+n;
   cout<<ans<<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 ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  string n;
  cin >> n;
  cout << "ABC" + n << endl;
}

Measured memory_bytes: 3608
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    K, N = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    max_d = K - A[-1] + A[0]
    for i in range(1, N):
        max_d = max(max_d, A[i] - A[i - 1])
    print(K - max_d)


if __name__ == '__main__':
    solve()


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
ll B[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll M;
    cin >> M;
    REP(i, M) {
        cin >> B[i];
    }

    vector<ll> v;
    REP(i, N) {
        auto it = lower_bound(B, B + M, A[i]);
        if (A[i] != *it)
            v.push_back(A[i]);
    }
    REP(i, v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int h1, m1, h2, m2, k;
    cin>>h1>>m1>>h2>>m2>>k;
    int st, en;
    st=h1*60+m1;
    en=h2*60+m2;
    int ans=en-st-k;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
//题目：有n(n<=3*1e5)个格子，每个格子可以选择涂成红色、蓝色、绿色或不涂色，
//三种颜色分别产生a,b,a+b(a,b<=3*1e5)的收益。问有多少种涂色方案使得总收益为 k(k<=18*1e10)。
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;

const int MOD=998244353;
const int N=3e5+5;
long long inv[N],finv[N],k[N];

void init()
{
	k[0]=k[1]=1;
	for(int i=2;i<=300000;i++){
		k[i]=k[i-1]*i%MOD;
	}
	inv[1]=1;
	for(int i=2;i<=300000;i++){
		inv[i]=(MOD-MOD/i*inv[MOD%i]%MOD)%MOD; 
	}
	finv[0]=finv[1]=1;
	for(int i=2;i<=300000;i++){
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

int main()
{
	ll n,a,b,d,x,y,s;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&s);
	init();
	ll ans=0;
	for(int i=0;i<=n;i++){
		if(i*a>s)break;
		ll j=s-i*a;
		if(j/b>n)continue;
		if(j%b==0){
			j/=b;
			ans=(ans+k[n]*finv[i]%MOD*finv[n-i]%MOD*k[n]%MOD*finv[j]%MOD*finv[n-j]%MOD)%MOD;
		}
	}
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 7168
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
# L = list(map(int, input().split()))
# A, B = map(int, input().split())
S = input()

l = len(S) - 1
leng = l // 2

check1 = "01" * leng
check2 = "10" * leng

if l % 2 != 0:
    check1 = "1" + check1
    check2 = "0" + check2

check1 = int(check1, 2)
check2 = int(check2, 2)
S = int(S, 2)

check1 ^= S
check2 ^= S

print(min(bin(check1).count('1'), bin(check2).count('1')))



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

using namespace std;
int main(void){
    int n, x =0;
    int j, d =0;
    int ans =1;
    cin >> n >> x;
    vector<int>L(n, 0);
    rep(i, n) cin >> L[i];
    rep(i, n){
        d+= L[i];
        if(d>x){
            cout << ans;
            return 0;;
        }
        ans+=1;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

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

  string s;
  vector<char> r;
  cin >> s;

  REP (i, s.length()) {
    r.push_back(s[i]);
    if (r.size() >= 2) {
      int L = r.size();
      if (r[L-2] == 'S' && r[L-1] == 'T') {
        r.pop_back();
        r.pop_back();
      }
    }
  }

  cout << r.size() << endl;
  
  return 0;
}


Measured memory_bytes: 788