akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<vector<int>> h(n, vector<int>(3));
	
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin>>h[i][j];
		

	std::vector<int> dp(3);
	for(int i=0;i<3;i++)
		dp[i]=0;

	int a,b,c;
	for(int i=0;i<n;i++)
	{
		a=max(dp[1]+h[i][0],dp[2]+h[i][0]);
		b=max(dp[0]+h[i][1],dp[2]+h[i][1]);
		c=max(dp[1]+h[i][2],dp[0]+h[i][2]);

		dp[0]=a;dp[1]=b;dp[2]=c;
	}

	
	
	auto it=max_element(dp.begin(), dp.end());
	cout<<*it;

	return 0;
}

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

int main() {
	int d;
	cin >> d;
	d = (d - 25) * -1;
	cout << "Christmas";
	rep(i, d) {
		cout << " Eve";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll INF = 1LL << 60;

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

template <typename T>
T gcd(T a, T b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

ll a, b;
void input() {
    cin >> a >> b;
}

void solve() {
    ll result = lcm<ll>(a, b);
    cout << result << endl;

}



int main() {
    input();
    solve();
}


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

int main()
{
  int ans = 0;
  
  int N, D;
  cin >> N >> D;
  vector<vector<int>> A(N, vector<int>(D));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < D; j++)
    {
      cin >> A.at(i).at(j);
    }
  }
  
  float dist;
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      dist = 0;
      for (int k = 0; k < D; k++)
      {
        int a, b;
        a = A.at(i).at(k);
        b = A.at(j).at(k);
        
        dist = dist + (a - b) * (a - b);
      }
      dist = sqrt(dist);
      if (dist == round(dist)) ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 512
package main

import "fmt"

func swap(x, y int)(int, int){
	if x > y {
		return y, x
	}
	return x, y
}

func main() {

	var a, b, c int
	fmt.Scan(&a, &b, &c)
	
	a, b = swap(a, b)
	a, c = swap(a, c)
	b, c = swap(b, c)

	fmt.Println(a, b, c)
}


Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))
#define setbits(x)      __builtin_popcountll(x)
  
void solve() {
   int n, a, b, total=0, inter=0;
   string s;
   cin>>n>>a>>b;
   cin>>s;
   for(int i=0;i<(int)s.length();i++) {
       if(s[i] =='c') {
           cout<<"No"<<endl;
           continue;
       }
       if(s[i] == 'a' && a+b > total) {
           cout<<"Yes"<<endl;
           total++;
           continue;
       }
       if(s[i] == 'b' && a+b > total && inter < b) {
           cout<<"Yes"<<endl;
           total++;
           inter++;
           continue;
       }
       cout<<"No"<<endl;
   }
}
 
 
int main() {
    fast
    solve();
    return 0;
}


Measured memory_bytes: 848
n,m=map(int,input().split())
s=[]
for i in range(m):
    a,b=map(int,input().split())
    s.append([a,b-1])
s.sort(key=lambda x:x[1])
ans=0
t=None
for i,j in s:
    if(t is None or t<i):
        t=j
        ans+=1

print(ans)

Measured memory_bytes: 21340
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define PII pair<int,int>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point
{
public:
	double x, y;
	Point(double X = 0, double Y = 0)
	{
		x = X;
		y = Y;
	}
	Point operator +(const Point &p)const { return Point(x + p.x, y + p.y); };
	Point operator -(const Point &p)const { return Point(x - p.x, y - p.y); };
	Point operator *(const double a)const { return Point(x*a, y*a); };
	Point operator /(const double a)const { return Point(x / a, y / a); };
	double norm()const { return x*x + y*y; };
	double length()const { return sqrt(norm()); };
	double dot(const Point &p)const { return x*p.x + y*p.y; };
	double cross(const Point &p)const { return x*p.y - y*p.x; };
	bool operator ==(const Point &p)const
	{
		return fabs(x - p.x)<EPS &&fabs(y - p.y)<EPS;
	}
	friend ostream& operator <<(ostream& os, const Point &p);
};
typedef Point Vector;

ostream& operator <<(ostream& os, const Point &p)
{
	return os << "(" << p.x << "," << p.y << ")";
}

