akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    B = [tuple(map(int, input().split())) for _ in range(m)]
    B.sort(reverse=True, key=itemgetter(1))
    tmp = 0
    for b, c in B:
        for i in range(tmp, b+tmp):
            if A[i] < c:
                A[i] = c
                tmp += 1
                if i == n-1:
                    print(sum(A))
                    exit()
            else:
                print(sum(A))
                exit()
    print(sum(A))


if __name__ == '__main__':
    main()

Measured memory_bytes: 31072
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n, m, x;
    cin >> n >> m >> x;
    ll cost_left = 0, cost_right = 0;
    for(int i = 0; i < m; ++i){
        ll a;
        cin >> a;
        if(a < x){
            cost_left++;
        }else{
            cost_right++;
        }
    }
    cout << min(cost_left, cost_right) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
ll n,m,k;
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<10;i++)
	{
		k=n*k-m;
		cout <<k<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
a = raw_input()

c = []
f = []
for i in range(len(a)):
    if a[i] == 'C':
        c.append(i)

    elif a[i] == 'F':
        f.append(i)

if c==[] or f==[]:
    print 'No'
elif min(c)<max(f):
    print 'Yes'

else:
    print 'No'


Measured memory_bytes: 2568
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)
#define VEC2(type,name,w,h) vector<vector<type>>name(h,vector<type>(w))

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    vector<tuple<ll,ll>> t;
    ll a,n,b;
    cin>>n;
    rep(i,n){
        cin>>a>>b;
        t.push_back(make_tuple(b,a));
    }
    ll time=0;
    sort(ALL(t));
    for(auto i : t){
        time+=get<1>(i);
        // cout<<"now-time:"<<time<<"  limit:"<<b<<"  a:"<<a<<endl;
        if(get<0>(i)<time){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}
/*
*/

Measured memory_bytes: 7472
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
	int i, j, tmp, g = 0, k = 3,cnt = 0;
	vector<int> A;

	rep(i, 3) {
		scanf("%d", &tmp);
		A.push_back(tmp);
	}

	sort(A.rbegin(), A.rend());

	rep(i, 3) {
		if ((A.at(i) & 1) == 0) {
			g++;
		}
	}
	k -= g;
	if (g == 2) {
		rep(i, 3) {
			if ((A.at(i) & 1) == 0) {
				A.at(i)++;
				
			}
		}
		cnt++;
	}
	else if(k == 2){
		rep(i, 3) {
			if ((A.at(i) & 1) == 1) {
				A.at(i)++;
				
			}
		}
		cnt++;
	}

	cnt += ((A.at(0) - A.at(1)) / 2) + ((A.at(0) - A.at(2)) / 2);
	printf("%d\n", cnt);
	return 0;
	

	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];
        int[] D = new int[M];
        for (int i = 0; i < M; ++i) {
            L[i] = sc.nextInt() - 1;
            R[i] = sc.nextInt() - 1;
            D[i] = sc.nextInt();
        }

        System.out.println(solve(N, L, R, D) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int N, int[] L, int[] R, int[] D) {
        Parent[] parents = new Parent[N];

        for (int i = 0; i < L.length; ++i) {
            Root rootL = findRoot(parents, L[i]);
            Root rootR = findRoot(parents, R[i]);

            if (rootL.index == rootR.index) {
                if (rootL.totalDelta + D[i] != rootR.totalDelta) {
                    return false;
                }
            } else {
                parents[rootR.index] = new Parent(rootL.index, rootL.totalDelta + D[i] - rootR.totalDelta);
            }
        }

        return true;
    }

    static Root findRoot(Parent[] parents, int node) {
        int rootIndex = node;
        int totalDelta = 0;
        while (parents[rootIndex] != null) {
            totalDelta += parents[rootIndex].delta;
            rootIndex = parents[rootIndex].index;
        }
        Root result = new Root(rootIndex, totalDelta);

        int p = node;
        while (p != rootIndex) {
            int nextIndex = parents[p].index;
            int nextTotalDelta = totalDelta - parents[p].delta;

            parents[p] = new Parent(rootIndex, totalDelta);

            p = nextIndex;
            totalDelta = nextTotalDelta;
        }

        return result;
    }
}

class Parent {
    int index;
    int delta;

    Parent(int index, int delta) {
        this.index = index;
        this.delta = delta;
    }
}

class Root {
    int index;
    int totalDelta;

