akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
  lint N,A,B,ans=0;
  cin >>N>>A>>B;
lint M[N]; lint S[N-1];
  for(long long int i=0;i<N;i++){
  cin >> M[i];
  if(i!=0)S[i-1]=(M[i]-M[i-1])*A;
  }
  rep(i,N-1){
    ans+=min(S[i],B);
   
  }
cout <<ans;
}


  


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;cin >> n;
    vector<int> table(n+10,0);
    for(int i=1;i<=99;i++){
        for(int j=1;j<=99;j++){
            for(int k=1;k<=99;k++){
                int d = i*i+j*j+k*k+i*j+j*k+k*i;
                if(d>n) continue;
                table[d]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout << table[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3556
s,t = input(),input()

S = len(s)
T = len(t)

dp = [[0]*(T+1) for _ in range(S+1)]

for i in range(S):
    for j in range(T):
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+(s[i]==t[j]))
    

ans = ''

while S > 0 and T > 0:
    if dp[S][T] == dp[S-1][T]: S -= 1
    elif dp[S][T] == dp[S][T-1]: T -= 1
    else: 
        S -= 1
        T -= 1
        ans = s[S] + ans
print(ans)

Measured memory_bytes: 144496
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
ll dp[N],h[N];
int main()
{
	ios
	ll n,i,j,k;
	cin>>n;k=2;
	for(i=0;i<N;i++)
		dp[i]=hell;
	for(i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	for(i=0;i<n;i++){
		for(j=1;j<=k;j++){
			dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
		}
	}
	//for(i=1;i<n;i++)cout<<dp[i]<<" ";
	cout<<dp[n-1];
	return 0;
}



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

std::vector< std::string > S(3, "");
std::vector< std::string::iterator > it(3);
std::vector< std::string::iterator > end(3);

int main(void){
    for(int i=0; i<3; ++i){
        std::cin >> S[i];
        it[i]  = S[i].begin();
        end[i] = S[i].end();
    }

    int turn = 0;
    int next = 0;
    while(true){
        turn = next;
        if(it[turn] == S[turn].end()){
            break;
        }

        next = (int)(*it[turn] - 'a');
        ++it[turn];
    }
    std::cout << (char)('A'+turn) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];

int main(){
    int k,n,m,T;
    cin>>n>>m>>k;
    int d=gcd(n,m);
    per(i,1,d+1){
        if(d%i==0){
            k--;
        }
        if(k==0){
            cout<<i<<endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 4005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n, a[N];
int suf[4][N];
ll ans = 0;
char s[N];

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	read(n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i)
		a[i] = s[i] == 'R' ? 1 : s[i] == 'G' ? 2 : 3;

	for (int i = n; i; --i) {
		suf[1][i] = suf[1][i + 1] + (a[i] == 1);
		suf[2][i] = suf[2][i + 1] + (a[i] == 2);
		suf[3][i] = suf[3][i + 1] + (a[i] == 3);
	}

	for (int i = 1; i < n; ++i)
		for (int j = i + 1; j < n; ++j) {
			if (a[i] == a[j]) continue;
			int tmp = suf[a[i] ^ a[j]][j + 1];
			if (j * 2 - i <= n && a[j * 2 - i] == (a[i] ^ a[j])) --tmp;
			ans += tmp;
		}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3892
def readInt():
  return int(input())


def readInts():
  return [int(i) for i in input().split()]


N = readInt()
AS = readInts()

cnt = 0

for i in range(N):
    minj = i
    for j in range(i, N):
        if AS[j] < AS[minj]:
            minj = j
    if i != minj:
        cnt += 1
        AS[i], AS[minj] = AS[minj], AS[i]

print(*AS)
print(cnt)



Measured memory_bytes: 5612
N = int(input())
num_list =list(input().split(" "))
num_list = list(map(int,num_list))
num_list.sort()
num_list.reverse()

if N >= 2:
    ans = num_list[0]
    N -= 2
    count = 1
    while N != 0:
        if N-2 >= 0:
            ans += num_list[count]*2
            count += 1
            N -= 2
        elif N-2 < 0:
            ans += num_list[count]
            break
else:
    ans = 0
print(ans)

Measured memory_bytes: 32724
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};
 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                   > pq;*/
  /*   #define MAXN 1000001
ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
*/
// take multiset of all edges
// meanwhile for all cc keep record of all edges in multiset too which can be used to digest
// one line or two lines
//

int main()
{   ll k;cin>>k;
 ll n=0;
    for(ll i=0;i<=k;i++)
    {
        n*=10;n+=7;n%=k;if(n%k==0){cout<<i+1;return 0;  }
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3632
from collections import deque
n,m = map(int,input().split())
e = [[] for i in range(n)]
l = [-1]*n
for i in range(m):
    a,b,c = map(int,input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)

def dfs(x,count):
    l[x] = count
    q = deque([])
    q.append(x)
    while q:
        bef = q.popleft()
        for nex in e[bef]:
            if l[nex] == -1:
                l[nex] = count
                q.append(nex)
count = 0
for i in range(n):
    if l[i] == -1 and e[i]:
        dfs(i,count)
        count += 1
print(count+l.count(-1))

Measured memory_bytes: 23800
//file_name:ABC56_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("H");}else{puts("D");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s,z;
    cin >> s >> z;
    if(s[0]==z[0])yn;
    return 0;
}



Measured memory_bytes: 256
in_str = input()
input_list = list(map(int,in_str.split()))
A = input_list[0]
B = input_list[1]
K = input_list[2]
count = 0
ans = 0
max = 100
for i in range(max):
  div = max-i
  if(A%div==0 and B%div==0):
    ans = div
    count+=1
    if(count==K):
      break
print(ans)

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

int main() {
  int n;
  cin >> n;
  
  bool travel = true;
  int a, b;
  int tn, xn, yn, tp, xp, yp;
  for(int i=0; i<n; i++) {
    cin >> tn >> xn >> yn;
    if(i==0) {
      a = tn-(abs(xn)+abs(yn));
      if(a<0 || a%2==1) travel = false;
    }
    else {
      b = (tn-tp)-(abs(xn-xp)+abs(yn-yp));
      if(b<0 || b%2==1) travel = false;
    }
    tp=tn, xp=xn, yp=yn;
  }
  
  if(travel) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n / (a+b) * a;
    n %= (a+b);
    ans += min(n, a);
    cout << ans << endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,C;
int L[10];
int D[10];

double dp[303][32];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C;
	FOR(i,N) cin>>L[i], D[i]=i;
	sort(L,L+N);
	
	double ret=0;
	do {
		ZERO(dp);
		dp[N*L[N-1]][0]=1;
		FOR(i,N*C) {
			if(i%N==0) continue;
			x=D[(i-1)%N];
			for(int mask=0;mask<1<<(N-1);mask++) if((mask&(1<<x))==0) {
				for(y=i;y<=N*C;y++) {
					dp[min(N*C,max(y,i+L[x]*N))][mask ^ (1<<x)] += dp[y][mask];
				}
			}
		}
		
		ret += dp[N*C][(1<<(N-1))-1] ;
		
	} while(next_permutation(D,D+(N-1)));
	
	FOR(i,N-1) ret/=i+1;
	_P("%.12lf\n",ret/pow(C,N-1));
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

int valores[3001][3001];

string getLCS(int valores[][3001], string text1, string text2, int i, int j) {
	if (i == 0 || j == 0)
		return "";
	if (text1[i-1] == text2[j-1])
		return getLCS(valores,text1,text2,i-1,j-1) + text1[i-1];
	if (valores[i][j-1] > valores[i-1][j])
		return getLCS(valores,text1,text2,i,j-1);
	else
		return getLCS(valores,text1,text2,i-1,j);
}

int main() {
	char text1[3001], text2[3001];
	scanf("%s%s", text1, text2);
	int n = strlen(text1), m = strlen(text2);

	for (int i = 0; i <= n; i++)
		valores[i][0] = 0;
	for (int j = 1; j <= m; j++)
		valores[0][j] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (text1[i-1] == text2[j-1])
				valores[i][j] = valores[i-1][j-1] + 1;
			else
				valores[i][j] = max(valores[i][j-1],valores[i-1][j]);
		}
	}

	string teste = getLCS(valores,text1,text2,n,m);
	cout << teste << endl;
}

Measured memory_bytes: 65664
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll a, b, x; cin >> a >> b >> x;

    constexpr ld pi = 3.141592653589793L;

    ld xh = (ld)x / a;
    if (a * a * b < x * 2) {
        ld t = atanl((ld)(a * b - xh) * 2 / a / a);
        cout << fixed << setprecision(30) << t / pi * 180 << endl;
    } else {
        ld t = atanl((ld)b * b / xh / 2);
        cout << fixed << setprecision(30) << t / pi * 180 << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int a, b;
	cin >> a >> b;
	if((a + b) % 2)
	cout << "IMPOSSIBLE\n";
	else
	cout << (a + b) / 2;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
max = -1
maxIndex=-1

index=0
for value in L:
    if max < value:
        max = value
        maxIndex = index
    index+=1

total=0
index=0
for value in L:
    if index != maxIndex:
        total+=value
    index+=1

if total > max:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

bool is(int n){
    return (n%2==0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c;
    cin>>a>>b>>c;
    
    if(is(a)||is(b)||is(c)){
        cout1(0)
        return 0;
    }
    
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    cout1(a*b)
}

Measured memory_bytes: 256
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    H,W = LMIIS()
    Ch,Cw = LMIIS()
    Ch -= 1
    Cw -= 1
    Dh,Dw = LMIIS()
    Dh -= 1
    Dw -= 1
    S = []
    for i in range(H):
        S.append(input())
    
    num_warp = []
    for i in range(H):
        num_warp.append([-1]*W)
    
    targets = deque([(Ch,Cw,0)])


    def check_and_move(y,x,d):
        if 0 <= y < H and 0 <= x < W and num_warp[y][x] == -1 and S[y][x] == '.':
            num_warp[y][x] = d
            return True
        return False




    # 歩行はDFS, ワープはBFS
    while targets:
        y,x,d = targets.pop()
        if not check_and_move(y,x,d):
            continue

        for y2,x2 in [(y-1,x),(y,x+1),(y+1,x),(y,x-1)]:
            targets.append((y2,x2,d))

        for y2,x2 in[
                (y-2,x-2),(y-2,x-1),(y-2,x),(y-2,x+1),(y-2,x+2),
                (y-1,x-2),(y-1,x-1),(y-1,x+1),(y-2,x+2),
                (y,x-2),(y,x+2),
                (y+1,x-2),(y+1,x-1),(y+1,x+1),(y+1,x+2),
                (y+2,x-2),(y+2,x-1),(y+2,x),(y+2,x+1),(y+2,x+2)
            ]:
            targets.appendleft((y2,x2,d+1))

    print(num_warp[Dh][Dw])



    
main()

Measured memory_bytes: 233008
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main()
{
	set<string> list;
	int n;
	cin>>n;
	rep(i,n){
		string str;
		cin>>str;
		list.insert(str);
	}
	cout<<list.size()<<endl;
	return 0;
}



Measured memory_bytes: 19220
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [isize; n]
    };

    let mut min = std::isize::MAX;
    let mut min_i = 0;
    for i in 0..n {
        let a = av[i];
        if a < min {
            min = a;
            min_i = i;
        }
    }
    let mut max = std::isize::MIN;
    let mut max_i = 0;
    for i in 0..n {
        let a = av[i];
        if a > max {
            max = a;
            max_i = i;
        }
    }
    if min.abs() > max.abs() {
        let mut res = Vec::new();
        res.push((min_i + 1, n));
        res.push((min_i + 1, n));
        for i in (0..n - 1).rev() {
            if av[i] > 0 {
                let i = i + 1;
                res.push((i + 1, i));
                res.push((i + 1, i));
            } else {
                let i = i + 1;
                res.push((i + 1, i));
            }
        }
        println!("{}", res.len());
        for (x, y) in res {
            println!("{} {}", x, y);
        }
    } else {
        let mut res = Vec::new();
        res.push((max_i + 1, 1));
        res.push((max_i + 1, 1));
        for i in 1..n {
            if av[i] > 0 {
                let i = i + 1;
                res.push((i - 1, i));
            } else {
                let i = i + 1;
                res.push((i - 1, i));
                res.push((i - 1, i));
            }
        }
        println!("{}", res.len());
        for (x, y) in res {
            println!("{} {}", x, y);
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2236
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

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

    double a[n];

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

    double req = sum/(4*m);

    ll cnt = 0;

    for(ll i=0; i<n; i++)
    {
        if(a[i] >= req)
        {
            cnt++;
        }
    }

    if(cnt >= m)
    {
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

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

int main(void)
{
	char a[101],b[101];
	while(scanf("%s%s",a,b)!=EOF)
	{
		int i=0;
		while(a[i]!= '\0')
			i++;
		for(int j=0;j<i;j++)
		{
			int num=0;int k;
			for(k=0;k<i;k++)
			{
				if(a[(k+j)%i]!=b[k])
					break;
				num++;
			}
			if(num == i)
			{
				cout<<"Yes\n";
				break;
			}
			if(j==i-1)
				cout<<"No\n";
		}

	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long llint;
llint n;
llint A[200001];
void input(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
}

void solve(){
  input();
  bool f=true;
  sort(A,A+n);
  for(int i=0;i<n-1;i++){
    if(A[i]==A[i+1]){
      f=false;
      break;
    }
  }
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    
    int h,w,k; cin >> h >> w >> k;
    string s[h];
    rep(i,h){
        cin >> s[i];
    }
    
    int ans=1001001;
    rep(i,(1<<(h-1))){
        int cnt=0;
        int x[h];
        int res=0;
        x[0]=0;
        rep(j,(h-1)){
            if(i&(1<<j)){
                //jは切る
                cnt++;
                x[j+1]=cnt;
                res++;
            }else{
                x[j+1]=cnt;
            }
        }
        
        if(res>=ans) continue;
        
        vector<int> num(h,0);
        rep(q,w){
            rep(p,h){
                if(s[p][q]=='1') num[x[p]]++;
                if(num[x[p]]>k){
                    res++;
                    q--;
                    rep(r,h) num[r]=0;
                    break;
                }
            }
            if(q<0&&num[0]==0){
                res=1001001;
                break;
            }
        }
        
        chmin(ans,res);
    }
    cout << ans << endl;
}


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

int main(){

    int N;
    cin >> N;

    vector<int> p(N, 0);
    vector<int> q(N, 0);
    for(int i = 0; i < N; i++){
        cin >> p.at(i);
    }

    q = p;

    sort(q.begin(), q.end());

    int hikaku = 0;
    for(int i = 0; i < N; i++){
        if(q.at(i) != p.at(i)){
            hikaku++;
        }
    }

    if(hikaku <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println(a*a*3);
    }

}


Measured memory_bytes: 22608
N = int(input())
li = list(map(int, input().split()))
li.sort()


S = 1
for i in range(N-1):
    if  li[i+1] == li[i]:
        S = S*0
    else:
        S = S
if S == 0:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
double func(double x,double y){
  double cnt=0;
  while(x<y){
    x=x*2;
    cnt++;
  }
  return cnt;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  double n,k;
  cin>>n>>k;
  double sum=0;
  for(double i=1;i<=n;i++){
    sum+=(1.0/n)*(1.0/(double)pow(2.0,func(i,k)));
  }
  cout<<fixed << setprecision(10) << sum<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll dp[3020][3020];//dp[index][weight]

int main(){
  int n;
  cin >> n;
  pair<long double,long double> p[n];
  rep(i,n)cin >> p[i].first >> p[i].second;
  int a[n];
  rep(i,n)a[i]=i;
  long double ans=0;
  do{
    long double temp=0;
    rep(i,n-1){
      temp+=sqrt((p[a[i+1]].first-p[a[i]].first)*(p[a[i+1]].first-p[a[i]].first)+(p[a[i+1]].second-p[a[i]].second)*(p[a[i+1]].second-p[a[i]].second));
    }
    ans+=temp;
  }while(next_permutation(a,a+n));
  long double num=1;
  rep(i,n)num*=i+1;
  cout << setprecision(10) <<  ans/num << endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll n, k;

int rec(ll dest, ll stp, vector<ll> &vec, vector<ll> &r) {
  if (stp == k) {
    return dest + 1;
  }
  if (r[dest] != -1) {
    ll rem = (k - r[dest]) % (stp - r[dest]);
    ll ans = dest;
    rep(i, rem) {
      ans = vec[ans];
    }
    return ans + 1;
  }
  r[dest] = stp;
  return rec(vec[dest], stp+1, vec, r);
}

int main()
{
  cin >> n >> k;
  vector<ll> vec(n);
  vector<ll> r(n, -1);
  rep(i, n) {
    cin >> vec[i];
    vec[i]--;
  }
  ll ans = rec(0, 0, vec, r);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6408
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = 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;}

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int N; cin >> N;
  vector<int> b(N);

  vector<vector<bool>> table(3, vector<bool>(3, false));
  rep(i, N){
    int b; cin >> b;
    rep(j, 3){
      rep(k, 3){
        if (a[j][k] == b) table[j][k] = true;
      }
    }
  }
  bool flag = false;
  if (table[0][0] && table[0][1] && table[0][2]) flag = true;
  if (table[1][0] && table[1][1] && table[1][2]) flag = true;
  if (table[2][0] && table[2][1] && table[2][2]) flag = true;
  if (table[0][0] && table[1][0] && table[2][0]) flag = true;
  if (table[0][1] && table[1][1] && table[2][1]) flag = true;
  if (table[0][2] && table[1][2] && table[2][2]) flag = true;
  if (table[0][0] && table[1][1] && table[2][2]) flag = true;
  if (table[0][2] && table[1][1] && table[2][0]) flag = true;

  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n, m, xc, yc = STDIN.gets.split(" ").map(&:to_i)
xs = STDIN.gets.split(" ").map(&:to_i)
ys = STDIN.gets.split(" ").map(&:to_i)

no = false
for z in (xc+1)..(yc) do
  ok = xs.all? { |x| x < z }
  next unless ok
  ok = ys.all? { |y| y >= z }
  next unless ok
  puts "No War"
  no = true
  break
end
puts "War" unless no


Measured memory_bytes: 1788
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var ACGT = 'ACGT';

    var max = 0;
    var testing = 0;

    for(var i = 0; i < input[0].length; i++) {
        if (ACGT.indexOf(input[0].charAt(i)) !== -1) {
            testing++;
            max = max < testing ? testing : max;
        } else {
            testing = 0;
        }
    }

    console.log(max);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/**
 * Square Route
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int m = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | m) == 0) break;

			//
			int[] ns = new int[n + 1];
			int[] ms = new int[m + 1];

			for (int i = 1; i < n + 1; i++) {
				ns[i] = parseInt(br.readLine()) + ns[i - 1];
			}
			for (int i = 1; i < m + 1; i++) {
				ms[i] = parseInt(br.readLine()) + ms[i - 1];
			}

			//
			int[][] nm = new int[Math.max(ns[n], ms[m]) + 1][2];

			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n + 1; j++) {
					nm[ns[j] - ns[i]][0]++;
				}
			}
			for (int i = 0; i < m; i++) {
				for (int j = i + 1; j < m + 1; j++) {
					nm[ms[j] - ms[i]][1]++;
				}
			}

			int sum = 0;
			for (int i = 1; i < nm.length; i++) {
				sum += nm[i][0] * nm[i][1];
			}
			System.out.println(sum);
		} //end while
	} //end main
}

Measured memory_bytes: 90976
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define endl '\n'
const ll mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll ans[n]={0};
    ans[1] = abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++){
        ans[i] = min(ans[i-1]+abs(arr[i-1]-arr[i]),ans[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
double ans=0.0;
int main(int argc,char const* argv[])
{
  int a,b,k,cnt=0,now=1;
  vector<int> primes;
  cin >> a >> b >> k;
  while(now<=100)
    {
      if(a%now==0 && b%now==0) 
	{
	  cnt++;
	  primes.push_back(now);
	}
      now++;
    }
  sort(primes.begin(),primes.end(),greater<int>());
  cout << primes[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

//#define int long long
//#define double long double
ll binpow(ll a, ll b, ll m){
	ll res = 1;
	while(b > 0){
		if(b&1) res = res * a % m;
		a = a * a % m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a, ll b){
	return (b==0 ? a : gcd(b,a%b));
}
void solve(){	
	int n;
	cin >> n;
	vector<int> v(n);
	re(v);
	vector<int> freq(100100);
	pii ans[2], ans2[2];
	for(int i=0;i<n;i+=2){
		freq[v[i]]++;
	}
	for(int i=0;i<100100;i++){
		if(freq[i] > ans[0].ff){
			ans[1] = ans[0];
			ans[0] = {freq[i], i};
		}
		else if(freq[i] > ans[1].ff){
			ans[1] = {freq[i], i};
		}
	}
	fill(td(freq), 0);
	for(int i=1;i<n;i+=2){
		freq[v[i]]++;
	}
	for(int i=0;i<100100;i++){
		if(freq[i] > ans2[0].ff){
			ans2[1] = ans2[0];
			ans2[0] = {freq[i], i};
		}
		else if(freq[i] > ans2[1].ff){
			ans2[1] = {freq[i], i};
		}
	}
	int res = n;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			if(ans[i].ss != ans2[j].ss){
				res = min(res, n - ans[i].ff - ans2[j].ff);
			}
		}
	}
	cout << res << endl;
} 
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t=1;
 	//cin >> t;
  while(t--){
  	solve();
  }
}


Measured memory_bytes: 4032
fun main(args: Array<String>) {

    val INF = 1000000

    val (N, k) = readLine()!!.split(" ").map(String::toInt)

    val h = readLine()!!.split(" ").map(String::toInt)

    val dp = Array(N) { Long.MAX_VALUE }

    dp[0] = 0
//    h.joinToString(" ") { "%6d".format(it) }.let(::println)
    for (i in 1 until N) {
        for (j in 1..k) {
            if (i >= j) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]))
//                dp.joinToString(" ") { "%6d".format(it) }.let(::println)
            }
        }
    }

    println(dp[N - 1])
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 0; i < N;) {
        int res = 0;
        int k = 0;
        while (A[i] == A[i + k]) {
            res++;
            k++;
        }
        if (res % 2 == 1) {
            ans++;
        }
        i += res;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n,y=map(int,input().split())
a,b,c=-1,-1,-1
for i in range(n+1):
  for j in range(n+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      a=i
      b=j
      c=n-i-j
      break
if c>=0:
  print(a,b,c)
else:
  print("-1 -1 -1")

Measured memory_bytes: 9224
# coding: utf-8

N = int(input())
A, B =map(int, input().split())
P = input().split()

q1 = []
q2 = []
q3 = []

for i in P:
    if int(i) <= A:
        q1.append(int(i))
    if int(i) >= A+1 and int(i) <= B:
        q2.append(int(i))
    if int(i) >= B+1:
        q3.append(int(i))

q_len = [len(q1), len(q2), len(q3)]
print(min(q_len))

Measured memory_bytes: 3064
#!/usr/bin/python3

(n, m) = map(int, input().split())

d = [ -1 for i in range(n) ]

ops = []
for i in range(m):
    ops.append(tuple(map(int, input().split())))


for op in ops:
    (s, c) = op
    if d[s - 1] >= 0 and d[s - 1] != c:
        print(-1)
        exit()
    else:
        d[s - 1] = c

for i in range(n):
    if d[i] == -1:
        if i == 0 and n > 1:
            d[i] = 1
        else:
            d[i] = 0
        
        
if n > 1 and d[0] == 0:
    print(-1)
else:
    print(''.join(map(str, d)))


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

a,b,c = map(int, input().split())
k = int(input())

while(a >= b and k>0):
    b *= 2
    k -= 1

while(b >= c and k>0):
    c *= 2
    k -= 1

if a < b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61628
#include<iostream>
using namespace std;
int main (){
	char a,b;
	cin>>a>>b;
	if(a=='H'&&b=='H')
      {
	    cout<<"H";
      }
     	if(a=='D'&&b=='H')
       	  { 
       	  cout<<"D";
          }     	
            if(a=='H'&&b=='D')
			 {
			cout<<"D"; 	
		 } 
		    if(a=='D'&&b=='D')
		       { 
		       cout<<"H";
		       
		       	}
}

Measured memory_bytes: 256
n = int(input())
inf = float('inf')

M1, M2 = -inf, -inf
m1, m2 = inf, inf

for i in range(n):
  x, y = map(int, input().split())
  d1 = x+y
  d2 = x-y
  M1 = max(M1, d1)
  m1 = min(m1, d1)
  M2 = max(M2, d2)
  m2 = min(m2, d2)

D1 = M1-m1
D2 = M2-m2

print(max(D1, D2))

Measured memory_bytes: 74968
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,w = map(int,readline().split())
WV = []
for i in range(n):
	WV.append(list(map(int,readline().split())))

dp = [[10**12]*(10**5+1) for _ in range(n+1)]
dp[0][0] = 0

#価値j以上で重さがwを満たすようなものの最大値
for i in range(n):
	for j in range(10**5+1):
		if WV[i][1] - j > 0:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = min(dp[i][j],dp[i][j-WV[i][1]]+WV[i][0])

ans = 0
for idx,i in enumerate(dp[-1]):
	if i <= w:
		ans = idx

print(ans)

Measured memory_bytes: 120044
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	a.push_back(0);
	sort(a.begin(), a.end());
	int mndiff = 1001001001;
	rep(i, n){
		int add = a.at(i+1) - a.at(i);
		if(add == 0) continue;
		mndiff = min(mndiff, add);
	}
	// cerr << mn << " " << mndiff << endl;
	while(1){
		int nx = 1001001001;
		rep2(i, 1, n+1){
			int add = a.at(i) % mndiff;
			if(add == 0) continue;
			nx = min(nx, add);
		}
		if(nx == 1001001001) break;
		mndiff = nx;
	}
	cout << mndiff << endl;
	return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn count_two(n: u64) -> u64 {
    fn go(count:u64, num: u64) -> u64 {
        if num % 2 == 0 {
            go(count +1, num / 2)
        } else {
            count
        }
    }
    go(0, n)
}

fn main() {
    let n: usize = read();
    let xs: Vec<u64> = (0..n).map(|_|read()).collect();
    let mut xs_sorted: Vec<u64> = xs.clone();
    xs_sorted.sort();
    let middle = xs_sorted[n / 2];
    let middle_m1 = xs_sorted[n / 2 - 1];
    for x in xs {
        println!("{}", if x < middle { middle } else {middle_m1} );
    }
}



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

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み
  vector<ll> parent;

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    parent.resize(N);
    rep(i,N){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
  }

  ll dijkstra(ll s, ll goal){
    rep(i,N){d[i] = INF;}
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que; //ansが小さい順に出る
    que.push(P(0,s)); // P < ans , Node >
    while(!que.empty()){
      P p = que.top(); que.pop(); //pに <ans,Node> 入れる
      ll v = p.second; //vに Node 入れる
      if(d[v] < p.first) continue; //すでに良い数値が入っているならパス
      rep(i,G[v].size()){
        edge& E = G[v][i];
        if(d[E.to] > d[v] + E.cost){ //更新するなら
          d[E.to] = d[v]+ E.cost;
          parent[E.to] = v; //親を記録,goalから遡れば道順
          que.push(P(d[E.to], E.to));
        }
      }
    }
    return d[goal];
  }
};

void Main(){

  int N;

  cin>>N;

  vector<tuple<int,int,int>> tp;

  rep(i,N){
    rep(j,N){
      int a; cin>>a;
      if(i==j or i>j) continue;
      tp.emplace_back(a,i,j);
    }
  }

  SORT(tp);

  graph g(N);
  ll ans=0;

  for(auto x:tp){

    ll dist=g.dijkstra(get<1>(x),get<2>(x));
    if(get<0>(x)==dist) continue;
    if(get<0>(x)>dist){
      cout<< -1 <<"\n";
      return;
    }
    else{
      g.add_edge(get<1>(x),get<2>(x),get<0>(x));
      g.add_edge(get<2>(x),get<1>(x),get<0>(x));
      ans+=get<0>(x);
    }
  }

  cout<< ans<<"\n";

}

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


Measured memory_bytes: 1148