class Segment
{
public:
	Point p1, p2;
	Segment(double x1, double y1, double x2, double y2)
	{
		p1.x = x1;
		p1.y = y1;
		p2.x = x2;
		p2.y = y2;
	}
	bool IsOrthogonal(const Segment &s)
	{
		Vector t1 = p2 - p1;
		Vector t2 = s.p2 - s.p1;
		return equals(0.0, t1.dot(t2));
	}
	bool IsParallel(const Segment &s)
	{
		Vector t1 = p2 - p1;
		Vector t2 = s.p2 - s.p1;
		return equals(0.0, t1.cross(t2));
	}
	Point GetProjection(double X, double Y)const
	{
		Vector V = p2 - p1;
		Point P(X, Y);
		Point ret = V*(V.dot(P - p1) / V.norm());
		return ret + p1;
	}
	Point GetReflect(double X, double Y)
	{
		Point t(X, Y);
		Point Pro = GetProjection(X, Y);
		Vector dV = Pro - t;
		return t + dV*2.0;
	}
};
typedef Segment Line;

class Circle
{
public:
	Point c;
	double r;
	Circle(Point C = Point(), double R = 0)
	{
		c = C;
		r = R;
	}
};


int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	Segment s(x1, y1, x2, y2);
	int q;
	cin >> q;
	REP(i, q)
	{
		double x, y;
		cin >> x >> y;
		Point ans=s.GetReflect(x, y);
		cout << fixed << setprecision(10) << ans.x << " " << ans.y << endl;
	}
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL x, y;cin >> x >> y;
    if(x%y == 0){
        cout << -1 << endl;
    }else{
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 764
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// IN THE NAME OF GOD
#include <bits/stdc++.h>

#define ff first
#define endl '\n'
#define in insert
#define ss second
#define ll long long
#define pb push_back
#define ld long double
#define pii pair <int, int>
#define pll pair <long long, long long>

using namespace std;

const int mod = 1e9 + 7, N = 2222, MAXN = 4e6 + 46;
ll n, k, dp[N][N], fact[MAXN], inv[MAXN], f[MAXN];

inline int C(int x, int y){
  return fact[x] * inv[y] % mod * inv[x - y] % mod;
}

int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  if(k == 1) return cout << 1, 0;

  fact[0] = inv[0] = inv[1] = f[0] = f[1] = dp[0][0] = 1;

  for(int i = 1; i < MAXN; i++){
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  for(int i = 2; i < MAXN; i++){
    f[i] = (mod - mod / i) * f[mod % i];
    f[i] %= mod;
    inv[i] = f[i] * inv[i - 1];
    inv[i] %= mod;
  }
  for(int i = 1; i <= n; i++){
    for(int j = i; j >= 1; j--){
      dp[i][j] = dp[i][j + 1];
      dp[i][j] += dp[i - 1][j - 1] * (i * k - j - 1 < k - 2 ? 0 : C(i * k - j - 1, k - 2));
      dp[i][j] %= mod;
    }
    dp[i][0] = dp[i][1];
  }
  cout << (dp[n][0] * fact[n]) % mod;
}
// programmer: a_h_k_81
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //


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

int main(){

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

    string s;
    cin>>s;
    for(char &c:s)if(c=='?')c='D';
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int n,m,l,r,D;
vector<pair<int,int>> v[100001];
int d[100001];
bool ok=true;

void dfs(int node,int num){
    d[node]=num;
    for(int i=0;i<v[node].size();i++){
        if(d[v[node][i].first]==1e9+1) dfs(v[node][i].first,num+v[node][i].second);
        else if(d[v[node][i].first]!=num+v[node][i].second) ok=false;
    }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>l>>r>>D;
        v[l].push_back(make_pair(r,D));
        v[r].push_back(make_pair(l,-D));
    }
    for(int i=1;i<=n;i++)d[i]=1e9+1;
    for(int i=1;i<=n;i++){
        if(d[i]==1e9+1) dfs(i,0);
    }
    cout<<(ok?"Yes":"No");
    return 0;
}


Measured memory_bytes: 12928
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			String S = scan.next();
			int Q = scan.nextInt();
			int[] T = new int [Q];
			int[] F = new int [Q];
			String[] C = new String[Q];
			StringBuffer sb = new StringBuffer();
			StringBuffer se = new StringBuffer();
			
			for(int i = 0;i<Q;i++) {
				T[i] = scan.nextInt();
				if(T[i]==2) {
					F[i] = scan.nextInt();
					C[i] = scan.next();
				}
			}
			
			
			sb.append(S);
			String sentou = "";
			String kouhou = "";
			
			boolean gyaku = false;
			
			for(int i = 0;i<Q;i++) {
				if(T[i]==1) {
					gyaku = !gyaku;
					//sb.reverse();
				}else if(T[i]==2) {
					if(F[i]==1) {
						if(gyaku) sb.append(C[i]);//kouhou = kouhou+C[i];//sb.append(C[i]);//逆
						else se.append(C[i]); //sentou = C[i]+sentou;//sb.insert(0, C[i]);//逆ではない
					}else if(F[i]==2) {
						if(gyaku)se.append(C[i]);//sentou = C[i]+sentou; //sb.insert(0, C[i]);
						else sb.append(C[i]); //kouhou = kouhou+C[i];//sb.append(C[i]);
					}
				}
			}
			
			se.reverse();
			
			sb.insert(0, se.toString());
			sb.append(kouhou);
			
			if(gyaku)sb.reverse();
			
			System.out.println(sb.toString());
			
			
			
			
			
			
		}	
	}
	
	
}