    Root(int index, int totalDelta) {
        this.index = index;
        this.totalDelta = totalDelta;
    }
}

Measured memory_bytes: 156984
#include <iostream>

using namespace std;

int main(){
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;

    for (int i=1; i<=k; i++){
        if (i<=a){
            ans += 1;
        }  else if (i<=a+b){
                continue;
        } else {
            ans -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

string str;

while(1){

cin >> str;

if(str =="0"){
break;
}

int sum=0;

for(int i=0;i<(int)str.size();i++){
sum += str[i] - '0';

}

cout << sum << endl;

}

return 0;

}


Measured memory_bytes: 3180
n = gets.to_i

x = []
u = []
n.times do|i|
	x[i], u[i] = gets.strip.split(" ")
	if u[i] == "JPY"
		x[i] = x[i].to_i
	else
		x[i] = x[i].to_f * 380000.0
	end
end

#p x
#p u
puts x.inject(:+)

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
 
int main(){
  int D,N;
  cin >> D >> N;
  if(D==0){
    if(N==100){
      cout << 101 << endl;}
    else{
      cout << N << endl;}
  }
  if(D==1){
    if(N==100){
      cout << 10100 << endl;}
    else{
      cout << N*100 << endl;}
  }
  if(D==2){
    if(N==100){
      cout << 1010000 << endl;}
    else{
    cout << N*10000 << endl;}
  }
}

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

using namespace std;

int solve(){
    int n;
    cin>>n;
    int res=0;
    for (int i = 1; i <= n; i++)
    {
        int t;
        cin>>t;
        if(i%2!=0 && t%2!=0) res++;
    }

    cout<<res;
    
    return 0;
}

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


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
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;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<ll> a(Q), b(Q);
    REP(i, Q) cin >> a[i] >> b[i];

    REP(i, Q){
        ll A = a[i], B = b[i];

        if(A > B) swap(A, B);

        if(A == B){
            cout << 2 * A - 2 << endl;
            continue;
        }

        if(A + 1 == B) {
            cout << 2 * A - 2 << endl;
            continue;
        }

        ll C = floor(sqrt(A * B));
        if(C * C == A * B) C--;

        if(C * (C + 1) >= A * B) {
            cout << 2 * C - 2 << endl;
            continue;
        }

        if(C * (C + 1) < A * B) {
            cout << 2 * C - 1 << endl;
            continue;
        }
    }

    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#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 uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

ll N;
string S;
vector<ll> A;
vector<ll> idxs[3];
bool l[300010],r[300010];
P col[300010];
ll cnt[3];

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

  ll res=1;
  cin>>N;
  cin>>S;
  A.resize(3*N);
  rep(i,3*N){
    if(S[i]=='R')A[i]=0;
    if(S[i]=='G')A[i]=1;
    if(S[i]=='B')A[i]=2;
    idxs[A[i]].push_back(i);
    col[i]=P(-1,-1);
  }

  rep(i,N){
    vector<ll> tmp;
    rep(j,3)tmp.push_back(idxs[j][i]);
    sort(all(tmp));
    col[tmp[1]]=P(A[tmp[0]],A[tmp[2]]);
    l[tmp[0]]=true;
    r[tmp[2]]=true;
  }

  rep(i,3*N){
    if(col[i]==P(-1,-1)){
      if(l[i])cnt[A[i]]++;
    }else{
      (res*=cnt[col[i].fi])%=mod;
      cnt[col[i].fi]--;
    }
  }
  memset(cnt,0,sizeof(cnt));
  for(ll i=3*N-1;i>=0;i--){
    if(col[i]==P(-1,-1)){
      if(r[i])cnt[A[i]]++;
    }else{
      (res*=cnt[col[i].se])%=mod;
      cnt[col[i].se]--;
    }
  }
  rep(i,N)(res*=(i+1))%=mod;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 11012
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	long l, r;
	cin >> l >> r;
	int waruL = l / 2019;
	int waruR = r / 2019;
	if (waruL < waruR)
	{
		cout << 0;
		return 0;
	}
	l = l % 2019;
	r = r % 2019;
	int m = 2019;
	for (int i = l; i < r; i++)
	{
		for (int j = i + 1; j <= r; j++)
		{
			if ((i * j) % 2019 < m)
			{
				m = (i * j) % 2019;
			}
		}
	}
	cout << m;
}



Measured memory_bytes: 31488
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		String acl = "ACL";
      
      	for(int i = 0;i < n;i++) System.out.print(acl);

		System.out.println();
	}
}

