akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main(){
    int N,a,b,ans_sum=0;
    cin >> N >> a >> b;
    for(int i=1;i<=N;i++){
        int sum=0,tmp=i;
        for(int j=0;j<5;j++){
            sum += tmp%10;
            tmp = tmp/10;
        }
        if(sum>=a && sum<=b){
        ans_sum+=i;
        } 
    }
    cout << ans_sum << endl;
}

Measured memory_bytes: 256
<?php
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}

$base = [];
for ($i=0; $i < $tmp[0]; $i++) {
  $base[$i] = $i+1;
}

$all = pat($base);

$p = preg_replace("/ /", "", $tmp[1]);
$q = preg_replace("/ /", "", $tmp[2]);

$p_index = array_search($p, $all);
$q_index = array_search($q, $all);

echo $p_index - $q_index < 0 ? $q_index - $p_index : $p_index - $q_index;

function pat($a, $s = '')
{
  $r = array();
  if (count($a) && is_array($a)) {
    //第1引数に文字の配列を渡されたらループして処理
    foreach ($a as $k => $v) {
      //文字の配列から1文字もらってこちらにくっつけて
      $_s = $s . $v;
      //もらった1文字を除いた文字の配列を作って
      $_a = $a;
      unset($_a[$k]);
      //再帰呼び出し
      $_r = pat($_a, $_s);
      //返り値にする変数に結果を追加
      $r = array_merge($r, $_r);
    }
  } else {
    //第1引数が空っぽの配列だったら、再帰呼び出しはここでストップ
    //返り値はこれだけ
    $r[] = $s;
  }
  return $r;
}

Measured memory_bytes: 15204
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	ll N; string S;
	cin >> N >> S;

	for (char p : S) {
		cout << char((p - 'A' + N) % 26 + 'A');
	}
	cout << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(long[][] a) {
    if (a.length == 1) return 1;

    int ans = int.max;
    int n = cast(int)a.length;
    foreach (i; 0..n) {
        foreach (j; 0..n) {
            if (i == j) continue;

            long dx = a[i][0] - a[j][0];
            long dy = a[i][1] - a[j][1];
            int match = 0;
            foreach (k; 0..n) {
                foreach (m; 0..n) {
                    if (k == m) continue;
                    if (a[k][0] - a[m][0] == dx && a[k][1] - a[m][1] == dy) {
                        match++;
                    }
                }
            }
            ans = min(ans, n - match);
        }
    }
    return ans;
}