Measured memory_bytes: 159480
char buf[25000];
i;
X,Y,Z;
k;
p;
n;
main()
{
	n=read(0,buf,25000);
	while(buf[i++]-' ');
	while(buf[i++]-' ');
	for(;;)
	{
		k=buf[i++];
		if(k<'0')break;
		X=X*10+k-'0';
	}
	--n;--n;
	p=1;
	for(;;)
	{
		k=buf[n--];
		if(k<'0')break;
		Z+=p*(k-'0');
		p*=10;
	}
	p=1;
	for(;;)
	{
		k=buf[n--];
		if(k<'0')break;
		Y+=p*(k-'0');
		p*=10;
	}
	X-=Z;if(X<0)X=-X;
	Y-=Z;if(Y<0)Y=-Y;
	printf("%d",X<Y?Y:X);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

bool chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  ll dp[N];
  const ll INF = 1LL << 60;
  for (int i = 0; i < N; i++) {
    dp[i] = INF;
  }
  dp[0] = 0;
  dp[1] = abs(H[0] - H[1]);
  for (int i = 2; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i - j < 0) break;
      chmin(dp[i], dp[i - j] + abs(H[i - j] - H[i]));
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  double l,r;
  double ll[4] = {0},rr[4]= {0};
  while( cin >> l >> r){

    if(l >= 1.1 )ll[0]++;
    else if(l >= 0.6 )ll[1]++;
    else if(l >= 0.2 )ll[2]++;
    else ll[3]++;
    if(r >= 1.1 )rr[0]++;
    else if(r >= 0.6 )rr[1]++;
    else if(r >= 0.2 )rr[2]++;
    else rr[3]++;
  }
  for(int i = 0 ; i < 4 ; i++){
    cout << ll[i] <<" " << rr[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s",in);
	int ret=0;
	for(int i=0;i<a-1;i++){
		if(in[i]!=in[i+1])ret++;
	}
	int ans=a-ret-1;
	while(b&&ans<a-1){
		b--;
		ans=min(a-1,ans+2);
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 256
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print ("Yes")
else:
    print ("No")


Measured memory_bytes: 2940
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int main(){
	int a;scanf("%d",&a);
	printf("%.12f\n",PI*2*a);
}

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

now=0
visited=set()
visited.add((0))
visited2=[0]


while True:
  k-=1
  now=a[now]-1

  if k==0:
    print(now+1)
    exit()

  
  if now in visited:
    visited.add((now))
    visited2.append(now)
    break

  visited.add((now))
  visited2.append(now)


xxx=visited2[-1]
cnt=[]
for i in range(len(visited2)):
  if visited2[i]==xxx:
    cnt.append(i)


k%=cnt[1]-cnt[0]


if k!=0:
  for i in range(k):
    now=a[now]-1
  

print(now+1)

Measured memory_bytes: 122040
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    vector<int> d(n);
    vector<int> sd(n+1);
    sd[0]=0;
    REP(i,n){
        cin >> v[i];
    }
    REP(i,n){
        cin >> c[i];
    }
    REP(i,n){
        d[i] = v[i]-c[i];
    }
    sort(all(d),greater<>());
    REP(i,n){
        sd[i+1] = d[i]+sd[i];
    }
    int res = 0;
    REP(i,n+1){
        chmax(res,sd[i]);
    }
    put(res);
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

ll MOD = 1000000007;

void solve() {
    ll n,l; cin >> n >> l;
    vector<ll> a(n);
    ll sum = 0;
    rep(i,n) cin >> a[i];
    int k = -1;
    rep(i,n-1){
        if(l <= a[i]+a[i+1]){
            k = i;
            break;
        }
    }
    if(k == -1) cout << "Impossible" << endl;
    else{
        cout << "Possible" << endl;
        rep(i,k) cout << i + 1 << endl;
        RFOR(i,k,n-1) cout << i + 1 << endl;
    }

}

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

    solve();

    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#define N 2000

int n,A[20];

int solve(int,int);

main(){

  int i,a[N],q,j,res;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);

  for(j=0;j<q;j++){
    scanf("%d",&a[i]);
    res=solve(0,a[i]);
    if(res==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


int solve(int i,int m){

  if(m==0) return 1;
  if(i>=n) return 0;

  int res =solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 588
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();
    let mut hp: Vec<(usize, usize)> = (0..n).map(|_| (sc.read(), sc.read())).collect();
    hp.sort_by_key(|&(h, p)| h + p);

    let inf = hp.iter().map(|&(_, p)| p).sum::<usize>() + 1;

    let mut dp = vec![vec![inf; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        let (h, p) = hp[i];
        for j in 0..n {
            dp[i + 1][j] = cmp::min(dp[i][j], dp[i + 1][j]);
            if h >= dp[i][j] {
                dp[i + 1][j + 1] = cmp::min(dp[i + 1][j + 1], dp[i][j] + p);
            }
        }
    }

    let mut max = 0;
    for i in 0..n {
        if dp[n][i + 1] < inf {
            max = i + 1;
        }
    }

    println!("{}", max);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 231804
N, K = data = list(map(int, input().split()))
h_list = list()

for _ in range(N):
    h_list.append(int(input()))

h_list.sort()

min_diff = 9999999999
for i in range(N - K + 1):
    diff = abs(h_list[i] - h_list[i + K - 1])
    min_diff = diff if diff < min_diff else min_diff

print(min_diff)


Measured memory_bytes: 7384
#include<iostream>
#include<vector>
using namespace std;
typedef long long int llint;
int main() {
	llint n, t;
	cin >> n >> t;
	if (n == 1) {
		llint x;
		cin >> x;
		cout << x + t << endl;
		return 0;
	}
	llint a, b;
	llint tmp = 0;
	llint ans = 0;
	cin >> b;
	for (int i = 1;i < n;i++) {
		cin >> a;
		if (b + t < a) {
			ans += b + t - tmp;
			tmp = a;
		}
		b = a;
		if (i == n - 1) {
			ans += a + t - tmp;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
l,r=gets.chomp.split(" ").map{|s| s.to_i}
if r-l>=2019
  puts 0
else
  ans=2019
  for i in l..r-1
    for j in i+1..r
      ans=[ans,(i*j)%2019].min
      break if ans==0
    end
  end
  puts ans
end

Measured memory_bytes: 3836
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << "DBG: " << #x << " " << (x) << "\n"

#define inn(x)            int x; in(x);
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n);
    inn(m);

    std::string s[n]; rep(i, n) in(s[i]);

    int left[n][m]; rep(i, n) left[i][0] = (s[i][0] == '.');
    rep(i, n) repr(j, 1, m)
        left[i][j] = (left[i][j - 1] + 1)*(s[i][j] == '.');


    int right[n][m]; rep(i, n) right[i][m - 1] = (s[i][m - 1] == '.');
    rep(i, n) rrep(j, m - 1)
        right[i][j] = (right[i][j + 1] + 1)*(s[i][j] == '.');


    int up[n][m]; rep(j, m) up[n - 1][j] = (s[n - 1][j] == '.');
    rep(j, m) rrep(i, n - 1)
        up[i][j] = (up[i + 1][j] + 1)*(s[i][j] == '.');


    int down[n][m]; rep(j, m) down[0][j] = (s[0][j] == '.');
    rep(j, m) repr(i, 1, n)
        down[i][j] = (down[i - 1][j] + 1)*(s[i][j] == '.');

    int ans = INT_MIN;
    rep(i, n) rep(j, m) {
        int x = up[i][j] + down[i][j] + left[i][j] + right[i][j];
        ans = std::max(ans, x - 3);
    }

    out(ans);
}


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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 67072
S = input()
T = input()
sc = S
flag = False
for i in range(len(sc)):
    if(sc==T and flag==False):
        print("Yes")
        flag = True
    tmp1 = sc[-1:]
    tmp2 = sc[:-1]
    # print(tmp1)
    # print(tmp2)
    sc = tmp1 + tmp2
if flag == False:
    print("No")


Measured memory_bytes: 3060
n=int(input())
import math
for i in range(1,n+1):
    t=0
    for x in range(1,101):
        if (x**2)*6>i:
            break
        for y in range(x,101):
            if x**2+3*(y**2)+2*x*y>i:
                break
            B=(x+y)
            C=x**2+y**2+x*y-i
            r=(B**2-4*C)**0.5
            z1=(-B+r)/2
            z2=(-B-r)/2
            if z1.is_integer() and z1>0:
                if x==y and y==z1:
                    t+=1
                elif x!=y and y!=z1 and z1!=x:
                    t+=6
                else:
                    t+=3
            if z2.is_integer() and z2>0:
                if x==y and y==z2:
                    t+=1
                elif x!=y and y!=z2 and z2!=x:
                    t+=6
                else:
                    t+=3
    print(t)

Measured memory_bytes: 70172
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String s = sc.next();
        System.out.println(s.substring(0,k-1) + Character.toLowerCase(s.charAt(k-1)) + s.substring(k));
    }
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)


n = int(input())
a = list(map(int, input().split()))
li = [0] * (n + 1)
r = [0] * (n + 1)

for i in range(n):
    li[i + 1] = gcd(li[i], a[i])
    r[n - i - 1] = gcd(r[n - i], a[n - i - 1])

ans = 0
for i in range(n):
    ans = max(ans, gcd(li[i], r[i + 1]))

print(ans)


Measured memory_bytes: 14060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	string n;
	cin>>n;
	int count = 0;
	rep(i,n.length()){
		if(n[i] == 'x'){
			count++;
		}
	}
	cout<<(count<=7?"YES":"NO")<<endl;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int sum=0;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&b[i]==c[i]){
        }
        else if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]){
            sum+=2;
        }
        else{
            sum++;
        }
    }
    cout<<sum<<endl;
}


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) {

		//?????£?????????
		int a = 0;
		int b = 0;

		int intjudge = 0;
		String strInput = null;

		try {
			//??\????????????????????????
			BufferedReader strLine = new BufferedReader(new InputStreamReader(System.in));
			strInput = strLine.readLine();

			String[] strNumList = strInput.split(" ");

			a = Integer.parseInt(strNumList[0]);
			b = Integer.parseInt(strNumList[1]);

			//??\?????°???????????§??????
			if (-1000 <= a && a <= 1000) {

				if (-1000 <= b && b <= 1000) {

					intjudge = (a - b);

					//???????????????
					if (intjudge > 0) {
						System.out.println("a > b");
					}else if (intjudge == 0) {
						System.out.println("a == b");
					}else {
						System.out.println("a < b");
					}
				}
				//if????????§????????¨
				/*else{
					System.out.println("b = ERROR");
				}*/
			}
			/*else{
				System.out.println("a = ERROR");
			}*/

			//??¨????????????
		} catch (IOException e) {
			System.out.println(e);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}
	}

}