Measured memory_bytes: 35684
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long

int main(){
    ll a,b;
    cin >> a >> b;
    for(ll i=b-a+1;i<=b+a-1;i++){
        cout << i <<" ";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int yama[10];
 
  //山の値を１０個入力する
  for(int i = 0; i < 10; i++){
    scanf("%d", &yama[i]);
  }

  //ソートする
  for(int i = 0; i < 9; i++){
    for(int j = 0; j < 9; j++){
      if(yama[j] < yama[j+1]){
	int a = yama[j+1];
	yama[j+1] = yama[j];
	yama[j] = a;
      }
    }
  }

  //値を出力
  for(int i = 0; i < 3; i++){
    printf("%d\n", yama[i]);
  }

  return 0;


}

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

using namespace std;
int dp[5500][5500];
int a[55],b[55],c[55];
int main(){
    int n,x,y,xx,yy;
    scanf("%d%d%d",&n,&xx,&yy);
    int total = 0;
    int i,fir=0,sec=0,j;
    for(i=1;i<=n;i++)
        {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        fir += a[i];
        sec += b[i];
    }
   // printf("max sum %d %d\n",fir,sec);
    int first,second;
    int ma = 1000000007;
    for(i=0;i<=fir;i++)for(j=0;j<=sec;j++)dp[i][j] = ma;
        dp[0][0] = 0;
    for(i=1;i<=n;i++)
    for(first = fir; first>=0;first--)
        for(second = sec; second>=0; second--)
        {
        if(dp[first][second]<ma)
            {
           x = first + a[i];
           y = second + b[i];
            if(x<=fir && y<=sec)
                dp[x][y] = min(dp[x][y],dp[first][second] + c[i]);
        }
    }
    int ans = ma;
    for(i=1;;i++)
        {
        x = xx*i;
        y = yy*i;
        if(x>fir)break;
        if(y>sec)break;
      //  printf("check for %d %d\n",x,y);
        ans = min(ans, dp[x][y]);
    }
    if(ans==ma)ans = -1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int l,r;
    cin >> l >> r;
    int mod = 2019;
    vector<int> L;
    int i = l;
    int j = r;
    if (r-l+1 >=2019) {
        cout << 0 << "\n";
        return 0;
    }
    for(int i=l; i<=r; ++i){
        L.pb(i%mod);
    }
    vector<int> LL;
    rep(i,L.size()) {
        for(int j=i+1; j<L.size(); ++j) {
            LL.pb(L[i]*L[j]%mod);

        }
    }
    sort(all(LL));
    cout << LL[0] << "\n";
}


Measured memory_bytes: 8684
n = int(input())
a = list(map(int, input().split()))

left = 0
right = 0
ans = 0
s = 0
while left < n and right < n:
    while right < n:
        if s + a[right] == s ^ a[right]:
            s += a[right]
            ans += (right - left + 1)
            right += 1
        else:
            break
    if right > left:
        s -= a[left]
        left += 1
    else:
        right += 1
        left += 1

print(ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 2e5;

int parent[MAX];
int rankb[MAX];
int cnt[MAX];
 
void init(int x) {
    for(int i = 0; i <= x; i++)
    parent[i] = i,rankb[i] = 0,cnt[i] = 1;
}
 
int root(int x) {
    return (parent[x]==x) ? x : parent[x]=root(parent[x]);
}
 
bool same(int x, int y) {
    return root(x) == root(y);
}
 
void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    int cntUnion = cnt[root(x)] + cnt[root(y)];
    if (rankb[x] < rankb[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
        if (rankb[x] == rankb[y]) rankb[x]++;
    }
    cnt[root(x)] = cntUnion;
}

int size(int x) {
    return cnt[root(x)];
}

int N, M;
int A[MAX], B[MAX];

void solve() {
    init(MAX);

    vi ans;
    ll inc = 1ll*N*(N-1)/2;
    REPR (i, M) {
        ans.PB(inc);
        int a = A[i], b = B[i];
        if (!same(a, b)) {
            inc -= 1ll * size(a) * size(b);
            unite(a, b);
        }
    }

    REPR (i, M) cout << ans[i] << endl;
}

int main () {
    cin >> N >> M;
    REP (i, M) cin >> A[i] >> B[i];
    solve();
}

Measured memory_bytes: 5364
N = input()
a_list = [int(i) for i in input().split(' ')]
mod = 1000000007

sum_list = []
sum = 0
for i in a_list:
  sum += i
  sum_list.append(sum)

sum = 0
for idx, i in enumerate(a_list[:-1]):
  sum += i*(sum_list[-1]-sum_list[idx])
  
print(sum%mod)


Measured memory_bytes: 31592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
set<ll> s;
int main(){
    ll n,k;
    cin>>n>>k;
    if(n%k==0){ 
        cout<<0<<endl;
        return 0;
    }
    else if(n>k){
        ll nn = n % k;
        ll nnn = abs(nn-k);
        cout<<min(nn,nnn)<<endl;
    }
    else{
        ll nn = abs(n-k);
        ll nnn = abs(nn-k);
        cout<<min(nn,nnn)<<endl;
    }
    /*
    ll nn = abs(n-k);
    ll nnn = abs(nn-k);
    cout<<min(nn,nnn)<<endl;*/
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

const int MaxN = 1e6;
int n;
long long a[MaxN + 5];

int main()
{
	scanf("%d", &n);
	a[0] = 2, a[1] = 1;
	for(int i = 2; i <= n; i++)	a[i] = a[i - 1] + a[i -2];
	printf("%lld\n", a[n]);
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATakoyaki solver = new ATakoyaki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATakoyaki {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), x = in.nextInt(), t = in.nextInt();

            out.println((((n + x) - 1) / x) * t);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 25648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    static int[] parent;
    static int[] size;

    static void make_set(int v) {
        parent[v] = v;
        size[v] = 1;
    }
    static int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }
    static void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (size[a] < size[b]) {
                int temp = a;
                a = b;
                b = temp;
            }
            parent[b] = a;
            size[a] += size[b];
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int m = Integer.parseInt(s[1]);

        parent = new int[n];
        size = new int[n];

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

        while(m-->0){
            s = br.readLine().split(" ");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);

            union_sets(a-1,b-1);
        }
        int ans = Integer.MIN_VALUE;

        for (int i = 0; i < n; i++) {
            ans = Math.max(ans, size[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 57624
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}

// <=================================================================================================================================
// <=================================================================================================================================

void fun(){
	string s,t;cin>>s>>t;
	int ans=LLONG_MAX;
	for(int i=0;i<s.length()-t.length()+1;i++){
		int temp=0;
		for(int j=0;j<t.length();j++){
			if(s[j+i]!=t[j])
				temp++;
		}
		ans=min(temp,ans);
	}
	cout<<ans;
}

signed  main() {
    lets_go

    int t;
    t=1;
//    cin >> t;
    while (t--) {

    fun();

    }



    return 0;

}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, M;

  scanf("%d%d", &N, &M);

  priority_queue<pair<int,int>> que1;
  priority_queue<int> que2;

  for (int i=0; i<N; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    que1.push({-A, B});
  }

  ll ans = 0;

  for (int i=M-1; i>=0; i--) {
    while(que1.size() && -que1.top().first <= M-i) {
      auto p = que1.top(); que1.pop();
      que2.push(p.second);
    }

    debug(que1.top());

    if (que2.size()) {
      ans += que2.top();
      que2.pop();
    }

    debug(ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1908
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;


struct Edge{
    int u,v;
};


vector<Edge> V;

int n,m;
long long ans;
const int MAXN = 1e5+10;

int par[MAXN];
long long siz[MAXN];

int fin(int x){
    if(par[x]==x)return x;
    return par[x]=fin(par[x]);
}

void uni(int x,int y){
    int ax = fin(x);
    int ay = fin(y);
    if(ax == ay) return ;
    ans -= siz[ay]*siz[ax];
    siz[ay]+=siz[ax];
    par[ax]=ay;
}

void init(){
    scanf("%d%d",&n,&m);
    for(int i = 0 ; i < m ; i ++){
        int u,v;
        scanf("%d%d",&u,&v);
        u--;
        v--;
        V.push_back({u,v});
    }
    reverse(V.begin(),V.end());
    for(int i = 0 ; i < n ; i ++){
        par[i]=i;
        siz[i]=1;
    }
}

int main (){
    init();
    ans = ((long long)n) * (n-1) /2;
    vector<long long >ansv;
    for(auto nowe:V){
        int u = nowe.u;
        int v = nowe.v;
        ansv.push_back(ans);
        uni(u,v);
    }
    reverse(ansv.begin(),ansv.end());
    for(auto x:ansv){
        printf("%lld\n",x);
    }
}


Measured memory_bytes: 4212
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int n, maxv = -114514191, minv = 9810114514;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		int x;
		cin >> x;
		maxv = max(maxv, x);
		minv = min(minv, x);
	}
	cout << abs(maxv - minv);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < m; ++i) 
        cin >> b[i];
    for (int i = 0; i < n - m + 1; ++i) {
        for (int j = 0; j < n - m + 1; ++j) {
            int ok = 1;
            for (int i1 = 0; i1 < m; ++i1) {
                for (int j1 = 0; j1 < m; ++j1) {
                    if (a[i + i1][j + j1] != b[i1][j1]) {
                        ok = 0;
                    }
                }
            }
            if (ok) {
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define INF 1000000000000000000LL
using namespace std;
typedef long long LL;
LL p[MAXN+5];
LL dp[MAXN+5];
int N;
LL M;
LL T;
void Init()
{
	memset(dp,-1,sizeof(dp));
}
LL GetVal(int i,int j)
{
	return dp[j-1]+T-2LL*(p[i]-p[j])+3LL*(p[i]-p[j])+p[j]-p[j-1];
}
int main()
{
//	freopen("computer.in","r",stdin);
//	freopen("computer.out","w",stdout);
	Init();
	dp[0]=0;
	scanf("%d %lld %lld",&N,&M,&T);
	for(int i=1;i<=N;i++)
		scanf("%lld",&p[i]);
	LL minval=INF;
	int pn=-1;
	dp[0]=0;
	for(int i=1;i<=N;i++)
	{
		int pos=lower_bound(p+1,p+1+N,p[i]-T/2)-p;
		if(2*(p[i]-p[pos])==T)
			pos++;
		if(2*(p[i]-p[pos-1])>=T)
			while(pn<pos-1)
			{
				pn++;
				if(pn!=0)	minval=min(dp[pn-1]-2LL*p[pn]-p[pn-1],minval);
				else		minval=min(-3LL*p[pn],minval);
			}
		dp[i]=GetVal(i,pos);
		dp[i]=min(dp[i],minval+3LL*p[i]);
	}
	printf("%lld\n",dp[N]+M-p[N]);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl n;
    cin >> n;
    intl t[n];
    cin(i,t);
    intl m;
    cin >> m;
    intl p[m],x[m];
    rep(i,m){
        cin >> p[i] >> x[i];
    }
    intl time = 0;
    rep(i,n){
        time += t[i];
    }
    rep(i,m){
        cout << time - t[p[i]-1] + x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

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

	x, y := 0.0, 0.0
	rotate := 90.0

	for {
		line := nextString()
		if line == "0,0" {
			break
		}

		numbers := strings.Split(line, ",")
		di, _ := strconv.ParseFloat(numbers[0], 64)
		ai, _ := strconv.ParseFloat(numbers[1], 64)

		rotateRadian := math.Pi * rotate / 180.0
		x += di * math.Cos(rotateRadian)
		y += di * math.Sin(rotateRadian)

		rotate -= ai

		// fmt.Println(x, y)
	}

	fmt.Println(int(x))
	fmt.Println(int(y))
}



Measured memory_bytes: 1116
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll N, M;
vector<vector<edge>> g;

vector<bool> see;

vector<ll> pos;

void dfs(ll v) {
	see[v] = 1;

	for (edge e : g[v]) {
		if (see[e.to] == 1) { continue; }
		pos[e.to] = pos[v] + e.d;
		dfs(e.to);
	}

	return;
}




int main() {

	cin >> N >> M;

	vector<ll> L(M + 1), R(M + 1), D(M + 1);

	repn(i, M) cin >> L[i] >> R[i] >> D[i];

	g.resize(N + 1);

	repn(i, M) {
		g[L[i]].push_back({ i,L[i],R[i],D[i] });
		g[R[i]].push_back({ i,R[i],L[i],-D[i] });
	}

	see.assign(N + 1, 0);
	pos.assign(N + 1, 0);

	repn(i, N) {
		if (see[i] == 0) { dfs(i); }
	}

	string ans = "Yes";

	repn(i, M) if (pos[R[i]] - pos[L[i]] != D[i]) { ans = "No"; }

	cout << ans;

	system("PAUSE");

	

}


Measured memory_bytes: 29812
#include<stdio.h>

int main()
{
	int ch[26] = { 0 }, i;
	char input;
	input = getchar();
	while (input != EOF)
	{
		if (input >= 'a' && input <= 'z')
			ch[input - 'a']++;
		else if (input >= 'A' && input <= 'Z')
			ch[input - 'A']++;
		input = getchar();
	}

	for (i = 0; i < 26; i++)
		printf("%c : %d\n", i + 'a', ch[i]);

	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=(1<<25);
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);

  for(int i=a[0];i<=a[n-1];i++){
    int sum=0;
    for(int j=0;j<n;j++){
      int s=abs(a[j]-i);
      sum+=s*s;
    }
    ans=min(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  rep(i,s.size()){
    int k = 0;
    rep(j,t.size()){
      if(i+j >= s.size()){
        k = 0;
        break;
      }
      if(s[i+j] == t[j])k++;
    }
    cnt = max(k,cnt);
  }
  cout << t.size()-cnt << "\n";
  
  

  return 0;
}

Measured memory_bytes: 3636
N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [False]*(K+1)

for i in range(K+1):
    for j in range(N):
        if i-A[j]>=0 and dp[i-A[j]] == False:
            dp[i] = True

        
if dp[K]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 43416
import itertools
import math

N = int(input())

X = []
Y = []

for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

goukei = 0
bunbo = 0
for junro in itertools.permutations(range(N)):
    bunbo += 1
    for i in range(len(junro)-1):
        goukei += ((X[junro[i]] - X[junro[i+1]]) ** 2 +
                   (Y[junro[i]] - Y[junro[i+1]]) ** 2) ** 0.5

print(goukei / bunbo)


Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a, b;
    cin >> a >> b;
    if (a == 'H' && b == 'H')
        cout << "H";
    else if (a == 'D' && b == 'D')
        cout << "H";
    else
        cout << "D";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		calc(str);
	}

	public static void calc(String str){
		String[] result = str.split(" ");

		int num1 = Integer.parseInt(result[0]);
		int num2 = Integer.parseInt(result[1]);

		int res1 = num1*num2;
		int res2 = (num1+num2)*2;

		System.out.println(Integer.toString(res1)+" "+Integer.toString(res2));
		}
}

Measured memory_bytes: 24112
n = int(input())
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
for _ in range(n):
    suit,num = input().split()
    if   suit=='S': cards[0][int(num)-1] = 0
    elif suit=='H': cards[1][int(num)-1] = 0
    elif suit=='C': cards[2][int(num)-1] = 0
    elif suit=='D': cards[3][int(num)-1] = 0
for s in cards:
    for n in s:
        if n!=0: print(n)


Measured memory_bytes: 5604
//#include <bits/stdc++.h>
#include <iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <string.h>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

int n,k,q;
 
  cin>>n;
  string t,s,u;
  cin>>t;
  if(n%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  

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

  	s+=t.at(i);

  }

  //rep(i,sizeof(s))if(s[i]==s[i+1]&&s[i]!='\0')k++;
// cout<<"Hellow worldy yes"<<endl;
 
for(int j=n/2;j<n;j++){
    u+=t.at(j);}

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

  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());

  
 return 0; 
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll N=2005;
ll a[N];
ll d[N];
ll q[N],s,t;
ll n,x;
ll ans=1e15;
int dist(int x,int y){
    if(x<y)
        return y-x;
    return y-x+n;
}
void Solve(ll l){
    s=1,t=0;
    ll sum=1ll*x*l;
    for(ll i=n-l+1;i<=n;i++){
        while(s<=t&&a[q[t]]>=a[i])
            t--;
        q[++t]=i;
    }
    for(ll i=1;i<=n;i++){
        while(s<=t&&dist(q[s],i)>l)
            s++;
        d[i]=a[i];
        if(s<=t)
            d[i]=min(d[i],a[q[s]]);
        while(s<=t&&a[q[t]]>=a[i])
            t--;
        q[++t]=i;
        sum+=d[i];
    }
    //printf("%lld\n",sum);
    ans=min(ans,sum);
}
int main()
{
    //freopen("slime.in","r",stdin);
   // freopen("slime.out","w",stdout);
    scanf("%lld%lld",&n,&x);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(ll i=0;i<n;i++){
        Solve(i);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
N = int(input())
grid=[[v for v in input()] for _ in range(N)]

ans=0
for a in range(N):
    new_grid=[]
    new_grid.extend(grid[a:])
    new_grid.extend(grid[:a])

    flag=True
    for i in range(N):
        for j in range(N):
            if new_grid[i][j]==new_grid[j][i]:
                continue
            else:
                flag=False
                break
    if flag:
        ans+=1
print(ans*N)


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

int main() {
  int N, M, ans;
  cin >> N >> M;
  ans = 0;
//  if((N <= 1) && (M <= 1)){
//  }
  if((N <= 1) && (M > 1)){
    ans = M * (M - 1) / 2;
  }
  if((N > 1) && (M <= 1)){
    ans = N * (N - 1) / 2;
  }
  if((N > 1) && (M > 1)){
    ans = N * (N - 1) / 2;
    ans += M * (M - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int r,g,b,n; cin >> r>>g>>b>>n;

    ll ans = 0;
    rep(i,n/r + 2) {
      rep(j,n/g + 2) {
        ll a = n - r*i - g*j; 
        if(a<0) continue;
        if(a%b == 0) ans++;
      }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

ll w, h; 
vector<pll> direction = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//vector<vector<ll>> vec(h, vector<ll>(w));
//vector<vector<bool>> seen(h, vector<bool>(w));

void dfs(vector<vector<ll>> &vec, vector<vector<bool>> &seen, ll y, ll x){
    seen[y][x] = true;

    /*
    cout << "---" << endl;
    rep(i, h){
        rep(j, w){
            cout << vec[i][j] << " ";
        }
        br;
    }
    cout << "---" << endl;
    */

    if(vec[y][x] == 1){
        for(ll i = 0; i < direction.size(); i++){
            ll next_y = y + direction[i].first;
            ll next_x = x + direction[i].second;

            //場外なら終わり
            if(next_y < 0 || next_y >= h){
                continue;
            }
            if(next_x < 0 || next_x >= w){
                continue;
            }

            if(seen[next_y][next_x] == false && vec[next_y][next_x] == 1){
                dfs(vec, seen, next_y, next_x);
            }
        }
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);

    vector<ll> res;

    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        vector<vector<ll>> vec(h, vector<ll>(w));
        vector<vector<bool>> seen(h, vector<bool>(w));
        vec.resize(h, vector<ll>(w, 0));
        seen.resize(h, vector<bool>(w, false));
        
        rep(i, h){
            rep(j, w){
                cin >> vec[i][j];
            }
        }

        ll ans = 0;
        rep(i, h){
            rep(j, w){
                if(vec[i][j] == 1 && seen[i][j] == false){
                    ans++;
                    dfs(vec, seen, i, j);
                }
            }
        }
        res.push_back(ans);

    }

    rep(i, res.size()){
        cout << res[i] << endl;
    }

}


Measured memory_bytes: 3320
#include<cstdio>
#include<iostream>
using namespace std;
int a[10000001],b[10000001];
int main()
{
	int i,n,max=-1,max1;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		if(max<a[i])
		{
			max=a[i];
			max1=i;
		}
	}
	max+=b[max1];
	cout<<max;
	return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
ll a[1000005],b[10];
int main()
{
    int n,l = 1;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    b[0] = -1;
    for(int i=n-1; i>=0; i--)
    {
        if(a[i]==a[i-1])
        {
            b[l++] = a[i];
            i--;
        }
        if(l==3)
            break;
    }
    if(l==3)
    printf("%lld\n",b[1]*b[2]);
    else
        printf("0\n");
    return 0;
}


/*
8
1 1 2 2 3 3 3 3
5
1 2 3 3 3
*/


Measured memory_bytes: 1280
e1,e2,e3,e4=map(int,input().split())
if e1==e2 or e1==e3 or e1==e4:
    f1=True
else:
    f1=False
if e2==e1 or e2==e3 or e2==e4:
    f2=True
else:
    f2=False
if e3==e1 or e3==e2 or e3==e4:
    f3=True
else:
    f3=False
if e4==e1 or e4==e2 or e4==e3:
    f4=True
else:
    f4=False
if f1==True and f2==True and f3==True and f4==True:
    print("yes")
else:
    print("no")


Measured memory_bytes: 5596
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int hh;
    int mm;
    int ss;
    
    scanf("%d", &ss);
    
    hh = ss/3600;
    ss -= hh*3600;
    mm = ss/60;
    ss -= mm*60;
    
    printf("%d:%d:%d\n", hh, mm, ss);
    
    return 0;
}

Measured memory_bytes: 592