void main() {
    int n = readint;
    long[][] a;
    for (int i = 0; i < n; i++) {
        a ~= reads!long;
    }
    writeln(calc(a));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;

const ll Mod=1e9+7;


ll modinv(ll a) {
    ll m=Mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int i,j;
  int n,x;
  cin>>n>>x;
  int s[n];
  for(i=0;i<n;i++) cin>>s[i];
  sort(s,s+n,greater<int>());
  
  VVI dp(n+1,VI(x+1));
  for(i=0;i<=x;i++) dp[n][i]=i;

  int inv[202];
  inv[0]=1;
  for(i=1;i<202;i++) inv[i]=modinv(i);

  for(i=n-1;i>=0;i--){
    for(j=0;j<=x;j++){
      dp[i][j]+=dp[i+1][j]*(Mod+1-inv[n-i])%Mod;
      dp[i][j]+=dp[i+1][j%s[i]]*inv[n-i]%Mod;
      dp[i][j]%=Mod;
    }
  }
  ll ans=dp[0][x];
  for(i=1;i<=n;i++) ans=ans*i%Mod;
  cout<<ans<<endl;

}

Measured memory_bytes: 158592
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n][n];rep(i,0,n)rep(j,0,n)cin>>a[i][j];
	ll dp[1<<n];rep(i,0,1<<n)dp[i]=0;
	dp[(1<<n)-1]=1;
	for(ll i=(1<<n)-1;i>=0;i--){
		ll tot=__builtin_popcount(i);
		rep(j,0,n)if(a[tot][j]&&!(i&(1<<j)))dp[i]=(dp[i]+dp[i|(1<<j)])%md;
	}
	cout<<dp[0]%md;
	
	
	return 0;
}



Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    int checker[20]={};
    int right=0;
    ll ans=0;
    rep(left,n){
        while(right<n){
            bool isOK=1;
            rep(i,20){
                if(a[right]&(1<<i)){
                    if(checker[i]){
                        isOK=0;
                        break;
                    }
                }
            }
            if(!isOK)break;
            else{
                rep(i,20){
                    if(a[right]&(1<<i))checker[i]++;
                }
            }
            right++;
        }
        ans+=(right-left);
        if(right==left)++right;
        else{
            rep(i,20){
                if(a[left]&(1<<i))checker[i]--;
            }
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 1024
A, B, K = map(int, input().split(' '))

for i in range(K):
    # A君は奇数なら食べる
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        B += int(A / 2)
        A -= int(A / 2)
    else:
        if B % 2 == 1:
            B -= 1
        A += int(B / 2)
        B -= int(B / 2)


print(A, B)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int n;cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
  	char h;
    cin>>h;
    if(h=='R'){ans++;}
    else{ans--;}
  }
  if(ans>0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  
return 0;
}

Measured memory_bytes: 256
input = gets.chomp.split("\s")
h, w = input[0].to_i, input[1].to_i

def output(h, w)
	arr = []
	for i in 1..w
		if h % 2 == 0
			if i % 2 == 0
				arr = arr + ["#"]
				out = arr.join
			else
				arr = arr + ["."]
				out = arr.join
			end
		else
			if i % 2 == 0
				arr = arr + ["."]
				out = arr.join
			else
				arr = arr + ["#"]
				out = arr.join
			end
		end
	end
	
return out
end

until (h == 0) && (w == 0)
	for i in 1..h
		out = output(i, w)
	puts out
	end
	
puts ""
input = gets.chomp.split("\s")
h, w = input[0].to_i, input[1].to_i
end

Measured memory_bytes: 7212
#include <bits/stdc++.h>
    
using namespace std;
vector<vector<long long> >num;
vector<vector<int> >dp;
vector<pair<int,int> >be;
int nein=-1,menge;
long long erg(int i,int j){
	nein=j;
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	else if(i==menge-2){
		dp[i+1][0]=num[i+1][0];
		dp[i+1][1]=num[i+1][1];
		dp[i+1][2]=num[i+1][2];	
			
			if(num[i+1][0]>=num[i+1][1]&&num[i+1][0]>=num[i+1][2]&&nein!=0){
			dp[i][j]=num[i+1][0]+num[i][j];
			return num[i+1][0]+num[i][j];
		}
		else if(num[i+1][1]>=num[i+1][0]&&num[i+1][1]>=num[i+1][2]&&nein!=1){
			dp[i][j]=num[i+1][1]+num[i][j];
			return num[i+1][1]+num[i][j];
		}
		else if(num[i+1][2]>=num[i+1][1]&&num[i+1][2]>=num[i+1][0]&&nein!=2){
			dp[i][j]=num[i+1][2]+num[i][j];
			return num[i+1][2]+num[i][j];
		}
	}
	long long cmp=0;
	for(int m=0;m<3;m++){
		if(m!=j){
			if(i>=0){
			cmp=max(cmp,erg(i+1,m)+num[i][j]);
			}	
		}
	}
	dp[i][j]=cmp;
	return cmp;
	
}
 int main(){
 	for(int i=0;i<100001;i++){
 		dp.push_back(vector<int>());
 		dp[i].push_back(-1);
 		dp[i].push_back(-1);
 		dp[i].push_back(-1);
	 }
 	
 int numm;
 cin>>menge;
 for(int i=0;i<menge;i++){
 	
 	num.push_back(vector<long long>());
 	cin>>numm;
 	num[i].push_back(numm);
 	cin>>numm;
 	num[i].push_back(numm);
 	cin>>numm;
 	num[i].push_back(numm);
 }
 long long comp=0;
 if(menge==1){
 	for(int i=0;i<3;i++){
 		comp=max(comp,num[0][i]);
	 }
	 cout<<comp;
	 return 0;
 }
 
  comp=max(erg(0,1),erg(0,2));
 cout<<max(comp,erg(0,0));
    return 0;
}


Measured memory_bytes: 21168
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}




int dis[10][10];






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 daburi = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1])daburi++;
	}

	int delans = (daburi + 1) / 2;
	int ans = n - (2 * delans);

	cout << ans << endl;


	return 0;

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG



int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  //vector<vector<int>> data(3, vector<int>(4));
  ll sum = 0;