Measured memory_bytes: 24172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define test ll tttt;cin>>tttt;while(tttt--)
#define rep(i,k,n) for(ll i=k;i<n;i++)
#define MOD 998244353
#define fast  ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define pb push_back
#define mod 1000000007
#define MAX 2000
#define F first
#define S second
#define all(s) s.begin(),s.end()
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986
ll inv_euclid(ll a, ll m = MOD) {ll m0 = m; ll y = 0, x = 1; if (m == 1)return 0; while (a > 1) {ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t;} if (x < 0)x += m0; return x;}
ll power(ll x, ll y, ll p)  { ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;} return res;}
ll max(ll a, ll b) {if (a > b)return a; return b;}
ll min(ll a, ll b) {if (a < b)return a; return b;}
ll ssum(ll n) {return (n * (n + 1)) / 2;}
ll gcd(ll a, ll b) {if (b == 0)return a; return gcd(b, a % b);}
ll lcm(ll a,ll b){
	return (a*b)/(gcd(a,b));
}

ll a[4000][4000];
int main() {
	string s,t;
	cin>>s>>t;
	ll ns=s.length();
	ll nt=t.length();
	rep(i,1,nt+1){
		rep(j,1,ns+1){
			if(t[i-1]==s[j-1])
				a[i][j]=a[i-1][j-1]+1;
			else
				a[i][j]=max(a[i-1][j],a[i][j-1]);
		}
	}
	string ans="";
	ll i=nt,j=ns;
	while(a[i][j]!=0){
		if(t[i-1]==s[j-1]){
			ans.pb(t[i-1]);
			i--;j--;
		}
		else if(a[i-1][j]>a[i][j-1])
			i--;
		else
			j--;
	}
	reverse(all(ans));
	cout<<ans;
}







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

#define F first
#define S second
#define eb emplace_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' | s[2] == '7')
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3640
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b = farr()
a,b = int(a),int(b*100+ .5)
ans = (a*b) //100
print(ans)


Measured memory_bytes: 37272
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    string s,t;
    cin >> s >> t;
    cout<<t<<s;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int a, b; cin >> a >> b;
    cout << max(0, a-2*b) << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner s = new Scanner(System.in);
    long A = s.nextLong();
    long B = s.nextLong();
    long K = s.nextLong();
 
    if(A < K){
      K = K - A;
      A = 0;
      if(B >= K){
        B = B - K;
      }else if (B < K){
        B = 0;
      }
        
    }else if(A >= K){
      A = A - K;
    }
    System.out.print(A +" ");
    System.out.println(B);
  }
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int t = 0;
    int a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        t += b - a + 1;
    }
    cout << t << endl;
}


Measured memory_bytes: 256
### main

loop do
  n, m, k = gets.split.map(&:to_i)
  break if (n | m | k) == 0
  #p [n, m, k]

  dp = Array.new(n + 1){[]}
  dp[1][0] = 0
  (1..m).each{|i| dp[1][i] = 1}
  min_s = 1
  max_s = m
  
  for i in (1...n)
    i1 = i + 1
    dp[i1] = Array.new(max_s + m + 1){0}

    for j in (min_s..max_s)
      (1..m).each{|d| dp[i1][j + d] += dp[i][j]}
    end

    min_s += 1
    max_s += m
  end
  #p dp[n]

  sum = 0
  for i in (min_s..max_s)
    d = i - k
    sum += ((d < 1) ? 1 : d) * dp[n][i]
  end

  puts "%.8f" % (sum.to_f / (m ** n))