for(ll i=0; i<N; i++){
  cin >> A[i];
  sum += A[i];

}

sort(A.begin(), A.end(), greater<int>());

for(ll i=0; i<M; i++){
  if( (4 * M * A[i]) < sum){
    cout << "No" << endl;
    return 0;
  }
}



cout << "Yes" << endl;
//cout << sum << endl;
return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> c(4);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == "AC") {
			c[0]++;
		}
		else if (s[i] == "WA") {
			c[1]++;
		}
		else if (s[i] == "TLE") {
			c[2]++;
		}
		else if (s[i] == "RE") {
			c[3]++;
		}
	}

	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;
	return 0;
}

Measured memory_bytes: 6424
#include <stdio.h>
#define w 200001
int main(void){
    // Your code here!
    int n,m;
    long int k;
    scanf("%d %d %ld",&n,&m,&k);
    
    long int a[w];
    long int A[w];
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
        if(i==0){
            A[i]=0;
        }
        A[i+1]=A[i]+a[i];
        
    }
    
    long int b[w];
    long int B[w];
    for(int i=0;i<m;i++){
        scanf("%ld",&b[i]);
        if(i==0){
            B[i]=0;
        }
        B[i+1]=B[i]+b[i];
        
    }
    
    int p=0;
    int mo=m;
    for(int i=0;i<=n;i++){
        if(A[i]>k)break;
        
        for(int j=mo;j>=0;j--){
            if(A[i]+B[j]<=k){
                if(i+j>p)p=i+j;
                mo=j;
                break;
            }
        }
        
    }
    
    
    printf("%d",p);
}

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

int main() {
	int n; cin >> n;
  	int s = 0, temp = n;
  	while(temp) {
    	s += temp % 10;
      	temp /= 10;
    }
  	
  	if(n % s == 0) cout << "Yes";
  	else cout << "No";
}

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

using namespace std;

int main() {
	int x1, y1;
	int x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int vx, vy;
	vx = x2-x1; vy = y2-y1;
	swap(vx, vy);
	vx = -vx;
	cout << x2+vx << " " << y2+vy << " "
		 << x1+vx << " " << y1+vy << endl;
	return 0;
}

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

const int MX = 1005;

char s[MX][MX];

int from[MX];

string SIX[6]  = {"aabb..", "b..cc.", "ba....", ".a..aa", "..a..b", "..a..b"};

string FIVE[5] = {"aabbc",
	              "dee.c",
	              "d..fg",
	              "h..fg",
	              "hssjj"};

string FOUR[4] = {"aabc",
	              "ddbc",
	              "fghh",
	              "fgjj"};