end

Measured memory_bytes: 6236
#include "bits/stdc++.h"
using namespace std;
int main()
{
  char c;
  scanf("%c" , &c);
  if(c == 'T')
    puts("A");
  else if(c == 'A')
    puts("T");
  else if(c == 'C')
    puts("G");
  else if(c == 'G')
    puts("C");
}
   


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

const int INF = 1e8;
 
int main(){ 
  int N, M;
  vector<int> A(1010), B(1010), covered(1010, 0);
  vector<vector<int>> C(1010, vector<int>(12));

  cin >> N >> M;
  for(int i=1; i<=M; i++){
    int b; cin >> A[i] >> B[i];
    for(int j=0; j<B[i]; j++){
      cin >> C[i][j];
      covered[i] += (1 << (C[i][j]-1));
    }
  }

  // dp[bits][i] : 鍵iまでを使ってbitsを開けるために必要な最小費用 
  vector<vector<int>> dp(1<<12, vector<int>(1010, INF));
  for(int i=0; i<=M; i++) dp[0][i] = 0;

  for(int bits = 1; bits<(1<<N); bits++){
    for(int i=0; i<M; i++){
      dp[bits][i+1] =  min(dp[bits & ~covered[i+1]][i] + A[i+1], dp[bits][i]);
      //cout << covered[i+1] << " " << (bits & ~covered[i+1]) << " " << dp[bits][i+1] << endl; 
    }
  }
  if(dp[(1<<N)-1][M] == INF){
    cout << -1 << endl;
  } else {
    cout << dp[(1<<N)-1][M] << endl;
  }
}

Measured memory_bytes: 16640
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,(a+b)/2+r*1j*3**.5/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5920
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

def count_inversion(target_list):
    return sum(sum(m<n for m in target_list[i+1:]) for i,n in enumerate(target_list))

A_list_copy = A_list
invension_increase = 0
for i in set(A_list):
    max_num = max(A_list_copy)
    max_count = A_list_copy.count(max(A_list_copy))
    A_list_copy = [num for num in A_list_copy if num != max_num]
    invension_increase += max_count * len(A_list_copy)

ans_count = count_inversion(A_list) * K
ans_count += invension_increase * K * (K - 1) // 2

print(ans_count % (10 ** 9 + 7))

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

using mint=modint998244353;
mint inv9=mint{1}/9;

struct S{
    mint value;
    mint len;
    S(mint value=1,mint len=10):value(value),len(len){}
};
using F=mint;

S op(S a,S b){
    a.value=a.value*b.len+b.value;
    a.len=a.len*b.len;
    return a;
}
S e(){ return S(0,1); }
S mapping(F f,S x){
    if(f==0) return x;
    x.value=(x.len-1)*inv9*f;
    return x;
}
F composition(F f,F g){
    if(f==0) return g;
    return f;
}
F id(){ return 0; }

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,q; cin>>n>>q;
    vector<S> a(n,S{});
    lazy_segtree<S,op,e,F,mapping,composition,id> s(a);
    rep(_,q){
        int l,r,d; cin>>l>>r>>d;
        l--;
        s.apply(l,r,d);
        printf("%d\n",s.all_prod().value.val());
    }
}




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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>>x(H,vector<char>(W));
  for(int i=0;i<H;i++){
    string S;
    cin>>S;
    for(int j=0;j<W;j++){
      x.at(i).at(j)=S.at(j);
    }
  }
  vector<vector<int>>p(H,vector<int>(W));
  vector<vector<int>>q(H,vector<int>(W));
  for(int i=0;i<H;i++){
    int a=0,b=-1;
    for(int j=0;j<W;j++){
      if(x.at(i).at(j)=='.'){
        a++;
      }
      else{
        for(int k=b+1;k<j;k++){
          p.at(i).at(k)=a;
        }
        b=j;
        a=0;
      }
    }
    for(int k=b+1;k<W;k++){
      p.at(i).at(k)=a;
    }
  }
  for(int j=0;j<W;j++){
    int a=0,b=-1;
    for(int i=0;i<H;i++){
      if(x.at(i).at(j)=='.'){
        a++;
      }
      else{
        for(int k=b+1;k<i;k++){
          q.at(k).at(j)=a;
        }
        b=i;
        a=0;
      }
    }
    for(int k=b+1;k<H;k++){
      q.at(k).at(j)=a;
    }
  }
  
  int Z=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      Z=max(p.at(i).at(j)+q.at(i).at(j)-1,Z);
    }
  }
  
  cout<<Z<<endl;
}

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

int main(){
  string s; cin >> s;
  int a, b, c, d;
  a = stoi(s.substr(0, 1)); b = stoi(s.substr(1, 1));
  c = stoi(s.substr(2, 1)); d = stoi(s.substr(3, 1));
  if(a + b + c + d == 7){
  	cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  }
  else if(a + b + c - d == 7){
  	cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  }
  else if(a + b - c + d == 7){
  	cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  }
  else if(a + b - c - d == 7){
  	cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  }
  else if(a - b + c + d == 7){
  	cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  }
  else if(a - b + c - d == 7){
  	cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  }
  else if(a - b - c + d == 7){
  	cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  }
  else if(a - b - c - d == 7){
  	cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
  }
}

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

struct Player {
	int id;
	int score;
	Player() {}
	Player(int id, int score) : id(id), score(score) {}
};
bool operator > (const Player& p1, const Player& p2) {
	if (p1.score > p2.score) return true;
	else if (p1.score < p2.score) return false;
	else return p1.id < p2.id;
}

int getScore(int s[], int n)
{
	int* frame = new int[n];
	bool* strike = new bool[n];
	bool* spare = new bool[n];
	for (int i=0; i<n; i++) { strike[i] = false; spare[i] = false; }
	frame[0] = 0;
	int s_frame[10];
	for (int i=0; i<10; i++) s_frame[i] = 0;
	int thrownum = 0;
	for (int i=0; i<n; i++) {
		if (thrownum == 0) {
			if (s[i] == 10) {
				strike[i] = true;
				frame[i+1] = frame[i] + 1;
			}
			else {
				frame[i+1] = frame[i];
				thrownum = 1;
			}
			s_frame[frame[i]] += s[i];
			if (i>1) {
				if (strike[i-2]) s_frame[frame[i-2]] += s[i];
			}
			if (i>0) {
				if (strike[i-1]) s_frame[frame[i-1]] += s[i];
				if (spare[i-1])  s_frame[frame[i-1]] += s[i];
			}
		}
		else if (thrownum == 1) {
			if (s[i-1] + s[i] == 10) {
				spare[i] = true;
			}
			if (frame[i] == 9) {
				if (spare[i] || strike[i-1] || strike[i]) {
					frame[i+1] = frame[i];
					thrownum = 2;
				}
			}
			else {
				frame[i+1] = frame[i] + 1;
				thrownum = 0;
			}
			s_frame[frame[i]] += s[i];
			if (i>1) {
				if (strike[i-2]) s_frame[frame[i-2]] += s[i];
			}
			if (i>0) {
				if (strike[i-1]) s_frame[frame[i-1]] += s[i];
				if (spare[i-1])  s_frame[frame[i-1]] += s[i];
			}
		}
		else { // thrownum == 2
			s_frame[frame[i]] += s[i];
		}
	}
	int res = 0;
	for (int i=0; i<10; i++) res += s_frame[i];
	delete[] frame;
	delete[] strike;
	delete[] spare;
	return res;
}