int main()
{
	from[0] = -1;
	for (int x : {4, 5, 7}) {
		for (int i = 0; i + x <= 1000; i++) {
			if (from[i]) from[i + x] = x;
		}
	}
	
	int n;
	ignore = scanf("%d", &n);
	
	if (n <= 2) {
		printf("-1\n");
		return 0;
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			s[i][j] = '.';
		}
	}
	
	if (n % 3 == 0) {
		for (int i = 0; i < n; i += 3) {
			s[i][i] = s[i][i + 1] = 'a';
			s[i][i + 2] = s[i + 1][i + 2] = 'b';
			s[i + 2][i + 2] = s[i + 2][i + 1] = 'c';
			s[i + 2][i] = s[i + 1][i] = 'd';
		}
		for (int i = 0; i < n; i++) {
			printf("%s\n", s[i]);
		}
		return 0;
	}
	
	int cur = n;
	int i = 0;
	while (cur > 0) {
		if (from[cur] == 4) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					s[i + j][i + k] = FOUR[j][k];
				}
			}
		}
		else if (from[cur] == 5) {
			for (int j = 0; j < 5; j++) {
				for (int k = 0; k < 5; k++) {
					s[i + j][i + k] = FIVE[j][k];
				}
			}
		}
		else if (from[cur] == 7) {
			for (int j = 0; j < 6; j++) {
				for (int k = 0; k < 6; k++) {
					s[i + j][i + k] = SIX[j][k];
				}
			}
			s[i][i + 6] = s[i + 1][i + 6] = 'z';
			s[i + 2][i + 6] = s[i + 3][i + 6] = 'y';
			s[i + 4][i + 6] = s[i + 5][i + 6] = 'x';
			s[i + 6][i] = s[i + 6][i + 1] = 'q';
			s[i + 6][i + 2] = s[i + 6][i + 3] = 'w';
			s[i + 6][i + 4] = s[i + 6][i + 5] = 'e'; 
		}
		
		i += from[cur];
		cur -= from[cur];
	}
	
	for (int j = 0; j < n; j++) {
		printf("%s\n", s[j]);
	}
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	long count = 0;
	for(int i=1;i<=N;i++){
	    if(i%3!=0 && i%5!=0) count += i;
	}
	System.out.print(count);
    }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	if(m%n==0){
		cout<<m/n<<"\n"s;
		return 0;
	}
	int ans=m/n;
	while(m%ans)--ans;
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] info = line.split(" ");
		int a = Integer.parseInt(info[0]);
		int b = Integer.parseInt(info[1]);
		int c = Integer.parseInt(info[2]);
		int count = 0;
		for (int i = a; i < b + 1; i++) {
			if (c % i == 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26260
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  int N;
  cin>>N;
  
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  
  int M;
  cin>>M;
  
  vector<string> T(M);
  for(int j=0;j<M;j++){
    cin>>T[j];
  }
  
  int ans=0;
  
  
  for(int i=0;i<N;i++){
    int check=0;
    for(int j=0;j<N;j++){
      if(S[i]==S[j]){
        check++;
      }
    }
    for(int j=0;j<M;j++){
      if(S[i]==T[j]){
        check--;
      }
    }
    ans=max(ans,check);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  x = abs(x);
  ll ans;
  if (x/d >= k) {
    ans = x - d * k;
  } else {
    ll e = x / d;
    k -= e;
    x -= e*d;
    if (k%2 == 1) {
      x = abs(x-d);
    }
    ans = x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3164
import sys

def solve(s, t):
   ans = 0
   for i, s_i in enumerate(s):
       if s_i == t[i]:
           ans += 1
   print(ans)

if __name__ == '__main__':
  s = sys.stdin.readline().strip()
  t = sys.stdin.readline().strip()
  solve(s, t)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



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


int main()
{
  ll n, k ;
  cin >> n >> k ;
  ll cnt1 = 0 ;
  ll cnt2 = 0 ;
  ll mod = 1000000007 ;
  ll ans ;
  
  vector<int> vec(n) ;
  
  REP(i,n){
    cin >> vec.at(i) ;
  }
  
  REP(i,n-1){
    FOR(j,i+1,n){
      if(vec.at(i)>vec.at(j)){
        cnt1++ ;
      }
    }
  }
  
  for(int i=n-1; i>=1; i--){
    for(int j=i-1; j>=0; j--){
      if(vec.at(i)>vec.at(j)){
        cnt2++ ;
      }
    }
  }
  
  ans = (k*(k+1)/2%mod*cnt1%mod+k*(k-1)/2%mod*cnt2%mod)%mod ;
  
  cout << ans <<endl ;

  return 0 ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	long long a,b,s=1;
	
	cin>>a>>b;
	
	do{
		if(a*2<=b)
		{
			s++;
			a=a*2;
		}	
		else
			break;
	}while(a<=b);
	
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    ABC = [(0, 0, 0)]
    for _ in range(N):
        a, b, c = map(int, input().split())
        ABC.append((a, b, c))

    dp_a = [0] * (N + 1)
    dp_b = [0] * (N + 1)
    dp_c = [0] * (N + 1)
    for i in range(1, N + 1):
        a, b, c = ABC[i]
        dp_a[i] = max(dp_b[i - 1] + a, dp_c[i - 1] + a)
        dp_b[i] = max(dp_c[i - 1] + b, dp_a[i - 1] + b)
        dp_c[i] = max(dp_a[i - 1] + c, dp_b[i - 1] + c)

    print(max(dp_a[-1], dp_b[-1], dp_c[-1]))


if __name__ == "__main__":
    main()


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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

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

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

int main() {
  int64 A, B, C, D;
  cin >> A >> B >> C >> D;
  bool f = false;
  if(C * 2 == A && D * 2 == B) f = true;
  cout << A * B / 2.0 << " " << f << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            double power = 1;

            for (int i = 1; i <= N; i++)
            {
                power = power * i %(Math.Pow(10,9)+7);
            }
            Console.WriteLine(power);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 27804
x=list(map(int,input().split()))
ans=[0,0,0,0]
ans[0]=x[2]+x[1]-x[3]
ans[1]=x[3]+x[2]-x[0]
ans[2]=x[0]+ans[0]-x[2]
ans[3]=x[1]+ans[1]-x[3]
print(*ans)

Measured memory_bytes: 3064
fun main(args: Array<String>){
    val (N) = readLine()!!.split(" ").map { it.toInt() }
    val As = readLine()!!.split(" ").map { it.toInt() }
    val ans = As.mapIndexed{index, i -> (index + 1) to i  }.sortedBy { it.second }.map { it.first }.joinToString(" ")
    println(ans)
}

Measured memory_bytes: 86912
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        v: [usize;n],
        c: [usize;n]
    }
    let mut ans = 0;

    for i in 0..n {
        if v[i] > c[i] {
            ans += v[i] - c[i]
        }
    }

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <stdio.h>

void bsort(int a[], int n)
{
  int i, j;

  for (i = 0; i < n - 1; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j - 1] > a[j]) {
        int temp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = temp;
      }
    }
  }
}

int main(void)
{
  int n, i;
  int l[200];

  scanf("%d", &n);
  for (i = 0; i < 2 * n; i++)
    scanf("%d", &l[i]);

  bsort(l, 2 * n);

  int sum = 0;

  for (i = 0; i < 2 * n; i++)
    if (i % 2 == 0) {
      sum += l[i];
    }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g,b ;
  cin >> r>> g >> b;
  
  if ((100*r + 10*g + b) % 4 == 0){
    cout<< "YES" << endl;
  }
    else if((100*r + 10*g + b) % 4 != 0) {
      cout << "NO" << endl;
    }
  }

      
    
  


Measured memory_bytes: 256
implicit none
integer :: a
integer :: XX, YY
read *,a

XX = a / 100
YY = mod(a,100)

if (0 < YY .and. YY < 13) then  ! YY can be year or month
   if (0 < XX .and. XX < 13) then  ! XX can be year or month
      write(6,'(a)') 'AMBIGUOUS'
   else  ! XX is year
      write(6,'(a)') 'YYMM'
   endif
else  ! YY is year
   if (0 < XX .and. XX < 13) then  ! XX can be year or month
      write(6,'(a)') 'MMYY'
   else  ! XX iss year
      write(6,'(a)') 'NA'
   endif
endif

stop
end

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

int main()
{
    int n;
    cin >> n;
    cout << 800*n-200*(int)(n/15) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[8],i,b,c;
while(1){
scanf("%d\n",&b);
if(b==0){
break;
}
for(i=0;i<7;i++){
a[i]=0;
}
for(i=0;i<b;i++){
scanf("%d\n",&c);
if(c<10){
a[0]++;
}
else if(c<20){
a[1]++;
}
else if(c<30){
a[2]++;
}
else if(c<40){
a[3]++;
}
else if(c<50){
a[4]++;
}
else if(c<60){
a[5]++;
}
else{
a[6]++;
}
}
for(i=0;i<7;i++){
printf("%d\n",a[i]);
}
}
return 0;
}




Measured memory_bytes: 2024
H,N=map(int,input().split())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)


inf=float('inf')
component=[0]
for i in range(H):
    component.append(inf)
DP=[]
for j in range(N+1):
    DP.append(component)#DPは(N+1)×(H+1)


for k in range(1,N+1):#k番目の魔法
    for l in range(1,H+1):#体力H
        DP[k][l]=min(DP[k-1][l],DP[k][max(0,l-A[k-1])]+B[k-1])

print(DP[N][H])










Measured memory_bytes: 48988
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rep(a,n,b) for(int i=a;i<n;i+=b)
#define rrep(a,n,b) for(ll i=n;i>=a;i-=b)
#define iter(obj) for(auto x : obj) 
#define pb(i) push_back(i)
#define ff first
#define ss second
#define pchr(flag) cout<<(flag ? "YES" : "NO")
#define ot(x) cout<<x
#define nl cout<<endl;
#define sc cout<<" "
#define ll long long int
#define input freopen("input.txt","r",stdin)
#define op freopen("output.txt","w",stdout);
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int N = 2e5+7;
const int MOD  = 1000000007;
const float PI = 3.1415926535;
//33333333333;
int prime[N];
void SieveOfEratosthenes(int n) 
{ 
     for (int p=2; p*p<=n; p++) {
        if (prime[p] == 0)  {
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 1; 
        } 
    } 
} 
int main() 
{ 
	fastio;
	int h,n,temp,sum=0;
	cin>>h>>n;
	rep(0,n,1) {
		cin>>temp;
		sum+=temp;
	}
	if(sum>=h) {
		cout<<"Yes";
	}
	else cout<<"No";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define MAX_V 210
#define INF 1000000000000000000LL

struct edge{long long to,reve;long long cap;};

vector<edge> E[MAX_V];
long long itr[MAX_V],lev[MAX_V];

void ae(long long x,long long y,long long cap){
  E[x].push_back((edge){y,(int)E[y].size(),cap});
  E[y].push_back((edge){x,(int)E[x].size()-1,0});
}

void bfs(long long cur){
  memset(lev,-1,sizeof(lev));
  queue<long long> q;
  lev[cur]=0;
  q.push(cur);
  while(q.size()){
    long long v=q.front(); q.pop();
    for(long long i = 0; i < E[v].size(); i++){
      edge &e = E[v][i];
      if(e.cap>0 && lev[e.to]<0){
        lev[e.to]=lev[v]+1, q.push(e.to);
      }
    }
  }
}

long long dfs(long long from,long long to,long long cf){
  if(from==to) return cf;
  for(long long &i = itr[from]; i < E[from].size(); i++){
    edge &e = E[from][i];
    if(e.cap>0 && lev[from]<lev[e.to]){
      long long f=dfs(e.to,to,min(cf,e.cap));
      if(f>0){
        e.cap-=f;
        E[e.to][e.reve].cap += f;
        return f;
      }
    }
  }
  return 0;
}

long long maxFlowDinic(long long from, long long to) {
  long long fl=0,tf;
  while(1) {
    bfs(from);
    if(lev[to]<0)return fl;
    memset(itr,0,sizeof(itr));
    while((tf=dfs(from,to,numeric_limits<int>::max()))>0)fl+=tf;
  }
}

int main(){
  ll sum = 0;
  ll n;
  cin >> n;
  rep(i,0,n){
    ll a;
    cin >> a;
    if(a>=0){
      ae(i+n,2*n+1,a);
      sum += a;
    }
    else{
      ae(2*n,i,-a);
    }
  }
  rep(i,0,n){
    ae(i,i+n,INF);
  }
  rep(i,1,n+1){
    rep(j,i+1,n+1){
      if(j%i==0){
        ae(i-1+n,j-1,INF);
      }
    }
  }
  ll ans = maxFlowDinic(2*n,2*n+1);
  cout << sum-ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y;
  int reward=0;
  cin >> x >> y;
  if(x==1)
    reward += 300000;
  else if(x==2)
    reward += 200000;
  else if(x==3)
    reward += 100000;
  
  if(y==1)
    reward += 300000;
  else if(y==2)
    reward += 200000;
  else if(y ==3)
    reward += 100000;
  
  if(x==1&y==1)
    reward += 400000;
  cout << reward << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

int main()
{
  char s[100001];
  scanf("%s", s);
  int l = strlen(s);
  for (int i = 0; i < l; i += 2)
  {
    printf("%c", s[i]);
  }
  printf("\n");
  return 0;
}

// void Main() {
//   char s[100001];
//   scanf("%s", s);
//   int l = strlen(s);
//   for (int i = 0; i < l; i += 2) {
//     printf("%c", s[i]);
//   }
//   printf("\n");
// }

// int main() {
//   std::cin.tie(nullptr);                  // 標準入出力高速化
//   std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
//   std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
//   Main();
// }

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
  int n,m,a,b,i,j;
  bool ans=false;
  vector<int> g[200010],k;
  cin >> n >> m;
  for (i=0;i<m;i++){
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (i=0;i<g[1].size();i++) k.push_back(g[1][i]);
  for (i=0;i<k.size();i++){
    for (j=0;j<g[k[i]].size();j++) if (g[k[i]][j]==n){
      ans=true;
      break;
    }
    if (ans) break;
  }
  if (ans) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 12784
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>> n;
  vector<ll> h(n);
  for(int i=0;i<n;i++) cin>>h[i];

  bool flag = true;
  for(int i=n-1;i>=0;i--){
    if(i!=n-1){
      if(h[i] - h[i+1] <= 0);
      else if(h[i] - h[i+1] == 1) h[i]--;
      else{
        flag = false;
        break;
      }
    }
  }

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


Measured memory_bytes: 1024
#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>;


int main() {
    int x, y;
    cin >> x >> y;
    int max_tatol = y/4;
    for(int i = max_tatol; i >= 0; i--){
        int tsuru = x - i;
        if(4*i + 2*tsuru == y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	cnt := 0
	p := ""
	var b []byte
	for i := 0; i < len(s); i++ {
		b = append(b, s[i])
		if string(b) == p {
			continue
		}
		p = string(b)
		b = []byte{}
		cnt++
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 4812
line = int(input().split(" ")[0])
a_vec =[]
b_vec =[]
res = []



for i in range(line):
    #a_vec.append([int(x) for x in a_input[i].split(" ")])
    a_vec.append([int(x) for x in input().split(" ")])


for i in range(len(a_vec[0])):
    b_vec.append(int(input()))

for a_row in a_vec:
    c = 0
    for i, a_col in enumerate(a_row):
        c += a_col * b_vec[i]
    res.append(c)

for r in res:
    print(r)

Measured memory_bytes: 8068
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int X, Y, Z;

  std::cin >> X >> Y >> Z;

  int c = 0;

  for ( ; ; c ++) {
    long long x = Y * c + (c > 0 ? (c + 1) * Z : 0);

    if (x > X) {
      c --;
      
      break;
    }
  }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

const int N = 1000 + 10;
int n;

LD x[N], y[N], r[N];

LD getdis(int u, int v) {
    LD sq = (x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v]);
    LD ret = sqrt(sq);
    if(ret > r[u] + r[v] + eps) {
        return (ret - r[u]) - r[v];
    }
    return 0;
}

int main() {
    cin >> x[0] >> y[0];
    cin >> x[1] >> y[1];
    cin >> n;
    REP(i, n) {
        cin >> x[i+2] >> y[i+2] >> r[i+2];
    }
    n += 2;
    vector<LD> dis(n, -1);
    dis[0] = 0;
    set<pair<LD, int>> pq;
    pq.insert({0, 0});
    int cnt = 0;
    while(!pq.empty()) {
        cnt++;
        if(cnt > n + 10) assert(0);
        int u = pq.begin()->second;
        pq.erase(pq.begin());
        REP(v, n) {
            if(u == v) continue;
            LD d = getdis(u, v);
            if(dis[v] == -1 || dis[u] + d + eps < dis[v]) {
                if(dis[v] != -1) {
                    pq.erase({dis[v], v});
                }
                dis[v] = dis[u] + d;
                pq.insert({dis[v], v});
            }
        }
    }
    cout << dis[1] << '\n';
}






























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

int main()
{
  string S;cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();

		for (int i = 1; i < n; i++) {
			int a = sc.nextInt();
			list.add(0);
			list.set(a - 1, list.get(a-1) + 1);
		}

		list.forEach(s -> {
			System.out.println(s);
		});
				System.out.println(0);

		sc.close();
	}

}

Measured memory_bytes: 52484
#include<stdio.h>

#define MAX 1000
#define INFINITY 10000

int n;
int M[MAX][MAX], color[MAX], d[MAX], p[MAX];

enum {
    WHITE,
    GRAY,
    BLACK
};

int prim() {
    for (int i = 0; i < n; ++i) {
        color[i] = WHITE;
        d[i] = INFINITY;
        p[i] = -1;
    }
    d[0] = 0;

    while (true) {
        int min = INFINITY;
        int target = -1;
        for (int i = 0; i < n; ++i) {
            if (d[i] < min && color[i] != BLACK) {
                min = d[i];
                target = i;
            }
        }
        if (target == -1) break;

        color[target] = BLACK;

        for (int v = 0; v < n; ++v) {
            if (color[v] != BLACK && M[target][v] != -1) {
                if(M[target][v] < d[v]) {
                    d[v] = M[target][v];
                    p[v] = target;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if (p[i] != -1) sum += M[i][p[i]];
    }
    return sum;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &M[i][j]);
        }
    }
    printf("%d\n", prim());
    return 0;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	string s;
	cin >> s;
	rep(i,s.size())
	{
		if(s[i] == '1') s[i] = '9';
		else if(s[i] == '9') s[i] = '1';
	}
	cout << s << endl;
	return 0;
}

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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int x = (C + B - 1) / B;
    int y = (A + D - 1) / D;
    if (x <= y)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3596
#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>;

const int INF = 1001001001;

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

  int n, x, y; cin >> n >> x >> y;
  --x; --y;
  vector<int> ans(n, 0);

  rep(i, n) {
    queue<int> q;
    vector<int> dist(n, INF);
    auto push = [&](int v, int d) {
		  if(dist[v] !=INF) return;
		  dist[v] = d;
		  q.push(v);
		};
    push(i, 0);
    while(!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];

      if(v-1 >= 0) push(v-1, d+1);
      if(v+1 < n) push(v+1, d+1);
      if(v == x) push(y, d+1);
      if(v == y) push(x, d+1);
    }
    rep(j, n) ++ans[dist[j]];
  }
  rep(i, n) ans[i]/=2;
  rep(i, n-1) {
    cout << ans[i+1] << endl;
  }
}
    


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

int main()
{
  ll n,k; cin>>n>>k;
  double ans = 0.0;
  for (int i=1; i<=n; i++) {
    double t = 1;
    while (i*t < k) t*=2;
    ans += 1.0/n/t;
  }
  printf("%.10lf\n", ans);

  return 0;
}

Measured memory_bytes: 256
import sys

N, K = map(int, input().split())
X = list(map(int, input().split()))

minus_x = []
plus_x = []

for x in X:
    if(x < 0):
        minus_x.append(x)
    elif(x > 0):
        plus_x.append(x)
    else:
        N -= 1
        K -= 1

n_minus = len(minus_x)
n_plus = len(plus_x)

if(K == 0):
    print(0)
    sys.exit()

ans = sys.maxsize
for i in range(K + 1):
    m = i
    p = K - i
    if(m > n_minus or p > n_plus):
        continue

    if(p == 0):
        tmp = -1 * minus_x[-1 * m]
    elif(m == 0):
        tmp = plus_x[p - 1]
    else:
        t_m = -1 * minus_x[-1 * m]
        t_p = plus_x[p - 1]
        tmp = min(t_m * 2 + t_p, t_m + t_p * 2)

    if(tmp < ans):
        ans = tmp

print(ans)

Measured memory_bytes: 14480
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  long h, w;
  cin >> h >> w;
  if((h%3)*(w%3)==0){
    cout << 0;
  }
  else {
    long ret = min(h, w);
    for(int i=0; i<h; i++){
      if(w%2==0){
        ret = min(ret, abs(i*w-(h-i)*w/2));
      }
      else {
        long dif = max({i*w, (h-i)*(w-1)/2, (h-i)*(w+1)/2})-min({i*w, (h-i)*(w-1)/2, (h-i)*(w+1)/2});
        ret = min(ret, dif);
      }
    }
    for(int i=0; i<w; i++){
      if(h%2==0){
        ret = min(ret, abs(i*h-(w-i)*h/2));
      }
      else {
        long dif = max({i*h, (w-i)*(h-1)/2, (w-i)*(h+1)/2})-min({i*h, (w-i)*(h-1)/2, (w-i)*(h+1)/2});
        ret = min(ret, dif);
      }
    }
    cout << ret;
  }
  return 0;
}


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


def main():
    AB = []
    n = int(input())
    for i in range(n):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key=lambda x: (x[1], -x[0]))
    time = 0
    for span, dead in AB:
        time += span
        if time > dead:
            print('No')
            return
    print('Yes')
    return


if __name__ == "__main__":
    main()


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

struct UnionFind
{
    vector< int > data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k)
    {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    int size(int k)
    {
        return(-data[find(k)]);
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};


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

    vector<int> p(N+1);
    for (int i = 1; i <= N; i++) cin >> p[i];

    UnionFind uf = UnionFind(N+1);
    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        uf.unite(x, y);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (uf.same(i, p[i])) ans++;
    }
    cout << ans << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int a,b;
	cin >> a >> b;
	int res;
	b--;
	if ((b % (a - 1)) == 0) {
		res = b / (a - 1);
	}
	else {
		res = b / (a - 1) + 1;
	}
	pv(res)
	return(0);
}

Measured memory_bytes: 256