int main()
{
	int score[30];
	std::string input;
	std::string sn; int n;
	while (true) {
		getline(std::cin, sn); n = std::stoi(sn);
		if (n==0) break;
		Player* players = new Player[n];
		for (int i=0; i<n; i++) {
			getline(std::cin, input);
			int id;
			int offset = 0;
			int pos;
			int index = 0;
			int s;
			pos = input.find(' ', offset);
			id = std::stoi(input.substr(offset, pos-offset));
			offset = pos + 1;
			while ( (pos = input.find(' ', offset)) != std::string::npos ) {
				s = std::stoi(input.substr(offset, pos-offset));
				score[index] = s; index++;
				offset = pos + 1;
			}
			s = std::stoi(input.substr(offset));
			score[index] = s; index++;
			players[i] = Player(id, getScore(score, index));
		}
		std::sort(players, players + n, std::greater<Player>());
		for (int i=0; i<n; i++) {
			std::cout << players[i].id << " " << players[i].score << std::endl;
		}
		delete[] players;
	}
	return 0;
}



Measured memory_bytes: 3132
from collections import Counter

N,*A = map(int, open(0).read().split())
ac = Counter(A)
if N % 2 == 0:
    for i in range(1,N,2):
        if ac[i] != 2:
            print(0)
            break
    else:
        print(pow(2,N//2,1000000007))
else:
    if ac[0] != 1:
        print(0)
    else:
        for i in range(2,N,2):
            if ac[i] != 2:
                print(0)
                break
        else:
            print(pow(2,N//2,1000000007))

Measured memory_bytes: 20336
//QWsin
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;

struct Node{
	int u,d;
	Node(int u=0,int d=0):u(u),d(d){}	
};

queue<int>q;

const int maxn=2500+10;
const int maxm=5000+10;

struct Edge{int u,v,w;Edge(int u=0,int v=0,int w=0):u(u),v(v),w(w){}};
struct Graph{
	int first[maxn],nxt[maxm],ecnt;
	Edge e[maxm];
	void add_edge(int u,int v,int w){
		nxt[ecnt]=first[u];first[u]=ecnt;e[ecnt++]=Edge(u,v,w);	
	}
	void clear(){memset(first,-1,sizeof first);ecnt=0;}
}g1,g2;

ll val[maxn];
int cnt[maxn];
bool inq[maxn];
int ok[maxn];

int main()
{
	g1.clear();g2.clear();
	int n,m,p;cin>>n>>m>>p;
	rep(i,1,m)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		g1.add_edge(u,v,w-p);
		g2.add_edge(v,u,w-p);
	}
	
	q.push(n);
	while(!q.empty())
	{
		int u=q.front();q.pop();
		ok[u]=1;
		for(int i=g2.first[u];i!=-1;i=g2.nxt[i])
		{
			int v=g2.e[i].v;
			if(!ok[v]) q.push(v),ok[v]=1;
		}
	}
	
	rep(i,1,n) val[i]=-1ll<<60;
	val[1]=0;q.push(1);inq[1]=1;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		inq[u]=0;
		for(int i=g1.first[u];i!=-1;i=g1.nxt[i])
		{
			int v=g1.e[i].v;
			if(!ok[v]) continue;
			if(val[v] < val[u]+g1.e[i].w)
			{
				val[v]=val[u]+g1.e[i].w;
				if(!inq[v])
				{
					cnt[v]=cnt[u]+1;
					if(cnt[v]>n){
						cout<<-1<<endl;
						return 0;
					}
					q.push(v);
				}
			}
		}
	}
	cout<<max(0ll,val[n])<<endl;
	return 0;
}


Measured memory_bytes: 896